PHP 클래스 OneLogin_Saml2_Utils

Defines several often used methods
파일 보기 프로젝트 열기: onelogin/php-saml 1 사용 예제들

공개 메소드들

메소드 설명
addSign ( string | DomDocument $xml, string $key, string $cert, string $signAlgorithm = XMLSecurityKey::RSA_SHA1 ) : string Adds signature key and senders certificate to an element (Message or Assertion).
calculateX509Fingerprint ( string $x509cert, $alg = 'sha1' ) : null | string Calculates the fingerprint of a x509cert.
castKey ( XMLSecurityKey $key, string $algorithm, string $type = 'public' ) : XMLSecurityKey Converts a XMLSecurityKey to the correct algorithm.
decryptElement ( DOMElement $encryptedData, XMLSecurityKey $inputKey ) : DOMElement Decrypts an encrypted element.
deleteLocalSession ( ) Deletes the local session.
extractOriginalQueryParam ( string $name ) : string Extract a query param - as it was sent - from $_SERVER[QUERY_STRING]
formatCert ( string $cert, boolean $heads = true ) : string Returns a x509 cert (adding header & footer if required).
formatFingerPrint ( string $fingerprint ) : string Formates a fingerprint.
formatPrivateKey ( string $key, boolean $heads = true ) : string Returns a private key (adding header & footer if required).
generateNameId ( string $value, string $spnq, string $format, string | null $cert = null ) : string Generates a nameID.
generateUniqueID ( ) : string Generates an unique string (used for example as ID for assertions).
getBaseURLPath ( ) return string The baseurlpath to be used when constructing URLs
getExpireTime ( string $cacheDuration = null, string $validUntil = null ) : integer Compares 2 dates and returns the earliest.
getProxyVars ( ) return bool
getSelfHost ( ) : string Returns the current host.
getSelfPort ( ) : null | string
getSelfProtocol ( ) : string
getSelfRoutedURLNoQuery ( ) : string Returns the routed URL of the current host + current view.
getSelfURL ( ) : string Returns the URL of the current host + current view + query.
getSelfURLNoQuery ( ) : string Returns the URL of the current host + current view.
getSelfURLhost ( ) : string Returns the protocol + the current host + the port (if different than common ports).
getStatus ( DOMDocument $dom ) : array Gets Status from a Response.
get_string_between ( string $str, string $start, string $end ) : string Extracts a substring between 2 marks
isHTTPS ( ) : boolean Checks if https or http.
isSessionStarted ( ) : boolean Checks if the session is started or not.
loadXML ( DOMDocument $dom, string $xml ) : DOMDocument This function load an XML string in a save way.
parseDuration ( string $duration, integer | null $timestamp = null ) : integer | null Interprets a ISO8601 duration value relative to a given timestamp.
parseSAML2Time ( string $time ) : integer Converts a SAML2 timestamp on the form yyyy-mm-ddThh:mm:ss(\.s+)?Z to a UNIX timestamp. The sub-second part is ignored.
parseTime2SAML ( string $time ) : string Converts a UNIX timestamp to SAML2 timestamp on the form yyyy-mm-ddThh:mm:ss(\.s+)?Z.
query ( DOMDocument $dom, string $query, DomElement $context = null ) : DOMNodeList Extracts nodes from the DOMDocument.
redirect ( string $url, array $parameters = [], boolean $stay = false ) : string | null Executes a redirection to the provided url (or return the target url).
setBaseURL ( $baseurl )
setBaseURLPath ( $baseurlpath )
setProxyVars ( $proxyVars )
setSelfHost ( $host )
setSelfPort ( $port )
setSelfProtocol ( $protocol )
t ( string $msg, array | null $args = [] ) : string Translates any string. Accepts args
validateSign ( string | DomNode $xml, string | null $cert = null, string | null $fingerprint = null, string | null $fingerprintalg = 'sha1', string | null $xpath = null ) : boolean Validates a signature (Message or Assertion).
validateXML ( string | DOMDocument $xml, string $schema, boolean $debug = false ) : string | DOMDocument This function attempts to validate an XML string against the specified schema.

보호된 메소드들

메소드 설명
buildWithBaseURLPath ( $info ) : string Returns the part of the URL with the BaseURLPath.
getRawHost ( ) : string

메소드 상세

addSign() 공개 정적인 메소드

Adds signature key and senders certificate to an element (Message or Assertion).
public static addSign ( string | DomDocument $xml, string $key, string $cert, string $signAlgorithm = XMLSecurityKey::RSA_SHA1 ) : string
$xml string | DomDocument The element we should sign
$key string The private key
$cert string The public
$signAlgorithm string Signature algorithm method
리턴 string

buildWithBaseURLPath() 보호된 정적인 메소드

Returns the part of the URL with the BaseURLPath.
protected static buildWithBaseURLPath ( $info ) : string
리턴 string

calculateX509Fingerprint() 공개 정적인 메소드

Calculates the fingerprint of a x509cert.
public static calculateX509Fingerprint ( string $x509cert, $alg = 'sha1' ) : null | string
$x509cert string x509 cert
리턴 null | string Formatted fingerprint

castKey() 공개 정적인 메소드

Converts a XMLSecurityKey to the correct algorithm.
public static castKey ( XMLSecurityKey $key, string $algorithm, string $type = 'public' ) : XMLSecurityKey
$key XMLSecurityKey The key.
$algorithm string The desired algorithm.
$type string Public or private key, defaults to public.
리턴 XMLSecurityKey The new key.

decryptElement() 공개 정적인 메소드

Decrypts an encrypted element.
public static decryptElement ( DOMElement $encryptedData, XMLSecurityKey $inputKey ) : DOMElement
$encryptedData DOMElement The encrypted data.
$inputKey XMLSecurityKey The decryption key.
리턴 DOMElement The decrypted element.

deleteLocalSession() 공개 정적인 메소드

Deletes the local session.
public static deleteLocalSession ( )

extractOriginalQueryParam() 공개 정적인 메소드

Extract a query param - as it was sent - from $_SERVER[QUERY_STRING]
public static extractOriginalQueryParam ( string $name ) : string
$name string The param to-be extracted
리턴 string

formatCert() 공개 정적인 메소드

Returns a x509 cert (adding header & footer if required).
public static formatCert ( string $cert, boolean $heads = true ) : string
$cert string A x509 unformated cert
$heads boolean True if we want to include head and footer
리턴 string $x509 Formatted cert

formatFingerPrint() 공개 정적인 메소드

Formates a fingerprint.
public static formatFingerPrint ( string $fingerprint ) : string
$fingerprint string fingerprint
리턴 string Formatted fingerprint

formatPrivateKey() 공개 정적인 메소드

Returns a private key (adding header & footer if required).
public static formatPrivateKey ( string $key, boolean $heads = true ) : string
$key string A private key
$heads boolean True if we want to include head and footer
리턴 string $rsaKey Formatted private key

generateNameId() 공개 정적인 메소드

Generates a nameID.
public static generateNameId ( string $value, string $spnq, string $format, string | null $cert = null ) : string
$value string fingerprint
$spnq string SP Name Qualifier
$format string SP Format
$cert string | null IdP Public cert to encrypt the nameID
리턴 string $nameIDElement DOMElement | XMLSec nameID

generateUniqueID() 공개 정적인 메소드

Generates an unique string (used for example as ID for assertions).
public static generateUniqueID ( ) : string
리턴 string A unique string

getBaseURLPath() 공개 정적인 메소드

return string The baseurlpath to be used when constructing URLs
public static getBaseURLPath ( )

getExpireTime() 공개 정적인 메소드

Compares 2 dates and returns the earliest.
public static getExpireTime ( string $cacheDuration = null, string $validUntil = null ) : integer
$cacheDuration string The duration, as a string.
$validUntil string The valid until date, as a string or as a timestamp
리턴 integer $expireTime The expiration time.

getProxyVars() 공개 정적인 메소드

return bool
public static getProxyVars ( )

getRawHost() 보호된 정적인 메소드

protected static getRawHost ( ) : string
리턴 string The raw host name

getSelfHost() 공개 정적인 메소드

Returns the current host.
public static getSelfHost ( ) : string
리턴 string $currentHost The current host

getSelfPort() 공개 정적인 메소드

public static getSelfPort ( ) : null | string
리턴 null | string The port number used for the request

getSelfProtocol() 공개 정적인 메소드

public static getSelfProtocol ( ) : string
리턴 string http|https

getSelfRoutedURLNoQuery() 공개 정적인 메소드

Returns the routed URL of the current host + current view.
public static getSelfRoutedURLNoQuery ( ) : string
리턴 string

getSelfURL() 공개 정적인 메소드

Returns the URL of the current host + current view + query.
public static getSelfURL ( ) : string
리턴 string

getSelfURLNoQuery() 공개 정적인 메소드

Returns the URL of the current host + current view.
public static getSelfURLNoQuery ( ) : string
리턴 string

getSelfURLhost() 공개 정적인 메소드

Returns the protocol + the current host + the port (if different than common ports).
public static getSelfURLhost ( ) : string
리턴 string $url

getStatus() 공개 정적인 메소드

Gets Status from a Response.
public static getStatus ( DOMDocument $dom ) : array
$dom DOMDocument The Response as XML
리턴 array $status The Status, an array with the code and a message.

get_string_between() 공개 정적인 메소드

Extracts a substring between 2 marks
public static get_string_between ( string $str, string $start, string $end ) : string
$str string The target string
$start string The initial mark
$end string The end mark
리턴 string A substring or an empty string if is not able to find the marks or if there is no string between the marks

isHTTPS() 공개 정적인 메소드

Checks if https or http.
public static isHTTPS ( ) : boolean
리턴 boolean $isHttps False if https is not active

isSessionStarted() 공개 정적인 메소드

Checks if the session is started or not.
public static isSessionStarted ( ) : boolean
리턴 boolean true if the sessíon is started

loadXML() 공개 정적인 메소드

Prevent XEE/XXE Attacks
public static loadXML ( DOMDocument $dom, string $xml ) : DOMDocument
$dom DOMDocument The document where load the xml.
$xml string The XML string to be loaded.
리턴 DOMDocument $dom The result of load the XML at the DomDocument

parseDuration() 공개 정적인 메소드

Interprets a ISO8601 duration value relative to a given timestamp.
public static parseDuration ( string $duration, integer | null $timestamp = null ) : integer | null
$duration string The duration, as a string.
$timestamp integer | null The unix timestamp we should apply the duration to. Optional, default to the current time.
리턴 integer | null The new timestamp, after the duration is applied.

parseSAML2Time() 공개 정적인 메소드

Converts a SAML2 timestamp on the form yyyy-mm-ddThh:mm:ss(\.s+)?Z to a UNIX timestamp. The sub-second part is ignored.
public static parseSAML2Time ( string $time ) : integer
$time string The time we should convert (SAML Timestamp).
리턴 integer $timestamp Converted to a unix timestamp.

parseTime2SAML() 공개 정적인 메소드

Converts a UNIX timestamp to SAML2 timestamp on the form yyyy-mm-ddThh:mm:ss(\.s+)?Z.
public static parseTime2SAML ( string $time ) : string
$time string The time we should convert (DateTime).
리턴 string $timestamp SAML2 timestamp.

query() 공개 정적인 메소드

Extracts nodes from the DOMDocument.
public static query ( DOMDocument $dom, string $query, DomElement $context = null ) : DOMNodeList
$dom DOMDocument The DOMDocument
$query string Xpath Expresion
$context DomElement Context Node (DomElement)
리턴 DOMNodeList The queried nodes

redirect() 공개 정적인 메소드

Executes a redirection to the provided url (or return the target url).
public static redirect ( string $url, array $parameters = [], boolean $stay = false ) : string | null
$url string The target url
$parameters array Extra parameters to be passed as part of the url
$stay boolean True if we want to stay (returns the url string) False to redirect
리턴 string | null $url

setBaseURL() 공개 정적인 메소드

public static setBaseURL ( $baseurl )
$baseurl string The base url to be used when constructing URLs

setBaseURLPath() 공개 정적인 메소드

public static setBaseURLPath ( $baseurlpath )
$baseurlpath string The baseurl path to use when constructing URLs

setProxyVars() 공개 정적인 메소드

public static setProxyVars ( $proxyVars )
$proxyVars bool Whether to use `X-Forwarded-*` headers to determine port/domain/protocol

setSelfHost() 공개 정적인 메소드

public static setSelfHost ( $host )
$host string The host to use when constructing URLs

setSelfPort() 공개 정적인 메소드

public static setSelfPort ( $port )
$port int The port number to use when constructing URLs

setSelfProtocol() 공개 정적인 메소드

public static setSelfProtocol ( $protocol )
$protocol string The protocol to identify as using, usually http or https

t() 공개 정적인 메소드

Translates any string. Accepts args
public static t ( string $msg, array | null $args = [] ) : string
$msg string Message to be translated
$args array | null Arguments
리턴 string $translatedMsg Translated text

validateSign() 공개 정적인 메소드

Validates a signature (Message or Assertion).
public static validateSign ( string | DomNode $xml, string | null $cert = null, string | null $fingerprint = null, string | null $fingerprintalg = 'sha1', string | null $xpath = null ) : boolean
$xml string | DomNode The element we should validate
$cert string | null The pubic cert
$fingerprint string | null The fingerprint of the public cert
$fingerprintalg string | null The algorithm used to get the fingerprint
$xpath string | null The xpath of the signed element
리턴 boolean

validateXML() 공개 정적인 메소드

It will parse the string into a DOM document and validate this document against the schema.
public static validateXML ( string | DOMDocument $xml, string $schema, boolean $debug = false ) : string | DOMDocument
$xml string | DOMDocument The XML string or document which should be validated.
$schema string The schema filename which should be used.
$debug boolean To disable/enable the debug mode
리턴 string | DOMDocument $dom string that explains the problem or the DOMDocument