Dashboard > RIFE > ... > Authentication > Easy retrieval of RoleUsersManager
RIFE Log In | Sign Up   View a printable version of the current page.
Easy retrieval of RoleUsersManager


Added by Geert Bevin, last edited by Geert Bevin on May 22, 2004
Labels: 
(None)

The RoleUsersManager class provides the functionalities to retrieve a RoleUsersManagers from a particular Authenticated element in a site.

Since you can have many authentication schemes and backends being active in a single web application. it's quite verbose to retrieve a RoleUsersManager when you want to perform some operations on its stored credentials. This class provides the functionalities to quickly perform this retrieval through the static getRoleUsersManager(Site site, String authElementId) method.

You can thus very easily update a user's attributes, for example:

public class BanUser extends Element
{
    public void processElement()
    {
        String login = getInput("login");
        
        RoleUsersManager credentials =
            RoleUsersManagerRetriever.getRoleUsersManager(getSite(), ".AUTH_USER");
        
        try
        {
            RoleUserAttributes attrs = credentials.getAttributes(login);
            attrs.getRoles().add("banneduser");
            credentials.updateUser(login, attrs);
        }
        catch (CredentialsManagerException e)
        {
            // handle the exception
        }
    }
}



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