Formatting output Plese Wait...
Detailed Description
HTTP Authentication Class.
Definition at line 10 of file zHttpAuth.php.
Member Function Documentation
zHttpAuth::zHttpAuth( unknown $cntrl )
zHttpAuth::attachController( unknown $cntrl )
zHttpAuth::setRawCredentials( string $usr, string $psw )
Set text username and Password.
- Parameters:
-
| $usr | Username in Plain text |
| $psw | Password in Plain text |
Definition at line 36 of file zHttpAuth.php.
Show Source00036 {
00037 $this->mode = Z_HTTP_AUTH_MODE_RAW;
00038 $this->data = array($usr, $psw);
00039 }
Top
zHttpAuth::setCredentialsDataCon( string $conName )
Set database Connection File. Used when UserName and Password are fetched from some table of some database.
- Parameters:
-
| $conName | Connection File Name. |
Definition at line 45 of file zHttpAuth.php.
Show Source00045 {
00046 $this->mode = Z_HTTP_AUTH_MODE_DB;
00047 $this->dataCon = $conName;
00048 }
Top
zHttpAuth::setCredentialsDataCol( string $tableName, string $usrCol, string $pswCol )
Set TableName, Username Column and Password Column. Used when UserName and Password are fetched from some table of some database.
- Parameters:
-
| $tableName | TableName in which teh username and password are stored. |
| $userCol | string Column Name that stores UserName(s) |
| $pswCol | Column name that stores Password(s) |
Definition at line 56 of file zHttpAuth.php.
Show Source00056 {
00057 $this->mode = Z_HTTP_AUTH_MODE_DB;
00058 $this->data = array($tableName, $usrCol, $pswCol);
00059 }
Top
Validates the HTTP request. Validates the HTTP request with the given credentials
- Returns:
- boolean
Definition at line 65 of file zHttpAuth.php.
References load_module(), perror(), and sendHeaders().
Referenced by isOk().
Show Source00065 {
00066 if(count($this->data) < 2){
00067 perror("<code>zigmoyd.HttpAuth.validate</code><br />Credentials are Not set");
00068 return false;
00069 }
00070 if(!isset($_SERVER['PHP_AUTH_USER'])){
00071 $this->sendHeaders();
00072 }else{
00073 switch($this->mode){
00074 case Z_HTTP_AUTH_MODE_RAW:
00075 if(count($this->data) != 2){
00076 perror("<code>zigmoyd.HttpAuth.validate</code><br />unexpected Credentials<br />Expecting UserName and Password Pair as the validation mode is set to RAW<br />But the Credentials are TableName UserCol and PswCol (like DB)");
00077 return false;
00078 }
00079
00080
00081 return ($_SERVER['PHP_AUTH_USER'] == $this->data[0] && $_SERVER['PHP_AUTH_PW'] == $this->data[1]);
00082 break;
00083 case Z_HTTP_AUTH_MODE_DB:
00084 if(count($this->data) != 3){
00085 perror("<code>zigmoyd.HttpAuth.validate</code><br />unexpected Credentials<br />Expecting TableName UserCol and PasswordCol as the validation mode is set to DB<br />But the Credentials are UserName and PswName (like RAW)");
00086 return false;
00087 }
00088 load_module('dbAccess');
00089 $db = new zDbAccess($this->dataCon, $this->data[0]);
00090 $db->fetch($this->data[1]);
00091 $db->fetch($this->data[2]);
00092 $db->identifyBy($this->data[1], $_SERVER['PHP_AUTH_USER']);
00093 $db->identifyBy($this->data[2], $_SERVER['PHP_AUTH_PW']);
00094 $retSet = $db->export();
00095 return(is_array($retSet) && count($retSet) >= 1);
00096 break;
00097 }
00098 }
00099 }
Top
sends anti Cache HTTP Headers.
For internal use only.
Definition at line 104 of file zHttpAuth.php.
Show Source00104 {
00105 $this->cntrl->setHeader("Pragma: no-cache");
00106 $this->cntrl->setHeader("Cache-Control: no-cache, must-revalidate");
00107 $this->cntrl->setHeader("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
00108 }
Top
zHttpAuth::setRealm( string $realmText )
set the Realm text which will be used on Authentication.
- Parameters:
-
| $realmText | realm Text which will be used. |
Definition at line 113 of file zHttpAuth.php.
Show Source00113 {
00114 $this->realm = $realmText;
00115 }
Top
zHttpAuth::sendHeaders( )
send HTTP headers.
For internal use only.
Definition at line 120 of file zHttpAuth.php.
References forward401(), ifCanceled(), and url_segment().
Referenced by loop(), and validate().
Show Source00120 {
00121 if(is_null($this->realm))$this->realm = '/'.implode('/', url_segment(ZIG_URL_SEGMENT_PATH));
00122 $this->cntrl->setHeader('WWW-Authenticate: Basic realm="'.$this->realm.'"');
00123 $this->cntrl->setHeader('HTTP/1.0 401 Unauthorized');
00124 if(is_null($this->cancelText))$this->ifCanceled();
00125 $this->forward401();
00126 }
Top
zHttpAuth::ifCanceled( string $cancelText = "UnAuthorized Access"
)
Returns boolean value if the user has provided valid credentials.
- Returns:
- boolean
Definition at line 152 of file zHttpAuth.php.
References validate().
Show Source00152 {
00153 return $this->validate();
00154 }
Top
Field Documentation
zHttpAuth::$data = array()
zHttpAuth::$cancelText = null
The documentation for this class was generated from the following file: