PHP Class SAML2\Message

Implements what is common between the samlp:RequestAbstractType and samlp:StatusResponseType element types.
Inheritance: implements saml2\SignedElement
显示文件 Open project: simplesamlphp/saml2 Class Usage Examples

Protected Properties

Property Type Description
$document DOMDocument This variable is used while generating XML from this message. It holds the \DOMDocument of the XML we are generating.
$extensions array Request extensions.
$messageContainedSignatureUponConstruction boolean

Public Methods

Method Description
addValidator ( callback $function, mixed $data ) Add a method for validating this message.
fromXML ( DOMElement $xml ) : Message Convert an XML element into a message.
getCertificates ( ) : array Retrieve the certificates that are included in the message.
getConsent ( ) : string Set the given consent for this message.
getDestination ( ) : string | null Retrieve the destination of this message.
getExtensions ( ) : SAML2\XML\samlp\Extensions Retrieve the Extensions.
getId ( ) : string Retrieve the identifier of this message.
getIssueInstant ( ) : integer Retrieve the issue timestamp of this message.
getIssuer ( ) : string | Issuer | null Retrieve the issuer if this message.
getRelayState ( ) : string | null Retrieve the RelayState associated with this message.
getSignatureKey ( ) : XMLSecurityKey | null Retrieve the private key we should use to sign the message.
getSignatureMethod ( ) : null | string
isMessageConstructedWithSignature ( ) : boolean Query whether or not the message contained a signature at the root level when the object was constructed.
setCertificates ( array $certificates ) Set the certificates that should be included in the message.
setConsent ( string $consent ) Set the given consent for this message.
setDestination ( string | null $destination ) Set the destination of this message.
setExtensions ( array | null $extensions ) Set the Extensions.
setId ( string $id ) Set the identifier of this message.
setIssueInstant ( integer $issueInstant ) Set the issue timestamp of this message.
setIssuer ( string | Issuer | null $issuer ) Set the issuer of this message.
setRelayState ( string | null $relayState ) Set the RelayState associated with this message.
setSignatureKey ( XMLsecurityKey $signatureKey = null ) Set the private key we should use to sign the message.
toSignedXML ( ) : DOMElement Convert this message to a signed XML document.
toUnsignedXML ( ) : DOMElement Convert this message to an unsigned XML document.
validate ( XMLSecurityKey $key ) : boolean Validate this message against a public key.

Protected Methods

Method Description
__construct ( string $tagName, DOMElement $xml = null ) Initialize a message.

Private Methods

Method Description
validateSignature ( DOMElement $xml ) Validate the signature element of a SAML message, and configure this object appropriately to perform the signature verification afterwards.

Method Details

__construct() protected method

This constructor takes an optional parameter with a \DOMElement. If this parameter is given, the message will be initialized with data from that XML element. If no XML element is given, the message is initialized with suitable default values.
protected __construct ( string $tagName, DOMElement $xml = null )
$tagName string The tag name of the root element
$xml DOMElement The input message

addValidator() public method

This function is used by the HTTP-Redirect binding, to make it possible to check the signature against the one included in the query string.
public addValidator ( callback $function, mixed $data )
$function callback The function which should be called
$data mixed The data that should be included as the first parameter to the function

fromXML() public static method

Convert an XML element into a message.
public static fromXML ( DOMElement $xml ) : Message
$xml DOMElement The root XML element
return Message The message

getCertificates() public method

Retrieve the certificates that are included in the message.
public getCertificates ( ) : array
return array An array of certificates

getConsent() public method

Most likely (though not required) a value of rn:oasis:names:tc:SAML:2.0:consent.
See also: SAML2\Constants
public getConsent ( ) : string
return string Consent

getDestination() public method

Retrieve the destination of this message.
public getDestination ( ) : string | null
return string | null The destination of this message, or NULL if no destination is given

getExtensions() public method

Retrieve the Extensions.
public getExtensions ( ) : SAML2\XML\samlp\Extensions
return SAML2\XML\samlp\Extensions

getId() public method

Retrieve the identifier of this message.
public getId ( ) : string
return string The identifier of this message

getIssueInstant() public method

Retrieve the issue timestamp of this message.
public getIssueInstant ( ) : integer
return integer The issue timestamp of this message, as an UNIX timestamp

getIssuer() public method

Retrieve the issuer if this message.
public getIssuer ( ) : string | Issuer | null
return string | SAML2\XML\saml\Issuer | null The issuer of this message, or NULL if no issuer is given

getRelayState() public method

Retrieve the RelayState associated with this message.
public getRelayState ( ) : string | null
return string | null The RelayState, or NULL if no RelayState is given

getSignatureKey() public method

Retrieve the private key we should use to sign the message.
public getSignatureKey ( ) : XMLSecurityKey | null
return RobRichards\XMLSecLibs\XMLSecurityKey | null The key, or NULL if no key is specified

getSignatureMethod() public method

public getSignatureMethod ( ) : null | string
return null | string

isMessageConstructedWithSignature() public method

Query whether or not the message contained a signature at the root level when the object was constructed.

setCertificates() public method

The certificates should be strings with the PEM encoded data.
public setCertificates ( array $certificates )
$certificates array An array of certificates

setConsent() public method

Most likely (though not required) a value of rn:oasis:names:tc:SAML:2.0:consent.
See also: SAML2\Constants
public setConsent ( string $consent )
$consent string

setDestination() public method

Set the destination of this message.
public setDestination ( string | null $destination )
$destination string | null The new destination of this message

setExtensions() public method

Set the Extensions.
public setExtensions ( array | null $extensions )
$extensions array | null The Extensions

setId() public method

Set the identifier of this message.
public setId ( string $id )
$id string The new identifier of this message

setIssueInstant() public method

Set the issue timestamp of this message.
public setIssueInstant ( integer $issueInstant )
$issueInstant integer The new issue timestamp of this message, as an UNIX timestamp

setIssuer() public method

Set the issuer of this message.
public setIssuer ( string | Issuer | null $issuer )
$issuer string | SAML2\XML\saml\Issuer | null The new issuer of this message

setRelayState() public method

Set the RelayState associated with this message.
public setRelayState ( string | null $relayState )
$relayState string | null The new RelayState

setSignatureKey() public method

If the key is null, the message will be sent unsigned.
public setSignatureKey ( XMLsecurityKey $signatureKey = null )
$signatureKey XMLsecurityKey

toSignedXML() public method

This method sign the resulting XML document if the private key for the signature is set.
public toSignedXML ( ) : DOMElement
return DOMElement The root element of the DOM tree

toUnsignedXML() public method

This method does not sign the resulting XML document.
public toUnsignedXML ( ) : DOMElement
return DOMElement The root element of the DOM tree

validate() public method

true is returned on success, false is returned if we don't have any signature we can validate. An exception is thrown if the signature validation fails.
public validate ( XMLSecurityKey $key ) : boolean
$key RobRichards\XMLSecLibs\XMLSecurityKey The key we should check against
return boolean true on success, false when we don't have a signature

Property Details

$document protected_oe property

This variable is used while generating XML from this message. It holds the \DOMDocument of the XML we are generating.
protected DOMDocument $document
return DOMDocument

$extensions protected_oe property

Request extensions.
protected array $extensions
return array

$messageContainedSignatureUponConstruction protected_oe property

protected bool $messageContainedSignatureUponConstruction
return boolean