001    /*
002      Copyright (C) 2001-2002 Renaud Pawlak <renaud@aopsys.com>
003                              Laurent Martelli <laurent@aopsys.com>
004      
005      This program is free software; you can redistribute it and/or modify
006      it under the terms of the GNU Lesser General Public License as
007      published by the Free Software Foundation; either version 2 of the
008      License, or (at your option) any later version.
009    
010      This program is distributed in the hope that it will be useful,
011      but WITHOUT ANY WARRANTY; without even the implied warranty of
012      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013      GNU Lesser General Public License for more details.
014    
015      You should have received a copy of the GNU Lesser General Public License
016      along with this program; if not, write to the Free Software
017      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
018    
019    package org.objectweb.jac.aspects.authentication;
020    
021    import org.objectweb.jac.core.rtti.ClassItem;
022    import org.objectweb.jac.core.rtti.MethodItem;
023    
024    
025    /**
026     * This is the configuration interface of the authentication aspect.
027     *
028     * <p>The authentication aspect's goal is to make sure that a user
029     * attribute is defined within the context. Several authentication
030     * policies are available and defined in the controller.
031     *
032     * @see AuthenticationAC
033     * @see #setAuthenticator(ClassItem)
034     * @see #setAuthenticator(ClassItem,String[]) */
035    
036    public interface AuthenticationConf {   
037    
038       /**
039        * This configuration method restricts a given set of methods.
040        *
041        * <p>When a method is restricted, the collaboration that contains
042        * the restricted method invocation must contain an attribute that
043        * represents the current user. If not, the authentication aspect
044        * ask the user to input its caracteristics.<p>
045        *
046        * @param classes a class expression
047        * @param objects an object expression
048        * @param methods an expression matching the methods to restrict
049        * @see #addRestrictedObjects(String)
050        * @see AuthenticationWrapper
051        */
052       
053       void addRestrictedMethods(String classes, 
054                                 String methods, 
055                                 String objects );
056    
057       /**
058        * This configuration method sets a controller method to a set of
059        * base methods.
060        *
061        * <p>Once the user is authenticated, the controller method is
062        * called with the user and the wrappee and the wrapped method as
063        * parameters. If the controller returns true, the user is allowed
064        * to call the method, otherwise an exception is raised.</p>
065        *
066        * @param classes a class expression
067        * @param methods an expression matching the methods to restrict
068        * @param controller the controller method (a static method of the
069        * prototype <code>boolean controller(String username,Object
070        * wrappee,MethodItem method)</code>)
071        *
072        * @see #setDisplayController(MethodItem)
073        * @see org.objectweb.jac.aspects.user.UserAC#userController(String,Object,MethodItem)
074        * @see AuthenticationWrapper#dummyController(String,Object,MethodItem)
075        * @see AuthenticationWrapper 
076        */
077       void setController(String classes, String methods, MethodItem controller);
078    
079       /**
080        * This configuration method sets a controller on displays so that
081        * all users must authenticate themselves before accessing the
082        * application.
083        *
084        * @param controller the controller method (a static method of the
085        * prototype <code>boolean controller(String username,Object
086        * wrappee,MethodItem method)</code>)
087        *
088        * @see #setController(String,String,MethodItem)
089        * @see org.objectweb.jac.aspects.user.UserAC#userController(String,Object,MethodItem)
090        * @see AuthenticationWrapper#dummyController(String,Object,MethodItem)
091        * @see AuthenticationWrapper */
092       void setDisplayController(MethodItem controller);
093    
094       /**
095        * Sets the message that is showed to the user when the access to a
096        * method is not granted by the controller (if any).
097        *
098        * @param message the message to popup
099        * @see #setController(String,String,MethodItem) 
100        */
101       void setAccessDeniedMessage(String message);
102    
103       /**
104        * Restricts some objects for authentication (all their methods).
105        *
106        * @param objects an object expression
107        * @see #addRestrictedMethods(String,String,String)
108        * @see AuthenticationWrapper */
109       
110       void addRestrictedObjects(String objects);
111    
112       /**
113        * Restricts some objects for authentication.
114        *
115        * @param classes a class expression
116        * @param objects an object expression
117        * @see #addRestrictedMethods(String,String,String)
118        * @see AuthenticationWrapper 
119        */
120       void addRestrictedObjects(String objects,String classes);
121    
122       /**
123        * Sets the authenticator to use.
124        *
125        * <p>The most used authenticator is the
126        * <code>org.objectweb.jac.aspects.authentication.UserPasswordAuthenticator</code>. It
127        * opens a popup on the current display to ask the user its login
128        * and password.</p>
129        *
130        * @param authenticatorClass the authenticator's class
131        * @param parameters parameters to give to the constructor
132        * @see Authenticator
133        * @see UserPasswordAuthenticator */
134    
135       void setAuthenticator(ClassItem authenticatorClass, String[] parameters);
136    
137       /**
138        * Sets the authenticator to use when the authenticator's
139        * constructor takes no parameters.
140        * 
141        * <p>The most used authenticator is the
142        * <code>org.objectweb.jac.aspects.authentication.UserPasswordAuthenticator</code>. It
143        * opens a popup on the current display to ask the user its
144        * login and password.</p>
145        *
146        * @param authenticatorClass the authenticator's class
147        * @see #setAuthenticator(ClassItem,String[])
148        * @see Authenticator
149        * @see UserPasswordAuthenticator */
150    
151       void setAuthenticator(ClassItem authenticatorClass);
152    
153    }