示例#1
0
 public function test_receive_response_profile()
 {
     $buildContainer = $this->getBuildContainer('_1db06e4f91d3997b7ed3285a59f77028071db2dc5f', new TimeProviderMock(new \DateTime('@' . Helper::parseSAMLTime('2015-11-22T15:37:14Z'), new \DateTimeZone('UTC'))));
     $builder = new \LightSaml\Builder\Profile\WebBrowserSso\Sp\SsoSpReceiveResponseProfileBuilder($buildContainer);
     $context = $builder->buildContext();
     $action = $builder->buildAction();
     $request = Request::create('https://localhost/lightsaml/lightSAML/web/sp/acs.php', 'POST', ['SAMLResponse' => $this->getSamlResponseCode()]);
     $context->getHttpRequestContext()->setRequest($request);
     $action->execute($context);
     /** @var Response $response */
     $response = $context->getInboundMessage();
     $this->assertInstanceOf(Response::class, $response);
     $this->assertCount(1, $response->getAllAssertions());
     $this->assertEquals('*****@*****.**', $response->getFirstAssertion()->getFirstAttributeStatement()->getFirstAttributeByName(ClaimTypes::EMAIL_ADDRESS)->getFirstAttributeValue());
 }
示例#2
0
文件: acs.php 项目: aarnaud/lightSAML
<?php

require_once __DIR__ . '/_config.php';
$buildContainer = SpConfig::current()->getBuildContainer();
$builder = new \LightSaml\Builder\Profile\WebBrowserSso\Sp\SsoSpReceiveResponseProfileBuilder($buildContainer);
$context = $builder->buildContext();
$action = $builder->buildAction();
if (SpConfig::current()->debug) {
    var_dump('ACTION TREE');
    var_dump($action->__toString());
}
try {
    $action->execute($context);
} catch (\Exception $ex) {
    var_dump('CONTEXT TREE');
    var_dump($context->__toString());
    throw new \RuntimeException('Error', 0, $ex);
}
var_dump('CONTEXT TREE');
var_dump($context->__toString());
$response = \LightSaml\Context\Profile\Helper\MessageContextHelper::asResponse($context->getInboundContext());
var_dump('RELAY STATE');
var_dump($response->getRelayState());
var_dump('ATTRIBUTES');
foreach ($response->getAllAssertions() as $assertion) {
    foreach ($assertion->getAllAttributeStatements() as $attributeStatement) {
        foreach ($attributeStatement->getAllAttributes() as $attribute) {
            var_dump($attribute);
        }
    }
}