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)) {
200 $url = self::addURLparameter(
$url, $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) {
262 $url = self::checkURLAllowed(
$url, $allowed_redirect_hosts);
266 self::_doRedirect(
$url, $parameters);
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);
static generateID()
Generate a random identifier, ID_LENGTH bytes long.
static debugMessage($message, $type)
static writeFile($filename, $data, $mode=0600)
Atomically write a file.
static getDefaultEndpoint(array $endpoints, array $bindings=null)
static resolveCert($path)
static normalizeAttributesArray($attributes)
Validate and normalize an array with attributes.
static transpose($array)
This function transposes a two-dimensional array, so that $a['k1']['k2'] becomes $a['k2']['k1'].
if(!isset($_REQUEST['ReturnTo'])) $returnTo
static requireAdmin()
Require admin access to the current page.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static popErrorMask()
Pop an error mask.
static isAdmin()
Check whether the current user is admin.
static getAdminLoginURL($returnTo=null)
static getDOMText($element)
static parseAttributes($attributes)
static formatDOMElement(DOMElement $root, $indentBase='')
static getAdminLoginURL($returnTo=null)
Retrieve a admin login URL.
static parseQueryString($query_string)
static resolveURL($url, $base=null)
static arrayize($data, $index=0)
Put a non-array variable into an array.
static aesEncrypt($data)
Encrypt data using AES-256-CBC and the system-wide secret salt as key.
static getTempDir()
This function retrieves the path to a directory where temporary files can be saved.
static getOS()
This function returns the Operating System we are running on.
static generateTimestamp($instant=null)
static redirectUntrustedURL($url, $parameters=array())
static parseDuration($duration, $timestamp=null)
static formatXMLString($xml, $indentBase='')
Format an XML string.
static aesDecrypt($ciphertext)
Decrypt data using AES-256-CBC and the system-wide secret salt as key.
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 aesEncrypt($clear)
static normalizeURL($url)
static getSecretSalt()
Retrieve the secret salt.
static redirectTrustedURL($url, $parameters=array())
This function redirects to the specified URL without performing any security checks.
static initTimezone()
Initialize the timezone.
$metadata['__DYNAMIC:1__']
static redirectUntrustedURL($url, $parameters=array())
This function redirects to the specified URL after performing the appropriate security checks on it...
static writeFile($filename, $data, $mode=0600)
static getFirstPathElement($trailingslash=true)
static generateTimestamp($instant=null)
This function generates a timestamp on the form used by the SAML protocols.
static formatXMLString($xml, $indentBase='')
static loadPublicKey(SimpleSAML_Configuration $metadata, $required=false, $prefix='')
static checkDateConditions($start=null, $end=null)
static redirect($url, $parameters=array(), $allowed_redirect_hosts=null)
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate
static validateXMLDocument($message, $type)
static loadPrivateKey(\SimpleSAML_Configuration $metadata, $required=false, $prefix='', $full_path=false)
Load a private key from metadata.
static getAcceptLanguage()
static debugSAMLMessage($message, $type)
Helper function to log SAML messages that we send or receive.
static createPostRedirectLink($destination, $post)
Attribute-related utility methods.
static validateCA($certificate, $caFile)
catch(Exception $e) $message
static ipCIDRcheck($cidr, $ip=null)
Check whether an IP address is part of a CIDR.
static parseStateID($stateId)
Get the ID and (optionally) a URL embedded in a StateID, in the form 'id:url'.
static parseDuration($duration, $timestamp=null)
Interpret a ISO8601 duration value relative to a given timestamp.
static setCookie($name, $value, $params=null, $throw=true)
Set a cookie.
static generateRandomBytes($length)
getBaseURL($t, $type='get', $key=null, $value=null)
static validateCertificate($certificate, $caFile)
Validate the certificate used to sign the XML against a CA file.
static redirectTrustedURL($url, $parameters=array())
static checkCookie($retryURL=null)
static loadPublicKey(\SimpleSAML_Configuration $metadata, $required=false, $prefix='')
Get public key or certificate from metadata.
static aesDecrypt($encData)
static submitPOSTData($destination, $data)
Submit a POST form to a specific destination.
static parseStateID($stateId)
if(array_key_exists('yes', $_REQUEST)) $attributes
if($session===NULL) $postData
static getDOMChildren(DOMElement $element, $localName, $namespaceURI)
static maskErrors($mask)
Disable error reporting for the given log levels.
static getSelfHostWithPath()
if(php_sapi_name() !='cli') $in
foreach($mandatory_scripts as $file) $timestamp
static setCookie($name, $value, array $params=null, $throw=true)
static createHttpPostRedirectLink($destination, $post)
static stringToHex($bytes)
static xsDateTimeToTimestamp($time)
This function converts a SAML2 timestamp on the form yyyy-mm-ddThh:mm:ss(.s+)?Z to a UNIX timestamp...
static ipCIDRcheck($cidr, $ip=null)
static arrayize($data, $index=0)
static fetch($path, $context=array(), $getHeaders=false)
static fatalError($trackId='na', $errorCode=null, Exception $e=null)
static transposeArray($in)
static checkSessionCookie($retryURL=null)
Check for session cookie, and show missing-cookie page if it is missing.
static _doRedirect($url, $parameters=array())
static loadPrivateKey(SimpleSAML_Configuration $metadata, $required=false, $prefix='')
static postRedirect($destination, $post)
static getSessionFromRequest()
Retrieves the current session.
static addURLparameter($url, $parameters)
static isDOMElementOfType(DOMNode $element, $name, $nsURI)
static resolvePath($path, $base=null)
static validateXML($xml, $schema)
static checkURLAllowed($url, array $trustedSites=null)