01: /**
02: * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a>
03: * @version $Id: AuthModulesDescriptor.java 6385 2007-10-25 14:02:26Z wehrens $
04: */package org.gridsphere.services.core.security.auth.modules.impl.descriptor;
05:
06: import org.gridsphere.portletcontainer.impl.JavaXMLBindingFactory;
07: import org.gridsphere.services.core.persistence.PersistenceManagerException;
08: import org.gridsphere.services.core.persistence.PersistenceManagerXml;
09:
10: import java.net.URL;
11: import java.util.Iterator;
12: import java.util.List;
13:
14: /**
15: * The <code>AuthModulesDescriptor</code>
16: */
17: public class AuthModulesDescriptor {
18:
19: private AuthModuleCollection authModules = null;
20: private PersistenceManagerXml pmXML = null;
21:
22: /**
23: * Constructor disallows non-argument instantiation
24: */
25: private AuthModulesDescriptor() {
26: }
27:
28: public AuthModulesDescriptor(String descriptorFile, URL mappingFile)
29: throws PersistenceManagerException {
30: pmXML = JavaXMLBindingFactory.createPersistenceManagerXml(
31: descriptorFile, mappingFile);
32: authModules = (AuthModuleCollection) pmXML.load();
33: }
34:
35: /**
36: * Returns the collection of auth module definitions
37: *
38: * @return the collection of auth module definitions
39: */
40: public AuthModuleCollection getCollection() {
41: return authModules;
42: }
43:
44: /**
45: * Sets the collection of auth module definitions
46: *
47: * @param authModules the collection of auth module definitions
48: */
49: public void setCollection(AuthModuleCollection authModules) {
50: this .authModules = authModules;
51: }
52:
53: /**
54: * Sets the auth module definition
55: *
56: * @param definition the auth module definition
57: */
58: public void setModuleDefinition(AuthModuleDefinition definition) {
59: List serviceDefs = authModules.getAuthModulesList();
60: Iterator it = serviceDefs.iterator();
61: while (it.hasNext()) {
62: AuthModuleDefinition def = (AuthModuleDefinition) it.next();
63: if (definition.getModuleName().equals(def.getModuleName())) {
64: def.setConfigParamList(definition.getConfigParamList());
65: }
66: }
67: }
68:
69: /**
70: * Saves the auth module descriptor
71: *
72: * @throws PersistenceManagerException if a Castor error occurs during the marshalling
73: */
74: public void save() throws PersistenceManagerException {
75: pmXML.save(authModules);
76: }
77:
78: }
|