Ejemplo n.º 1
0
                $authlogattr = $config->getValue('statistics.authlogattr', null);
                if ($authlogattr && array_key_exists($authlogattr, $attributes)) {
                    SimpleSAML_Logger::stats('AUTH-login-radius OK ' . $attributes[$authlogattr][0]);
                } else {
                    SimpleSAML_Logger::stats('AUTH-login-radius OK');
                }
                SimpleSAML_Utilities::redirectTrustedURL($relaystate);
            case RADIUS_ACCESS_REJECT:
                SimpleSAML_Logger::info('AUTH - radius: ' . $_POST['username'] . ' failed to authenticate');
                throw new Exception('Radius authentication error: Bad credentials ');
                break;
            case RADIUS_ACCESS_CHALLENGE:
                SimpleSAML_Logger::critical('AUTH - radius: Challenge requested: ' . radius_strerror($radius));
                throw new Exception('Radius authentication error: Challenge requested');
                break;
            default:
                SimpleSAML_Logger::critical('AUTH  -radius: General radius error: ' . radius_strerror($radius));
                throw new Exception('Error during radius authentication: ' . radius_strerror($radius));
        }
    } catch (Exception $e) {
        $error = $e->getMessage();
    }
}
$t = new SimpleSAML_XHTML_Template($config, 'login.php', 'login');
$t->data['header'] = 'simpleSAMLphp: Enter username and password';
$t->data['relaystate'] = $relaystate;
$t->data['error'] = $error;
if (isset($error)) {
    $t->data['username'] = $_POST['username'];
}
$t->show();
Ejemplo n.º 2
0
 /**
  * Find template path.
  *
  * This function locates the given template based on the template name. It will first search for the template in
  * the current theme directory, and then the default theme.
  *
  * The template name may be on the form <module name>:<template path>, in which case it will search for the
  * template file in the given module.
  *
  * @param string $template The relative path from the theme directory to the template file.
  *
  * @return string The absolute path to the template file.
  *
  * @throws Exception If the template file couldn't be found.
  */
 private function findTemplatePath($template)
 {
     assert('is_string($template)');
     $tmp = explode(':', $template, 2);
     if (count($tmp) === 2) {
         $templateModule = $tmp[0];
         $templateName = $tmp[1];
     } else {
         $templateModule = 'default';
         $templateName = $tmp[0];
     }
     $tmp = explode(':', $this->configuration->getString('theme.use', 'default'), 2);
     if (count($tmp) === 2) {
         $themeModule = $tmp[0];
         $themeName = $tmp[1];
     } else {
         $themeModule = null;
         $themeName = $tmp[0];
     }
     // first check the current theme
     if ($themeModule !== null) {
         // .../module/<themeModule>/themes/<themeName>/<templateModule>/<templateName>
         $filename = SimpleSAML_Module::getModuleDir($themeModule) . '/themes/' . $themeName . '/' . $templateModule . '/' . $templateName;
     } elseif ($templateModule !== 'default') {
         // .../module/<templateModule>/templates/<themeName>/<templateName>
         $filename = SimpleSAML_Module::getModuleDir($templateModule) . '/templates/' . $templateName;
     } else {
         // .../templates/<theme>/<templateName>
         $filename = $this->configuration->getPathValue('templatedir', 'templates/') . $templateName;
     }
     if (file_exists($filename)) {
         return $filename;
     }
     // not found in current theme
     SimpleSAML_Logger::debug($_SERVER['PHP_SELF'] . ' - Template: Could not find template file [' . $template . '] at [' . $filename . '] - now trying the base template');
     // try default theme
     if ($templateModule !== 'default') {
         // .../module/<templateModule>/templates/<templateName>
         $filename = SimpleSAML_Module::getModuleDir($templateModule) . '/templates/' . $templateName;
     } else {
         // .../templates/<templateName>
         $filename = $this->configuration->getPathValue('templatedir', 'templates/') . '/' . $templateName;
     }
     if (file_exists($filename)) {
         return $filename;
     }
     // not found in default template - log error and throw exception
     $error = 'Template: Could not find template file [' . $template . '] at [' . $filename . ']';
     SimpleSAML_Logger::critical($_SERVER['PHP_SELF'] . ' - ' . $error);
     throw new Exception($error);
 }
Ejemplo n.º 3
0
if (empty($userids)) {
    throw new Exception('Could not generate useridentifier for storing consent. Attribute [' . $userid_attributename . '] was not available.');
}
$userid = $userids[0];
// Get all SP metadata
$all_sp_metadata = $metadata->getList('saml20-sp-remote');
// Parse action, if any
$action = null;
$sp_entityid = null;
if (!empty($_GET['cv'])) {
    $sp_entityid = $_GET['cv'];
}
if (!empty($_GET['action'])) {
    $action = $_GET["action"];
}
SimpleSAML_Logger::critical('consentAdmin: sp: ' . $sp_entityid . ' action: ' . $action);
// Remove services, whitch have consent disabled
if (isset($idp_metadata['consent.disable'])) {
    foreach ($idp_metadata['consent.disable'] as $disable) {
        if (array_key_exists($disable, $all_sp_metadata)) {
            unset($all_sp_metadata[$disable]);
        }
    }
}
SimpleSAML_Logger::info('consentAdmin: ' . $idp_entityid);
// Calc correct source
$source = $idp_metadata['metadata-set'] . '|' . $idp_entityid;
// Parse consent config
$consent_storage = sspmod_consent_Store::parseStoreConfig($cA_config->getValue('consentadmin'));
// Calc correct user ID hash
$hashed_user_id = sspmod_consent_Auth_Process_Consent::getHashedUserID($userid, $source);
Ejemplo n.º 4
0
 /**
  * Logs with an arbitrary level.
  *
  * @param mixed $level
  * @param string $message
  * @param array $context
  * @return NULL
  */
 public function log($level, $message, array $context = array())
 {
     switch ($level) {
         case SimpleSAML_Logger::ALERT:
             SimpleSAML_Logger::alert($message);
             break;
         case SimpleSAML_Logger::CRIT:
             SimpleSAML_Logger::critical($message);
             break;
         case SimpleSAML_Logger::DEBUG:
             SimpleSAML_Logger::debug($message);
             break;
         case SimpleSAML_Logger::EMERG:
             SimpleSAML_Logger::emergency($message);
             break;
         case SimpleSAML_Logger::ERR:
             SimpleSAML_Logger::error($message);
             break;
         case SimpleSAML_Logger::INFO:
             SimpleSAML_Logger::info($message);
             break;
         case SimpleSAML_Logger::NOTICE:
             SimpleSAML_Logger::notice($message);
             break;
         case SimpleSAML_Logger::WARNING:
             SimpleSAML_Logger::warning($message);
     }
 }
Ejemplo n.º 5
0
 /**
  * Show the template to the user.
  */
 public function show()
 {
     $filename = $this->configuration->getPathValue('templatedir') . $this->configuration->getValue('theme.use') . '/' . $this->template;
     if (!file_exists($filename)) {
         SimpleSAML_Logger::warning($_SERVER['PHP_SELF'] . ' - Template: Could not find template file [' . $this->template . '] at [' . $filename . '] - now trying the base template');
         $filename = $this->configuration->getPathValue('templatedir') . $this->configuration->getValue('theme.base') . '/' . $this->template;
         if (!file_exists($filename)) {
             SimpleSAML_Logger::critical($_SERVER['PHP_SELF'] . ' - Template: Could not find template file [' . $this->template . '] at [' . $filename . ']');
             echo 'Fatal error: Could not find template file [' . $this->template . '] at [' . $filename . ']';
             exit(0);
         }
     }
     require_once $filename;
 }
Ejemplo n.º 6
0
 /**
  * Critical conditions.
  *
  * Example: Application component unavailable, unexpected exception.
  *
  * @param string $message
  * @param array $context
  * @return NULL
  */
 public function critical($message, array $context = array())
 {
     SimpleSAML_Logger::critical($message . var_export($context, TRUE));
 }