/** * 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.setKeyInfoGenerator(kiGenerator); } else { log.info("No factory for named KeyInfoGenerator {} was found for credential type{}", keyInfoGenName,
encParams.setKeyInfoGenerator(kiGenerator); } else { log.info("No factory for named KeyInfoGenerator {} was found for credential type{}", keyInfoGenName,
KeyInfo.DEFAULT_ELEMENT_NAME); encParams.setKeyInfoGenerator(new StaticKeyInfoGenerator(keyInfo)); encParams.setAlgorithm(algorithm); encParams.setEncryptionCredential(encryptionCredential);