public class SamlResponse extends Object
| Constructor and Description |
|---|
SamlResponse(Saml2Settings settings,
HttpRequest request)
Constructor to have a Response object full builded and ready to validate
the saml response
|
| Modifier and Type | Method and Description |
|---|---|
Boolean |
checkOneAuthnStatement()
Checks that the samlp:Response/saml:Assertion/saml:AuthnStatement element exists and is unique.
|
Boolean |
checkOneCondition()
Checks that the samlp:Response/saml:Assertion/saml:Conditions element exists and is unique.
|
void |
checkStatus()
Checks the Status
|
String |
getAssertionId() |
List<org.joda.time.Instant> |
getAssertionNotOnOrAfter() |
HashMap<String,List<String>> |
getAttributes()
Gets the Attributes from the AttributeStatement element.
|
List<String> |
getAudiences()
Gets the audiences.
|
String |
getError()
After execute a validation process, if fails this method returns the cause
|
List<String> |
getIssuers()
Gets the Issuers (from Response and Assertion).
|
String |
getNameId()
Gets the NameID value provided from the SAML Response String.
|
HashMap<String,String> |
getNameIdData()
Gets the NameID provided from the SAML Response Document.
|
String |
getSessionIndex()
Gets the SessionIndex from the AuthnStatement.
|
org.joda.time.DateTime |
getSessionNotOnOrAfter()
Gets the SessionNotOnOrAfter from the AuthnStatement.
|
static SamlResponseStatus |
getStatus(Document dom)
Get Status from a Response
|
boolean |
isValid()
Determines if the SAML Response is valid using the certificate.
|
boolean |
isValid(String requestId)
Determines if the SAML Response is valid using the certificate.
|
void |
loadXmlFromBase64(String responseStr)
Load a XML base64encoded SAMLResponse
|
ArrayList<String> |
processSignedElements()
Verifies the signature nodes:
- Checks that are Response or Assertion
- Check that IDs and reference URI are unique and consistent.
|
void |
setDestinationUrl(String urld)
Aux method to set the destination url
|
Boolean |
validateNumAssertions()
Verifies that the document only contains a single Assertion (encrypted or not).
|
boolean |
validateSignedElements(ArrayList<String> signedElements)
Verifies that the document has the expected signed nodes.
|
boolean |
validateTimestamps()
Verifies that the document is still valid according Conditions Element.
|
public SamlResponse(Saml2Settings settings, HttpRequest request) throws Exception
settings - Saml2Settings object. Setting datarequest - the HttpRequest object to be processed (Contains GET and POST parameters, request URL, ...).Exceptionpublic void loadXmlFromBase64(String responseStr) throws Exception
responseStr - Saml2Settings object. Setting dataExceptionpublic boolean isValid(String requestId)
requestId - The ID of the AuthNRequest sent by this SP to the IdPpublic boolean isValid()
public HashMap<String,String> getNameIdData() throws Exception
Exceptionpublic String getNameId() throws Exception
Exceptionpublic HashMap<String,List<String>> getAttributes() throws Exception
Exceptionpublic void checkStatus()
IllegalArgumentException - If status is not successpublic static SamlResponseStatus getStatus(Document dom) throws IllegalArgumentException
dom - The Response as XMLIllegalArgumentException - if the response not contain status or if Unexpected XPath errorpublic Boolean checkOneCondition() throws XPathExpressionException
XPathExpressionExceptionpublic Boolean checkOneAuthnStatement() throws XPathExpressionException
XPathExpressionExceptionpublic List<String> getAudiences() throws XPathExpressionException
XPathExpressionExceptionpublic List<String> getIssuers() throws Exception
Exceptionpublic org.joda.time.DateTime getSessionNotOnOrAfter()
throws XPathExpressionException
XPathExpressionExceptionpublic String getSessionIndex() throws XPathExpressionException
XPathExpressionExceptionpublic String getAssertionId() throws XPathExpressionException
XPathExpressionExceptionpublic List<org.joda.time.Instant> getAssertionNotOnOrAfter() throws XPathExpressionException
XPathExpressionExceptionpublic Boolean validateNumAssertions() throws IllegalArgumentException
IllegalArgumentExceptionpublic ArrayList<String> processSignedElements() throws Exception
Exceptionpublic boolean validateSignedElements(ArrayList<String> signedElements) throws Exception
signedElements - the elements to be validatedExceptionpublic boolean validateTimestamps()
public void setDestinationUrl(String urld)
urld - the url to set as currentUrlpublic String getError()
Copyright © 2016. All rights reserved.