36 $store = SimpleSAML_Store::getInstance();
38 throw new \Exception(
'Unable to send artifact without a datastore configured.');
42 $artifact = base64_encode(
"\x00\x04\x00\x00" . sha1($message->
getIssuer(),
true) . $generatedId) ;
44 $artifactDataString = $artifactData->ownerDocument->saveXML($artifactData);
46 $store->set(
'artifact',
$artifact, $artifactDataString, Temporal::getTime() + 15*60);
80 public function receive()
82 if (array_key_exists(
'SAMLart', $_REQUEST)) {
83 $artifact = base64_decode($_REQUEST[
'SAMLart']);
84 $endpointIndex = bin2hex(substr(
$artifact, 2, 2));
87 throw new \Exception(
'Missing SAMLart parameter.');
95 throw new \Exception(
'No metadata found for remote provider with SHA1 ID: ' . var_export(
$sourceId,
true));
99 foreach (
$idpMetadata->getEndpoints(
'ArtifactResolutionService') as $ep) {
100 if ($ep[
'index'] === hexdec($endpointIndex)) {
107 throw new \Exception(
'No ArtifactResolutionService with the correct index.');
110 Utils::getContainer()->getLogger()->debug(
"ArtifactResolutionService endpoint being used is := " .
$endpoint[
'Location']);
117 $ar->setIssuer($this->spMetadata->getString(
'entityid'));
118 $ar->setArtifact($_REQUEST[
'SAMLart']);
119 $ar->setDestination(
$endpoint[
'Location']);
131 throw new \Exception(
'Received error from ArtifactResolutionService.');
141 $samlResponse = Message::fromXML(
$xml);
142 $samlResponse->addValidator(array(get_class($this),
'validateSignature'),
$artifactResponse);
144 if (isset($_REQUEST[
'RelayState'])) {
145 $samlResponse->setRelayState($_REQUEST[
'RelayState']);
148 return $samlResponse;
156 $this->spMetadata = $sp;
getRelayState()
Retrieve the RelayState associated with this message.
getIssuer()
Retrieve the issuer if this message.
if(! $oauthconfig->getBoolean('getUserInfo.enable', FALSE)) $store
Base class for all SAML 2 messages.
catch(Exception $e) $message
if(!array_key_exists(sspmod_authfacebook_Auth_Source_Facebook::AUTHID, $state)) $sourceId
getRedirectURL(Message $message)
Create the redirect URL for a message.
static generateRandomBytes($length)
static validateSignature(ArtifactResponse $message, XMLSecurityKey $key)
A validator which returns true if the ArtifactResponse was signed with the given key.
setSPMetadata(SimpleSAML_Configuration $sp)
static addSign(SimpleSAML_Configuration $srcMetadata, SimpleSAML_Configuration $dstMetadata, \SAML2\SignedElement $element)
Add signature key and sender certificate to an element (Message or Assertion).
validate(XMLSecurityKey $key)
Validate this message against a public key.
toUnsignedXML()
Convert this message to an unsigned XML document.
static stringToHex($bytes)
send(Message $message)
Send a SAML 2 message using the HTTP-Redirect binding.
getDestination()
Retrieve the destination of this message.
static addURLparameter($url, $parameters)