Decrypt SAML 2.0 Response

Asaf Peter Asaf.Peter at exlibrisgroup.com
Mon Nov 26 07:34:49 EST 2012


Hi,

I get the attached  XML response from Shibboleth IDP:

I am trying to decrypt it using the following code:

 File keyStoreFile = new File("C:/Users/MyUser/my-private-key.pfx");
        String certAlias = "re-23d2gt1b-779r-39ez-1156-91b3f80eaee2";
        String password = "my_password";
        KeyStore keyStore = KeyStore.getInstance("PKCS12");
        keyStore.load(new FileInputStream(keyStoreFile), password.toCharArray());
        RSAPrivateKey privateKey = (RSAPrivateKey) keyStore.getKey(certAlias, password.toCharArray());
        BasicX509Credential decryptionCredential = new BasicX509Credential();
        decryptionCredential.setPrivateKey(privateKey);
        Decrypter decrypter = new Decrypter(null, new StaticKeyInfoCredentialResolver(decryptionCredential), new InlineEncryptedKeyResolver());
        Assertion decryptedAssertion;
        try {
            decryptedAssertion = decrypter.decrypt(response.getEncryptedAssertions().get(0)); // SUCCESS!!!
        }

The decryption seems to work now - no exception is thrown and I get the decryptedAssertion.
However, I cannot find the user id in the decryptedAssertion.
The decryptedAssertion.getAttributeStatements() returns an empty list.
Am I missing something?

Thanks,
Asaf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://shibboleth.net/pipermail/dev/attachments/20121126/c74d84bc/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SAML2GoodResponseExample.xml
Type: text/xml
Size: 12941 bytes
Desc: SAML2GoodResponseExample.xml
Url : http://shibboleth.net/pipermail/dev/attachments/20121126/c74d84bc/attachment.xml 


More information about the dev mailing list