org.opensaml.xml.security.keyinfo.StaticKeyInfoCredentialResolver Java Examples
The following examples show how to use
org.opensaml.xml.security.keyinfo.StaticKeyInfoCredentialResolver.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SAMLClient.java From saml-sdk-java with Apache License 2.0 | 6 votes |
/** * Decrypt an assertion using the privkey stored in SPConfig. */ private Assertion decrypt(EncryptedAssertion encrypted) throws DecryptionException { if (spConfig.getPrivateKey() == null) throw new DecryptionException("Encrypted assertion found but no SP key available"); BasicCredential cred = new BasicCredential(); cred.setPrivateKey(spConfig.getPrivateKey()); StaticKeyInfoCredentialResolver resolver = new StaticKeyInfoCredentialResolver(cred); Decrypter decrypter = new Decrypter(null, resolver, new InlineEncryptedKeyResolver()); decrypter.setRootInNewDocument(true); return decrypter.decrypt(encrypted); }
Example #2
Source File: SamlHelper.java From secure-data-service with Apache License 2.0 | 6 votes |
protected Assertion decryptAssertion(EncryptedAssertion encryptedAssertion, KeyStore.PrivateKeyEntry keystoreEntry) { BasicX509Credential decryptionCredential = new BasicX509Credential(); decryptionCredential.setPrivateKey(keystoreEntry.getPrivateKey()); StaticKeyInfoCredentialResolver resolver = new StaticKeyInfoCredentialResolver(decryptionCredential); ChainingEncryptedKeyResolver keyResolver = new ChainingEncryptedKeyResolver(); keyResolver.getResolverChain().add(new InlineEncryptedKeyResolver()); keyResolver.getResolverChain().add(new EncryptedElementTypeEncryptedKeyResolver()); keyResolver.getResolverChain().add(new SimpleRetrievalMethodEncryptedKeyResolver()); Decrypter decrypter = new Decrypter(null, resolver, keyResolver); decrypter.setRootInNewDocument(true); Assertion assertion = null; try { assertion = decrypter.decrypt(encryptedAssertion); } catch (DecryptionException e) { raiseSamlValidationError("Unable to decrypt SAML assertion", null); } return assertion; }