/** * @return \SpConfig */ public static function current() { if (null == self::$instance) { self::$instance = new static(); } return self::$instance; }
<?php require_once __DIR__ . '/_config.php'; $buildContainer = SpConfig::current()->getBuildContainer(); $ssoState = $buildContainer->getStoreContainer()->getSsoStateStore()->get(); foreach ($ssoState->getSsoSessions() as $ssoSession) { print "<ul>\n"; print "<li>IDP: " . $ssoSession->getIdpEntityId() . "</li>\n"; print "<li>SP: " . $ssoSession->getSpEntityId() . "</li>\n"; print "<li>NameID: " . $ssoSession->getNameId() . "</li>\n"; print "<li>NameIDFormat: " . $ssoSession->getNameIdFormat() . "</li>\n"; print "<li>SessionIndex: " . $ssoSession->getSessionIndex() . "</li>\n"; print "<li>AuthnInstant: " . $ssoSession->getSessionInstant()->format('Y-m-d H:i:s P') . "</li>\n"; print "<li>FirstAuthOn: " . $ssoSession->getFirstAuthOn()->format('Y-m-d H:i:s P') . "</li>\n"; print "<li>LastAuthOn: " . $ssoSession->getLastAuthOn()->format('Y-m-d H:i:s P') . "</li>\n"; print "</ul>\n"; } if (empty($ssoState->getSsoSessions())) { print "<p>No sessions established</p>\n"; }
<?php require_once __DIR__ . '/_config.php'; $all = SpConfig::current()->getBuildContainer()->getPartyContainer()->getIdpEntityDescriptorStore()->all(); switch (count($all)) { case 0: print "None IDP configured"; exit; case 1: header('Location: login.php?idp=' . $all[0]->getEntityID()); exit; } print "<h1>Following IDPs are configured</h1>\n"; print "<p><small>Choose one</small></p>\n"; foreach ($all as $idp) { if ($idp->getAllIdpSsoDescriptors()) { print "<p><a href=\"login.php?idp={$idp->getEntityID()}\">{$idp->getEntityID()}</a></p>\n"; } } print "\n<p>LigthSAML</p>\n";
<?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); } } }
<?php require_once __DIR__ . '/_config.php'; $builder = new \LightSaml\Builder\Profile\Metadata\MetadataProfileBuilder(SpConfig::current()->getBuildContainer()); $context = $builder->buildContext(); $action = $builder->buildAction(); //print "<pre>\n"; //print_r($action->debugPrintTree()); // //exit; $action->execute($context); $context->getHttpResponseContext()->getResponse()->send();