Decrypt SAML 2.0 Response

Paul Hethmon paul.hethmon at clareitysecurity.com
Mon Nov 26 08:14:14 EST 2012


Do you know for certain that the IdP is sending you attribute statements? They are not required to be present.

Paul

From: Asaf Peter <Asaf.Peter at exlibrisgroup.com<mailto:Asaf.Peter at exlibrisgroup.com>>
Reply-To: Shibboleth Dev <dev at shibboleth.net<mailto:dev at shibboleth.net>>
Date: Monday, November 26, 2012 7:34 AM
To: Shibboleth Dev <dev at shibboleth.net<mailto:dev at shibboleth.net>>
Subject: Decrypt SAML 2.0 Response

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/63ba381f/attachment-0001.html 


More information about the dev mailing list