01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.security;
11:
12: import org.mmbase.util.functions.*;
13: import java.util.Map;
14:
15: /**
16: * This class is used when no authentication is configured. Every credential is rewarded with a
17: * UserContext object. So every attempt to log in will succeed.
18: *
19: * @author Eduard Witteveen
20: * @version $Id: NoAuthentication.java,v 1.11 2008/03/17 15:37:59 michiel Exp $
21: * @see UserContext
22: */
23: final public class NoAuthentication extends Authentication {
24:
25: static final String TYPE = "no authentication";
26: static final UserContext userContext = new BasicUser(TYPE);
27:
28: // package because NoAuthorization uses it to get the one 'possible context' (which is of course the 'getOwnerField' of the only possible user)
29: // (this is assuming that NoAuthentication is used too, but if not so, that does not matter)
30:
31: /**
32: * This method does nothing
33: */
34: protected void load() {
35: }
36:
37: /**
38: * Returns always the same object (an user 'anonymous'with rank 'administrator'')
39: * @see UserContext
40: */
41: public UserContext login(String application, Map loginInfo,
42: Object[] parameters) throws SecurityException {
43: String userName = loginInfo == null ? null : (String) loginInfo
44: .get(AuthenticationData.PARAMETER_USERNAME.getName());
45: if (userName != null) {
46: return new BasicUser(TYPE, userName);
47: } else {
48: return userContext;
49: }
50: }
51:
52: /**
53: * Users remain valid always.
54: * @return true
55: */
56: public boolean isValid(UserContext usercontext)
57: throws SecurityException {
58: return true;
59: }
60:
61: /**
62: * {@inheritDoc}
63: * @since MMBase-1.8
64: */
65: public int getDefaultMethod(String protocol) {
66: return METHOD_DELEGATE;
67: }
68:
69: public String[] getTypes(int method) {
70: return new String[] { TYPE };
71: }
72:
73: public Parameters createParameters(String application) {
74: return new AutodefiningParameters();
75: }
76:
77: }
|