mace-opensaml-users - Re: Validating a signature - Help
Subject: OpenSAML user discussion
List archive
- From: Brent Putman <>
- To:
- Subject: Re: Validating a signature - Help
- Date: Fri, 15 Feb 2008 18:22:52 -0500
In case you didn't find it, have a look here: https://spaces.internet2.edu/display/SHIB/OSTwoUserManJavaDSIG That describes the use of the org.opensaml.xml.signature.SignatureValidator, which is our lowest level component that does the actual cryptographic validation of the signature.. More below... Jerry Thome wrote:
Yeah, the above SignatureValidator is what you need for the low-level crypto operation. To get a Java X509Certificate or PublicKey object from the KeyInfo, see the org.opensaml.xml.security.keyinfo.KeyInfoHelper class. There are methods to convert the Java cert or key into a Credential in the org.opensaml.xml.security.SecurityHelper. Or even better, see the KeyInfoCredentialResolver stuff in the security.keyinfo package. These are the lowest level things you could do
To be clear, you don't *have* to use certificates or keys from SAML metadata. But for production use, you do have to perform some trust evaluation on the validation key. You can't just validate with what's in the response KeyInfo and be done. For anything other than playing around and learning, you have to do some trust evaluation, and that's what the SignatureTrustEngines are for - the perform the cryptographic validation of the signature and the trust evaluation of the key/certificate together, based on resolving trusted information using some kind of resolver, e.g. CredentialResolver of trusted credentials. Just FYI.
Technically, you probably shouldn't cast that to a ResponseImpl, but rather just Response, which is an interface. Don't want to make assumptions about the underlying class implementation. It might change, etc. KeyInfo keyInfo = sig.getKeyInfo(); You can also use a KeyInfoCredentialResolver to get the Credential out of the KeyInfo: KeyInfoCredentialResolver kiResolver = Configuration.getGlobalSecurityConfiguration().getDefaultKeyInfoCredentialResolver(); CriteriaSet criteriaSet = new CriteriaSet( new KeyInfoCriteria(keyInfo) ); Credential cred = kiResolver.resolveSingle(criteriaSet); And use that resolved credential as the input to the SignatureValidator.
Note that the *SchemaValidators called like that only validate that actual object, not any children (e.g. Assertions within the Response). If you to validate the whole response, do something like: ValidatorSuite suite = Configuration.getValidatorSuite("saml2-core-schema-validator"); suite.validate(response); Assuming that you're using SAML 2. Of course you could also do DOM-level schema validation via the ParserPool, which would be much more efficient. HTH, Brent |
- Validating a signature - Help, Jerry Thome, 02/15/2008
- Re: Validating a signature - Help, Brent Putman, 02/15/2008
- Re: Validating a signature - Help, Jerry Thome, 02/18/2008
- Re: Validating a signature - Help, Brent Putman, 02/19/2008
- Re: Validating a signature - Help, Brent Putman, 02/19/2008
- Re: Validating a signature - Help, Jerry Thome, 02/18/2008
- Re: Validating a signature - Help, Brent Putman, 02/15/2008
Archive powered by MHonArc 2.6.16.