本文整理汇总了PHP中SimpleSAML_Configuration类的典型用法代码示例。如果您正苦于以下问题:PHP SimpleSAML_Configuration类的具体用法?PHP SimpleSAML_Configuration怎么用?PHP SimpleSAML_Configuration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleSAML_Configuration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Initialize the output.
*
* @param SimpleSAML_Configuration $config The configuration for this output.
*/
public function __construct(SimpleSAML_Configuration $config)
{
$logLevel = $config->getString('level', 'notice');
$this->logger = array('SimpleSAML_Logger', $logLevel);
if (!is_callable($this->logger)) {
throw new Exception('Invalid log level: ' . var_export($logLevel, TRUE));
}
}
示例2: __construct
/**
* Initialize the output.
*
* @param SimpleSAML_Configuration $config The configuration for this output.
*/
public function __construct(SimpleSAML_Configuration $config)
{
$this->logDir = $config->getPathValue('directory');
if ($this->logDir === NULL) {
throw new Exception('Missing "directory" option for core:File');
}
if (!is_dir($this->logDir)) {
throw new Exception('Could not find log directory: ' . var_export($this->logDir, TRUE));
}
}
示例3: __construct
/**
* Build a new logging handler based on syslog.
*/
public function __construct(\SimpleSAML_Configuration $config)
{
$facility = $config->getInteger('logging.facility', defined('LOG_LOCAL5') ? constant('LOG_LOCAL5') : LOG_USER);
$processname = $config->getString('logging.processname', 'SimpleSAMLphp');
// Setting facility to LOG_USER (only valid in Windows), enable log level rewrite on windows systems
if (System::getOS() === System::WINDOWS) {
$this->isWindows = true;
$facility = LOG_USER;
}
openlog($processname, LOG_PID, $facility);
}
示例4: __construct
/**
* Initialize this EntitySource.
*
* @param SimpleSAML_Configuration $config The configuration.
*/
public function __construct(sspmod_aggregator2_Aggregator $aggregator, SimpleSAML_Configuration $config)
{
$this->logLoc = 'aggregator2:' . $aggregator->getId() . ': ';
$this->aggregator = $aggregator;
$this->url = $config->getString('url');
$this->sslCAFile = $config->getString('ssl.cafile', NULL);
if ($this->sslCAFile === NULL) {
$this->sslCAFile = $aggregator->getCAFile();
}
$this->certificate = $config->getString('cert', NULL);
$this->cacheId = sha1($this->url);
$this->cacheTag = sha1(serialize($config));
}
示例5: __construct
public function __construct(array $config)
{
if (!is_string($config['directory'])) {
throw new Exception('Invalid directory option in config.');
}
$conf = new SimpleSAML_Configuration(array(), '');
$path = $conf->resolvePath($config['directory']);
if (!is_dir($path)) {
throw new Exception('Invalid storage directory [' . $path . '].');
}
if (!is_writable($path)) {
throw new Exception('Storage directory [' . $path . '] is not writable.');
}
$this->directory = preg_replace('/\\/$/', '', $path) . '/';
}
示例6: __construct
public function __construct(\SimpleSAML_Configuration $config)
{
$storeConfig = $config->getValue('ticketstore', array('directory' => 'ticketcache'));
if (!is_string($storeConfig['directory'])) {
throw new Exception('Invalid directory option in config.');
}
$path = $config->resolvePath($storeConfig['directory']);
if (!is_dir($path)) {
throw new Exception('Directory for CAS Server ticket storage [' . $path . '] does not exists. ');
}
if (!is_writable($path)) {
throw new Exception('Directory for CAS Server ticket storage [' . $path . '] is not writable. ');
}
$this->pathToTicketDirectory = preg_replace('/\\/$/', '', $path);
}
示例7: getInstance
/**
* Retrieve our singleton instance.
*
* @return SimpleSAML_Store|false The data store, or false if it isn't enabled.
*/
public static function getInstance()
{
if (self::$instance !== null) {
return self::$instance;
}
$config = SimpleSAML_Configuration::getInstance();
$storeType = $config->getString('store.type', null);
if ($storeType === null) {
$storeType = $config->getString('session.handler', 'phpsession');
}
switch ($storeType) {
case 'phpsession':
// we cannot support advanced features with the PHP session store
self::$instance = false;
break;
case 'memcache':
self::$instance = new SimpleSAML_Store_Memcache();
break;
case 'sql':
self::$instance = new SimpleSAML_Store_SQL();
break;
default:
// datastore from module
$className = SimpleSAML_Module::resolveClass($storeType, 'Store', 'SimpleSAML_Store');
self::$instance = new $className();
}
return self::$instance;
}
示例8: __construct
/**
* Constructor for the metadata signer.
*
* You can pass an list of options as key-value pairs in the array. This allows you to initialize
* a metadata signer in one call.
*
* The following keys are recognized:
* - privatekey The file with the private key, relative to the cert-directory.
* - privatekey_pass The passphrase for the private key.
* - certificate The file with the certificate, relative to the cert-directory.
* - privatekey_array The private key, as an array returned from SimpleSAML_Utilities::loadPrivateKey.
* - publickey_array The public key, as an array returned from SimpleSAML_Utilities::loadPublicKey.
* - id The name of the ID attribute.
*
* @param $options Associative array with options for the constructor. Defaults to an empty array.
*/
public function __construct($options = array())
{
assert('is_array($options)');
if (self::$certDir === FALSE) {
$config = SimpleSAML_Configuration::getInstance();
self::$certDir = $config->getPathValue('certdir', 'cert/');
}
$this->idAttrName = FALSE;
$this->privateKey = FALSE;
$this->certificate = FALSE;
$this->extraCertificates = array();
if (array_key_exists('privatekey', $options)) {
$pass = NULL;
if (array_key_exists('privatekey_pass', $options)) {
$pass = $options['privatekey_pass'];
}
$this->loadPrivateKey($options['privatekey'], $pass);
}
if (array_key_exists('certificate', $options)) {
$this->loadCertificate($options['certificate']);
}
if (array_key_exists('privatekey_array', $options)) {
$this->loadPrivateKeyArray($options['privatekey_array']);
}
if (array_key_exists('publickey_array', $options)) {
$this->loadPublicKeyArray($options['publickey_array']);
}
if (array_key_exists('id', $options)) {
$this->setIdAttribute($options['id']);
}
}
示例9: core_hook_sanitycheck
/**
* Hook to do sanitycheck
*
* @param array &$hookinfo hookinfo
*/
function core_hook_sanitycheck(&$hookinfo)
{
assert('is_array($hookinfo)');
assert('array_key_exists("errors", $hookinfo)');
assert('array_key_exists("info", $hookinfo)');
$config = SimpleSAML_Configuration::getInstance();
if ($config->getString('auth.adminpassword', '123') === '123') {
$hookinfo['errors'][] = '[core] Password in config.php is not set properly';
} else {
$hookinfo['info'][] = '[core] Password in config.php is set properly';
}
if ($config->getString('technicalcontact_email', 'na@example.org') === 'na@example.org') {
$hookinfo['errors'][] = '[core] In config.php technicalcontact_email is not set properly';
} else {
$hookinfo['info'][] = '[core] In config.php technicalcontact_email is set properly';
}
if (version_compare(phpversion(), '5.3', '>=')) {
$hookinfo['info'][] = '[core] You are running PHP version ' . phpversion() . '. Great.';
} else {
$hookinfo['errors'][] = '[core] You are running PHP version ' . phpversion() . '. SimpleSAMLphp requires version >= 5.3. Please upgrade!';
}
$info = array();
$mihookinfo = array('info' => &$info);
$availmodules = SimpleSAML_Module::getModules();
SimpleSAML_Module::callHooks('moduleinfo', $mihookinfo);
foreach ($info as $mi => $i) {
if (isset($i['dependencies']) && is_array($i['dependencies'])) {
foreach ($i['dependencies'] as $dep) {
if (!in_array($dep, $availmodules)) {
$hookinfo['errors'][] = '[core] Module dependency not met: ' . $mi . ' requires ' . $dep;
}
}
}
}
}
示例10: sendResponse
/**
* Send a response to the SP.
*
* @param array $state The authentication state.
*/
public static function sendResponse(array $state)
{
assert('isset($state["Attributes"])');
assert('isset($state["SPMetadata"])');
assert('isset($state["saml:shire"])');
assert('array_key_exists("saml:target", $state)');
// Can be NULL
$spMetadata = $state["SPMetadata"];
$spEntityId = $spMetadata['entityid'];
$spMetadata = SimpleSAML_Configuration::loadFromArray($spMetadata, '$metadata[' . var_export($spEntityId, TRUE) . ']');
SimpleSAML\Logger::info('Sending SAML 1.1 Response to ' . var_export($spEntityId, TRUE));
$attributes = $state['Attributes'];
$shire = $state['saml:shire'];
$target = $state['saml:target'];
$idp = SimpleSAML_IdP::getByState($state);
$idpMetadata = $idp->getConfig();
$config = SimpleSAML_Configuration::getInstance();
$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
$statsData = array('spEntityID' => $spEntityId, 'idpEntityID' => $idpMetadata->getString('entityid'), 'protocol' => 'saml1');
if (isset($state['saml:AuthnRequestReceivedAt'])) {
$statsData['logintime'] = microtime(TRUE) - $state['saml:AuthnRequestReceivedAt'];
}
SimpleSAML_Stats::log('saml:idp:Response', $statsData);
// Generate and send response.
$ar = new SimpleSAML_XML_Shib13_AuthnResponse();
$authnResponseXML = $ar->generate($idpMetadata, $spMetadata, $shire, $attributes);
$httppost = new SimpleSAML_Bindings_Shib13_HTTPPost($config, $metadata);
$httppost->sendResponse($authnResponseXML, $idpMetadata, $spMetadata, $target, $shire);
}
示例11: getInstance
/**
* Retrieve our singleton instance.
*
* @return SimpleSAML_Store|FALSE The datastore, or FALSE if it isn't enabled.
*/
public static function getInstance()
{
if (self::$instance !== NULL) {
return self::$instance;
}
$config = SimpleSAML_Configuration::getInstance();
$storeType = $config->getString('store.type', NULL);
if ($storeType === NULL) {
$storeType = $config->getString('session.handler', 'phpsession');
}
switch ($storeType) {
case 'phpsession':
/* We cannot support advanced features with the PHP session store. */
self::$instance = FALSE;
break;
case 'memcache':
self::$instance = new SimpleSAML_Store_Memcache();
break;
case 'sql':
self::$instance = new SimpleSAML_Store_SQL();
break;
default:
if (strpos($storeType, ':') === FALSE) {
throw new SimpleSAML_Error_Exception('Unknown datastore type: ' . var_export($storeType, TRUE));
}
/* Datastore from module. */
$className = SimpleSAML_Module::resolveClass($storeType, 'Store', 'SimpleSAML_Store');
self::$instance = new $className();
}
return self::$instance;
}
示例12: createLogoutResponse
protected function createLogoutResponse($testrun, $logoutRequest, $logoutRelayState)
{
$this->log($testrun, 'Creating response with relaystate [' . $logoutRelayState . ']');
$idpMetadata = SimpleSAML_Configuration::loadFromArray($this->idpmetadata);
$spMetadata = SimpleSAML_Configuration::loadFromArray($this->metadata);
// Get SingleLogoutService URL
$consumerURLf = $spMetadata->getDefaultEndpoint('SingleLogoutService', array('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect'));
$consumerURL = $consumerURLf['Location'];
/* Create an send response. */
$response = sspmod_saml2_Message::buildLogoutResponse($idpMetadata, $spMetadata);
$response->setRelayState($logoutRequest->getRelayState());
$response->setInResponseTo($logoutRequest->getId());
$keyArray = SimpleSAML_Utilities::loadPrivateKey($idpMetadata, TRUE);
$certArray = SimpleSAML_Utilities::loadPublicKey($idpMetadata, FALSE);
$privateKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'private'));
$privateKey->loadKey($keyArray['PEM'], FALSE);
$response->setSignatureKey($privateKey);
if ($certArray === NULL) {
throw new Exception('No certificates found. [1]');
}
if (!array_key_exists('PEM', $certArray)) {
throw new Exception('No certificates found. [2]');
}
$response->setCertificates(array($certArray['PEM']));
#$this->tweakResponse($testrun, $response);
$msgStr = $response->toUnsignedXML();
#$this->tweakResponseDOM($testrun, $msgStr);
$msgStr = $msgStr->ownerDocument->saveXML($msgStr);
# echo '<pre>'; echo(htmlspecialchars($msgStr)); exit;
# $msgStr = base64_encode($msgStr);
# $msgStr = htmlspecialchars($msgStr);
return array('url' => $consumerURL, 'Response' => $msgStr, 'ResponseObj' => $response, 'RelayState' => $logoutRelayState);
}
示例13: statistics_hook_sanitycheck
/**
* Hook to do santity checks
*
* @param array &$hookinfo hookinfo
*/
function statistics_hook_sanitycheck(&$hookinfo)
{
assert('is_array($hookinfo)');
assert('array_key_exists("errors", $hookinfo)');
assert('array_key_exists("info", $hookinfo)');
try {
$statconfig = SimpleSAML_Configuration::getConfig('module_statistics.php');
} catch (Exception $e) {
$hookinfo['errors'][] = '[statistics] Could not get configuration: ' . $e->getMessage();
return;
}
$statdir = $statconfig->getValue('statdir');
$inputfile = $statconfig->getValue('inputfile');
if (file_exists($statdir)) {
$hookinfo['info'][] = '[statistics] Statistics dir [' . $statdir . '] exists';
if (is_writable($statdir)) {
$hookinfo['info'][] = '[statistics] Statistics dir [' . $statdir . '] is writable';
} else {
$hookinfo['errors'][] = '[statistics] Statistics dir [' . $statdir . '] is not writable';
}
} else {
$hookinfo['errors'][] = '[statistics] Statistics dir [' . $statdir . '] does not exists';
}
if (file_exists($inputfile)) {
$hookinfo['info'][] = '[statistics] Input file [' . $inputfile . '] exists';
} else {
$hookinfo['errors'][] = '[statistics] Input file [' . $inputfile . '] does not exists';
}
}
示例14: __construct
/**
* Constructor for this authentication source.
*
* @param array $info Information about this authentication source.
* @param array $config The configuration of the module
*
* @throws Exception If the KRB5 extension is not installed or active.
*/
public function __construct($info, $config)
{
assert('is_array($info)');
assert('is_array($config)');
if (!extension_loaded('krb5')) {
throw new Exception('KRB5 Extension not installed');
}
// call the parent constructor first, as required by the interface
parent::__construct($info, $config);
$config = SimpleSAML_Configuration::loadFromArray($config);
$this->backend = $config->getString('fallback');
$this->hostname = $config->getString('hostname');
$this->port = $config->getInteger('port', 389);
$this->referrals = $config->getBoolean('referrals', true);
$this->enableTLS = $config->getBoolean('enable_tls', false);
$this->debugLDAP = $config->getBoolean('debugLDAP', false);
$this->timeout = $config->getInteger('timeout', 30);
$this->keytab = $config->getString('keytab');
$this->base = $config->getArrayizeString('base');
$this->attr = $config->getString('attr', 'uid');
$this->subnet = $config->getArray('subnet', null);
$this->admin_user = $config->getString('adminUser', null);
$this->admin_pw = $config->getString('adminPassword', null);
$this->attributes = $config->getArray('attributes', null);
}
示例15: process
public function process(&$state)
{
assert('is_array($state)');
if (empty($state['Expire']) || empty($state['Authority'])) {
return;
}
$now = time();
$delta = $state['Expire'] - $now;
$globalConfig = SimpleSAML_Configuration::getInstance();
$sessionDuration = $globalConfig->getInteger('session.duration', 8 * 60 * 60);
/* Extend only if half of session duration already passed */
if ($delta >= $sessionDuration * 0.5) {
return;
}
/* Update authority expire time */
$session = SimpleSAML_Session::getSessionFromRequest();
$session->setAuthorityExpire($state['Authority']);
/* Update session cookies duration */
/* If remember me is active */
$rememberMeExpire = $session->getRememberMeExpire();
if (!empty($state['RememberMe']) && $rememberMeExpire !== NULL && $globalConfig->getBoolean('session.rememberme.enable', FALSE)) {
$session->setRememberMeExpire();
return;
}
/* Or if session lifetime is more than zero */
$sessionHandler = SimpleSAML_SessionHandler::getSessionHandler();
$cookieParams = $sessionHandler->getCookieParams();
if ($cookieParams['lifetime'] > 0) {
$session->updateSessionCookies();
}
}