KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > EjbIORConfigurationDescriptor


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.deployment;
24
25 import java.util.Properties JavaDoc;
26 import java.io.InputStream JavaDoc;
27 import java.io.IOException JavaDoc;
28 import java.util.logging.*;
29 import com.sun.logging.*;
30
31 import com.sun.enterprise.deployment.util.LogDomains;
32
33 /**
34  * This descriptor holds the security configuration of an EJB IOR.
35  *
36  */

37
38 public class EjbIORConfigurationDescriptor {
39     // For backward compatiblity with CTS, equalsIgnoreCase should be used
40
// for comparison with NONE, SUPPORTED, REQUIRED.
41
public static final String JavaDoc NONE = "NONE";
42     public static final String JavaDoc SUPPORTED = "SUPPORTED";
43     public static final String JavaDoc REQUIRED = "REQUIRED";
44
45     public static final String JavaDoc USERNAME_PASSWORD = "username_password";
46     public static final String JavaDoc DEFAULT_REALM = "default";
47
48     private String JavaDoc integrity = SUPPORTED;
49     private String JavaDoc confidentiality = SUPPORTED;
50     private String JavaDoc establishTrustInTarget = SUPPORTED;
51     private String JavaDoc establishTrustInClient = SUPPORTED;
52     private String JavaDoc authenticationMethod = USERNAME_PASSWORD;
53     private String JavaDoc realmName = DEFAULT_REALM;
54     private String JavaDoc callerPropagation = SUPPORTED;
55     private boolean required = false;
56        
57     static Logger _logger = LogDomains.getLogger(LogDomains.DPL_LOGGER);
58     
59     /**
60     * Default constructor.
61     */

62     public EjbIORConfigurationDescriptor() {
63     try {
64         if (Boolean.getBoolean("interop.ssl.required")) {
65         integrity = REQUIRED;
66         confidentiality = REQUIRED;
67         establishTrustInClient = REQUIRED;
68         establishTrustInTarget = SUPPORTED;
69         }
70
71             if (Boolean.getBoolean("interop.authRequired.enabled")) {
72         required = true;
73         authenticationMethod = USERNAME_PASSWORD;
74         }
75     } catch(Throwable JavaDoc ioe) {
76         //ioe.printStackTrace();
77
_logger.log(Level.WARNING,"enterprise.deployment_ioexcp",ioe);
78             
79         // ignore
80
}
81     }
82
83     public EjbIORConfigurationDescriptor(boolean enableUsernamePassword) {
84     if(enableUsernamePassword) {
85         required = true;
86         authenticationMethod = USERNAME_PASSWORD;
87     }
88     }
89
90     /**
91      * Get the value of the integrity element. Default value is "supported".
92      * @return the value (one of supported, required, none).
93      */

94     public String JavaDoc getIntegrity() {
95     return integrity;
96     }
97
98     /**
99      * Set the value of the integrity element to the specified value.
100      * @param the value (one of supported, required, none).
101      */

102     public void setIntegrity(String JavaDoc val) {
103     if(!val.equalsIgnoreCase(NONE) && !val.equalsIgnoreCase(SUPPORTED) &&
104         !val.equalsIgnoreCase(REQUIRED)) {
105         throw new RuntimeException JavaDoc("Incorrect value for integrity:" + val);
106     }
107
108     integrity = val;
109     }
110
111     /**
112      * Get the value of the confidentiality element.
113      * Default value is "supported".
114      * @return the value (one of supported, required, none).
115      */

116     public String JavaDoc getConfidentiality() {
117     return confidentiality;
118     }
119
120     /**
121      * Set the value of the confidentiality element to the specified value.
122      * @param the value (one of supported, required, none).
123      */

124     public void setConfidentiality(String JavaDoc val) {
125     if(!val.equalsIgnoreCase(NONE) && !val.equalsIgnoreCase(SUPPORTED) &&
126         !val.equalsIgnoreCase(REQUIRED)) {
127         throw new RuntimeException JavaDoc("Incorrect value for confidentiality:" +
128                     val);
129     }
130     confidentiality = val;
131     }
132     
133     /**
134      * Get the value of establishTrustInTarget in the transport layer.
135      * The default value is "supported".
136      * @return the value (required, supported, or none)
137      */

138     public String JavaDoc getEstablishTrustInTarget() {
139     return establishTrustInTarget;
140     }
141
142     /**
143      * Set the value of establishTrustInTarget in the transport layer.
144      * @param the value (required, supported, or none)
145      */

146     public void setEstablishTrustInTarget(String JavaDoc val) {
147     if(!val.equalsIgnoreCase(NONE) && !val.equalsIgnoreCase(SUPPORTED)) {
148         throw new RuntimeException JavaDoc("Incorrect value for " +
149             "establishTrustInTarget:" + val);
150     }
151
152     establishTrustInTarget = val;
153     }
154
155     /**
156      * Get the value of establishTrustInClient in the transport layer.
157      * The default value is "supported".
158      * @return the value (required, supported, or none)
159      */

160     public String JavaDoc getEstablishTrustInClient() {
161     return establishTrustInClient;
162     }
163
164     /**
165      * Set the value of establishTrustInClient in the transport layer.
166      * @param the value (required, supported, or none)
167      */

168     public void setEstablishTrustInClient(String JavaDoc val) {
169     if(!val.equalsIgnoreCase(NONE) && !val.equalsIgnoreCase(SUPPORTED) &&
170         !val.equalsIgnoreCase(REQUIRED)) {
171         throw new RuntimeException JavaDoc("Incorrect value for " +
172             "establishTrustInClient:" + val);
173     }
174
175     establishTrustInClient = val;
176     }
177
178     /**
179      * Return the authentication method used to authenticate clients.
180      * The default value is "username_password".
181      * @return the authentication method.
182      */

183     public String JavaDoc getAuthenticationMethod() {
184     return authenticationMethod;
185     }
186
187     /**
188      * Set the authentication method used to authenticate clients.
189      * @param the authentication method.
190      */

191     public void setAuthenticationMethod(String JavaDoc val) {
192     if(!val.equalsIgnoreCase(USERNAME_PASSWORD) && !val.equalsIgnoreCase(NONE)) {
193         throw new RuntimeException JavaDoc("Incorrect value for " +
194             "authentication method:" + val);
195     }
196     authenticationMethod = val;
197     }
198
199     /**
200      * Return the realm name to authenticate the caller in.
201      * The default value is "default".
202      * @return the realm name.
203      */

204     public String JavaDoc getRealmName() {
205     return realmName;
206     }
207
208     /**
209      * Set the realm name to authenticate the caller in.
210      * @param the realm name.
211      */

212     public void setRealmName(String JavaDoc val) {
213     realmName = val;
214     }
215
216     /**
217      * Return the value of identity assertion in the SAS_Context layer.
218      * @return the value (one of none, required or supported).
219      */

220     public String JavaDoc getCallerPropagation() {
221     return callerPropagation;
222     }
223
224     /**
225      * Set the value of identity assertion in the SAS_Context layer.
226      * @param the value (one of none, required or supported).
227      */

228     public void setCallerPropagation(String JavaDoc val) {
229     if(!val.equalsIgnoreCase(NONE) && !val.equalsIgnoreCase(SUPPORTED) &&
230         !val.equalsIgnoreCase(REQUIRED)) {
231         throw new RuntimeException JavaDoc("Incorrect value for callerPropagation:" + val);
232     }
233     callerPropagation = val;
234     }
235
236     /**
237      * Get whether the establishTrustInClient element is required
238      * in the AS_context.
239      * @return the value (true or false).
240      */

241     public boolean isAuthMethodRequired() {
242     return required;
243     }
244
245     /**
246      * Set whether the establishTrustInClient element should be required
247      * in the AS_context.
248      * @param the value (true or false).
249      */

250     public void setAuthMethodRequired(boolean val) {
251     required = val;
252     }
253     
254
255     /**
256      * Set whether the establishTrustInClient element should be required
257      * in the AS_context.
258      * @param the value (true or false).
259      */

260     public void setAuthMethodRequired(String JavaDoc val) {
261     required = new Boolean JavaDoc(val).booleanValue();
262     }
263
264     /**
265     * Returns a formatted String of the attributes of this object.
266     */

267     public void print(StringBuffer JavaDoc toStringBuffer) {
268     toStringBuffer.append("\n integrity ").append(integrity);
269     toStringBuffer.append( "\n confidentiality " ).append( confidentiality);
270     toStringBuffer.append( "\n establishTrustInTarget ").append(establishTrustInTarget);
271     toStringBuffer.append( "\n establishTrustInClient ").append(establishTrustInClient);
272     toStringBuffer.append( "\n callerPropagation ").append(callerPropagation);
273     toStringBuffer.append( "\n realm ").append(realmName);
274     toStringBuffer.append( "\n authenticationMethod ").append(authenticationMethod).append("\n");
275     }
276 }
277     
278
Popular Tags