public KeyInfoGenerator getKeyInfoGenerator(Credential credential) { NamedKeyInfoGeneratorManager manager = DefaultSecurityConfigurationBootstrap .buildBasicKeyInfoGeneratorManager(); return manager.getDefaultManager().getFactory(credential).newInstance(); }
@Override public final KeyInfoGenerator getKeyInfoGenerator() { final NamedKeyInfoGeneratorManager mgmr = DefaultSecurityConfigurationBootstrap.buildBasicKeyInfoGeneratorManager(); final Credential credential = getCredential(); return mgmr.getDefaultManager().getFactory(credential).newInstance(); }
private KeyInfo getKeyInfo(final Credential c, final String keyName) { final SecurityConfiguration secConfiguration = Configuration.getGlobalSecurityConfiguration(); final NamedKeyInfoGeneratorManager namedKeyInfoGeneratorManager = secConfiguration.getKeyInfoGeneratorManager(); final KeyInfoGeneratorManager keyInfoGeneratorManager = namedKeyInfoGeneratorManager.getDefaultManager(); final KeyInfoGeneratorFactory keyInfoGeneratorFactory = keyInfoGeneratorManager.getFactory(c); final KeyInfoGenerator keyInfoGenerator = keyInfoGeneratorFactory.newInstance(); KeyInfo keyInfo; keyInfo = keyInfoGenerator.generate(c); KeyInfoHelper.addKeyName(keyInfo, keyName); return keyInfo; }
Assertion assertion = createAssertion(); // Assume this contains a recipient's RSA public key Credential keyEncryptionCredential = getKEKCredential(); EncryptionParameters encParams = new EncryptionParameters(); encParams.setAlgorithm(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256); KeyEncryptionParameters kekParams = new KeyEncryptionParameters(); kekParams.setEncryptionCredential(keyEncryptionCredential); kekParams.setAlgorithm(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP); KeyInfoGeneratorFactory kigf = Configuration.getGlobalSecurityConfiguration() .getKeyInfoGeneratorManager().getDefaultManager() .getFactory(keyEncryptionCredential); kekParams.setKeyInfoGenerator(kigf.newInstance()); Encrypter samlEncrypter = new Encrypter(encParams, kekParams); samlEncrypter.setKeyPlacement(KeyPlacement.PEER);
final KeyInfoGenerator kig = kigf.newInstance(); try { final KeyInfo keyInfo = kig.generate(cred);
KeyInfoGeneratorFactory factory = keyInfoGeneratorManager .getFactory(credential); KeyInfoGenerator generator = factory.newInstance(); return generator.generate(credential);