_settings = $settings; $spData = $this->_settings->getSPData(); $idpData = $this->_settings->getIdPData(); $security = $this->_settings->getSecurityData(); $id = OneLogin_Saml2_Utils::generateUniqueID(); $issueInstant = OneLogin_Saml2_Utils::parseTime2SAML(time()); $subjectStr = ""; if (isset($nameIdValueReq)) { $subjectStr = << {$nameIdValueReq} SUBJECT; } $nameIdPolicyStr = ''; if ($setNameIdPolicy) { $nameIDPolicyFormat = $spData['NameIDFormat']; if (isset($security['wantNameIdEncrypted']) && $security['wantNameIdEncrypted']) { $nameIDPolicyFormat = OneLogin_Saml2_Constants::NAMEID_ENCRYPTED; } $nameIdPolicyStr = << NAMEIDPOLICY; } $providerNameStr = ''; $organizationData = $settings->getOrganization(); if (!empty($organizationData)) { $langs = array_keys($organizationData); if (in_array('en-US', $langs)) { $lang = 'en-US'; } else { $lang = $langs[0]; } if (isset($organizationData[$lang]['displayname']) && !empty($organizationData[$lang]['displayname'])) { $providerNameStr = << urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport REQUESTEDAUTHN; } else { $requestedAuthnStr .= " \n"; foreach ($security['requestedAuthnContext'] as $contextValue) { $requestedAuthnStr .= " ".$contextValue."\n"; } $requestedAuthnStr .= ' '; } } $spEntityId = htmlspecialchars($spData['entityId'], ENT_QUOTES); $acsUrl = htmlspecialchars($spData['assertionConsumerService']['url'], ENT_QUOTES); $request = << {$spEntityId}{$subjectStr}{$nameIdPolicyStr}{$requestedAuthnStr} AUTHNREQUEST; $this->_id = $id; $this->_authnRequest = $request; } /** * Returns deflated, base64 encoded, unsigned AuthnRequest. * * @param bool|null $deflate Whether or not we should 'gzdeflate' the request body before we return it. * * @return string */ public function getRequest($deflate = null) { $subject = $this->_authnRequest; if (is_null($deflate)) { $deflate = $this->_settings->shouldCompressRequests(); } if ($deflate) { $subject = gzdeflate($this->_authnRequest); } $base64Request = base64_encode($subject); return $base64Request; } /** * Returns the AuthNRequest ID. * * @return string */ public function getId() { return $this->_id; } /** * Returns the XML that will be sent as part of the request * * @return string */ public function getXML() { return $this->_authnRequest; } }