本文整理汇总了PHP中SimpleSAML_Configuration::getOptionalConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleSAML_Configuration::getOptionalConfig方法的具体用法?PHP SimpleSAML_Configuration::getOptionalConfig怎么用?PHP SimpleSAML_Configuration::getOptionalConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleSAML_Configuration
的用法示例。
在下文中一共展示了SimpleSAML_Configuration::getOptionalConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isModuleEnabled
/**
* Determine whether a module is enabled.
*
* Will return false if the given module doesn't exists.
*
* @param string $module Name of the module
*
* @return bool True if the given module is enabled, false otherwise.
*
* @throws Exception If module.enable is set and is not boolean.
*/
public static function isModuleEnabled($module)
{
$moduleDir = self::getModuleDir($module);
if (!is_dir($moduleDir)) {
return false;
}
$globalConfig = SimpleSAML_Configuration::getOptionalConfig();
$moduleEnable = $globalConfig->getArray('module.enable', array());
if (isset($moduleEnable[$module])) {
if (is_bool($moduleEnable[$module]) === true) {
return $moduleEnable[$module];
}
throw new Exception("Invalid module.enable value for for the module {$module}");
}
if (assert_options(ASSERT_ACTIVE) && !file_exists($moduleDir . '/default-enable') && !file_exists($moduleDir . '/default-disable')) {
SimpleSAML_Logger::error("Missing default-enable or default-disable file for the module {$module}");
}
if (file_exists($moduleDir . '/enable')) {
return true;
}
if (!file_exists($moduleDir . '/disable') && file_exists($moduleDir . '/default-enable')) {
return true;
}
return false;
}
示例2: portal_hook_htmlinject
/**
* Hook to inject HTML content into all pages...
*
* @param array &$hookinfo hookinfo
*/
function portal_hook_htmlinject(&$hookinfo)
{
assert('is_array($hookinfo)');
assert('array_key_exists("pre", $hookinfo)');
assert('array_key_exists("post", $hookinfo)');
assert('array_key_exists("page", $hookinfo)');
$links = array('links' => array());
SimpleSAML_Module::callHooks('frontpage', $links);
$portalConfig = SimpleSAML_Configuration::getOptionalConfig('module_portal.php');
$allLinks = array();
foreach ($links as $ls) {
$allLinks = array_merge($allLinks, $ls);
}
$pagesets = $portalConfig->getValue('pagesets', array(array('frontpage_welcome', 'frontpage_config', 'frontpage_auth', 'frontpage_federation')));
SimpleSAML_Module::callHooks('portalextras', $pagesets);
$portal = new sspmod_portal_Portal($allLinks, $pagesets);
if (!$portal->isPortalized($hookinfo['page'])) {
return;
}
// Include jquery UI CSS files in header.
$hookinfo['jquery']['css'] = TRUE;
$hookinfo['jquery']['version'] = '1.6';
// Header
$hookinfo['pre'][] = '<div id="portalmenu" class="ui-tabs ui-widget ui-widget-content ui-corner-all">' . $portal->getMenu($hookinfo['page']) . '<div id="portalcontent" class="ui-tabs-panel ui-widget-content ui-corner-bottom">';
// Footer
$hookinfo['post'][] = '</div></div>';
}
示例3: sanitycheck_hook_cron
/**
* Hook to run a cron job.
*
* @param array &$croninfo Output
*/
function sanitycheck_hook_cron(&$croninfo)
{
assert('is_array($croninfo)');
assert('array_key_exists("summary", $croninfo)');
assert('array_key_exists("tag", $croninfo)');
SimpleSAML_Logger::info('cron [sanitycheck]: Running cron in cron tag [' . $croninfo['tag'] . '] ');
try {
$sconfig = SimpleSAML_Configuration::getOptionalConfig('config-sanitycheck.php');
$cronTag = $sconfig->getString('cron_tag', NULL);
if ($cronTag === NULL || $cronTag !== $croninfo['tag']) {
return;
}
$info = array();
$errors = array();
$hookinfo = array('info' => &$info, 'errors' => &$errors);
SimpleSAML_Module::callHooks('sanitycheck', $hookinfo);
if (count($errors) > 0) {
foreach ($errors as $err) {
$croninfo['summary'][] = 'Sanitycheck error: ' . $err;
}
}
} catch (Exception $e) {
$croninfo['summary'][] = 'Error executing sanity check: ' . $e->getMessage();
}
}
示例4: oauth2_hook_cron
function oauth2_hook_cron(&$croninfo)
{
assert('is_array($croninfo)');
assert('array_key_exists("summary", $croninfo)');
assert('array_key_exists("tag", $croninfo)');
$oauth2config = SimpleSAML_Configuration::getOptionalConfig('module_oauth2.php');
if (is_null($oauth2config->getValue('cron_tag', 'hourly'))) {
return;
}
if ($oauth2config->getValue('cron_tag', NULL) !== $croninfo['tag']) {
return;
}
try {
$store = SimpleSAML_Store::getInstance();
if (!$store instanceof \SimpleSAML\Modules\DBAL\Store\DBAL) {
throw new \SimpleSAML_Error_Exception('OAuth2 module: Only DBAL Store is supported');
}
$accessTokenRepository = new AccessTokenRepository();
$accessTokenRepository->removeExpiredAccessTokens();
$authTokenRepository = new AuthCodeRepository();
$authTokenRepository->removeExpiredAuthCodes();
$refreshTokenRepository = new RefreshTokenRepository();
$refreshTokenRepository->removeExpiredRefreshTokens();
$croninfo['summary'][] = 'OAuth2 clean up. Removed expired entries from OAuth2 storage.';
} catch (Exception $e) {
$message = 'OAuth2 clean up cron script failed: ' . $e->getMessage();
SimpleSAML\Logger::warning($message);
$croninfo['summary'][] = $message;
}
}
示例5: __construct
/**
* ClientRepository constructor.
*/
public function __construct()
{
$this->config = \SimpleSAML_Configuration::getOptionalConfig('module_oauth2.php');
$this->store = \SimpleSAML_Store::getInstance();
if (!$this->store instanceof DBAL) {
throw new \SimpleSAML_Error_Exception('OAuth2 module: Only DBAL Store is supported');
}
$this->conn = $this->store->getConnection();
}
示例6: getById
/**
* Retrieve an access control list with the given id.
*
* @param string $id The id of the access control list.
* @return array The access control list array.
*/
private static function getById($id)
{
assert('is_string($id)');
$config = SimpleSAML_Configuration::getOptionalConfig('acl.php');
if (!$config->hasValue($id)) {
throw new SimpleSAML_Error_Exception('No ACL with id ' . var_export($id, TRUE) . ' in config/acl.php.');
}
return $config->getArray($id);
}
示例7: metarefresh_hook_cron
/**
* Hook to run a cron job.
*
* @param array &$croninfo Output
*/
function metarefresh_hook_cron(&$croninfo)
{
assert('is_array($croninfo)');
assert('array_key_exists("summary", $croninfo)');
assert('array_key_exists("tag", $croninfo)');
SimpleSAML_Logger::info('cron [metarefresh]: Running cron in cron tag [' . $croninfo['tag'] . '] ');
try {
$config = SimpleSAML_Configuration::getInstance();
$mconfig = SimpleSAML_Configuration::getOptionalConfig('config-metarefresh.php');
$sets = $mconfig->getConfigList('sets', array());
foreach ($sets as $setkey => $set) {
// Only process sets where cron matches the current cron tag.
$cronTags = $set->getArray('cron');
if (!in_array($croninfo['tag'], $cronTags)) {
continue;
}
SimpleSAML_Logger::info('cron [metarefresh]: Executing set [' . $setkey . ']');
$expireAfter = $set->getInteger('expireAfter', NULL);
if ($expireAfter !== NULL) {
$expire = time() + $expireAfter;
} else {
$expire = NULL;
}
$metaloader = new sspmod_metarefresh_MetaLoader($expire);
foreach ($set->getArray('sources') as $source) {
SimpleSAML_Logger::debug('cron [metarefresh]: In set [' . $setkey . '] loading source [' . $source['src'] . ']');
$metaloader->loadSource($source);
}
$outputDir = $set->getString('outputDir');
$outputDir = $config->resolvePath($outputDir);
$outputFormat = $set->getValueValidate('outputFormat', array('flatfile', 'serialize'), 'flatfile');
switch ($outputFormat) {
case 'flatfile':
$metaloader->writeMetadataFiles($outputDir);
break;
case 'serialize':
$metaloader->writeMetadataSerialize($outputDir);
break;
}
if ($set->hasValue('arp')) {
$arpconfig = SimpleSAML_Configuration::loadFromArray($set->getValue('arp'));
$metaloader->writeARPfile($arpconfig);
}
}
} catch (Exception $e) {
$croninfo['summary'][] = 'Error during metarefresh: ' . $e->getMessage();
}
}
示例8: show
public static function show($path = '/simplesaml/module.php/discojuice/discojuice/') {
$djconfig = SimpleSAML_Configuration::getOptionalConfig('discojuicecentral.php');
$config = SimpleSAML_Configuration::getInstance();
$feed = new sspmod_discojuice_Feed();
$metadata = json_decode($feed->read(), TRUE);
$t = new SimpleSAML_XHTML_Template($config, 'discojuice:central.tpl.php');
$t->data['metadata'] = $metadata;
$t->data['discojuice.options'] = $djconfig->getValue('discojuice.options');
$t->data['discojuice.options']['discoPath'] = $path;
$t->data['acl'] = $djconfig->getValue('acl');
$t->show();
}
示例9: oauth_hook_cron
/**
* Hook to run a cron job.
*
* @param array &$croninfo Output
*/
function oauth_hook_cron(&$croninfo)
{
assert('is_array($croninfo)');
assert('array_key_exists("summary", $croninfo)');
assert('array_key_exists("tag", $croninfo)');
$oauthconfig = SimpleSAML_Configuration::getOptionalConfig('module_statistics.php');
if (is_null($oauthconfig->getValue('cron_tag', 'hourly'))) {
return;
}
if ($oauthconfig->getValue('cron_tag', NULL) !== $croninfo['tag']) {
return;
}
try {
$store = new sspmod_core_Storage_SQLPermanentStorage('oauth');
$cleaned = $store->removeExpired();
# if ($cleaned > 0)
$croninfo['summary'][] = 'OAuth clean up. Removed ' . $cleaned . ' expired entries from OAuth storage.';
} catch (Exception $e) {
$message = 'OAuth clean up cron script failed: ' . $e->getMessage();
SimpleSAML_Logger::warning($message);
$croninfo['summary'][] = $message;
}
}
示例10: head
public static function head($includeJQuery = TRUE) {
$version = '0.1-4';
$config = SimpleSAML_Configuration::getInstance();
$djconfig = SimpleSAML_Configuration::getOptionalConfig('discojuiceembed.php');
if ($includeJQuery) {
echo '
<!-- JQuery (Required for DiscoJuice) -->
<script type="text/javascript" src="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/jquery-1.6.min.js') . '"></script>
<script type="text/javascript" src="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/jquery-ui-1.8.5.custom.min.js') . '"></script>
<link rel="stylesheet" type="text/css" href="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/css/custom/jquery-ui-1.8.5.custom.css') . '" />
';
}
echo '
<!-- DiscoJuice (version identifier: ' . $version . ' ) -->
<script type="text/javascript" src="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/discojuice.misc.js?v=' . $version) . '"></script>
<script type="text/javascript" src="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/discojuice.ui.js?v=' . $version) . '"></script>
<script type="text/javascript" src="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/discojuice.control.js?v=' . $version) . '"></script>
<link rel="stylesheet" type="text/css" href="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/css/discojuice.css?v=' . $version) . '" />
';
$options = $djconfig->getValue('discojuice.options');
$target = $djconfig->getValue('target');
echo '<script type="text/javascript">';
echo 'var options = ' . json_encode($options) . ';' . "\n";
echo 'var target = "' . $target . '";' . "\n\n";
echo 'options.countryAPI = "' . SimpleSAML_Module::getModuleURL('discojuice/country.php'). '"; ' . "\n";
if (empty($options['metadata'])) {
echo 'options.metadata = "' . SimpleSAML_Module::getModuleURL('discojuice/feed.php'). '"; ' . "\n";
}
if (!empty($options['disco'])) {
echo 'options.disco.url = "' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/discojuiceDiscoveryResponse.html?'). '"; ' . "\n";
}
echo 'options.discoPath = "' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/') . '"; ' . "\n";
echo 'options.callback = ' . $djconfig->getValue('callback', 'null') . ';' . "\n\n";
echo '
$(document).ready(function() {
$(target).DiscoJuice(options);
});
</script>
';
}
示例11: getSources
/**
* Retrieve list of authentication sources.
*
* @param string $authId The authentication source identifier.
* @return array The id of all authentication sources.
*/
public static function getSources()
{
$config = SimpleSAML_Configuration::getOptionalConfig('authsources.php');
return $config->getOptions();
}
示例12: array
<?php
$config = SimpleSAML_Configuration::getInstance();
$mconfig = SimpleSAML_Configuration::getOptionalConfig('config-metarefresh.php');
SimpleSAML\Utils\Auth::requireAdmin();
SimpleSAML_Logger::setCaptureLog(TRUE);
$sets = $mconfig->getConfigList('sets', array());
foreach ($sets as $setkey => $set) {
SimpleSAML_Logger::info('[metarefresh]: Executing set [' . $setkey . ']');
try {
$expireAfter = $set->getInteger('expireAfter', NULL);
if ($expireAfter !== NULL) {
$expire = time() + $expireAfter;
} else {
$expire = NULL;
}
$metaloader = new sspmod_metarefresh_MetaLoader($expire);
# Get global black/whitelists
$blacklist = $mconfig->getArray('blacklist', array());
$whitelist = $mconfig->getArray('whitelist', array());
// get global type filters
$available_types = array('saml20-idp-remote', 'saml20-sp-remote', 'shib13-idp-remote', 'shib13-sp-remote', 'attributeauthority-remote');
$set_types = $set->getArrayize('types', $available_types);
foreach ($set->getArray('sources') as $source) {
// filter metadata by type of entity
if (isset($source['types'])) {
$metaloader->setTypes($source['types']);
} else {
$metaloader->setTypes($set_types);
}
# Merge global and src specific blacklists
示例13: getChosenSourceConfig
/**
* retourne la configuration de la source réelle utilisée pour l'authentification
*
* @return array
*/
protected function getChosenSourceConfig() {
//si on est en multiauth, il va y avoir une délégation de source
//on va donc regarder la configuration de la source choisie par l'utilisateur
if($this->authSourceConfig[0] != 'multiauth:MultiAuth') {
return $this->authSourceConfig;
} else {
$session = SimpleSAML_Session::getInstance();
$delegationAuthId = $session->getData(sspmod_multiauth_Auth_Source_MultiAuth::SESSION_SOURCE, $this->authSource);
if ($delegationAuthId == null) {
//aucune source choisie pour l'instant par l'utilisateur
return $this->authSourceConfig;
}
$config = SimpleSAML_Configuration::getOptionalConfig('authsources.php');
return $config->getArray($delegationAuthId);
}
}
示例14: metarefresh_hook_cron
/**
* Hook to run a cron job.
*
* @param array &$croninfo Output
*/
function metarefresh_hook_cron(&$croninfo)
{
assert('is_array($croninfo)');
assert('array_key_exists("summary", $croninfo)');
assert('array_key_exists("tag", $croninfo)');
SimpleSAML_Logger::info('cron [metarefresh]: Running cron in cron tag [' . $croninfo['tag'] . '] ');
try {
$config = SimpleSAML_Configuration::getInstance();
$mconfig = SimpleSAML_Configuration::getOptionalConfig('config-metarefresh.php');
$sets = $mconfig->getConfigList('sets', array());
$stateFile = $config->getPathValue('datadir', 'data/') . 'metarefresh-state.php';
foreach ($sets as $setkey => $set) {
// Only process sets where cron matches the current cron tag.
$cronTags = $set->getArray('cron');
if (!in_array($croninfo['tag'], $cronTags)) {
continue;
}
SimpleSAML_Logger::info('cron [metarefresh]: Executing set [' . $setkey . ']');
$expireAfter = $set->getInteger('expireAfter', NULL);
if ($expireAfter !== NULL) {
$expire = time() + $expireAfter;
} else {
$expire = NULL;
}
$outputDir = $set->getString('outputDir');
$outputDir = $config->resolvePath($outputDir);
$outputFormat = $set->getValueValidate('outputFormat', array('flatfile', 'serialize'), 'flatfile');
$oldMetadataSrc = SimpleSAML_Metadata_MetaDataStorageSource::getSource(array('type' => $outputFormat, 'directory' => $outputDir));
$metaloader = new sspmod_metarefresh_MetaLoader($expire, $stateFile, $oldMetadataSrc);
# Get global blacklist, whitelist and caching info
$blacklist = $mconfig->getArray('blacklist', array());
$whitelist = $mconfig->getArray('whitelist', array());
$conditionalGET = $mconfig->getBoolean('conditionalGET', FALSE);
// get global type filters
$available_types = array('saml20-idp-remote', 'saml20-sp-remote', 'shib13-idp-remote', 'shib13-sp-remote', 'attributeauthority-remote');
$set_types = $set->getArrayize('types', $available_types);
foreach ($set->getArray('sources') as $source) {
// filter metadata by type of entity
if (isset($source['types'])) {
$metaloader->setTypes($source['types']);
} else {
$metaloader->setTypes($set_types);
}
# Merge global and src specific blacklists
if (isset($source['blacklist'])) {
$source['blacklist'] = array_unique(array_merge($source['blacklist'], $blacklist));
} else {
$source['blacklist'] = $blacklist;
}
# Merge global and src specific whitelists
if (isset($source['whitelist'])) {
$source['whitelist'] = array_unique(array_merge($source['whitelist'], $whitelist));
} else {
$source['whitelist'] = $whitelist;
}
# Let src specific conditionalGET override global one
if (!isset($source['conditionalGET'])) {
$source['conditionalGET'] = $conditionalGET;
}
SimpleSAML_Logger::debug('cron [metarefresh]: In set [' . $setkey . '] loading source [' . $source['src'] . ']');
$metaloader->loadSource($source);
}
// Write state information back to disk
$metaloader->writeState();
switch ($outputFormat) {
case 'flatfile':
$metaloader->writeMetadataFiles($outputDir);
break;
case 'serialize':
$metaloader->writeMetadataSerialize($outputDir);
break;
}
if ($set->hasValue('arp')) {
$arpconfig = SimpleSAML_Configuration::loadFromArray($set->getValue('arp'));
$metaloader->writeARPfile($arpconfig);
}
}
} catch (Exception $e) {
$croninfo['summary'][] = 'Error during metarefresh: ' . $e->getMessage();
}
}
示例15: requireOwnership
<?php
/* Load simpleSAMLphp, configuration and metadata */
$config = SimpleSAML_Configuration::getInstance();
$session = SimpleSAML_Session::getSessionFromRequest();
$oauthconfig = SimpleSAML_Configuration::getOptionalConfig('module_oauth.php');
$store = new sspmod_core_Storage_SQLPermanentStorage('oauth');
//$authsource = $oauthconfig->getValue('auth', 'admin');
$authsource = "admin";
// force admin to authenticate as registry maintainer
$useridattr = $oauthconfig->getValue('useridattr', 'user');
//$useridattr = $oauthconfig->getValue('useridattr', 'uid');
if ($session->isValid($authsource)) {
$attributes = $session->getAttributes();
// Check if userid exists
if (!isset($attributes[$useridattr])) {
throw new Exception('User ID is missing');
}
$userid = $attributes[$useridattr][0];
} else {
SimpleSAML_Auth_Default::initLogin($authsource, SimpleSAML_Utilities::selfURL());
}
function requireOwnership($entry, $userid)
{
if (!isset($entry['owner'])) {
throw new Exception('OAuth Consumer has no owner. Which means no one is granted access, not even you.');
}
if ($entry['owner'] !== $userid) {
throw new Exception('OAuth Consumer has an owner that is not equal to your userid, hence you are not granted access.');
}
}