01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: MixedAuthenticatedDeployer.java 3643 2007-01-12 15:29:45Z gbevin $
07: */
08: package com.uwyn.rife.authentication.elements;
09:
10: import com.uwyn.rife.authentication.credentialsmanagers.CredentialsManagerFactoryFactory;
11: import com.uwyn.rife.authentication.credentialsmanagers.DatabaseUsersFactory;
12: import com.uwyn.rife.authentication.remembermanagers.DatabaseRememberFactory;
13: import com.uwyn.rife.authentication.remembermanagers.RememberManagerFactoryFactory;
14: import com.uwyn.rife.authentication.sessionmanagers.MemorySessions;
15: import com.uwyn.rife.authentication.sessionmanagers.SessionManagerFactoryFactory;
16: import com.uwyn.rife.authentication.sessionmanagers.SimpleSessionManagerFactory;
17: import com.uwyn.rife.authentication.sessionvalidators.BasicSessionValidator;
18: import com.uwyn.rife.authentication.sessionvalidators.SessionValidatorFactoryFactory;
19: import com.uwyn.rife.authentication.sessionvalidators.SimpleSessionValidatorFactory;
20: import com.uwyn.rife.engine.exceptions.EngineException;
21: import com.uwyn.rife.ioc.HierarchicalProperties;
22:
23: /**
24: * Deployer for {@link Authenticated} elements that by default sets up the
25: * credentials and remember-me managers for database storage, but the session
26: * managers for memory storage.
27: *
28: * @author Geert Bevin (gbevin[remove] at uwyn dot com)
29: * @version $Revision: 3643 $
30: * @since 1.0
31: */
32: public class MixedAuthenticatedDeployer extends
33: FactoryPropertyAuthenticatedDeployer {
34: public void deploy() throws EngineException {
35: HierarchicalProperties properties = getElementInfo()
36: .getProperties();
37: if (getElementInfo()
38: .isPropertyEmpty(
39: SessionManagerFactoryFactory.PROPERTYNAME_FACTORY_CLASS)) {
40: properties
41: .put(
42: SessionManagerFactoryFactory.PROPERTYNAME_FACTORY_CLASS,
43: SimpleSessionManagerFactory.class.getName());
44: }
45: if (getElementInfo().isPropertyEmpty(
46: SimpleSessionManagerFactory.PROPERTYNAME_MANAGER_CLASS)) {
47: properties
48: .put(
49: SimpleSessionManagerFactory.PROPERTYNAME_MANAGER_CLASS,
50: MemorySessions.class.getName());
51: }
52:
53: if (getElementInfo()
54: .isPropertyEmpty(
55: SessionValidatorFactoryFactory.PROPERTYNAME_FACTORY_CLASS)) {
56: properties
57: .put(
58: SessionValidatorFactoryFactory.PROPERTYNAME_FACTORY_CLASS,
59: SimpleSessionValidatorFactory.class
60: .getName());
61: }
62: if (getElementInfo()
63: .isPropertyEmpty(
64: SimpleSessionValidatorFactory.PROPERTYNAME_MANAGER_CLASS)) {
65: properties
66: .put(
67: SimpleSessionValidatorFactory.PROPERTYNAME_MANAGER_CLASS,
68: BasicSessionValidator.class.getName());
69: }
70:
71: if (getElementInfo()
72: .isPropertyEmpty(
73: CredentialsManagerFactoryFactory.PROPERTYNAME_FACTORY_CLASS)) {
74: properties
75: .put(
76: CredentialsManagerFactoryFactory.PROPERTYNAME_FACTORY_CLASS,
77: DatabaseUsersFactory.class.getName());
78: }
79:
80: if (getElementInfo()
81: .isPropertyEmpty(
82: RememberManagerFactoryFactory.PROPERTYNAME_FACTORY_CLASS)) {
83: properties
84: .put(
85: RememberManagerFactoryFactory.PROPERTYNAME_FACTORY_CLASS,
86: DatabaseRememberFactory.class.getName());
87: }
88:
89: super.deploy();
90: }
91: }
|