org.objectweb.jac.aspects.authentication
Class AuthenticationAC

java.lang.Object
  |
  +--org.objectweb.jac.core.AspectComponent
        |
        +--org.objectweb.jac.aspects.authentication.AuthenticationAC
All Implemented Interfaces:
AuthenticationConf, BaseProgramListener, Serializable

public class AuthenticationAC
extends AspectComponent
implements AuthenticationConf

This AC weaves the authentication aspect.

The authentication ensures that the authenticated method are called only when the user is known in the context. An external controller (such as the one defined by the user aspect) can by used to actually grant of refuse the access.

See Also:
AuthenticationWrapper, UserAC, Serialized Form

Field Summary
protected  HashSet trustedUsers
          Stores the trusted users.
static String USER
          The contextual attribute that contains the authenticated user if any.
 
Fields inherited from class org.objectweb.jac.core.AspectComponent
application, blockKeywords, cr, currentConfigMethod, currentImports, firstCall, NOT_SHARED, SHARED, startWeavingCCount, startWeavingCount, startWeavingMethod, startWeavingType, systemListener, wrappers
 
Fields inherited from interface org.objectweb.jac.core.BaseProgramListener
FOUND_OBJECT
 
Constructor Summary
AuthenticationAC()
           
 
Method Summary
 void addRestrictedMethods(String classes, String methods, String objects)
          This configuration method restricts a given set of methods.
 void addRestrictedObjects(String objects)
          Restricts some objects for authentication (all their methods).
 void addRestrictedObjects(String objects, String classes)
          Restricts some objects for authentication.
 void addTrustedUser(String username)
           
 Set getTrustedUsers()
          Returns all the declared trusted users.
 boolean isTrustedUser(String username)
          Tells if a given user is trusted or not.
 void setAccessDeniedMessage(String message)
          Sets the message that is showed to the user when the access to a method is not granted by the controller (if any).
 void setAuthenticator(ClassItem authenticatorClass)
          Sets the authenticator to use when the authenticator's constructor takes no parameters.
 void setAuthenticator(ClassItem authenticatorClass, String[] parameters)
          Sets the authenticator to use.
 void setController(String classes, String methods, MethodItem controller)
          This configuration method sets a controller method to a set of base methods.
 void setDisplayController(MethodItem controller)
          This configuration method sets a controller on displays so that all users must authenticate themselves before accessing the application.
 
Methods inherited from class org.objectweb.jac.core.AspectComponent
addWrapper, afterApplicationStarted, afterRunningWrapper, afterWrap, afterWrappeeInit, attr, attrdef, beforeConfiguration, beforeReload, beforeRunningWrapper, beforeWrappeeInit, configure, defines, defineTimer, doRegister, doUnregister, error, getAC, getApplication, getBlockKeywords, getConfigurationMethods, getConfigurationMethodsName, getConfigurationMethodsName, getDefaultConfigs, getName, getNameCounters, getWrappers, init, isConfigurationMethod, isSystemListener, onExit, pointcut, pointcut, pointcut, pointcut, pointcut, pointcut, pointcut, pointcut, setApplication, setAttribute, setAttribute, setAttribute, setSystemListener, simulateUsingNewInstance, unweave, unwrapAll, updateNameCounters, warning, weave, whenClone, whenCloseDisplay, whenConfigured, whenDeleted, whenDeserialized, whenFree, whenGetObjects, whenNameObject, whenObjectMiss, whenReload, whenRemoteInstantiation, whenSerialized, whenTopologyChanged, whenUsingNewClass, whenUsingNewInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USER

public static final String USER
The contextual attribute that contains the authenticated user if any.

See Also:
Constant Field Values

trustedUsers

protected HashSet trustedUsers
Stores the trusted users.

Constructor Detail

AuthenticationAC

public AuthenticationAC()
Method Detail

isTrustedUser

public boolean isTrustedUser(String username)
Tells if a given user is trusted or not.

Parameters:
username - the user's name
Returns:
true if the user has been added to the trusted users list

getTrustedUsers

public Set getTrustedUsers()
Returns all the declared trusted users.

See Also:
addTrustedUser(String)

addTrustedUser

public void addTrustedUser(String username)

setController

public void setController(String classes,
                          String methods,
                          MethodItem controller)
Description copied from interface: AuthenticationConf
This configuration method sets a controller method to a set of base methods.

Once the user is authenticated, the controller method is called with the user and the wrappee and the wrapped method as parameters. If the controller returns true, the user is allowed to call the method, otherwise an exception is raised.

Specified by:
setController in interface AuthenticationConf
Parameters:
classes - a class expression
methods - an expression matching the methods to restrict
controller - the controller method (a static method of the prototype boolean controller(String username,Object wrappee,MethodItem method))
See Also:
AuthenticationConf.setDisplayController(MethodItem), UserAC.userController(String,Object,MethodItem), AuthenticationWrapper.dummyController(String,Object,MethodItem), AuthenticationWrapper

setDisplayController

public void setDisplayController(MethodItem controller)
Description copied from interface: AuthenticationConf
This configuration method sets a controller on displays so that all users must authenticate themselves before accessing the application.

Specified by:
setDisplayController in interface AuthenticationConf
Parameters:
controller - the controller method (a static method of the prototype boolean controller(String username,Object wrappee,MethodItem method))
See Also:
AuthenticationConf.setController(String,String,MethodItem), UserAC.userController(String,Object,MethodItem), AuthenticationWrapper.dummyController(String,Object,MethodItem), AuthenticationWrapper

setAccessDeniedMessage

public void setAccessDeniedMessage(String message)
Description copied from interface: AuthenticationConf
Sets the message that is showed to the user when the access to a method is not granted by the controller (if any).

Specified by:
setAccessDeniedMessage in interface AuthenticationConf
Parameters:
message - the message to popup
See Also:
AuthenticationConf.setController(String,String,MethodItem)

addRestrictedMethods

public void addRestrictedMethods(String classes,
                                 String methods,
                                 String objects)
Description copied from interface: AuthenticationConf
This configuration method restricts a given set of methods.

When a method is restricted, the collaboration that contains the restricted method invocation must contain an attribute that represents the current user. If not, the authentication aspect ask the user to input its caracteristics.

Specified by:
addRestrictedMethods in interface AuthenticationConf
Parameters:
classes - a class expression
objects - an object expression
methods - an expression matching the methods to restrict
See Also:
AuthenticationConf.addRestrictedObjects(String), AuthenticationWrapper

addRestrictedObjects

public void addRestrictedObjects(String objects)
Description copied from interface: AuthenticationConf
Restricts some objects for authentication (all their methods).

Specified by:
addRestrictedObjects in interface AuthenticationConf
Parameters:
objects - an object expression
See Also:
AuthenticationConf.addRestrictedMethods(String,String,String), AuthenticationWrapper

addRestrictedObjects

public void addRestrictedObjects(String objects,
                                 String classes)
Description copied from interface: AuthenticationConf
Restricts some objects for authentication.

Specified by:
addRestrictedObjects in interface AuthenticationConf
Parameters:
classes - a class expression
objects - an object expression
See Also:
AuthenticationConf.addRestrictedMethods(String,String,String), AuthenticationWrapper

setAuthenticator

public void setAuthenticator(ClassItem authenticatorClass)
Description copied from interface: AuthenticationConf
Sets the authenticator to use when the authenticator's constructor takes no parameters.

The most used authenticator is the org.objectweb.jac.aspects.authentication.UserPasswordAuthenticator. It opens a popup on the current display to ask the user its login and password.

Specified by:
setAuthenticator in interface AuthenticationConf
Parameters:
authenticatorClass - the authenticator's class
See Also:
AuthenticationConf.setAuthenticator(ClassItem,String[]), Authenticator, UserPasswordAuthenticator

setAuthenticator

public void setAuthenticator(ClassItem authenticatorClass,
                             String[] parameters)
Description copied from interface: AuthenticationConf
Sets the authenticator to use.

The most used authenticator is the org.objectweb.jac.aspects.authentication.UserPasswordAuthenticator. It opens a popup on the current display to ask the user its login and password.

Specified by:
setAuthenticator in interface AuthenticationConf
Parameters:
authenticatorClass - the authenticator's class
parameters - parameters to give to the constructor
See Also:
Authenticator, UserPasswordAuthenticator