com.github.nagyesta.lowkeyvault.service.key.ReadOnlyKeyVaultKeyEntity Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lowkey-vault-app Show documentation
Show all versions of lowkey-vault-app Show documentation
Assembled application of Lowkey Vault.
package com.github.nagyesta.lowkeyvault.service.key;
import com.github.nagyesta.lowkeyvault.model.v7_2.key.constants.EncryptionAlgorithm;
import com.github.nagyesta.lowkeyvault.model.v7_2.key.constants.KeyOperation;
import com.github.nagyesta.lowkeyvault.model.v7_2.key.constants.KeyType;
import com.github.nagyesta.lowkeyvault.model.v7_2.key.constants.SignatureAlgorithm;
import com.github.nagyesta.lowkeyvault.service.common.BaseVaultEntity;
import com.github.nagyesta.lowkeyvault.service.key.id.VersionedKeyEntityId;
import com.github.nagyesta.lowkeyvault.service.key.impl.KeyCreationInput;
import org.springframework.util.Assert;
import java.nio.charset.StandardCharsets;
import java.util.List;
public interface ReadOnlyKeyVaultKeyEntity extends BaseVaultEntity, ReadOnlyDeletedEntity {
KeyType getKeyType();
KeyCreationInput> keyCreationInput();
default byte[] encrypt(final String clear, final EncryptionAlgorithm encryptionAlgorithm, final byte[] iv) {
Assert.hasText(clear, "Clear text must not be blank.");
return encryptBytes(clear.getBytes(StandardCharsets.UTF_8), encryptionAlgorithm, iv);
}
default String decrypt(final byte[] encrypted, final EncryptionAlgorithm encryptionAlgorithm, final byte[] iv) {
return new String(decryptToBytes(encrypted, encryptionAlgorithm, iv));
}
byte[] encryptBytes(byte[] clear, EncryptionAlgorithm encryptionAlgorithm, byte[] iv);
byte[] decryptToBytes(byte[] encrypted, EncryptionAlgorithm encryptionAlgorithm, byte[] iv);
byte[] signBytes(byte[] digest, SignatureAlgorithm encryptionAlgorithm);
boolean verifySignedBytes(byte[] digest, SignatureAlgorithm encryptionAlgorithm, byte[] signature);
VersionedKeyEntityId getId();
List getOperations();
}