PHP 클래스 SimpleSAML_Configuration, simplesamlphp

저자: Andreas Aakre Solberg, UNINETT AS. ([email protected])
파일 보기 프로젝트 열기: simplesamlphp/simplesamlphp 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( array $config, string $location ) Initializes a configuration from the given array.
copyFromBase ( string $instancename, string $filename ) Load a configuration file which is located in the same directory as this configuration file.
getArray ( string $name, mixed $default = self::REQUIRED_OPTION ) : array | mixed This function retrieves an array configuration option.
getArrayize ( string $name, mixed $default = self::REQUIRED_OPTION ) : array This function retrieves an array configuration option.
getArrayizeString ( string $name, mixed $default = self::REQUIRED_OPTION ) : array This function retrieves a configuration option with a string or an array of strings.
getBaseDir ( ) : string Retrieve the base directory for this SimpleSAMLphp installation.
getBasePath ( ) : string Retrieve the absolute path pointing to the SimpleSAMLphp installation.
getBaseURL ( ) : string Retrieve the absolute path of the SimpleSAMLphp installation, relative to the root of the website.
getBoolean ( string $name, mixed $default = self::REQUIRED_OPTION ) : boolean | mixed This function retrieves a boolean configuration option.
getConfig ( string $filename = 'config.php', string $configSet = 'simplesaml' ) : SimpleSAML_Configuration Load a configuration file from a configuration set.
getConfigItem ( string $name, mixed $default = self::REQUIRED_OPTION ) : mixed Retrieve an array as a SimpleSAML_Configuration object.
getConfigList ( string $name, mixed $default = self::REQUIRED_OPTION ) : mixed Retrieve an array of arrays as an array of SimpleSAML_Configuration objects.
getDefaultEndpoint ( string $endpointType, array $bindings = null, mixed $default = self::REQUIRED_OPTION ) : array | null Find the default endpoint of the given type.
getEndpointPrioritizedByBinding ( string $endpointType, array $bindings, mixed $default = self::REQUIRED_OPTION ) : array | null Find an endpoint of the given type, using a list of supported bindings as a way to prioritize.
getEndpoints ( string $endpointType ) : array Helper function for dealing with metadata endpoints.
getInstance ( string $instancename = 'simplesaml' ) : SimpleSAML_Configuration Get a configuration file by its instance name.
getInteger ( string $name, mixed $default = self::REQUIRED_OPTION ) : integer | mixed This function retrieves an integer configuration option.
getIntegerRange ( string $name, integer $minimum, integer $maximum, mixed $default = self::REQUIRED_OPTION ) : integer | mixed This function retrieves an integer configuration option where the value must be in the specified range.
getLocalizedString ( string $name, mixed $default = self::REQUIRED_OPTION ) : array Retrieve a string which may be localized into many languages.
getOptionalConfig ( string $filename = 'config.php', string $configSet = 'simplesaml' ) : SimpleSAML_Configuration Load a configuration file from a configuration set.
getOptions ( ) : array Retrieve list of options.
getPathValue ( string $name, string | null $default = null ) : string | null Retrieve a path configuration option set in config.php.
getPublicKeys ( string | null $use = null, boolean $required = false, string $prefix = '' ) : array | null Get public key from metadata.
getString ( string $name, mixed $default = self::REQUIRED_OPTION ) : string | mixed This function retrieves a string configuration option.
getValue ( string $name, mixed $default = null ) : mixed Retrieve a configuration option set in config.php.
getValueValidate ( string $name, array $allowedValues, mixed $default = self::REQUIRED_OPTION ) : mixed Retrieve a configuration option with one of the given values.
getVersion ( ) : string Retrieve the current version of SimpleSAMLphp.
hasValue ( string $name ) : boolean Check whether a key in the configuration exists or not.
hasValueOneOf ( array $names ) : boolean Check whether any key of the set given exists in the configuration.
init ( string $path, string $instancename = 'simplesaml', string $configfilename = 'config.php' ) Initialize a instance name with the given configuration file.
loadFromArray ( array $config, string $location = '[ARRAY]', string | null $instance = null ) : SimpleSAML_Configuration Loads a configuration from the given array.
resolvePath ( string | null $path ) : string | null This function resolves a path which may be relative to the SimpleSAMLphp base directory.
setConfigDir ( string $path, string $configSet = 'simplesaml' ) Set the directory for configuration files for the given configuration set.
toArray ( ) : array Convert this configuration object back to an array.

비공개 메소드들

메소드 설명
getDefaultBinding ( string $endpointType ) : string Retrieve the default binding for the given endpoint type.
loadFromFile ( string $filename, boolean $required ) : SimpleSAML_Configuration Load the given configuration file.

메소드 상세

__construct() 공개 메소드

Initializes a configuration from the given array.
public __construct ( array $config, string $location )
$config array The configuration array.
$location string The location which will be given when an error occurs.

copyFromBase() 공개 메소드

TODO: remove.
또한 보기: getConfig()
사용 중단: This function is superseeded by the getConfig() function.
public copyFromBase ( string $instancename, string $filename )
$instancename string
$filename string

getArray() 공개 메소드

An exception will be thrown if this option isn't an array, or if this option isn't found, and no default value is given.
public getArray ( string $name, mixed $default = self::REQUIRED_OPTION ) : array | mixed
$name string The name of the option.
$default mixed A default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
리턴 array | mixed The option with the given name, or $default if the option isn't found and $default is specified.

getArrayize() 공개 메소드

If the configuration option isn't an array, it will be converted to an array.
public getArrayize ( string $name, mixed $default = self::REQUIRED_OPTION ) : array
$name string The name of the option.
$default mixed A default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
리턴 array The option with the given name, or $default if the option isn't found and $default is specified.

getArrayizeString() 공개 메소드

If the configuration option is a string, it will be converted to an array with a single string
public getArrayizeString ( string $name, mixed $default = self::REQUIRED_OPTION ) : array
$name string The name of the option.
$default mixed A default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
리턴 array The option with the given name, or $default if the option isn't found and $default is specified.

getBaseDir() 공개 메소드

This function first checks the 'basedir' configuration option. If this option is undefined or null, then we fall back to looking at the current filename.
public getBaseDir ( ) : string
리턴 string The absolute path to the base directory for this SimpleSAMLphp installation. This path will always end with a slash.

getBasePath() 공개 메소드

The path is guaranteed to start and end with a slash ('/'). E.g.: /simplesaml/
public getBasePath ( ) : string
리턴 string The absolute path where SimpleSAMLphp can be reached in the web server.

getBaseURL() 공개 메소드

For example: simplesaml/ The path will always end with a '/' and never have a leading slash.
사용 중단: This method will be removed in SimpleSAMLphp 2.0. Please use getBasePath() instead.
public getBaseURL ( ) : string
리턴 string The absolute path relative to the root of the website.

getBoolean() 공개 메소드

An exception will be thrown if this option isn't a boolean, or if this option isn't found, and no default value is given.
public getBoolean ( string $name, mixed $default = self::REQUIRED_OPTION ) : boolean | mixed
$name string The name of the option.
$default mixed A default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
리턴 boolean | mixed The option with the given name, or $default if the option isn't found and $default is specified.

getConfig() 공개 정적인 메소드

Load a configuration file from a configuration set.
public static getConfig ( string $filename = 'config.php', string $configSet = 'simplesaml' ) : SimpleSAML_Configuration
$filename string The name of the configuration file.
$configSet string The configuration set. Optional, defaults to 'simplesaml'.
리턴 SimpleSAML_Configuration The SimpleSAML_Configuration object.

getConfigItem() 공개 메소드

This function will load the value of an option into a SimpleSAML_Configuration object. The option must contain an array. An exception will be thrown if this option isn't an array, or if this option isn't found, and no default value is given.
public getConfigItem ( string $name, mixed $default = self::REQUIRED_OPTION ) : mixed
$name string The name of the option.
$default mixed A default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
리턴 mixed The option with the given name, or $default if the option isn't found and $default is specified.

getConfigList() 공개 메소드

This function will retrieve an option containing an array of arrays, and create an array of SimpleSAML_Configuration objects from that array. The indexes in the new array will be the same as the original indexes, but the values will be SimpleSAML_Configuration objects. An exception will be thrown if this option isn't an array of arrays, or if this option isn't found, and no default value is given.
public getConfigList ( string $name, mixed $default = self::REQUIRED_OPTION ) : mixed
$name string The name of the option.
$default mixed A default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
리턴 mixed The option with the given name, or $default if the option isn't found and $default is specified.

getDefaultEndpoint() 공개 메소드

Find the default endpoint of the given type.
public getDefaultEndpoint ( string $endpointType, array $bindings = null, mixed $default = self::REQUIRED_OPTION ) : array | null
$endpointType string The endpoint type.
$bindings array Array with acceptable bindings. Can be null if any binding is allowed.
$default mixed The default value to return if no matching endpoint is found. If no default is provided, an exception will be thrown.
리턴 array | null The default endpoint, or null if no acceptable endpoints are used.

getEndpointPrioritizedByBinding() 공개 메소드

Find an endpoint of the given type, using a list of supported bindings as a way to prioritize.
public getEndpointPrioritizedByBinding ( string $endpointType, array $bindings, mixed $default = self::REQUIRED_OPTION ) : array | null
$endpointType string The endpoint type.
$bindings array Sorted array of acceptable bindings.
$default mixed The default value to return if no matching endpoint is found. If no default is provided, an exception will be thrown.
리턴 array | null The default endpoint, or null if no acceptable endpoints are used.

getEndpoints() 공개 메소드

Helper function for dealing with metadata endpoints.
public getEndpoints ( string $endpointType ) : array
$endpointType string The endpoint type.
리턴 array Array of endpoints of the given type.

getInstance() 공개 정적인 메소드

This function retrieves a configuration file by its instance name. The instance name is initialized by the init function, or by copyFromBase function. If no configuration file with the given instance name is found, an exception will be thrown.
public static getInstance ( string $instancename = 'simplesaml' ) : SimpleSAML_Configuration
$instancename string The instance name of the configuration file. Deprecated.
리턴 SimpleSAML_Configuration The configuration object.

getInteger() 공개 메소드

An exception will be thrown if this option isn't an integer, or if this option isn't found, and no default value is given.
public getInteger ( string $name, mixed $default = self::REQUIRED_OPTION ) : integer | mixed
$name string The name of the option.
$default mixed A default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
리턴 integer | mixed The option with the given name, or $default if the option isn't found and $default is specified.

getIntegerRange() 공개 메소드

An exception will be thrown if: - the option isn't an integer - the option isn't found, and no default value is given - the value is outside of the allowed range
public getIntegerRange ( string $name, integer $minimum, integer $maximum, mixed $default = self::REQUIRED_OPTION ) : integer | mixed
$name string The name of the option.
$minimum integer The smallest value which is allowed.
$maximum integer The largest value which is allowed.
$default mixed A default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
리턴 integer | mixed The option with the given name, or $default if the option isn't found and $default is specified.

getLocalizedString() 공개 메소드

The default language returned is always 'en'.
public getLocalizedString ( string $name, mixed $default = self::REQUIRED_OPTION ) : array
$name string The name of the option.
$default mixed The default value. If no default is given, and the option isn't found, an exception will be thrown.
리턴 array Associative array with language => string pairs.

getOptionalConfig() 공개 정적인 메소드

This function will return a configuration object even if the file does not exist.
public static getOptionalConfig ( string $filename = 'config.php', string $configSet = 'simplesaml' ) : SimpleSAML_Configuration
$filename string The name of the configuration file.
$configSet string The configuration set. Optional, defaults to 'simplesaml'.
리턴 SimpleSAML_Configuration A configuration object.

getOptions() 공개 메소드

This function returns the name of all options which are defined in this configuration file, as an array of strings.
public getOptions ( ) : array
리턴 array Name of all options defined in this configuration file.

getPathValue() 공개 메소드

The function will always return an absolute path unless the option is not set. It will then return the default value. It checks if the value starts with a slash, and prefixes it with the value from getBaseDir if it doesn't.
public getPathValue ( string $name, string | null $default = null ) : string | null
$name string Name of the configuration option.
$default string | null Default value of the configuration option. This parameter will default to null if not specified.
리턴 string | null The path configuration option with name $name, or $default if the option was not found.

getPublicKeys() 공개 메소드

Get public key from metadata.
public getPublicKeys ( string | null $use = null, boolean $required = false, string $prefix = '' ) : array | null
$use string | null The purpose this key can be used for. (encryption or signing).
$required boolean Whether the public key is required. If this is true, a missing key will cause an exception. Default is false.
$prefix string The prefix which should be used when reading from the metadata array. Defaults to ''.
리턴 array | null Public key data, or null if no public key or was found.

getString() 공개 메소드

An exception will be thrown if this option isn't a string, or if this option isn't found, and no default value is given.
public getString ( string $name, mixed $default = self::REQUIRED_OPTION ) : string | mixed
$name string The name of the option.
$default mixed A default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
리턴 string | mixed The option with the given name, or $default if the option isn't found and $default is specified.

getValue() 공개 메소드

Retrieve a configuration option set in config.php.
public getValue ( string $name, mixed $default = null ) : mixed
$name string Name of the configuration option.
$default mixed Default value of the configuration option. This parameter will default to null if not specified. This can be set to SimpleSAML_Configuration::REQUIRED_OPTION, which will cause an exception to be thrown if the option isn't found.
리턴 mixed The configuration option with name $name, or $default if the option was not found.

getValueValidate() 공개 메소드

This will check that the configuration option matches one of the given values. The match will use strict comparison. An exception will be thrown if it does not match. The option can be mandatory or optional. If no default value is given, it will be considered to be mandatory, and an exception will be thrown if it isn't provided. If a default value is given, it is considered to be optional, and the default value is returned. The default value is automatically included in the list of allowed values.
public getValueValidate ( string $name, array $allowedValues, mixed $default = self::REQUIRED_OPTION ) : mixed
$name string The name of the option.
$allowedValues array The values the option is allowed to take, as an array.
$default mixed The default value which will be returned if the option isn't found. If this parameter isn't given, the option will be considered to be mandatory. The default value can be any value, including null.
리턴 mixed The option with the given name, or $default if the option isn't found and $default is given.

getVersion() 공개 메소드

Retrieve the current version of SimpleSAMLphp.
public getVersion ( ) : string
리턴 string

hasValue() 공개 메소드

Check whether a key in the configuration exists or not.
public hasValue ( string $name ) : boolean
$name string The key in the configuration to look for.
리턴 boolean If the value is set in this configuration.

hasValueOneOf() 공개 메소드

Check whether any key of the set given exists in the configuration.
public hasValueOneOf ( array $names ) : boolean
$names array An array of options to look for.
리턴 boolean If any of the keys in $names exist in the configuration

init() 공개 정적인 메소드

TODO: remove.
또한 보기: setConfigDir()
사용 중단: This function is superseeded by the setConfigDir function.
public static init ( string $path, string $instancename = 'simplesaml', string $configfilename = 'config.php' )
$path string
$instancename string
$configfilename string

loadFromArray() 공개 정적인 메소드

Loads a configuration from the given array.
public static loadFromArray ( array $config, string $location = '[ARRAY]', string | null $instance = null ) : SimpleSAML_Configuration
$config array The configuration array.
$location string The location which will be given when an error occurs. Optional.
$instance string | null The name of this instance. If specified, the configuration will be loaded and an instance with that name will be kept for it to be retrieved later with getInstance($instance). If null, the configuration will not be kept for later use. Defaults to null.
리턴 SimpleSAML_Configuration The configuration object.

resolvePath() 공개 메소드

The path will never end with a '/'.
public resolvePath ( string | null $path ) : string | null
$path string | null The path we should resolve. This option may be null.
리턴 string | null $path if $path is an absolute path, or $path prepended with the base directory of this SimpleSAMLphp installation. We will return NULL if $path is null.

setConfigDir() 공개 정적인 메소드

Set the directory for configuration files for the given configuration set.
public static setConfigDir ( string $path, string $configSet = 'simplesaml' )
$path string The directory which contains the configuration files.
$configSet string The configuration set. Defaults to 'simplesaml'.

toArray() 공개 메소드

Convert this configuration object back to an array.
public toArray ( ) : array
리턴 array An associative array with all configuration options and values.