KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > security > AuthenticationData


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.security;
11 import org.mmbase.util.functions.*;
12
13
14 /**
15  * This interface represents information about the authentication implemtentation.
16  *
17  * @author Michiel Meeuwissen
18  * @version $Id: AuthenticationData.java,v 1.6 2005/10/12 19:07:31 michiel Exp $
19  * @since MMBase-1.8
20  */

21 public interface AuthenticationData {
22
23     static final int METHOD_UNSET = -1;
24
25     // general methods
26
/**
27      * Requests an 'anonymous' cloud, with a user with no credentials. This can only be used if the
28      * security implementation provides the 'anonymous' authentication application.
29      */

30     static final int METHOD_ANONYMOUS = 0;
31     /**
32      * Delegates authentication completely to the authentication implementation. When using http, request and response
33      * objects are added to the credentials which can be used for user-interaction.
34      */

35     static final int METHOD_DELEGATE = 1;
36     /**
37      * Logon with given credentials (only Strings), and don't store this any where (except for the current 'page').
38      */

39     static final int METHOD_PAGELOGON = 2;
40
41
42     // http methods
43
/**
44      * Use Http 'Basic' authentication. This only provides username / password and is not very safe,
45      * because http basic authentication sends those unencrypted.
46      */

47     static final int METHOD_HTTP = 100;
48     /**
49      * Use the authenticated user which is stored in the session, or if no such user can be found,
50      * try to supply 'anonymous'.
51      */

52     static final int METHOD_ASIS = 101;
53     /**
54      * Remove the authenticated user from the session, and otherwise invalidate the user if
55      * necessary (e.g. notify an authentication service).
56      */

57     static final int METHOD_LOGOUT = 102;
58     /**
59      * Use a dedicated 'login' jsp, to log in.
60      */

61     static final int METHOD_LOGINPAGE = 103;
62     /**
63      * Delegates authentication comletely to the authentication implementation {@link
64      * #METHOD_DELEGATE}, but stores the authenticated in the session then. A second request with
65      * this method will simply use the session.
66      */

67     static final int METHOD_SESSIONDELEGATE = 104;
68     /**
69      * Logon with given credentials (only Strings), and don't store this in the session.
70      */

71     static final int METHOD_SESSIONLOGON = 105;
72
73
74
75     //static final int METHOD_GIVEN_OR_ANONYMOUS = 5;
76

77
78     static final int METHOD_DEFAULT = Integer.MAX_VALUE;
79
80     static final String JavaDoc STRINGS = "org.mmbase.security.resources.parameters";
81
82     /**
83      * Common parameters for logon-info
84      */

85     static final Parameter PARAMETER_USERNAME = new Parameter("username", String JavaDoc.class, true);
86     static final Parameter PARAMETER_PASSWORD = new Parameter("password", String JavaDoc.class, true);
87     static final Parameter PARAMETER_USERNAMES = new Parameter("usernames", java.util.List JavaDoc.class);
88     static final Parameter PARAMETER_RANK = new Parameter("rank", Rank.class);
89     // static final Parameter PARAMETER_REMOTEADDR = new Parameter("remoteaddr", String.class);
90

91     static final Parameter PARAMETER_SESSIONNAME = new Parameter("sessionname", String JavaDoc.class);
92
93     // parameters used for logout
94
static final Parameter PARAMETER_LOGOUT = new Parameter("logout", Boolean JavaDoc.class);
95     static final Parameter PARAMETER_AUTHENTICATE = new Parameter("authenticate", String JavaDoc.class);
96
97
98     /**
99      * The method returns wether the UserContext has become invalid for some reason (change in security config?)
100      * @param userContext The UserContext of which we want to know the rights
101      * @return <code>true</code> when valid, otherwise <code>false</code>
102      * @exception SecurityException When something strange happened
103      */

104     boolean isValid(UserContext userContext) throws SecurityException JavaDoc;
105
106     /**
107      * Several 'methods' to authenticate could be available.
108      * This method converts a user-friendly string describing the 'method' to a integer constant which can be used in
109      * {@link #getTypes(int)}.
110      * @param m A String like 'http', 'anonymous', 'loginpage', or 'delegatesession'.
111      * @return An integer contant.
112      */

113     int getMethod(String JavaDoc m);
114
115     /**
116      * The security implementation can override a default method. The default default method (as
117      * implemented in {@link org.mmbase.security.Authentication} for the 'http' protocol is HTTP
118      * (which means that basic authentication of the http protocol can be used), but may not be
119      * feasible for every implementation (it is e.g. useless if the security implementation does not have
120      * name/password authentication).
121      * @param protocol For which protocol or <code>null</code>, which means 'HTTP/1.1'.
122      */

123     int getDefaultMethod(String JavaDoc protocol);
124
125     /**
126      * Gives all availabe authentication types. The first one can be used as the default.
127      */

128     String JavaDoc[] getTypes();
129
130     /**
131      * For a given method, returns the available 'applications'. The first one can be used as the default.
132      */

133     String JavaDoc[] getTypes(int method);
134
135     /**
136      * For a given authentication type returns a parameters object to fill with credentials. {@link Parameters#toMap} can be used as the second argument
137      * for {@link org.mmbase.security.Authentication#login}
138      */

139
140     Parameters createParameters(String JavaDoc application);
141 }
142
Popular Tags