# \OneLogin_Saml2_Response

SAML 2 Authentication Response

## Summary

Methods
Properties
Constants
__construct()
isValid()
getId()
getAssertionId()
getAssertionNotOnOrAfter()
checkStatus()
checkOneCondition()
checkOneAuthnStatement()
getAudiences()
getIssuers()
getNameIdData()
getNameId()
getNameIdFormat()
getNameIdNameQualifier()
getNameIdSPNameQualifier()
getSessionNotOnOrAfter()
getSessionIndex()
getAttributes()
getAttributesWithFriendlyName()
validateNumAssertions()
processSignedElements()
validateTimestamps()
validateSignedElements()
getError()
getXMLDocument()
$response
$document
$decryptedDocument
$encrypted
No constants found
_queryAssertion()
_decryptAssertion()
$_settings
N/A
_getAttributesByKeyName()
_query()
$_error
$_validSCDNotOnOrAfter
N/A

File
  Response.php
Package
  Default
Class hierarchy
  \OneLogin_Saml2_Response

## Tags

None found

## Properties

### $response

    $response : string

The decoded, unprocessed XML response provided to the constructor.

#### Type

string

#

## Tags

None found

### $document

    $document : \DomDocument

A DOMDocument class loaded from the SAML Response.

#### Type

\DomDocument

#

## Tags

None found

### $decryptedDocument

    $decryptedDocument : \DomDocument

A DOMDocument class loaded from the SAML Response (Decrypted).

#### Type

\DomDocument

#

## Tags

None found

### $encrypted

    $encrypted : boolean

The response contains an encrypted assertion.

#### Type

boolean

#

## Tags

None found

### $_settings

    $_settings : \OneLogin_Saml2_Settings

Settings

#### Type

\OneLogin_Saml2_Settings

#

## Tags

None found

### $_error

    $_error : string

After validation, if it fail this var has the cause of the problem

#### Type

string

#

## Tags

None found

### $_validSCDNotOnOrAfter

    $_validSCDNotOnOrAfter : integer

NotOnOrAfter value of a valid SubjectConfirmationData node

#### Type

integer

#

## Tags

None found

## Methods

### __construct()

    __construct(\OneLogin_Saml2_Settings  $settings, string  $response)

Constructs the SAML Response object.

#### Parameters

\OneLogin_Saml2_Settings | $settings | Settings.
string | $response | A UUEncoded SAML response from the IdP.

#### Throws

\OneLogin_Saml2_Error
\OneLogin_Saml2_ValidationError

#

## Tags

None found

### isValid()

    isValid(string|null  $requestId = null) : boolean

Determines if the SAML Response is valid using the certificate.

#### Parameters

string|null | $requestId | The ID of the AuthNRequest sent by this SP to the IdP

#### Returns

boolean —

Validate the document

#

## Tags

None found

### getId()

    getId() : string|null

#### Returns

string|null —

the ID of the Response

#

## Tags

None found

### getAssertionId()

    getAssertionId() : string|null

#### Throws

\InvalidArgumentException

#### Returns

string|null —

the ID of the assertion in the Response

#

## Tags

None found

### getAssertionNotOnOrAfter()

    getAssertionNotOnOrAfter() : integer

#### Returns

integer —

the NotOnOrAfter value of the valid SubjectConfirmationData node if any

#

## Tags

None found

### checkStatus()

    checkStatus()

Checks if the Status is success

#### Throws

\OneLogin_Saml2_ValidationError

  If status is not success

#

## Tags

None found

### checkOneCondition()

    checkOneCondition() : boolean

Checks that the samlp:Response/saml:Assertion/saml:Conditions element exists and is unique.

#### Returns

boolean —

true if the Conditions element exists and is unique

#

## Tags

None found

### checkOneAuthnStatement()

    checkOneAuthnStatement() : boolean

Checks that the samlp:Response/saml:Assertion/saml:AuthnStatement element exists and is unique.

#### Returns

boolean —

true if the AuthnStatement element exists and is unique

#

## Tags

None found

### getAudiences()

    getAudiences() : array

Gets the audiences.

#### Returns

array —

@audience The valid audiences of the response

#

## Tags

None found

### getIssuers()

    getIssuers() : array

Gets the Issuers (from Response and Assertion).

#### Throws

\OneLogin_Saml2_ValidationError

#### Returns

array —

@issuers The issuers of the assertion/response

#

## Tags

None found

### getNameIdData()

    getNameIdData() : array

Gets the NameID Data provided by the SAML response from the IdP.

#### Throws

\OneLogin_Saml2_ValidationError

#### Returns

array —

Name ID Data (Value, Format, NameQualifier, SPNameQualifier)

#

## Tags

None found

### getNameId()

    getNameId() : string|null

Gets the NameID provided by the SAML response from the IdP.

#### Throws

\OneLogin_Saml2_ValidationError

#### Returns

string|null —

Name ID Value

#

## Tags

None found

### getNameIdFormat()

    getNameIdFormat() : string|null

Gets the NameID Format provided by the SAML response from the IdP.

#### Throws

\OneLogin_Saml2_ValidationError

#### Returns

string|null —

Name ID Format

#

## Tags

None found

### getNameIdNameQualifier()

    getNameIdNameQualifier() : string|null

Gets the NameID NameQualifier provided by the SAML response from the IdP.

#### Throws

\OneLogin_Saml2_ValidationError

#### Returns

string|null —

Name ID NameQualifier

#

## Tags

None found

### getNameIdSPNameQualifier()

    getNameIdSPNameQualifier() : string|null

Gets the NameID SP NameQualifier provided by the SAML response from the IdP.

#### Throws

\ValidationError

#### Returns

string|null —

NameID SP NameQualifier

#

## Tags

None found

### getSessionNotOnOrAfter()

    getSessionNotOnOrAfter() : integer|null

Gets the SessionNotOnOrAfter from the AuthnStatement.

Could be used to set the local session expiration

#### Throws

\Exception

#### Returns

integer|null —

The SessionNotOnOrAfter value

#

## Tags

None found

### getSessionIndex()

    getSessionIndex() : string|null

Gets the SessionIndex from the AuthnStatement.

Could be used to be stored in the local session in order to be used in a future Logout Request that the SP could send to the SP, to set what specific session must be deleted

#### Returns

string|null —

The SessionIndex value

#

## Tags

None found

### getAttributes()

    getAttributes() : array

Gets the Attributes from the AttributeStatement element.

#### Throws

\OneLogin_Saml2_ValidationError

#### Returns

array —

The attributes of the SAML Assertion

#

## Tags

None found

### getAttributesWithFriendlyName()

    getAttributesWithFriendlyName() : array

Gets the Attributes from the AttributeStatement element using their FriendlyName.

#### Throws

\OneLogin_Saml2_ValidationError

#### Returns

array —

The attributes of the SAML Assertion

#

## Tags

None found

### validateNumAssertions()

    validateNumAssertions() : boolean

Verifies that the document only contains a single Assertion (encrypted or not).

#### Returns

boolean —

TRUE if the document passes.

#

## Tags

None found

### processSignedElements()

    processSignedElements() : array

Verifies the signature nodes: - Checks that are Response or Assertion - Check that IDs and reference URI are unique and consistent.

#### Throws

\OneLogin_Saml2_ValidationError

#### Returns

array —

Signed element tags

#

## Tags

None found

### validateTimestamps()

    validateTimestamps() : boolean

Verifies that the document is still valid according Conditions Element.

#### Throws

\Exception
\OneLogin_Saml2_ValidationError

#### Returns

boolean

#

## Tags

None found

### validateSignedElements()

    validateSignedElements(  $signedElements) : boolean

Verifies that the document has the expected signed nodes.

#### Parameters

| $signedElements |

#### Throws

\OneLogin_Saml2_ValidationError

#### Returns

boolean

#

## Tags

None found

### getError()

    getError() : string

After execute a validation process, if fails this method returns the cause

#### Returns

string —

Cause

#

## Tags

None found

### getXMLDocument()

    getXMLDocument() : \DomDocument

Returns the SAML Response document (If contains an encrypted assertion, decrypts it)

#### Returns

\DomDocument —

SAML Response

#

## Tags

None found

### _queryAssertion()

    _queryAssertion(string  $assertionXpath) : \DOMNodeList

Extracts a node from the DOMDocument (Assertion).

#### Parameters

string | $assertionXpath | Xpath Expression

#### Returns

\DOMNodeList —

The queried node

#

## Tags

None found

### _decryptAssertion()

    _decryptAssertion(\DomNode  $dom) : \DOMDocument

Decrypts the Assertion (DOMDocument)

#### Parameters

\DomNode | $dom | DomDocument

#### Throws

\OneLogin_Saml2_Error
\OneLogin_Saml2_ValidationError

#### Returns

\DOMDocument —

Decrypted Assertion

#

## Tags

None found

### _getAttributesByKeyName()

    _getAttributesByKeyName(string  $keyName = "Name") : array

#### Parameters

string | $keyName |

#### Throws

\OneLogin_Saml2_ValidationError

#### Returns

array

#

## Tags

None found

### _query()

    _query(string  $query) : \DOMNodeList

Extracts nodes that match the query from the DOMDocument (Response Menssage)

#### Parameters

string | $query | Xpath Expresion

#### Returns

\DOMNodeList —

The queried nodes

#

## Tags

None found

### Response.php