VCL
[ class tree: VCL ] [ index: VCL ] [ all elements ]

Class: BasicAuthentication

Source Location: /auth.inc.php

Class Overview

Object
   |
   --Persistent
      |
      --Component
         |
         --BasicAuthentication

Performs authentication using basic HTTP


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods

Class: Component

Component::__construct()
Component constructor
Component::ajaxCall()
Dumps the javascript code to make an ajax call to the server.
Component::callEvent()
Calls a server event.
Component::defaultName()
Component::defaultTag()
Component::dumpChildrenFormItems()
This method is called by the page just after dumping the starting form tag.
Component::dumpChildrenHeaderCode()
Dumps the header code for all the children
Component::dumpChildrenJavascript()
Dumps the javascript code for all the children
Component::dumpFormItems()
Dumps code just after the form tag, useful to dump hidden fields for state retrieving for non visible components
Component::dumpHeaderCode()
Dumps header code required
Component::dumpHiddenKeyFields()
Dumps hidden field values for the key record
Component::dumpJavascript()
Dumps the javascript code needed by this component
Component::dumpJSEvent()
Dumps javascript code for an event
Component::fixupProperty()
Resolves the right reference to an object property
Component::generateAjaxEvent()
Returns the javascript code to generate an ajax call.
Component::getName()
Specifies the name for the component. The name is used as an identifier and should be unique.
Component::getTag()
A versatile property of every Component that can be used in any way you want
Component::hasValidDataField()
Returns true if a valid data field is attached to the component
Component::init()
Initializes a component
Component::insertComponent()
Inserts a component into the component's collection
Component::loaded()
Initializes the component after the form file has been read into memory.
Component::loadedChildren()
Calls childrens loaded
Component::loadResource()
Loads this component from a string
Component::preinit()
Method called before init()
Component::readAccessibility()
Provides accessibility info to the embedded RPC engine.
Component::readComponentCount()
Indicates the number of components owned by the component.
Component::readComponents()
Lists all the components owned by this component.
Component::readControlState()
A flag to know the state of the control, csLoading, csDesigning
Component::readDataFieldValue()
This property returns the value of the datafield if any.
Component::readFromResource()
Reads a component from a resource file
Component::readNamePath()
Specifies the path to uniquely identify a component, qualified by the owner when required.
Component::readOwner()
Indicates the component that is responsible for streaming and freeing this component.
Component::removeComponent()
Removes a component from the component's collection
Component::serializeChildren()
Serializes all children
Component::setName()
Component::setTag()
Component::unserializeChildren()
Unserializes all children by calling unserialize for all the components
Component::updateDataField()
Updates the field on the dataset attached, if any
Component::writeControlState()

Class: Persistent

Persistent::allowserialize()
This method provides an opportunity for the component developer to prevent the serialization/unserialization of a property.
Persistent::assign()
Assigns the source properties to this object.
Persistent::assignError()
Raises an assignation error.
Persistent::assignTo()
Assigns this object to another object.
Persistent::inSession()
This method determines if this object exists in the current session.
Persistent::readNamePath()
Used to serialize/unserialize. It returns the full path to identify this component.
Persistent::readOwner()
Owner of the component.
Persistent::serialize()
Stores this object into the session.
Persistent::unserialize()
This method uses PHP reflection to iterate through published properties (the ones starting with get) and retrieve the properties stored by a previous serialize() call.

Class: Object

Object::__construct()
Constructs an object and initializes its data before the object is first used.
Object::className()
Returns a string indicating the type of the object instance (as opposed to the type of the variable passed as an argument).
Object::classNameIs()
Determines whether an object is of a specific type.
Object::classParent()
Returns the type of the immediate ancestor of a class.
Object::inheritsFrom()
Determines the relationship of two object types.
Object::methodExists()
Check if a method exists declared on this object instance.
Object::readProperty()
Reads a property from the streams
Object::__get()
To virtualize properties
Object::__set()
To virtualize properties

Class Details

[line 259]
Performs authentication using basic HTTP

This component is useful for protecting web pages easily by just dropping a component. For basic usage, just set UserName and Password to the valid value to log in and call the Execute() method in the OnBeforeShow event of your page.

For more advance usage, OnAuthenticate event it allows you to authenticate using your own rules.




Tags:



[ Top ]


Class Variables

$_errormessage = "Unauthorized"

[line 262]



Tags:

access:  protected

Type:   mixed


[ Top ]

$_onauthenticate = null

[line 378]



Tags:

access:  protected

Type:   mixed


[ Top ]

$_password = ""

[line 264]



Tags:

access:  protected

Type:   mixed


[ Top ]

$_title = "Login"

[line 261]



Tags:

access:  protected

Type:   mixed


[ Top ]

$_username = ""

[line 263]



Tags:

access:  protected

Type:   mixed


[ Top ]



Class Methods


method defaultErrorMessage [line 357]

void defaultErrorMessage( )



[ Top ]

method defaultOnAuthenticate [line 415]

void defaultOnAuthenticate( )



[ Top ]

method defaultPassword [line 303]

void defaultPassword( )



[ Top ]

method defaultTitle [line 374]

void defaultTitle( )



[ Top ]

method defaultUsername [line 339]

void defaultUsername( )



[ Top ]

method Execute [line 441]

void Execute( )

Executes the authentication and checks if the user has been authenticated or not.

This method tries to perform the user authentication, if the user has not been already authenticated, requests the username/password using a browser dialog, but if the user has been authenticated, does nothing.

If the event OnAuthenticate is assigned, the valid username/password will be provided by code if not, the Username/Password properties will be used to authenticate

  1.  <?php
  2.  function PasswordProtectedPageBeforeShow($sender$params)
  3.  {
  4.     //Before the page is shown, call Execute to force user authentication
  5.     $this->BasicAuthentication1->Execute();
  6.  }
  7.  ?>




Tags:



[ Top ]

method getErrorMessage [line 355]

string getErrorMessage( )

Error message to show when the user is not authenticated, this is the string shown on the browser when the authentication fails

Use this property to show an specific error message when the authentication cannot be performed due wrong username/password combinations are provided by the user. The error message will be shown on the top of a blank page in most browsers, but that depends on the browser.

The default value for this property is "Unauthorized"




Tags:



[ Top ]

method getOnAuthenticate [line 413]

mixed getOnAuthenticate( )

Event fired after the user has entered username and password

This event is fired when the component needs to authenticate the user by code.

In $params['username'] you will get the username entered by the user

In $params['password'] you will get the password entered by the user

This event is the right place for you to write customize authentication code, you can, for example query a database to know if the username/password combination is valid. To allow the user access the page, simply return true, and return false if the input information is not valid

  1.  <?php
  2.        function BasicAuthentication1Authenticate($sender$params)
  3.        {
  4.                 //You can use the Username and Password properties to automatically check for that
  5.                 //But if you want to search in a list/database, you can use the OnAuthenticate event
  6.                 if (($params['username']=='delphiforphp'&& ($params['password']=='rules'))
  7.                 {
  8.                         return(true);
  9.                 }
  10.                 else return(false);
  11.        }
  12.  ?>




Tags:



[ Top ]

method getPassword [line 301]

string getPassword( )

Password to request to the user, the password entered by the user will be checked against the value of this property

Use this property to specify a valid password the user will need to provide in order to access the page this component is located on.

If you need to provide several valid passwords, check OnAuthenticate event as you can write there any validation code to the password sent by the user.

Remember this password is stored in clear text in the .xml.php of your form, so you will need to protect properly such file against unauthorized access to prevent them get the password.

  1.  <?php
  2.        function BasicAuthentication1Authenticate($sender$params)
  3.        {
  4.                 //You can use the Username and Password properties to automatically check for that
  5.                 //But if you want to search in a list/database, you can use the OnAuthenticate event
  6.                 if (($params['username']=='delphiforphp'&& ($params['password']=='rules'))
  7.                 {
  8.                         return(true);
  9.                 }
  10.                 else return(false);
  11.        }
  12.  ?>




Tags:



[ Top ]

method getTitle [line 372]

string getTitle( )

Title of the authentication dialog to show the user

When the browser tries to authenticate the user, in most cases will show a dialog requesting for username and password, and this property specifies the caption for such dialog, or part of it, depending on the browser.

The default value is "Login", which will be fine for most cases.




Tags:



[ Top ]

method getUsername [line 337]

string getUsername( )

Valid username to authenticate against the username entered by the user

Use this property to specify a valid username the user will need to provide in order to access the page this component is located on.

If you need to provide several valid usernames, check OnAuthenticate event as you can write there any validation code to the username sent by the user.

Remember this property is stored in clear text in the .xml.php of your form, so you will need to protect properly such file against unauthorized access to prevent them get the username.

  1.  <?php
  2.        function BasicAuthentication1Authenticate($sender$params)
  3.        {
  4.                 //You can use the Username and Password properties to automatically check for that
  5.                 //But if you want to search in a list/database, you can use the OnAuthenticate event
  6.                 if (($params['username']=='delphiforphp'&& ($params['password']=='rules'))
  7.                 {
  8.                         return(true);
  9.                 }
  10.                 else return(false);
  11.        }
  12.  ?>




Tags:



[ Top ]

method setErrorMessage [line 356]

void setErrorMessage( $value)



Parameters:

   $value  

[ Top ]

method setOnAuthenticate [line 414]

void setOnAuthenticate( $value)



Parameters:

   $value  

[ Top ]

method setPassword [line 302]

void setPassword( $value)



Parameters:

   $value  

[ Top ]

method setTitle [line 373]

void setTitle( $value)



Parameters:

   $value  

[ Top ]

method setUsername [line 338]

void setUsername( $value)



Parameters:

   $value  

[ Top ]


Documentation generated on Sat, 13 Jun 2009 10:50:54 -0700 by phpDocumentor 1.4.1