org.objectweb.jonas.security
Class RoleMechanism

java.lang.Object
  extended byorg.objectweb.jonas.security.RoleMechanism

public class RoleMechanism
extends java.lang.Object

Managed roles defined in a resource and check the right access between method roles and principal roles

Author:
Jeff Mesnil, Florent Benoit : use a JOnAS Resource (Memory, Datasource, LDAP)

Method Summary
static RoleMechanism getInstance()
          Return the unique instance
 boolean isCallerInRole(java.security.Principal principal, java.lang.String role)
          Check if the given role match the principal roles
 boolean isCallerInRole(java.security.Principal principal, java.lang.String role, java.lang.String[] pRoles)
          Check if the given role match the principal roles
 boolean isCallerInRoles(java.security.Principal principal, java.lang.String[] roles)
          Check if the given roles match the principal roles
 boolean isCallerInRoles(java.security.Principal principal, java.lang.String[] roles, java.lang.String[] pRoles)
          Check if the given roles match the principal roles
 void setRealmResource(java.lang.String resourceName)
          Use the given realm for the mapping between the principal and the roles
 java.lang.String toString()
          Method toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static RoleMechanism getInstance()
Return the unique instance

Returns:
RoleMechanism the unique instance

setRealmResource

public void setRealmResource(java.lang.String resourceName)
                      throws java.lang.Exception
Use the given realm for the mapping between the principal and the roles

Parameters:
resourceName - the realm to use
Throws:
java.lang.Exception - if the realm doesn't exist

isCallerInRole

public boolean isCallerInRole(java.security.Principal principal,
                              java.lang.String role,
                              java.lang.String[] pRoles)
Check if the given role match the principal roles

Parameters:
principal - principal
role - the given role
pRoles - the roles of the principal
Returns:
boolean true if given role match the principal roles

isCallerInRole

public boolean isCallerInRole(java.security.Principal principal,
                              java.lang.String role)
Check if the given role match the principal roles

Parameters:
principal - principal
role - the given role
Returns:
boolean true if given role match the principal roles

isCallerInRoles

public boolean isCallerInRoles(java.security.Principal principal,
                               java.lang.String[] roles,
                               java.lang.String[] pRoles)
Check if the given roles match the principal roles

Parameters:
principal - principal
roles - the given roles
pRoles - the roles of the principal
Returns:
boolean if given roles match the principal roles

isCallerInRoles

public boolean isCallerInRoles(java.security.Principal principal,
                               java.lang.String[] roles)
Check if the given roles match the principal roles

Parameters:
principal - principal
roles - the given roles
Returns:
boolean if given roles match the principal roles

toString

public java.lang.String toString()
Method toString

Returns:
String a string representation of the object