org.apache.cocoon.auth
Class ApplicationUtil

java.lang.Object
  extended byorg.apache.cocoon.auth.ApplicationUtil

public class ApplicationUtil
extends Object

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.java 587757 2007-10-24 02:52:49Z vgritsenko $

Constructor Summary
ApplicationUtil()
           
 
Method Summary
 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
 

Constructor Detail

ApplicationUtil

public ApplicationUtil()
Method Detail

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-2008 The Apache Software Foundation. All Rights Reserved.