public final class Crypt
extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Crypt.Result
A crypt operation result.
|
Modifier and Type | Field and Description |
---|---|
static String |
CLASS_PROPERTY
Class property.
|
static String |
DECRYPT_KEY_PROPERTY
Decrypt key property.
|
static String |
DECRYPT_PROPERTY
Decrypt property.
|
static String |
ENCRYPT_KEY_PROPERTY
Encrypt key property.
|
static String |
ENCRYPT_PROPERTY
Encrypt property.
|
static String |
IDENT_PROPERTY
Ident property.
|
static String |
KEY_PROPERTIES
Key properties.
|
static String |
PASSWORD_PROPERTY
Password property.
|
static String |
PATH_PROPERTY
Path property.
|
static String |
PRIVATE_PROPERTIES
Public properties.
|
static String |
PUBLIC_PROPERTIES
Public properties.
|
static String |
SIGN_KEY_PROPERTY
Sign key property.
|
static String |
SIGN_PROPERTY
Sign property.
|
static String |
VERIFY_KEY_PROPERTY
Verify key property.
|
static String |
VERIFY_PROPERTY
Verify property.
|
Constructor and Description |
---|
Crypt() |
Modifier and Type | Method and Description |
---|---|
Crypt.Result |
decrypt(Serializable serializable,
String[] decryptionKeyIdents)
Decrypts a serializable when encrypted.
|
Crypt.Result |
encrypt(Serializable serializable,
String[] encryptionKeyIdents)
Encrypts a serializable.
|
Crypt.Result |
encryptAndSign(Serializable serializable,
String[] encryptionKeyIdents,
String[] signingKeyIdents)
Encryts and signs a serializable.
|
static Class<?> |
encryptedClass()
Returns the encrypted class.
|
Streamer |
getStreamer()
Gets the streamer.
|
static boolean |
isEncrypted(Serializable serializable)
Asks if a serializable is encrypted.
|
boolean |
isSecure()
Asks if the engine is secure.
|
static boolean |
isSigned(Serializable serializable)
Asks if a serializable is signed.
|
Serializable |
load(File fromFile,
boolean verify,
String[] verifyKeyIdents,
boolean decrypt,
String[] decryptKeyIdents)
Loads the content from a file.
|
Serializable |
load(XMLDocument xmlDocument,
String origin,
boolean verify,
String[] verifyKeyIdents,
boolean decrypt,
String[] decryptKeyIdents)
Loads the content from a file.
|
static Serializable |
newEncrypted(String encrypted)
Returns an encrypted object.
|
static Serializable |
newSigned(Serializable serializable,
String signed)
Returns a signed object.
|
boolean |
setUp(KeyedGroups cryptProperties,
Optional<KeyedGroups> streamerProperties)
Sets up this.
|
Crypt.Result |
sign(Serializable serializable,
String[] signingKeyIdents)
Signs a serializable.
|
static Class<?> |
signedClass()
Returns the signed class.
|
void |
tearDown()
Tears down what has been set up.
|
Crypt.Result |
verify(Serializable serializable,
String[] verificationKeyIdents)
Verifies the signature of a serializable.
|
Crypt.Result |
verifyAndDecrypt(Serializable serializable,
String[] verificationKeyIdents,
String[] decryptionKeyIdent)
Verifies and decrypts a serializable.
|
public static final String CLASS_PROPERTY
public static final String DECRYPT_KEY_PROPERTY
public static final String DECRYPT_PROPERTY
public static final String ENCRYPT_KEY_PROPERTY
public static final String ENCRYPT_PROPERTY
public static final String IDENT_PROPERTY
public static final String KEY_PROPERTIES
public static final String PASSWORD_PROPERTY
public static final String PATH_PROPERTY
public static final String PRIVATE_PROPERTIES
public static final String PUBLIC_PROPERTIES
public static final String SIGN_KEY_PROPERTY
public static final String SIGN_PROPERTY
public static final String VERIFY_KEY_PROPERTY
public static final String VERIFY_PROPERTY
@Nonnull @CheckReturnValue public static Class<?> encryptedClass()
Needed by the encrypted converter.
@CheckReturnValue public static boolean isEncrypted(@Nonnull Serializable serializable)
serializable
- The serializable.@CheckReturnValue public static boolean isSigned(@Nonnull Serializable serializable)
serializable
- The serializable.@Nonnull @CheckReturnValue public static Serializable newEncrypted(@Nonnull String encrypted)
Needed by tests and the encrypted converter.
encrypted
- A string representing an encrypted object.@Nonnull @CheckReturnValue public static Serializable newSigned(@Nonnull Serializable serializable, @Nonnull String signed)
Needed by tests.
serializable
- A serializable.signed
- A string representing signed object.@Nonnull @CheckReturnValue public static Class<?> signedClass()
Needed by the signed converter.
@Nonnull @CheckReturnValue public Crypt.Result decrypt(@Nonnull Serializable serializable, @Nonnull String[] decryptionKeyIdents)
serializable
- The object.decryptionKeyIdents
- The decryption key idents (may be empty).@Nonnull @CheckReturnValue public Crypt.Result encrypt(@Nullable Serializable serializable, @Nonnull String[] encryptionKeyIdents)
serializable
- The serializable.encryptionKeyIdents
- The encryption key idents (may be empty).@Nonnull @CheckReturnValue public Crypt.Result encryptAndSign(@Nullable Serializable serializable, @Nonnull String[] encryptionKeyIdents, @Nonnull String[] signingKeyIdents)
serializable
- The serializable.encryptionKeyIdents
- The encryption key idents (may be empty).signingKeyIdents
- The signing key idents (may be empty).@Nonnull @CheckReturnValue public Streamer getStreamer()
@CheckReturnValue public boolean isSecure()
@Nullable @CheckReturnValue public Serializable load(@Nonnull File fromFile, boolean verify, @Nonnull String[] verifyKeyIdents, boolean decrypt, @Nonnull String[] decryptKeyIdents)
fromFile
- The file.verify
- True to verify.verifyKeyIdents
- The verify key idents.decrypt
- True to decrypt.decryptKeyIdents
- The decrypt idents.@Nullable @CheckReturnValue public Serializable load(@Nonnull XMLDocument xmlDocument, @Nonnull String origin, boolean verify, @Nonnull String[] verifyKeyIdents, boolean decrypt, @Nonnull String[] decryptKeyIdents)
xmlDocument
- The XML document.origin
- The origin of the document.verify
- True to verify.verifyKeyIdents
- The verify key idents (may be empty).decrypt
- True to decrypt.decryptKeyIdents
- The decrypt idents (may be empty).@CheckReturnValue public boolean setUp(@Nonnull KeyedGroups cryptProperties, @Nonnull Optional<KeyedGroups> streamerProperties)
cryptProperties
- The crypt configuration properties.streamerProperties
- The optional streamer properties.@Nonnull @CheckReturnValue public Crypt.Result sign(@Nullable Serializable serializable, @Nonnull String[] signingKeyIdents)
serializable
- The serializable.signingKeyIdents
- The signing key idents (may be empty).public void tearDown()
@Nonnull @CheckReturnValue public Crypt.Result verify(@Nonnull Serializable serializable, @Nonnull String[] verificationKeyIdents)
serializable
- The serializable.verificationKeyIdents
- The verification key idents (may be empty).@Nonnull @CheckReturnValue public Crypt.Result verifyAndDecrypt(@Nonnull Serializable serializable, @Nonnull String[] verificationKeyIdents, @Nonnull String[] decryptionKeyIdent)
serializable
- The serializable.verificationKeyIdents
- The verification key idents (may be empty).decryptionKeyIdent
- The decryption key ident (may be empty).Copyright © 2003-2019 Serge Brisson. All Rights Reserved.