当前位置: 首页>>代码示例>>PHP>>正文


PHP SimpleSAML_Configuration::getDefaultEndpoint方法代码示例

本文整理汇总了PHP中SimpleSAML_Configuration::getDefaultEndpoint方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleSAML_Configuration::getDefaultEndpoint方法的具体用法?PHP SimpleSAML_Configuration::getDefaultEndpoint怎么用?PHP SimpleSAML_Configuration::getDefaultEndpoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleSAML_Configuration的用法示例。


在下文中一共展示了SimpleSAML_Configuration::getDefaultEndpoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: receive

 /**
  * This function receives a SAML 1.1 artifact.
  *
  * @param SimpleSAML_Configuration $spMetadata  The metadata of the SP.
  * @param SimpleSAML_Configuration $idpMetadata  The metadata of the IdP.
  * @return string  The <saml1p:Response> element, as an XML string.
  */
 public static function receive(SimpleSAML_Configuration $spMetadata, SimpleSAML_Configuration $idpMetadata)
 {
     $artifacts = self::getArtifacts();
     $request = self::buildRequest($artifacts);
     \SimpleSAML\Utils\XML::debugSAMLMessage($request, 'out');
     $url = $idpMetadata->getDefaultEndpoint('ArtifactResolutionService', array('urn:oasis:names:tc:SAML:1.0:bindings:SOAP-binding'));
     $url = $url['Location'];
     $peerPublicKeys = $idpMetadata->getPublicKeys('signing', TRUE);
     $certData = '';
     foreach ($peerPublicKeys as $key) {
         if ($key['type'] !== 'X509Certificate') {
             continue;
         }
         $certData .= "-----BEGIN CERTIFICATE-----\n" . chunk_split($key['X509Certificate'], 64) . "-----END CERTIFICATE-----\n";
     }
     $file = SimpleSAML\Utils\System::getTempDir() . DIRECTORY_SEPARATOR . sha1($certData) . '.crt';
     if (!file_exists($file)) {
         SimpleSAML\Utils\System::writeFile($file, $certData);
     }
     $spKeyCertFile = \SimpleSAML\Utils\Config::getCertPath($spMetadata->getString('privatekey'));
     $opts = array('ssl' => array('verify_peer' => TRUE, 'cafile' => $file, 'local_cert' => $spKeyCertFile, 'capture_peer_cert' => TRUE, 'capture_peer_chain' => TRUE), 'http' => array('method' => 'POST', 'content' => $request, 'header' => 'SOAPAction: http://www.oasis-open.org/committees/security' . "\r\n" . 'Content-Type: text/xml'));
     // Fetch the artifact
     $response = \SimpleSAML\Utils\HTTP::fetch($url, $opts);
     if ($response === FALSE) {
         throw new SimpleSAML_Error_Exception('Failed to retrieve assertion from IdP.');
     }
     \SimpleSAML\Utils\XML::debugSAMLMessage($response, 'in');
     // Find the response in the SOAP message
     $response = self::extractResponse($response);
     return $response;
 }
开发者ID:PitcherAG,项目名称:simplesamlphp,代码行数:38,代码来源:Artifact.php

示例2: getAssertionConsumerService

 /**
  * Find SP AssertionConsumerService based on parameter in AuthnRequest.
  *
  * @param array $supportedBindings  The bindings we allow for the response.
  * @param SimpleSAML_Configuration $spMetadata  The metadata for the SP.
  * @param string|NULL $AssertionConsumerServiceURL  AssertionConsumerServiceURL from request.
  * @param string|NULL $ProtocolBinding  ProtocolBinding from request.
  * @param int|NULL $AssertionConsumerServiceIndex  AssertionConsumerServiceIndex from request.
  * @return array  Array with the Location and Binding we should use for the response.
  */
 public static function getAssertionConsumerService(array $supportedBindings, SimpleSAML_Configuration $spMetadata, $AssertionConsumerServiceURL, $ProtocolBinding, $AssertionConsumerServiceIndex)
 {
     assert('is_string($AssertionConsumerServiceURL) || is_null($AssertionConsumerServiceURL)');
     assert('is_string($ProtocolBinding) || is_null($ProtocolBinding)');
     assert('is_int($AssertionConsumerServiceIndex) || is_null($AssertionConsumerServiceIndex)');
     /* We want to pick the best matching endpoint in the case where for example
      * only the ProtocolBinding is given. We therefore pick endpoints with the
      * following priority:
      *  1. isDefault="true"
      *  2. isDefault unset
      *  3. isDefault="false"
      */
     $firstNotFalse = NULL;
     $firstFalse = NULL;
     foreach ($spMetadata->getEndpoints('AssertionConsumerService') as $ep) {
         if ($AssertionConsumerServiceURL !== NULL && $ep['Location'] !== $AssertionConsumerServiceURL) {
             continue;
         }
         if ($ProtocolBinding !== NULL && $ep['Binding'] !== $ProtocolBinding) {
             continue;
         }
         if ($AssertionConsumerServiceIndex !== NULL && $ep['index'] !== $AssertionConsumerServiceIndex) {
             continue;
         }
         if (!in_array($ep['Binding'], $supportedBindings, TRUE)) {
             /* The endpoint has an unsupported binding. */
             continue;
         }
         /* We have an endpoint that matches all our requirements. Check if it is the best one. */
         if (array_key_exists('isDefault', $ep)) {
             if ($ep['isDefault'] === TRUE) {
                 /* This is the first matching endpoint with isDefault set to TRUE. */
                 return $ep;
             }
             /* isDefault is set to FALSE, but the endpoint is still useable. */
             if ($firstFalse === NULL) {
                 /* This is the first endpoint that we can use. */
                 $firstFalse = $ep;
             }
         } else {
             if ($firstNotFalse === NULL) {
                 /* This is the first endpoint without isDefault set. */
                 $firstNotFalse = $ep;
             }
         }
     }
     if ($firstNotFalse !== NULL) {
         return $firstNotFalse;
     } elseif ($firstFalse !== NULL) {
         return $firstFalse;
     }
     SimpleSAML_Logger::warning('Authentication request specifies invalid AssertionConsumerService:');
     if ($AssertionConsumerServiceURL !== NULL) {
         SimpleSAML_Logger::warning('AssertionConsumerServiceURL: ' . var_export($AssertionConsumerServiceURL, TRUE));
     }
     if ($ProtocolBinding !== NULL) {
         SimpleSAML_Logger::warning('ProtocolBinding: ' . var_export($ProtocolBinding, TRUE));
     }
     if ($AssertionConsumerServiceIndex !== NULL) {
         SimpleSAML_Logger::warning('AssertionConsumerServiceIndex: ' . var_export($AssertionConsumerServiceIndex, TRUE));
     }
     /* We have no good endpoints. Our last resort is to just use the default endpoint. */
     return $spMetadata->getDefaultEndpoint('AssertionConsumerService', $supportedBindings);
 }
开发者ID:rediris-es,项目名称:simplesamlphp,代码行数:74,代码来源:SAML2.php

示例3: buildLogoutResponse

 /**
  * Build a logout response based on information in the metadata.
  *
  * @param SimpleSAML_Configuration $srcMetadata  The metadata of the sender.
  * @param SimpleSAML_Configuration $dstpMetadata  The metadata of the recipient.
  */
 public static function buildLogoutResponse(SimpleSAML_Configuration $srcMetadata, SimpleSAML_Configuration $dstMetadata)
 {
     $dst = $dstMetadata->getDefaultEndpoint('SingleLogoutService', array(SAML2_Const::BINDING_HTTP_REDIRECT));
     if (isset($dst['ResponseLocation'])) {
         $dst = $dst['ResponseLocation'];
     } else {
         $dst = $dst['Location'];
     }
     $lr = new SAML2_LogoutResponse();
     $lr->setIssuer($srcMetadata->getString('entityid'));
     $lr->setDestination($dst);
     self::addRedirectSign($srcMetadata, $dstMetadata, $lr);
     return $lr;
 }
开发者ID:filonuse,项目名称:fedlab,代码行数:20,代码来源:Message.php


注:本文中的SimpleSAML_Configuration::getDefaultEndpoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。