Dashboard > RIFE > ... > Authentication > User identification facility
RIFE Log In | Sign Up   View a printable version of the current page.
User identification facility


Added by Geert Bevin, last edited by Geert Bevin on Sep 18, 2007  (view change)
Labels: 
(None)

See also: Conditionally display privileged content

It's becoming quite common in websites to not force users to be authenticated before they are able to access a section. Instead, pages show different content for and offer other functionalities to users that can correctly be identified. An anonymous visitor simply sees alternative content and is probably restricted in the actions that he can perform.

RIFE offers an easy way to develop websites with these functionalities. User identification is tied to authentication and the identity of a user is obtained from the authentication managers that are used by a specific authentication element. Similar to authentication, RIFE uses element inheritance for the identification.

An identification element, element/identified.xml, can for example be declared like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE element SYSTEM "/dtd/element.dtd">
<element extends="rife/authenticated/identified.xml">
    <childtrigger name="authid"/>
</element>

The child trigger name should be the same as the one that is used by the authentication element. Most probably this will be authid, unless you're using different parallel authentication schemes.

To include an identification element in the site structure, you have to tell it which authentication element should be used to perform the identification. This is done by setting the authentication element ID as the value of the property with the name authElementId.

For example:

<element id="AUTH" file="element/authentication.xml"/>
<element id="IDENTIFIED" file="rife/authenticated/identified.xml">
    <property name="authElementId">AUTH</property>
    <childtrigger name="authid"/>
</element>

All the elements that depend on the identification now simply have to inherit from the IDENTIFIED element. To gain access to an identified user, you should obtain the request attribute with the name that's accessible from the static variable Identified.IDENTITY_ATTRIBUTE_NAME.

For example:

public class SomeElement extends Element
{
    public void processElement()
    {
        RoleUserIdentity identity = (RoleUserIdentity)getRequestAttribute(Identified.IDENTITY_ATTRIBUTE_NAME);
        if (null == identity)
        {
            // perform anonymous logic
        }
        else
        {
            // perform identified logic
        }
    }
}

Note that all authentication elements also provide identification functionalities. So if your element already inherits from such an element there is no use to make it inherit also from an identified element.



Are you enjoying Confluence? Please consider purchasing it today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.1a Build:#515 May 19, 2006) - Bug/feature request - Contact Administrators