Class Saml2ResponseValidator
java.lang.Object
com.codename1.backend.security.saml2.Saml2ResponseValidator
Decides whether a SAML 2.0 Response an identity provider posted signs a
user in, following the Web Browser SSO profile (SAML 2.0 profiles,
section 4.1.4) and Spring Security's defaults.
A response is accepted only when all of this holds:
- It is a
samlp:Responseof version 2.0 with aSuccessstatus, addressed (Destination, when present) to this server's ACS address and issued (when it names an issuer) by the registration's identity provider. - It answers the AuthnRequest this browser sent (
InResponseTo), or it is unsolicited and answers nothing. One that names a request when none was sent from this browser is refused. - It holds exactly one
Assertion. AnEncryptedAssertionis refused as unsupported: there is no RSA decryption in this runtime. - The response, the assertion, or both, carry a signature that verifies
under
XmlSignature's rules with one of the registration's certificates. A signature that is present and does not verify refuses the response even when the other one does. - The assertion is issued by the identity provider, its
Conditionshold now (within the clock skew), and everyAudienceRestrictionnames this server's entity ID. - Its subject has a bearer
SubjectConfirmationwhose data is for this ACS address, unexpired, and for this request when it names one. - It has an
AuthnStatement. - Its ID has not been accepted before (a replay), for as long as it is valid.
The replay cache is per process. Behind a load balancer the same assertion could be accepted once by each server: keep the assertion lifetime short at the identity provider, or route a browser to one server.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvalidate(byte[] response, RelyingPartyRegistration registration, String acsLocation, String entityId, String inResponseTo, long now) Checksresponse, the decoded XML of aSAMLResponseparameter.
-
Constructor Details
-
Saml2ResponseValidator
public Saml2ResponseValidator()
-
-
Method Details
-
validate
public Saml2AuthenticatedPrincipal validate(byte[] response, RelyingPartyRegistration registration, String acsLocation, String entityId, String inResponseTo, long now) Checksresponse, the decoded XML of aSAMLResponseparameter.- Parameters:
acsLocation- this server's ACS address for the registration, resolvedentityId- this server's entity ID for the registration, resolvedinResponseTo- the ID of the AuthnRequest this browser sent; null when it sent nonenow- the time to judge validity at, in milliseconds- Returns:
- who signed in
- Throws:
Saml2AuthenticationException- when the response is refused
-