/** * Constructor. */ public EncryptionParameters() { // This will be the default for auto encryption key generation setAlgorithm(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256); }
/** * Constructor. */ public EncryptionParameters() { // This will be the default for auto encryption key generation setAlgorithm(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256); }
encParams.setAlgorithm(secConfig.getAutoGeneratedDataEncryptionKeyAlgorithmURI()); } else { encParams.setAlgorithm(secConfig.getDataEncryptionAlgorithmURI(encryptionCredential));
/** * Returns a SAML v2.0 XML {@link Encrypter} for symmetric keys * * @param algorithm * secret key algorithm * @param secretKey * the symmetric secret key * @return the encrypter */ public static Encrypter getEncrypter(String algorithm, SecretKey secretKey) { LOG.debug("get encrypter: secret.algo=" + algorithm); KeyInfo keyInfo = buildXMLObject(KeyInfo.class, KeyInfo.DEFAULT_ELEMENT_NAME); BasicCredential encryptionCredential = new BasicCredential(); encryptionCredential.setSecretKey(secretKey); EncryptionParameters encParams = new EncryptionParameters(); encParams.setKeyInfoGenerator(new StaticKeyInfoGenerator(keyInfo)); encParams.setAlgorithm(algorithm); encParams.setEncryptionCredential(encryptionCredential); List<KeyEncryptionParameters> kekParamsList = new ArrayList<KeyEncryptionParameters>(); return new Encrypter(encParams, kekParamsList); }
encParams.setAlgorithm(secConfig.getAutoGeneratedDataEncryptionKeyAlgorithmURI()); } else { encParams.setAlgorithm(secConfig.getDataEncryptionAlgorithmURI(encryptionCredential));
encParams.setAlgorithm(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128); if (null != secretKey) { encParams.setAlgorithm(algorithm); encParams.setEncryptionCredential(encryptionCredential);
@Override public EncryptedAssertion doEncryptedAssertion(Assertion assertion, X509Credential cred, String alias, String encryptionAlgorithm) throws IdentityException { try { Credential symmetricCredential = SecurityHelper.getSimpleCredential( SecurityHelper.generateSymmetricKey(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256)); EncryptionParameters encParams = new EncryptionParameters(); encParams.setAlgorithm(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256); encParams.setEncryptionCredential(symmetricCredential); KeyEncryptionParameters keyEncryptionParameters = new KeyEncryptionParameters(); keyEncryptionParameters.setAlgorithm(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSA15); keyEncryptionParameters.setEncryptionCredential(cred); Encrypter encrypter = new Encrypter(encParams, keyEncryptionParameters); encrypter.setKeyPlacement(Encrypter.KeyPlacement.INLINE); EncryptedAssertion encrypted = encrypter.encrypt(assertion); return encrypted; } catch (Exception e) { throw IdentityException.error("Error while Encrypting Assertion", e); } } }
@Override public EncryptedAssertion doEncryptedAssertion(Assertion assertion, X509Credential cred, String alias, String encryptionAlgorithm) throws IdentityException { try { Credential symmetricCredential = SecurityHelper.getSimpleCredential( SecurityHelper.generateSymmetricKey(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256)); EncryptionParameters encParams = new EncryptionParameters(); encParams.setAlgorithm(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256); encParams.setEncryptionCredential(symmetricCredential); KeyEncryptionParameters keyEncryptionParameters = new KeyEncryptionParameters(); keyEncryptionParameters.setAlgorithm(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSA15); keyEncryptionParameters.setEncryptionCredential(cred); Encrypter encrypter = new Encrypter(encParams, keyEncryptionParameters); encrypter.setKeyPlacement(Encrypter.KeyPlacement.INLINE); EncryptedAssertion encrypted = encrypter.encrypt(assertion); return encrypted; } catch (Exception e) { throw IdentityException.error("Error while Encrypting Assertion", e); } } }
encParams.setAlgorithm("http://www.w3.org/2001/04/xmlenc#aes256-cbc"); encParams.setEncryptionCredential(symmetricCredential);