01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 2005 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library 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 library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * Initial Developer : Matt Wringe
22: *
23: * --------------------------------------------------------------------------
24: * $Id: ContextDDModifier.java 7057 2005-07-18 23:53:31Z mwringe $
25: * --------------------------------------------------------------------------
26: */package org.objectweb.jonas_ws.wsgen.ddmodifier;
27:
28: import org.w3c.dom.Document;
29: import org.w3c.dom.Element;
30:
31: /**
32: * Modify a the context.xml file. Wrapper around a web.xml DOM
33: *
34: * @author Matt Wringe
35: */
36: public class ContextDDModifier extends DeploymentDescModifier {
37:
38: /**
39: * The class used by Tomcat to setup the realm
40: */
41: private static final String REALM_CLASS_NAME = "org.objectweb.jonas.security.realm.web.catalina55.JACC";
42:
43: /**
44: * Create a new ContextDDModifier
45: *
46: * @param doc the context.xml Document
47: */
48: public ContextDDModifier(Document doc) {
49: super (doc.getDocumentElement(), doc);
50: }
51:
52: /**
53: * Setups the realm for Tomcat to use
54: *
55: * @param realm the realm to use
56: */
57: public void addContextRealm(String realm) {
58: Element contextElement = getElement();
59:
60: contextElement.appendChild(setRealm(realm));
61: }
62:
63: /**
64: * Returns an element that defines the realm to use
65: *
66: * @param realm the realm to use
67: * @return an element the defines the realm to use
68: */
69: private Element setRealm(String realm) {
70: Element realmElement = newElement("Realm");
71: realmElement.setAttribute("className", REALM_CLASS_NAME);
72: realmElement.setAttribute("resourceName", realm);
73:
74: return realmElement;
75: }
76:
77: }
|