26        return \SimpleSAML\Utils\HTTP::getSelfHost();
 
   35        return \SimpleSAML\Utils\HTTP::getSelfURLHost();
 
   44        return \SimpleSAML\Utils\HTTP::isHTTPS();
 
   54        return \SimpleSAML\Utils\HTTP::getSelfURLNoQuery();
 
   64        return \SimpleSAML\Utils\HTTP::getSelfHostWithPath();
 
   74        return \SimpleSAML\Utils\HTTP::getFirstPathElement($trailingslash);
 
   83        return \SimpleSAML\Utils\HTTP::getSelfURL();
 
  101        return \SimpleSAML\Utils\HTTP::addURLParameters(
$url, $parameters);
 
  110        return \SimpleSAML\Utils\HTTP::checkURLAllowed(
$url, $trustedSites);
 
  128        $currentTime = time();
 
  133            if (($startTime < 0) || (($startTime - 600) > $currentTime)) {
 
  139            if (($endTime < 0) || ($endTime <= $currentTime)) {
 
  195        assert(is_string(
$url));
 
  196        assert(!empty(
$url));
 
  197        assert(is_array($parameters));
 
  199        if (!empty($parameters)) {
 
  207        if (
$_SERVER[
'SERVER_PROTOCOL'] === 
'HTTP/1.1' &&
 
  208            $_SERVER[
'REQUEST_METHOD'] === 
'POST' 
  215        if (strlen(
$url) > 2048) {
 
  223        header(
'Pragma: no-cache');
 
  224        header(
'Cache-Control: no-cache, must-revalidate');
 
  227        echo 
'<?xml version="1.0" encoding="UTF-8"?>'.
"\n";
 
  228        echo 
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'.
 
  229            ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.
"\n";
 
  230        echo 
'<html xmlns="http://www.w3.org/1999/xhtml">';
 
  232                                        <meta http-equiv="content-type" content="text/html; charset=utf-8"> 
  233                                        <title>Redirect</title> 
  236        echo 
'<h1>Redirect</h1>';
 
  238        echo 
'You were redirected to: ';
 
  239        echo 
'<a id="redirlink" href="'.
 
  240            htmlspecialchars(
$url).
'">'.htmlspecialchars(
$url).
'</a>';
 
  241        echo 
'<script type="text/javascript">document.getElementById("redirlink").focus();</script>';
 
  255    public static function redirect(
$url, $parameters = array(), $allowed_redirect_hosts = 
null)
 
  257        assert(is_string(
$url));
 
  258        assert(strlen(
$url) > 0);
 
  259        assert(is_array($parameters));
 
  261        if ($allowed_redirect_hosts !== 
null) {
 
  312    public static function getDOMChildren(DOMElement $element, $localName, $namespaceURI)
 
  314        return SimpleSAML\Utils\XML::getDOMChildren($element, $localName, $namespaceURI);
 
  323        return SimpleSAML\Utils\XML::getDOMText($element);
 
  333        return \SimpleSAML\Utils\HTTP::getAcceptLanguage();
 
  342        $result = \SimpleSAML\Utils\XML::isValid(
$xml, $schema);
 
  361        assert(is_int($length));
 
  363        return openssl_random_pseudo_bytes($length);
 
  373        for (
$i = 0; 
$i < strlen($bytes); 
$i++) {
 
  374            $ret .= sprintf(
'%02x', ord($bytes[
$i]));
 
  385        return \SimpleSAML\Utils\System::resolvePath(
$path, 
$base);
 
  394        return \SimpleSAML\Utils\HTTP::resolveURL(
$url, 
$base);
 
  403        return \SimpleSAML\Utils\HTTP::normalizeURL(
$url);
 
  412        return \SimpleSAML\Utils\HTTP::parseQueryString($query_string);
 
  441        if (!function_exists(
'error_get_last')) {
 
  442            return '[Cannot get error message]';
 
  445        $error = error_get_last();
 
  446        if ($error === 
null) {
 
  447            return '[No error message found]';
 
  450        return $error[
'message'];
 
  459        return \SimpleSAML\Utils\Config::getCertPath(
$path);
 
  486        SimpleSAML\Utils\XML::formatDOMElement(
$root, $indentBase);
 
  561        assert(is_array(
$post));
 
  572        $redirInfo = base64_encode(
SimpleSAML\Utils\Crypto::aesEncrypt(
$session->getSessionId().
':'.$postId));
 
  575        $url = preg_replace(
"#^https:#", 
"http:", 
$url);
 
  641        return \SimpleSAML\Utils\Config\Metadata::getDefaultEndpoint($endpoints, 
$bindings);
 
  669        return \SimpleSAML\Utils\HTTP::fetch(
$path, 
$context, $getHeaders);
 
if(php_sapi_name() !='cli') $in
$metadata['__DYNAMIC:1__']
if(!isset($_REQUEST['ReturnTo'])) $returnTo
foreach($mandatory_scripts as $file) $timestamp
An exception for terminatinating execution or to throw for unit testing.
static xsDateTimeToTimestamp($time)
This function converts a SAML2 timestamp on the form yyyy-mm-ddThh:mm:ss(.s+)?Z to a UNIX timestamp.
static popErrorMask()
Pop an error mask.
static maskErrors($mask)
Disable error reporting for the given log levels.
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
static arrayize($data, $index=0)
Put a non-array variable into an array.
static transpose($array)
This function transposes a two-dimensional array, so that $a['k1']['k2'] becomes $a['k2']['k1'].
static normalizeAttributesArray($attributes)
Validate and normalize an array with attributes.
static isAdmin()
Check whether the current user is admin.
static getAdminLoginURL($returnTo=null)
Retrieve a admin login URL.
static requireAdmin()
Require admin access to the current page.
static getSecretSalt()
Retrieve the secret salt.
static loadPublicKey(\SimpleSAML_Configuration $metadata, $required=false, $prefix='')
Get public key or certificate from metadata.
static aesEncrypt($data)
Encrypt data using AES-256-CBC and the system-wide secret salt as key.
static loadPrivateKey(\SimpleSAML_Configuration $metadata, $required=false, $prefix='', $full_path=false)
Load a private key from metadata.
static aesDecrypt($ciphertext)
Decrypt data using AES-256-CBC and the system-wide secret salt as key.
static submitPOSTData($destination, $data)
Submit a POST form to a specific destination.
static checkSessionCookie($retryURL=null)
Check for session cookie, and show missing-cookie page if it is missing.
static redirectUntrustedURL($url, $parameters=array())
This function redirects to the specified URL after performing the appropriate security checks on it.
static setCookie($name, $value, $params=null, $throw=true)
Set a cookie.
static redirectTrustedURL($url, $parameters=array())
This function redirects to the specified URL without performing any security checks.
static ipCIDRcheck($cidr, $ip=null)
Check whether an IP address is part of a CIDR.
static generateID()
Generate a random identifier, ID_LENGTH bytes long.
static writeFile($filename, $data, $mode=0600)
Atomically write a file.
static getOS()
This function returns the Operating System we are running on.
static getTempDir()
This function retrieves the path to a directory where temporary files can be saved.
static generateTimestamp($instant=null)
This function generates a timestamp on the form used by the SAML protocols.
static initTimezone()
Initialize the timezone.
static parseDuration($duration, $timestamp=null)
Interpret a ISO8601 duration value relative to a given timestamp.
static isDOMNodeOfType(\DOMNode $element, $name, $nsURI)
This function checks if the DOMElement has the correct localName and namespaceURI.
static checkSAMLMessage($message, $type)
This function performs some sanity checks on XML documents, and optionally validates them against the...
static debugSAMLMessage($message, $type)
Helper function to log SAML messages that we send or receive.
static formatXMLString($xml, $indentBase='')
Format an XML string.
static validateCertificate($certificate, $caFile)
Validate the certificate used to sign the XML against a CA file.
static parseStateID($stateId)
Get the ID and (optionally) a URL embedded in a StateID, in the form 'id:url'.
static getSessionFromRequest()
Retrieves the current session.
static setCookie($name, $value, array $params=null, $throw=true)
static fetch($path, $context=array(), $getHeaders=false)
static parseDuration($duration, $timestamp=null)
static redirectUntrustedURL($url, $parameters=array())
static aesEncrypt($clear)
static stringToHex($bytes)
static addURLparameter($url, $parameters)
static checkCookie($retryURL=null)
static generateRandomBytes($length)
static postRedirect($destination, $post)
static resolvePath($path, $base=null)
static checkURLAllowed($url, array $trustedSites=null)
static loadPrivateKey(SimpleSAML_Configuration $metadata, $required=false, $prefix='')
static getDOMText($element)
static isDOMElementOfType(DOMNode $element, $name, $nsURI)
static getDefaultEndpoint(array $endpoints, array $bindings=null)
static ipCIDRcheck($cidr, $ip=null)
static fatalError($trackId='na', $errorCode=null, Exception $e=null)
static arrayize($data, $index=0)
static getFirstPathElement($trailingslash=true)
static parseQueryString($query_string)
static parseAttributes($attributes)
static validateXMLDocument($message, $type)
static redirectTrustedURL($url, $parameters=array())
static generateTimestamp($instant=null)
static formatDOMElement(DOMElement $root, $indentBase='')
static resolveURL($url, $base=null)
static getAdminLoginURL($returnTo=null)
static debugMessage($message, $type)
static loadPublicKey(SimpleSAML_Configuration $metadata, $required=false, $prefix='')
static redirect($url, $parameters=array(), $allowed_redirect_hosts=null)
static resolveCert($path)
static transposeArray($in)
static writeFile($filename, $data, $mode=0600)
static _doRedirect($url, $parameters=array())
static getAcceptLanguage()
static validateCA($certificate, $caFile)
static checkDateConditions($start=null, $end=null)
static validateXML($xml, $schema)
static getSelfHostWithPath()
static formatXMLString($xml, $indentBase='')
static aesDecrypt($encData)
static createHttpPostRedirectLink($destination, $post)
static getDOMChildren(DOMElement $element, $localName, $namespaceURI)
static createPostRedirectLink($destination, $post)
static parseStateID($stateId)
static normalizeURL($url)
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate
if(array_key_exists('yes', $_REQUEST)) $attributes
catch(Exception $e) $message
Attribute-related utility methods.
if($session===NULL) $postData
getBaseURL($t, $type='get', $key=null, $value=null)
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']