01: package org.esupportail.cas.server.handlers.test;
02:
03: import org.dom4j.Element;
04: import org.esupportail.cas.server.util.BasicHandler;
05:
06: /**
07: * This class implements an 'password equals username' handler class. It is used by
08: * GenericHandler for debugging purposes.
09: *
10: * @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
11: */
12: public final class PasswordEqualsUsernameHandler extends BasicHandler {
13:
14: /**
15: * Constructor.
16: *
17: * @param handlerElement the XML element that declares the handler
18: * in the configuration file
19: * @param configDebug debugging mode of the global configuration
20: */
21: public PasswordEqualsUsernameHandler(final Element handlerElement,
22: final Boolean configDebug) {
23: super (handlerElement, configDebug);
24: traceBegin();
25: traceEnd();
26: }
27:
28: /**
29: * Try to authenticate a user.
30: *
31: * @param username the user's name
32: * @param password the user's password
33: *
34: * @return BasicHandler.SUCCEDED if password equals username,
35: * or BasicHandler.FAILED_CONTINUE otherwise.
36: */
37: public int authenticate(final String username, final String password) {
38: traceBegin();
39: if (password.equals(username)) {
40: traceEnd("SUCCEEDED");
41: return SUCCEEDED;
42: } else {
43: traceEnd("FAILED_CONTINUE");
44: return FAILED_CONTINUE;
45: }
46: }
47:
48: }
|