checkSPCerts() public method

Checks if the x509 certs of the SP exists and are valid.
public checkSPCerts ( ) : boolean
return boolean
示例#1
0
 /**
  * Generates the Signature for a SAML Response
  *
  * @param string $samlResponse  The SAML Response
  * @param string $relayState    The RelayState
  * @param string $signAlgorithm Signature algorithm method
  *
  * @return string A base64 encoded signature
  *
  * @throws Exception
  * @throws OneLogin_Saml2_Error
  */
 public function buildResponseSignature($samlResponse, $relayState, $signAlgorithm = XMLSecurityKey::RSA_SHA1)
 {
     if (!$this->_settings->checkSPCerts()) {
         throw new OneLogin_Saml2_Error("Trying to sign the SAML Response but can't load the SP certs", OneLogin_Saml2_Error::SP_CERTS_NOT_FOUND);
     }
     $key = $this->_settings->getSPkey();
     $objKey = new XMLSecurityKey($signAlgorithm, array('type' => 'private'));
     $objKey->loadKey($key, false);
     $security = $this->_settings->getSecurityData();
     if ($security['lowercaseUrlencoding']) {
         $msg = 'SAMLResponse=' . rawurlencode($samlResponse);
         if (isset($relayState)) {
             $msg .= '&RelayState=' . rawurlencode($relayState);
         }
         $msg .= '&SigAlg=' . rawurlencode($signAlgorithm);
     } else {
         $msg = 'SAMLResponse=' . urlencode($samlResponse);
         if (isset($relayState)) {
             $msg .= '&RelayState=' . urlencode($relayState);
         }
         $msg .= '&SigAlg=' . urlencode($signAlgorithm);
     }
     $signature = $objKey->signData($msg);
     return base64_encode($signature);
 }
示例#2
0
 /**
  * Tests the checkSPCerts method of the OneLogin_Saml2_Settings
  *
  * @covers OneLogin_Saml2_Settings::checkSPCerts
  * @covers OneLogin_Saml2_Settings::getSPcert
  * @covers OneLogin_Saml2_Settings::getSPkey
  */
 public function testCheckSPCerts()
 {
     $settings = new OneLogin_Saml2_Settings();
     $this->assertTrue($settings->checkSPCerts());
     $settingsDir = TEST_ROOT . '/settings/';
     include $settingsDir . 'settings2.php';
     $settings2 = new OneLogin_Saml2_Settings($settingsInfo);
     $this->assertTrue($settings2->checkSPCerts());
     $this->assertEquals($settings2->getSPkey(), $settings->getSPkey());
     $this->assertEquals($settings2->getSPcert(), $settings->getSPcert());
 }