01: /*
02: * JOSSO: Java Open Single Sign-On
03: *
04: * Copyright 2004-2008, Atricore, Inc.
05: *
06: * This is free software; you can redistribute it and/or modify it
07: * under the terms of the GNU Lesser General Public License as
08: * published by the Free Software Foundation; either version 2.1 of
09: * the License, or (at your option) any later version.
10: *
11: * This software is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this software; if not, write to the Free
18: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20: */
21: package org.josso.util;
22:
23: import org.apache.commons.logging.Log;
24: import org.apache.commons.logging.LogFactory;
25: import org.josso.gateway.SSOGateway;
26:
27: /**
28: * SSO Gateway abstract factory.
29: *
30: * @author <a href="mailto:sgonzalez@josso.org">Sebastian Gonzalez Oyuela</a>
31: * @version $Id: SSOGatewayFactory.java 508 2008-02-18 13:32:29Z sgonzalez $
32: */
33:
34: public abstract class SSOGatewayFactory {
35:
36: private static final Log logger = LogFactory
37: .getLog(SSOGatewayFactory.class);
38:
39: private static final String property = "org.josso.util.SSOGatewayFactory";
40:
41: private static final String factory = "org.josso.util.SSOGatewayFactoryImpl";
42:
43: public static SSOGatewayFactory getInstance() {
44: String n = factory;
45: try {
46: n = System.getProperty(property, factory);
47: } catch (SecurityException e) {
48: n = factory;
49: }
50:
51: try {
52: return (SSOGatewayFactory) Class.forName(n).newInstance();
53:
54: } catch (ClassNotFoundException e) {
55: throw new FactoryConfigurationError("Cannot load class "
56: + "Factory class \"" + n + "\"", e);
57:
58: } catch (InstantiationException e) {
59: throw new FactoryConfigurationError(
60: "Cannot instantiate the "
61: + "specified Security Manager Client class \""
62: + n + "\"", e);
63:
64: } catch (IllegalAccessException e) {
65: throw new FactoryConfigurationError(
66: "Cannot access the specified "
67: + "Security Manager Client class \"" + n
68: + "\"", e);
69:
70: } catch (ClassCastException e) {
71: throw new FactoryConfigurationError(
72: "The specified class \"" + n
73: + "\" is not instance of \""
74: + SSOGatewayFactory.class.getName() + "\"",
75: e);
76: }
77:
78: }
79:
80: public abstract SSOGateway getNewSSOGateway();
81:
82: }
|