use of com.orientechnologies.orient.core.exception.OInvalidStorageEncryptionKeyException in project orientdb by orientechnologies.
the class ODESEncryption method configure.
public OEncryption configure(final String iOptions) {
initialized = false;
if (iOptions == null)
throw new OSecurityException("DES encryption has been selected, but no key was found. Please configure it by passing the key as property at database create/open. The property key is: '" + OGlobalConfiguration.STORAGE_ENCRYPTION_KEY.getKey() + "'");
try {
final byte[] key = OBase64Utils.decode(iOptions);
final DESKeySpec desKeySpec = new DESKeySpec(key);
final SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM_NAME);
theKey = keyFactory.generateSecret(desKeySpec);
cipher = Cipher.getInstance(TRANSFORMATION);
} catch (Exception e) {
throw OException.wrapException(new OInvalidStorageEncryptionKeyException("Cannot initialize DES encryption with current key. Assure the key is a BASE64 - 64 bits long"), e);
}
this.initialized = true;
return this;
}
use of com.orientechnologies.orient.core.exception.OInvalidStorageEncryptionKeyException in project orientdb by orientechnologies.
the class OAESEncryption method configure.
public OEncryption configure(final String iOptions) {
initialized = false;
if (iOptions == null)
throw new OSecurityException("AES encryption has been selected, but no key was found. Please configure it by passing the key as property at database create/open. The property key is: '" + OGlobalConfiguration.STORAGE_ENCRYPTION_KEY.getKey() + "'");
try {
final byte[] key = OBase64Utils.decode(iOptions);
// AES
theKey = new SecretKeySpec(key, ALGORITHM_NAME);
cipher = Cipher.getInstance(TRANSFORMATION);
} catch (Exception e) {
throw OException.wrapException(new OInvalidStorageEncryptionKeyException("Cannot initialize AES encryption with current key. Assure the key is a BASE64 - 128 oe 256 bits long"), e);
}
this.initialized = true;
return this;
}
Aggregations