use of javax.security.auth.DestroyFailedException in project j2objc by google.
the class DestroyFailedExceptionTest method testDestroyFailedException02.
/**
* javax.security.auth.DestroyFailedException#DestroyFailedException(String msg)
* Assertion: constructs with not null parameter.
*/
public void testDestroyFailedException02() {
DestroyFailedException dfE;
for (int i = 0; i < msgs.length; i++) {
dfE = new DestroyFailedException(msgs[i]);
assertEquals("getMessage() must return: ".concat(msgs[i]), dfE.getMessage(), msgs[i]);
assertNull("getCause() must return null", dfE.getCause());
}
}
use of javax.security.auth.DestroyFailedException in project cxf by apache.
the class AbstractContentEncryptionAlgorithm method getContentEncryptionKey.
public byte[] getContentEncryptionKey(JweHeaders headers) {
final byte[] theCek;
if (cek == null) {
String algoJava = getAlgorithm().getJavaName();
SecretKey secretKey = CryptoUtils.getSecretKey(AlgorithmUtils.stripAlgoProperties(algoJava), getContentEncryptionKeySize(headers));
theCek = secretKey.getEncoded();
if (generateCekOnce) {
synchronized (this) {
cek = theCek;
}
}
// Clean the key after we're done with it
try {
secretKey.destroy();
} catch (DestroyFailedException e) {
// ignore
}
} else {
theCek = cek;
}
return theCek;
}
use of javax.security.auth.DestroyFailedException in project cxf by apache.
the class AbstractJweDecryption method doDecrypt.
protected JweDecryptionOutput doDecrypt(JweDecryptionInput jweDecryptionInput, byte[] cek) {
KeyProperties keyProperties = new KeyProperties(getContentEncryptionAlgorithm(jweDecryptionInput));
keyProperties.setAdditionalData(getContentEncryptionCipherAAD(jweDecryptionInput));
AlgorithmParameterSpec spec = getContentEncryptionCipherSpec(jweDecryptionInput);
keyProperties.setAlgoSpec(spec);
boolean compressionSupported = JoseConstants.JWE_DEFLATE_ZIP_ALGORITHM.equals(jweDecryptionInput.getJweHeaders().getZipAlgorithm());
keyProperties.setCompressionSupported(compressionSupported);
byte[] actualCek = getActualCek(cek, jweDecryptionInput.getJweHeaders().getContentEncryptionAlgorithm().getJwaName());
SecretKey secretKey = CryptoUtils.createSecretKeySpec(actualCek, keyProperties.getKeyAlgo());
byte[] bytes = CryptoUtils.decryptBytes(getEncryptedContentWithAuthTag(jweDecryptionInput), secretKey, keyProperties);
// Here we're finished with the SecretKey we created, so we can destroy it
try {
secretKey.destroy();
} catch (DestroyFailedException e) {
// ignore
}
Arrays.fill(cek, (byte) 0);
if (actualCek != cek) {
Arrays.fill(actualCek, (byte) 0);
}
return new JweDecryptionOutput(jweDecryptionInput.getJweHeaders(), bytes);
}
use of javax.security.auth.DestroyFailedException in project cxf by apache.
the class ModelEncryptionSupport method decryptRefreshToken.
public static RefreshToken decryptRefreshToken(OAuthDataProvider provider, String encodedToken, String encodedSecretKey, KeyProperties props) throws SecurityException {
SecretKey key = CryptoUtils.decodeSecretKey(encodedSecretKey, props.getKeyAlgo());
RefreshToken refreshToken = decryptRefreshToken(provider, encodedToken, key, props);
// Clean the secret key from memory when we're done
try {
key.destroy();
} catch (DestroyFailedException ex) {
// ignore
}
return refreshToken;
}
use of javax.security.auth.DestroyFailedException in project cxf by apache.
the class ModelEncryptionSupport method decryptClient.
public static Client decryptClient(String encodedSequence, String encodedSecretKey, KeyProperties props) throws SecurityException {
SecretKey key = CryptoUtils.decodeSecretKey(encodedSecretKey, props.getKeyAlgo());
Client client = decryptClient(encodedSequence, key, props);
// Clean the secret key from memory when we're done
try {
key.destroy();
} catch (DestroyFailedException ex) {
// ignore
}
return client;
}
Aggregations