01: /*
02: * The contents of this file are subject to the
03: * Mozilla Public License Version 1.1 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
06: *
07: * Software distributed under the License is distributed on an "AS IS"
08: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
09: * See the License for the specific language governing rights and
10: * limitations under the License.
11: *
12: * The Initial Developer of the Original Code is Simulacra Media Ltd.
13: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14: *
15: * All Rights Reserved.
16: *
17: * Contributor(s):
18: */
19: package org.openharmonise.rm.security.authentication;
20:
21: import java.util.logging.*;
22:
23: import org.openharmonise.rm.config.*;
24:
25: /**
26: * Factory class to return the correct UserAuthenticator.
27: *
28: * @author Michael Bell
29: * @version $Revision: 1.2 $
30: *
31: */
32: public class UserAuthenticatorFactory {
33:
34: private static UserAuthenticator m_auth = null;
35: private static Logger logger = Logger
36: .getLogger(UserAuthenticatorFactory.class.getName());
37:
38: /**
39: *
40: */
41: public UserAuthenticatorFactory() {
42: super ();
43: }
44:
45: /**
46: * Gets an appropriate UserAuthenticator object.
47: *
48: * @return Returns a valid UserAuthenticator
49: */
50: static public UserAuthenticator getAuthenticator() {
51:
52: if (m_auth == null) {
53: try {
54: // m_auth = new UserAuthenticatorImpl();
55: String crypto = ConfigSettings.getProperty(
56: "PWD_ENCRYPTION", "NONE");
57: if (crypto.equals("NONE")) {
58: m_auth = new UserAuthenticatorImpl(
59: new DefaultPasswordHelper());
60: } else {
61: m_auth = new UserAuthenticatorImpl(
62: new CryptPasswordHelper(crypto));
63: }
64: } catch (ConfigException e) {
65: logger.severe(e.getMessage());
66: }
67: }
68:
69: return m_auth;
70: }
71:
72: }
|