SimpleSAML_Configuration::loadFromArray PHP Method

loadFromArray() public static method

Loads a configuration from the given array.
public static loadFromArray ( array $config, string $location = '[ARRAY]', string | null $instance = null ) : SimpleSAML_Configuration
$config array The configuration array.
$location string The location which will be given when an error occurs. Optional.
$instance string | null The name of this instance. If specified, the configuration will be loaded and an instance with that name will be kept for it to be retrieved later with getInstance($instance). If null, the configuration will not be kept for later use. Defaults to null.
return SimpleSAML_Configuration The configuration object.
    public static function loadFromArray($config, $location = '[ARRAY]', $instance = null)
    {
        assert('is_array($config)');
        assert('is_string($location)');
        $c = new SimpleSAML_Configuration($config, $location);
        if ($instance !== null) {
            self::$instance[$instance] = $c;
        }
        return $c;
    }

Usage Example

コード例 #1
0
ファイル: SAML2.php プロジェクト: filonuse/fedlab
 /**
  * Handle authentication error.
  *
  * SimpleSAML_Error_Exception $exception  The exception.
  * @param array $state  The error state.
  */
 public static function handleAuthError(SimpleSAML_Error_Exception $exception, array $state)
 {
     assert('isset($state["SPMetadata"])');
     assert('isset($state["saml:ConsumerURL"])');
     assert('array_key_exists("saml:RequestId", $state)');
     // Can be NULL.
     assert('array_key_exists("saml:RelayState", $state)');
     // Can be NULL.
     $spMetadata = $state["SPMetadata"];
     $spEntityId = $spMetadata['entityid'];
     $spMetadata = SimpleSAML_Configuration::loadFromArray($spMetadata, '$metadata[' . var_export($spEntityId, TRUE) . ']');
     $requestId = $state['saml:RequestId'];
     $relayState = $state['saml:RelayState'];
     $consumerURL = $state['saml:ConsumerURL'];
     $protocolBinding = $state['saml:Binding'];
     $idp = SimpleSAML_IdP::getByState($state);
     $idpMetadata = $idp->getConfig();
     $error = sspmod_saml_Error::fromException($exception);
     SimpleSAML_Logger::warning('Returning error to sp: ' . var_export($spEntityId, TRUE));
     $error->logWarning();
     $ar = self::buildResponse($idpMetadata, $spMetadata, $consumerURL);
     $ar->setInResponseTo($requestId);
     $ar->setRelayState($relayState);
     $ar->setStatus(array('Code' => $error->getStatus(), 'SubCode' => $error->getSubStatus(), 'Message' => $error->getStatusMessage()));
     $binding = SAML2_Binding::getBinding($protocolBinding);
     $binding->send($ar);
 }
All Usage Examples Of SimpleSAML_Configuration::loadFromArray