org.apache.cocoon.auth
Class ApplicationUtil

java.lang.Object
  extended by org.apache.cocoon.auth.ApplicationUtil
All Implemented Interfaces:
Contextualizable

public class ApplicationUtil
extends Object
implements Contextualizable

Utility class that can be used from flow script to access the different application functions of Cocoon Authentication. The easiest way to use this class in flow script is to create an instance using cocoon.createObject(): var util = cocoon.createObject("org.apache.cocoon.auth.ApplicationUtil"); and then you can invoke one of the instance methods like var user = util.getUser();

Version:
$Id: ApplicationUtil.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Field Summary
protected  Context context
          The Avalon context.
 
Constructor Summary
ApplicationUtil()
           
 
Method Summary
 void contextualize(Context aContext)
           
 Application getApplication()
          Return the current application.
static Application getApplication(Map objectModel)
          Return the current application.
 Object getData()
          Return the current user data.
static Object getData(Map objectModel)
          Return the current user data.
 User getUser()
          Return the current user.
static User getUser(Map objectModel)
          Return the current user.
 boolean isUserInRole(User user, String role)
          Checks if the user has the given role.
static boolean isUserInRole(User user, String role, Map objectModel)
          Checks if the user has the given role.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected Context context
The Avalon context.

Constructor Detail

ApplicationUtil

public ApplicationUtil()
Method Detail

contextualize

public void contextualize(Context aContext)
                   throws ContextException
Specified by:
contextualize in interface Contextualizable
Throws:
ContextException
See Also:
Contextualizable.contextualize(org.apache.avalon.framework.context.Context)

getUser

public static User getUser(Map objectModel)
Return the current user.

Parameters:
objectModel - The object model of the current request.
Returns:
The current user or null.

getApplication

public static Application getApplication(Map objectModel)
Return the current application.

Parameters:
objectModel - The object model of the current request.
Returns:
The current application or null.

getData

public static Object getData(Map objectModel)
Return the current user data.

Parameters:
objectModel - The object model of the current request.
Returns:
The current user data or null.

isUserInRole

public static boolean isUserInRole(User user,
                                   String role,
                                   Map objectModel)
Checks if the user has the given role. First User.isUserInRole(String) is invoked. If the result is false, the Request.isUserInRole(java.lang.String) is called.

Parameters:
user - The user to test.
role - The role.
objectModel - The Cocoon object model.
Returns:
This returns true, if the user has the role; otherwise false is returned.

getUser

public User getUser()
Return the current user.

Returns:
The current user or null.

getApplication

public Application getApplication()
Return the current application.

Returns:
The current application or null.

getData

public Object getData()
Return the current user data.

Returns:
The current user data or null.

isUserInRole

public boolean isUserInRole(User user,
                            String role)
Checks if the user has the given role. First User.isUserInRole(String) is invoked. If the result is false, the Request.isUserInRole(java.lang.String) is called.

Parameters:
user - The user to test.
role - The role.
Returns:
This returns true, if the user has the role; otherwise false is returned.


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.