/** * Attach the data to the token, and establish the Callback URL and verifier * @param $requestTokenKey RequestToken that was authorized * @param $data Data that is authorized and to be attached to the requestToken * @return array(string:url, string:verifier) ; empty verifier for 1.0-response */ public function authorize($requestTokenKey, $data) { $url = null; $verifier = ''; $version = $this->defaultversion; // See whether to remember values from the original requestToken request: $request_attributes = $this->store->get('requesttorequest', $requestTokenKey, ''); // must be there .. if ($request_attributes['value']) { // establish version to work with $v = $request_attributes['value']['version']; if ($v) { $version = $v; } // establish callback to use if ($request_attributes['value']['callback']) { $url = $request_attributes['value']['callback']; } } // Is there a callback registered? This is leading, even over a supplied oauth_callback-parameter $oConsumer = $this->lookup_consumer($request_attributes['value']['consumerKey']); if ($oConsumer && $oConsumer->callback_url) { $url = $oConsumer->callback_url; } $verifier = SimpleSAML\Utils\Random::generateID(); $url = \SimpleSAML\Utils\HTTP::addURLParameters($url, array("oauth_verifier" => $verifier)); $this->store->set('authorized', $requestTokenKey, $verifier, $data, $this->config->getValue('requestTokenDuration', 60 * 30)); return array($url, $verifier); }
/** * Test SimpleSAML\Utils\HTTP::addURLParameters(). */ public function testAddURLParameters() { $url = 'http://example.com/'; $params = array('foo' => 'bar', 'bar' => 'foo'); $this->assertEquals($url . '?foo=bar&bar=foo', HTTP::addURLParameters($url, $params)); $url = 'http://example.com/?'; $params = array('foo' => 'bar', 'bar' => 'foo'); $this->assertEquals($url . 'foo=bar&bar=foo', HTTP::addURLParameters($url, $params)); $url = 'http://example.com/?foo=bar'; $params = array('bar' => 'foo'); $this->assertEquals($url . '&bar=foo', HTTP::addURLParameters($url, $params)); }
/** * Gets the language navigation bar. * * @param SimpleSAML_XHTML_Template $view The view object, * @param array $post The _POST array. * * @return string Resulting html markup. */ function simplesamlphp_get_languagebar(SimpleSAML_XHTML_Template $view, $params = array()) { if (!empty($params['post'])) { return ''; } if (isset($view->data['hideLanguageBar']) && $view->data['hideLanguageBar'] === TRUE) { return ''; } $languages = simplesamlphp_get_languages(); $result = '<ul class="dropdown-menu">'; $template = '<li><a href="!href">!name</a></li>'; foreach ($languages as $lang => $name) { $href = \SimpleSAML\Utils\HTTP::addURLParameters(\SimpleSAML\Utils\HTTP::getSelfURL(), array($params['languageParameterName'] => $lang)); $result .= strtr($template, array('!href' => $href, '!name' => $name)); } return $result . '</ul>'; }
/** * Log-in using Twitter platform * * @param array &$state Information about the current authentication. */ public function authenticate(&$state) { assert('is_array($state)'); /* We are going to need the authId in order to retrieve this authentication source later. */ $state[self::AUTHID] = $this->authId; $stateID = SimpleSAML_Auth_State::saveState($state, self::STAGE_INIT); $consumer = new sspmod_oauth_Consumer($this->key, $this->secret); // Get the request token $linkback = SimpleSAML_Module::getModuleURL('authtwitter/linkback.php', array('AuthState' => $stateID)); $requestToken = $consumer->getRequestToken('https://api.twitter.com/oauth/request_token', array('oauth_callback' => $linkback)); SimpleSAML_Logger::debug("Got a request token from the OAuth service provider [" . $requestToken->key . "] with the secret [" . $requestToken->secret . "]"); $state['authtwitter:authdata:requestToken'] = $requestToken; SimpleSAML_Auth_State::saveState($state, self::STAGE_INIT); // Authorize the request token $url = 'https://api.twitter.com/oauth/authenticate'; if ($this->force_login) { $url = \SimpleSAML\Utils\HTTP::addURLParameters($url, array('force_login' => 'true')); } $consumer->getAuthorizeRequest($url, $requestToken); }
/** * Get absolute URL to a specified module resource. * * This function creates an absolute URL to a resource stored under ".../modules/<module>/www/". * * @param string $resource Resource path, on the form "<module name>/<resource>" * @param array $parameters Extra parameters which should be added to the URL. Optional. * * @return string The absolute URL to the given resource. */ public static function getModuleURL($resource, array $parameters = array()) { assert('is_string($resource)'); assert('$resource[0] !== "/"'); $url = \SimpleSAML\Utils\HTTP::getBaseURL() . 'module.php/' . $resource; if (!empty($parameters)) { $url = \SimpleSAML\Utils\HTTP::addURLParameters($url, $parameters); } return $url; }
public function getAuthorizeRequest($url, $requestToken, $redirect = TRUE, $callback = NULL) { $params = array('oauth_token' => $requestToken->key); if ($callback) { $params['oauth_callback'] = $callback; } $authorizeURL = \SimpleSAML\Utils\HTTP::addURLParameters($url, $params); if ($redirect) { \SimpleSAML\Utils\HTTP::redirectTrustedURL($authorizeURL); exit; } return $authorizeURL; }
/** * Helper function for sending CDC messages. * * @param string $to The URL the message should be delivered to. * @param string $parameter The query parameter the message should be sent in. * @param array $message The CDC message. */ private function send($to, $parameter, array $message) { assert('is_string($to)'); assert('is_string($parameter)'); $message['timestamp'] = time(); $message = json_encode($message); $message = base64_encode($message); $signature = $this->calcSignature($message); $params = array($parameter => $message, 'Signature' => $signature); $url = \SimpleSAML\Utils\HTTP::addURLParameters($to, $params); if (strlen($url) < 2048) { \SimpleSAML\Utils\HTTP::redirectTrustedURL($url); } else { \SimpleSAML\Utils\HTTP::submitPOSTData($to, $params); } }
/** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::addURLParameters() instead. */ public static function addURLparameter($url, $parameters) { return \SimpleSAML\Utils\HTTP::addURLParameters($url, $parameters); }
} if (isset($this->data['hideLanguageBar']) && $this->data['hideLanguageBar'] === TRUE) { $includeLanguageBar = FALSE; } if ($includeLanguageBar) { $languages = $this->getLanguageList(); if (count($languages) > 1) { echo '<div id="languagebar">'; $langnames = array('no' => 'Bokmål', 'nn' => 'Nynorsk', 'se' => 'Sámegiella', 'sam' => 'Åarjelh-saemien giele', 'da' => 'Dansk', 'en' => 'English', 'de' => 'Deutsch', 'sv' => 'Svenska', 'fi' => 'Suomeksi', 'es' => 'Español', 'fr' => 'Français', 'it' => 'Italiano', 'nl' => 'Nederlands', 'lb' => 'Lëtzebuergesch', 'cs' => 'Čeština', 'sl' => 'Slovenščina', 'lt' => 'Lietuvių kalba', 'hr' => 'Hrvatski', 'hu' => 'Magyar', 'pl' => 'Język polski', 'pt' => 'Português', 'pt-br' => 'Português brasileiro', 'ru' => 'русский язык', 'et' => 'eesti keel', 'tr' => 'Türkçe', 'el' => 'ελληνικά', 'ja' => '日本語', 'zh' => '简体中文', 'zh-tw' => '繁體中文', 'ar' => 'العربية', 'fa' => 'پارسی', 'ur' => 'اردو', 'he' => 'עִבְרִית', 'id' => 'Bahasa Indonesia', 'sr' => 'Srpski', 'lv' => 'Latviešu', 'ro' => 'Românește', 'eu' => 'Euskara'); $textarray = array(); foreach ($languages as $lang => $current) { $lang = strtolower($lang); if ($current) { $textarray[] = $langnames[$lang]; } else { $textarray[] = '<a href="' . htmlspecialchars(\SimpleSAML\Utils\HTTP::addURLParameters(\SimpleSAML\Utils\HTTP::getSelfURL(), array($this->languageParameterName => $lang))) . '">' . $langnames[$lang] . '</a>'; } } echo join(' | ', $textarray); echo '</div>'; } } ?> <div id="content"> <?php if (!empty($this->data['htmlinject']['htmlContentPre'])) { foreach ($this->data['htmlinject']['htmlContentPre'] as $c) { echo $c;
$site = $op[1]; $site = pack("H*", $site); $server->removeTrustRoot($identity, $site); } } \SimpleSAML\Utils\HTTP::redirectTrustedURL($identity); } if ($ownPage) { $trustedSites = $server->getTrustRoots($identity); } else { $trustedSites = array(); } $userBase = SimpleSAML\Module::getModuleURL('openidProvider/user.php'); $xrds = SimpleSAML\Module::getModuleURL('openidProvider/xrds.php'); if ($userId !== FALSE) { $xrds = \SimpleSAML\Utils\HTTP::addURLParameters($xrds, array('user' => $userId)); } $as = $server->getAuthSource(); $t = new SimpleSAML_XHTML_Template($globalConfig, 'openidProvider:user.tpl.php'); $t->data['identity'] = $identity; $t->data['loggedInAs'] = $server->getUserId(); $t->data['loginURL'] = $as->getLoginURL($userBase); $t->data['logoutURL'] = $as->getLogoutURL(); $t->data['ownPage'] = $ownPage; $t->data['serverURL'] = $server->getServerURL(); $t->data['trustedSites'] = $trustedSites; $t->data['userId'] = $userId; $t->data['userIdURL'] = $userBase . '/' . $userId; $t->data['xrdsURL'] = $xrds; $t->show(); exit(0);
/** * Receive an authentication request. * * @param SimpleSAML_IdP $idp The IdP we are receiving it for. */ public static function receiveAuthnRequest(SimpleSAML_IdP $idp) { if (isset($_REQUEST['cookieTime'])) { $cookieTime = (int) $_REQUEST['cookieTime']; if ($cookieTime + 5 > time()) { /* * Less than five seconds has passed since we were * here the last time. Cookies are probably disabled. */ \SimpleSAML\Utils\HTTP::checkSessionCookie(\SimpleSAML\Utils\HTTP::getSelfURL()); } } if (!isset($_REQUEST['providerId'])) { throw new SimpleSAML_Error_BadRequest('Missing providerId parameter.'); } $spEntityId = (string) $_REQUEST['providerId']; if (!isset($_REQUEST['shire'])) { throw new SimpleSAML_Error_BadRequest('Missing shire parameter.'); } $shire = (string) $_REQUEST['shire']; if (isset($_REQUEST['target'])) { $target = $_REQUEST['target']; } else { $target = NULL; } SimpleSAML\Logger::info('Shib1.3 - IdP.SSOService: Got incoming Shib authnRequest from ' . var_export($spEntityId, TRUE) . '.'); $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); $spMetadata = $metadata->getMetaDataConfig($spEntityId, 'shib13-sp-remote'); $found = FALSE; foreach ($spMetadata->getEndpoints('AssertionConsumerService') as $ep) { if ($ep['Binding'] !== 'urn:oasis:names:tc:SAML:1.0:profiles:browser-post') { continue; } if ($ep['Location'] !== $shire) { continue; } $found = TRUE; break; } if (!$found) { throw new Exception('Invalid AssertionConsumerService for SP ' . var_export($spEntityId, TRUE) . ': ' . var_export($shire, TRUE)); } SimpleSAML_Stats::log('saml:idp:AuthnRequest', array('spEntityID' => $spEntityId, 'protocol' => 'saml1')); $sessionLostURL = \SimpleSAML\Utils\HTTP::addURLParameters(\SimpleSAML\Utils\HTTP::getSelfURL(), array('cookieTime' => time())); $state = array('Responder' => array('sspmod_saml_IdP_SAML1', 'sendResponse'), 'SPMetadata' => $spMetadata->toArray(), SimpleSAML_Auth_State::RESTART => $sessionLostURL, 'saml:shire' => $shire, 'saml:target' => $target, 'saml:AuthnRequestReceivedAt' => microtime(TRUE)); $idp->handleAuthenticationRequest($state); }
<?php if (empty($_REQUEST['entityID'])) { throw new Exception('Missing parameter [entityID]'); } if (empty($_REQUEST['return'])) { throw new Exception('Missing parameter [return]'); } $djconfig = SimpleSAML_Configuration::getOptionalConfig('discojuice.php'); $config = SimpleSAML_Configuration::getInstance(); // EntityID $entityid = $_REQUEST['entityID']; // Return to... $returnidparam = !empty($_REQUEST['returnIDParam']) ? $_REQUEST['returnIDParam'] : 'entityID'; $href = \SimpleSAML\Utils\HTTP::addURLParameters($_REQUEST['return'], array($returnidparam => '')); $hostedConfig = array($djconfig->getString('name', 'Service'), $entityid, SimpleSAML\Module::getModuleURL('discojuice/response.html'), $djconfig->getArray('feeds', array('edugain')), $href); /* "a.signin", "Teest Demooo", "https://example.org/saml2/entityid", "' . SimpleSAML\Module::getModuleURL('discojuice/discojuice/discojuiceDiscoveryResponse.html') . '", ["kalmar"], "http://example.org/login?idp=" */ $t = new SimpleSAML_XHTML_Template($config, 'discojuice:central.tpl.php'); $t->data['hostedConfig'] = $hostedConfig; $t->data['enableCentralStorage'] = $djconfig->getBoolean('enableCentralStorage', true); $t->data['additionalFeeds'] = $djconfig->getArray('additionalFeeds', null); $t->show();
* renew * gateway * */ if (!array_key_exists('service', $_GET)) { throw new Exception('Required URL query parameter [service] not provided. (CAS Server)'); } $service = $_GET['service']; $forceAuthn = isset($_GET['renew']) && $_GET['renew']; $isPassive = isset($_GET['gateway']) && $_GET['gateway']; $config = SimpleSAML_Configuration::getInstance(); $casconfig = SimpleSAML_Configuration::getConfig('module_casserver.php'); $legal_service_urls = $casconfig->getValue('legal_service_urls'); if (!checkServiceURL($service, $legal_service_urls)) { throw new Exception('Service parameter provided to CAS server is not listed as a legal service: [service] = ' . $service); } $auth = $casconfig->getValue('auth', 'saml2'); if (!in_array($auth, array('saml2', 'shib13'))) { throw new Exception('CAS Service configured to use [auth] = ' . $auth . ' only [saml2,shib13] is legal.'); } $as = new SimpleSAML_Auth_Simple($auth); if (!$as->isAuthenticated()) { $params = array('ForceAuthn' => $forceAuthn, 'isPassive' => $isPassive); $as->login($params); } $attributes = $as->getAttributes(); $path = $casconfig->resolvePath($casconfig->getValue('ticketcache', '/tmp')); $ticket = str_replace('_', 'ST-', SimpleSAML\Utils\Random::generateID()); storeTicket($ticket, $path, array('service' => $service, 'forceAuthn' => $forceAuthn, 'attributes' => $attributes, 'proxies' => array(), 'validbefore' => time() + 5)); \SimpleSAML\Utils\HTTP::redirectTrustedURL(\SimpleSAML\Utils\HTTP::addURLParameters($service, array('ticket' => $ticket)));
/** * Save the state, and return a URL that can contain a reference to the state. * * @param string $page The name of the page. * @param array $state The state array. * @return string A URL with the state ID as a parameter. */ private function getStateURL($page, array $state) { assert('is_string($page)'); $stateId = SimpleSAML_Auth_State::saveState($state, 'openidProvider:resumeState'); $stateURL = SimpleSAML\Module::getModuleURL('openidProvider/' . $page); $stateURL = \SimpleSAML\Utils\HTTP::addURLParameters($stateURL, array('StateID' => $stateId)); return $stateURL; }
if (!$idpmeta->hasValue('OrganizationURL')) { throw new SimpleSAML_Error_Exception('If OrganizationName is set, OrganizationURL must also be set.'); } $metaArray['OrganizationURL'] = $idpmeta->getLocalizedString('OrganizationURL'); } $metaflat = '$metadata[' . var_export($idpentityid, true) . '] = ' . var_export($metaArray, true) . ';'; $metaBuilder = new SimpleSAML_Metadata_SAMLBuilder($idpentityid); $metaBuilder->addMetadataIdP11($metaArray); $metaBuilder->addOrganizationInfo($metaArray); $metaBuilder->addContact('technical', \SimpleSAML\Utils\Config\Metadata::getContact(array('emailAddress' => $config->getString('technicalcontact_email', null), 'name' => $config->getString('technicalcontact_name', null), 'contactType' => 'technical'))); $metaxml = $metaBuilder->getEntityDescriptorText(); // sign the metadata if enabled $metaxml = SimpleSAML_Metadata_Signer::sign($metaxml, $idpmeta->toArray(), 'Shib 1.3 IdP'); if (array_key_exists('output', $_GET) && $_GET['output'] == 'xhtml') { $defaultidp = $config->getString('default-shib13-idp', null); $t = new SimpleSAML_XHTML_Template($config, 'metadata.php', 'admin'); $t->data['clipboard.js'] = true; $t->data['header'] = 'shib13-idp'; $t->data['metaurl'] = \SimpleSAML\Utils\HTTP::addURLParameters(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery(), array('output' => 'xml')); $t->data['metadata'] = htmlspecialchars($metaxml); $t->data['metadataflat'] = htmlspecialchars($metaflat); $t->data['defaultidp'] = $defaultidp; $t->show(); } else { header('Content-Type: application/xml'); echo $metaxml; exit(0); } } catch (Exception $exception) { throw new SimpleSAML_Error_Error('METADATA', $exception); }
/** * Receive an authentication request. * * @param SimpleSAML_IdP $idp The IdP we are receiving it for. */ public static function receiveAuthnRequest(SimpleSAML_IdP $idp) { $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); $idpMetadata = $idp->getConfig(); $supportedBindings = array(SAML2_Const::BINDING_HTTP_POST); if ($idpMetadata->getBoolean('saml20.sendartifact', FALSE)) { $supportedBindings[] = SAML2_Const::BINDING_HTTP_ARTIFACT; } if ($idpMetadata->getBoolean('saml20.hok.assertion', FALSE)) { $supportedBindings[] = SAML2_Const::BINDING_HOK_SSO; } if (isset($_REQUEST['spentityid'])) { /* IdP initiated authentication. */ if (isset($_REQUEST['cookieTime'])) { $cookieTime = (int) $_REQUEST['cookieTime']; if ($cookieTime + 5 > time()) { /* * Less than five seconds has passed since we were * here the last time. Cookies are probably disabled. */ \SimpleSAML\Utils\HTTP::checkSessionCookie(\SimpleSAML\Utils\HTTP::getSelfURL()); } } $spEntityId = (string) $_REQUEST['spentityid']; $spMetadata = $metadata->getMetaDataConfig($spEntityId, 'saml20-sp-remote'); if (isset($_REQUEST['RelayState'])) { $relayState = (string) $_REQUEST['RelayState']; } else { $relayState = NULL; } if (isset($_REQUEST['binding'])) { $protocolBinding = (string) $_REQUEST['binding']; } else { $protocolBinding = NULL; } if (isset($_REQUEST['NameIDFormat'])) { $nameIDFormat = (string) $_REQUEST['NameIDFormat']; } else { $nameIDFormat = NULL; } $requestId = NULL; $IDPList = array(); $ProxyCount = NULL; $RequesterID = NULL; $forceAuthn = FALSE; $isPassive = FALSE; $consumerURL = NULL; $consumerIndex = NULL; $extensions = NULL; $allowCreate = TRUE; $idpInit = TRUE; SimpleSAML_Logger::info('SAML2.0 - IdP.SSOService: IdP initiated authentication: ' . var_export($spEntityId, TRUE)); } else { $binding = SAML2_Binding::getCurrentBinding(); $request = $binding->receive(); if (!$request instanceof SAML2_AuthnRequest) { throw new SimpleSAML_Error_BadRequest('Message received on authentication request endpoint wasn\'t an authentication request.'); } $spEntityId = $request->getIssuer(); if ($spEntityId === NULL) { throw new SimpleSAML_Error_BadRequest('Received message on authentication request endpoint without issuer.'); } $spMetadata = $metadata->getMetaDataConfig($spEntityId, 'saml20-sp-remote'); sspmod_saml_Message::validateMessage($spMetadata, $idpMetadata, $request); $relayState = $request->getRelayState(); $requestId = $request->getId(); $IDPList = $request->getIDPList(); $ProxyCount = $request->getProxyCount(); if ($ProxyCount !== null) { $ProxyCount--; } $RequesterID = $request->getRequesterID(); $forceAuthn = $request->getForceAuthn(); $isPassive = $request->getIsPassive(); $consumerURL = $request->getAssertionConsumerServiceURL(); $protocolBinding = $request->getProtocolBinding(); $consumerIndex = $request->getAssertionConsumerServiceIndex(); $extensions = $request->getExtensions(); $nameIdPolicy = $request->getNameIdPolicy(); if (isset($nameIdPolicy['Format'])) { $nameIDFormat = $nameIdPolicy['Format']; } else { $nameIDFormat = NULL; } if (isset($nameIdPolicy['AllowCreate'])) { $allowCreate = $nameIdPolicy['AllowCreate']; } else { $allowCreate = FALSE; } $idpInit = FALSE; SimpleSAML_Logger::info('SAML2.0 - IdP.SSOService: incoming authentication request: ' . var_export($spEntityId, TRUE)); } SimpleSAML_Stats::log('saml:idp:AuthnRequest', array('spEntityID' => $spEntityId, 'idpEntityID' => $idpMetadata->getString('entityid'), 'forceAuthn' => $forceAuthn, 'isPassive' => $isPassive, 'protocol' => 'saml2', 'idpInit' => $idpInit)); $acsEndpoint = self::getAssertionConsumerService($supportedBindings, $spMetadata, $consumerURL, $protocolBinding, $consumerIndex); $IDPList = array_unique(array_merge($IDPList, $spMetadata->getArrayizeString('IDPList', array()))); if ($ProxyCount === null) { $ProxyCount = $spMetadata->getInteger('ProxyCount', null); } if (!$forceAuthn) { $forceAuthn = $spMetadata->getBoolean('ForceAuthn', FALSE); } $sessionLostParams = array('spentityid' => $spEntityId, 'cookieTime' => time()); if ($relayState !== NULL) { $sessionLostParams['RelayState'] = $relayState; } $sessionLostURL = \SimpleSAML\Utils\HTTP::addURLParameters(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery(), $sessionLostParams); $state = array('Responder' => array('sspmod_saml_IdP_SAML2', 'sendResponse'), SimpleSAML_Auth_State::EXCEPTION_HANDLER_FUNC => array('sspmod_saml_IdP_SAML2', 'handleAuthError'), SimpleSAML_Auth_State::RESTART => $sessionLostURL, 'SPMetadata' => $spMetadata->toArray(), 'saml:RelayState' => $relayState, 'saml:RequestId' => $requestId, 'saml:IDPList' => $IDPList, 'saml:ProxyCount' => $ProxyCount, 'saml:RequesterID' => $RequesterID, 'ForceAuthn' => $forceAuthn, 'isPassive' => $isPassive, 'saml:ConsumerURL' => $acsEndpoint['Location'], 'saml:Binding' => $acsEndpoint['Binding'], 'saml:NameIDFormat' => $nameIDFormat, 'saml:AllowCreate' => $allowCreate, 'saml:Extensions' => $extensions, 'saml:AuthnRequestReceivedAt' => microtime(TRUE)); $idp->handleAuthenticationRequest($state); }
/** * Uses the cas service validate, this provides additional attributes * * @param string $ticket * @param string $service * @return list username and attributes */ private function casServiceValidate($ticket, $service) { $url = \SimpleSAML\Utils\HTTP::addURLParameters($this->_casConfig['serviceValidate'], array('ticket' => $ticket, 'service' => $service)); $result = \SimpleSAML\Utils\HTTP::fetch($url); $dom = DOMDocument::loadXML($result); $xPath = new DOMXpath($dom); $xPath->registerNamespace("cas", 'http://www.yale.edu/tp/cas'); $success = $xPath->query("/cas:serviceResponse/cas:authenticationSuccess/cas:user"); if ($success->length == 0) { $failure = $xPath->evaluate("/cas:serviceResponse/cas:authenticationFailure"); throw new Exception("Error when validating CAS service ticket: " . $failure->item(0)->textContent); } else { $attributes = array(); if ($casattributes = $this->_casConfig['attributes']) { # some has attributes in the xml - attributes is a list of XPath expressions to get them foreach ($casattributes as $name => $query) { $attrs = $xPath->query($query); foreach ($attrs as $attrvalue) { $attributes[$name][] = $attrvalue->textContent; } } } $casusername = $success->item(0)->textContent; return array($casusername, $attributes); } }
/** * Initiate authentication. Returns a URL to redirect the user to. * * @param string $app_url The SSP URL to return to after authenticating (similar to an ACS). */ public function request_authentication($app_url) { $res = $this->call_aselect('authenticate', array('app_id' => $this->app_id, 'app_url' => $app_url)); $as_url = $res['as_url']; unset($res['as_url']); return \SimpleSAML\Utils\HTTP::addURLParameters($as_url, $res); }
/** * Generate an array for its use in the language bar, indexed by the ISO 639-2 codes of the languages available, * containing their localized names and the URL that should be used in order to change to that language. * * @return array The array containing information of all available languages. */ private function generateLanguageBar() { $languages = $this->translator->getLanguage()->getLanguageList(); $langmap = null; if (count($languages) > 1) { $parameterName = $this->getTranslator()->getLanguage()->getLanguageParameterName(); $langmap = array(); foreach ($languages as $lang => $current) { $lang = strtolower($lang); $langname = $this->translator->getLanguage()->getLanguageLocalizedName($lang); $url = false; if (!$current) { $url = htmlspecialchars(\SimpleSAML\Utils\HTTP::addURLParameters('', array($parameterName => $lang))); } $langmap[$lang] = array('name' => $langname, 'url' => $url); } } return $langmap; }