### Question:
SamlHelper { 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; }  @PostConstruct void init(); Pair<String, String> createSamlAuthnRequestForRedirect(String destination, boolean forceAuthn, int idpType); org.w3c.dom.Document parseToDoc(String data); String decodeSAMLPostResponse(String encodedReponse); Signature getDigitalSignature(KeyStore.PrivateKeyEntry keystoreEntry); void validateSignature(Response samlResponse, Assertion assertion); LinkedMultiValueMap<String, String> extractAttributesFromResponse(Assertion samlAssertion); String getArtifactUrl(String realmId, String artifact); org.opensaml.saml2.core.Response convertToSAMLResponse(org.w3c.dom.Element element); Assertion getAssertion(org.opensaml.saml2.core.Response samlResponse, KeyStore.PrivateKeyEntry keystoreEntry); void validateStatus(org.opensaml.saml2.core.Response samlResponse); static final Namespace SAML_NS; static final Namespace SAMLP_NS; }### Answer:
@Test public void testInlineDecryption() { Resource inlineAssertionResource = new ClassPathResource("saml/inlineEncryptedAssertion.xml"); EncryptedAssertion encAssertion = createAssertion(inlineAssertionResource); Assertion assertion = samlHelper.decryptAssertion(encAssertion, encryptPKEntry); verifyAssertion(assertion); }
@Test public void testPeerDecryption() { Resource peerAssertionResource = new ClassPathResource("saml/peerEncryptedAssertion.xml"); EncryptedAssertion encAssertion = createAssertion(peerAssertionResource); Assertion assertion = samlHelper.decryptAssertion(encAssertion, encryptPKEntry); verifyAssertion(assertion); }