mace-opensaml-users - Re: [OpenSAML] Decrypting SAML from File
Subject: OpenSAML user discussion
List archive
- From: Brent Putman <>
- To:
- Subject: Re: [OpenSAML] Decrypting SAML from File
- Date: Thu, 05 Feb 2009 21:12:46 -0500
Ruthenbeck, Justin wrote:
Yes.
Well, the OpenSAML Decrypter in the org.opensaml.saml2.encryption package *is* the high-level API. It doesn't really get much higher than that. It's literally: Foo foo = decrypter.decrypt(encryptedFoo) It does inherit from the XML Decrypter, which does have a lot of lower-level methods for dealing with things manually and for special cases, but for SAML you can mostly ignore those. The complexity comes in when you consider how you might go about resolving the right decryption key to use. You do need to know 1) that you're using asymmetric crypto for EncryptedKey transport (vs. possibly a pre-shared symmetric key for data encryption or something), and 2) if the former is the case, also how the sender is going to send you the encrypted data encryption key. There's really no way to avoid dealing with those questions, and is largely determined by the whoever is sending you the encrypted data. They need to inform you as to what they are going to do. FYI, probably the most common case is an EncryptedKey carrying the symmetric data encryption key which has been encrypted with RSA. If you're doing asymmetric crypto (since you mentioned private key), and they are sending you an EncryptedKey located inside the EncryptedData/KeyInfo, then something as simple as this will suffice: Credential decryptionCredential = SecurityHelper.getSimpleCredential(publicKey, privateKey); StaticKeyInfoCredentialResolver skicr = new StaticKeyInfoCredentialResolver(decryptionCredential); Decrypter decrypter = new Decrypter(null, skicr, new InlineEncryptedKeyResolver()); try { Attribute decryptedAttribute = decrypter.decrypt(encryptedAttribute); } catch (DecryptionException e) { e.printStackTrace(); } You could also instead use a Credential Resolver to resolve your decryption key in some more complex manner, esp. if you will have more than one. If they're sending you the EncryptedKey as a child of the SAML encrypted type, rather than in the EncryptedData/KeyInfo, then you would use the EncryptedElementTypeEncryptedKeyResolver rather than the Inline one. Even better, combine them both with a ChainingEncryptedKeyResolver, and then it will work for both cases, and you won't have to care.
Yes, sorry about that. I've been meaning to work on that for ages. I'll add some docs and examples there tomorrow. However, the docs for the 2 Decrypter classes do explain most of this, at least the arguments for the constructor, which is mostly what you need to know: http://www.opensaml.org/docs/opensaml/2.2.2/apidocs/org/opensaml/saml2/encryption/Decrypter.html http://www.opensaml.org/docs/opensaml/2.2.2/apidocs/org/opensaml/xml/encryption/Decrypter.html HTH, Brent |
- Decrypting SAML from File, Ruthenbeck, Justin, 02/05/2009
- Re: [OpenSAML] Decrypting SAML from File, Brent Putman, 02/05/2009
- RE: [OpenSAML] Decrypting SAML from File, Ruthenbeck, Justin, 02/06/2009
- Re: [OpenSAML] Decrypting SAML from File, Brent Putman, 02/06/2009
- Re: [OpenSAML] Decrypting SAML from File, Brent Putman, 02/07/2009
- RE: [OpenSAML] Decrypting SAML from File, Ruthenbeck, Justin, 02/09/2009
- RE: [OpenSAML] Decrypting SAML from File, Ruthenbeck, Justin, 02/06/2009
- Re: [OpenSAML] Decrypting SAML from File, Brent Putman, 02/05/2009
Archive powered by MHonArc 2.6.16.