20 include_once (
'WHAT/Class.Authenticator.php');
29 private $username =
'';
39 $this->
username = $session->read(
'username');
45 $this->
username = getHttpVars($this->parms{
'username'});
46 if (is_callable(array(
50 if (!$this->provider->validateCredential(getHttpVars($this->parms{
'username'}), getHttpVars($this->parms{
'password'}))) {
59 $session->register(
'username', getHttpVars($this->parms{
'username'}));
60 $session->setuid(getHttpVars($this->parms{
'username'}));
64 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error: " . get_class($this->provider) .
" must implement function validateCredential()");
73 if (!$this->auth_session) {
74 include_once (
'WHAT/Class.Session.php');
75 $this->auth_session =
new Session($this->parms{
'cookie'});
76 if (array_key_exists($this->parms{
'cookie'}, $_COOKIE)) {
77 $this->auth_session->
Set($_COOKIE[$this->parms{
'cookie'}]);
79 $this->auth_session->Set();
91 if (is_callable(array(
93 'validateAuthorization'
95 return $this->provider->validateAuthorization($opt);
107 $parsed_referer = parse_url(
$_SERVER[
'HTTP_REFERER']);
110 if ($parsed_referer[
'path'] !=
"") {
111 $referer_uri.= $parsed_referer[
'path'];
113 if ($parsed_referer[
'query'] !=
"") {
114 $referer_uri.=
"?" . $parsed_referer[
'query'];
116 if ($parsed_referer[
'fragment'] !=
"") {
117 $referer_uri.=
"#" . $parsed_referer[
'fragment'];
121 $session->register(
'username',
'');
124 if ($referer_uri ==
"") {
126 $session->register(
'fromuri',
$_SERVER[
'REQUEST_URI']);
127 }
else if ($session->read(
'fromuri') ==
"" && $referer_uri !=
$_SERVER[
'REQUEST_URI']) {
129 $session->register(
'fromuri',
$_SERVER[
'REQUEST_URI']);
132 if (array_key_exists(
'authurl', $this->parms)) {
134 foreach ($args as $k => $v) $sargs.= sprintf(
"&%s=%s", $k, urlencode($v));
137 if (substr($this->parms{
'authurl'}, 0, 9) ==
"guest.php") {
140 if (strpos(
$location,
'?') ===
false && $sargs !=
'') {
141 $sargs = sprintf(
'?%s', $sargs);
145 if (strpos(
$location,
'?') ===
false && $sargs !=
'') {
146 $sargs = sprintf(
'?%s', $sargs);
150 header(sprintf(
'Location: %s%s',
$location, $sargs));
154 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error: no authurl of askAuthentication() method defined for " . $this->parms{
'type'} . $this->parms{
'provider'} .
"Provider");
165 $username = $session_auth->read(
'username');
166 if ($username !=
'') {
169 return $this->username;
188 if (array_key_exists($this->parms{
'cookie'}, $_COOKIE)) {
190 $session_auth->close();
192 if ($redir_uri ==
"") {
193 if (array_key_exists(
'authurl', $this->parms)) {
194 header(
'Location: ' . $this->parms[
'authurl']);
197 $redir_uri = GetParam(
"CORE_BASEURL");
199 header(
'Location: ' . $redir_uri);
212 return $session_auth->read(
$name);
222 return $session_auth->read(
$name);