KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > appserver > jboss > CmpTcpService


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13
14 package org.ejbca.appserver.jboss;
15
16 import java.util.Properties JavaDoc;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.ejbca.ui.tcp.CmpTcpConfiguration;
20 import org.ejbca.ui.tcp.CmpTcpServer;
21 import org.jboss.system.ServiceMBeanSupport;
22
23 /**
24  * An MBean service managing listening for cmp messages over tcp.
25  */

26 public class CmpTcpService extends ServiceMBeanSupport implements CmpTcpServiceMBean
27 {
28     
29     /** This defines if we allows messages that has a POPO setting of raVerify.
30      * If this variable is true, and raVerify is the POPO defined in the message, no POPO check will be done.
31      */

32     private String JavaDoc allowRaVerifyPopo = "false";
33     /** The default CA used for signing requests, if it is not given in the request itself. */
34     private String JavaDoc defaultCA = null;
35     /** Defines which component from the DN should be used as username in EJBCA. Can be DN, UID or nothing. Nothing means that the DN will be used to look up the user. */
36     private String JavaDoc extractUsernameComponent = null;
37     
38     /** The operation mode, RA or NORMAL */
39     private String JavaDoc operationMode = "normal";
40     /** The endEntityProfile to be used when adding users in RA mode */
41     private String JavaDoc eeProfile = "EMTPTY";
42     /** The certificate profile to use when adding users in RA mode */
43     private String JavaDoc certProfile = "ENDUSER";
44     /** Tha CA to user when adding users in RA mode */
45     private String JavaDoc caName = "AdminCA1";
46     /** Parameter used to determine which protection response messages will have */
47     private String JavaDoc responseProtection = null;
48     /** Parameter used to authenticate RA messages if we are using RA mode to create users */
49     private String JavaDoc raAuthenticationSecret = null;
50     private String JavaDoc raNameGenerationParameters = "CN"; // Can be CN or UID
51
private String JavaDoc raModeNameGenerationScheme = "DN";
52     private String JavaDoc prefix = null;
53     private String JavaDoc postfix = null;
54     
55     private String JavaDoc portNo = "829";
56     private String JavaDoc logDir = "./log";
57     private String JavaDoc confFile = "";
58     
59     public String JavaDoc getName()
60     {
61         return "CmpTcpService";
62     }
63     
64     public void startService() throws Exception JavaDoc
65     {
66         Properties JavaDoc properties = new Properties JavaDoc();
67         String JavaDoc str = getAllowRaVerifyPopo();
68         if (StringUtils.equals("true", str)) {
69             log.debug("allowRAVerifyPopo=true");
70             properties.setProperty("allowRaVerifyPopo", "true");
71         }
72         str = getDefaultCA();
73         log.debug("defaultCA="+str);
74         if (StringUtils.isNotEmpty(str)) {
75             properties.setProperty("defaultCA", str);
76         }
77         str = getExtractUsernameComponent();
78         log.debug("extractUsernameComponent="+str);
79         if (StringUtils.isNotEmpty(str)) {
80             properties.setProperty("extractUsernameComponent", str);
81         }
82         str = getOperationMode();
83         log.debug("operationMode="+str);
84         if (StringUtils.isNotEmpty(str)) {
85             properties.setProperty("operationMode", str);
86         }
87         str = getRaModeNameGenerationScheme();
88         log.debug("raModeNameGenerationScheme="+str);
89         if (StringUtils.isNotEmpty(str)) {
90             properties.setProperty("raModeNameGenerationScheme", str);
91         }
92         str = getRaNameGenerationParameters();
93         log.debug("raModeNameGenerationParameters="+str);
94         if (StringUtils.isNotEmpty(str)) {
95             properties.setProperty("raModeNameGenerationParameters", str);
96         }
97         str = getPrefix();
98         log.debug("raModeNameGenerationPrefix="+str);
99         if (StringUtils.isNotEmpty(str)) {
100             properties.setProperty("raModeNameGenerationPrefix", str);
101         }
102         str = getPostfix();
103         log.debug("raModeNameGenerationPostfix="+str);
104         if (StringUtils.isNotEmpty(str)) {
105             properties.setProperty("raModeNameGenerationPostfix", str);
106         }
107         
108         str = getResponseProtection();
109         if (StringUtils.isNotEmpty(str)) {
110             log.debug("responseProtection="+str);
111             properties.setProperty("responseProtection", str);
112         }
113         str = getRaAuthenticationSecret();
114         if (StringUtils.isNotEmpty(str)) {
115             log.debug("raAuthenticationSecret is not null");
116             properties.setProperty("raAuthenticationSecret", str);
117         }
118         str = getEeProfile();
119         if (StringUtils.isNotEmpty(str)) {
120             log.debug("endEntityProfile="+str);
121             properties.setProperty("endEntityProfile", str);
122         }
123         str = getCertProfile();
124         if (StringUtils.isNotEmpty(str)) {
125             log.debug("certificateProfile="+str);
126             properties.setProperty("certificateProfile", str);
127         }
128         str = getCaName();
129         if (StringUtils.isNotEmpty(str)) {
130             log.debug("caName="+str);
131             properties.setProperty("caName", str);
132         }
133         str = getPortNo();
134         if (StringUtils.isNotEmpty(str)) {
135             log.debug("portNo="+str);
136             properties.setProperty("portNo", str);
137         }
138         str = getLogDir();
139         if (StringUtils.isNotEmpty(str)) {
140             log.debug("logDir="+str);
141             properties.setProperty("logDir", str);
142         }
143         str = getConfFile();
144         if (StringUtils.isNotEmpty(str)) {
145             log.debug("confFile="+str);
146             properties.setProperty("confFile", str);
147         }
148         
149         CmpTcpConfiguration.instance().init(properties);
150         CmpTcpServer.start();
151     }
152     
153     public void stopService()
154     {
155         CmpTcpServer.stop();
156     }
157
158     public String JavaDoc getAllowRaVerifyPopo() {
159         return allowRaVerifyPopo;
160     }
161
162     public void setAllowRaVerifyPopo(String JavaDoc allowRaVerifyPopo) {
163         this.allowRaVerifyPopo = allowRaVerifyPopo;
164     }
165
166     public String JavaDoc getCaName() {
167         return caName;
168     }
169
170     public void setCaName(String JavaDoc caName) {
171         this.caName = caName;
172     }
173
174     public String JavaDoc getCertProfile() {
175         return certProfile;
176     }
177
178     public void setCertProfile(String JavaDoc certProfile) {
179         this.certProfile = certProfile;
180     }
181
182     public String JavaDoc getDefaultCA() {
183         return defaultCA;
184     }
185
186     public void setDefaultCA(String JavaDoc defaultCA) {
187         this.defaultCA = defaultCA;
188     }
189
190     public String JavaDoc getRaModeNameGenerationScheme() {
191         return raModeNameGenerationScheme;
192     }
193
194     public void setRaModeNameGenerationScheme(String JavaDoc generatorComponent) {
195         raModeNameGenerationScheme = generatorComponent;
196     }
197
198     public String JavaDoc getEeProfile() {
199         return eeProfile;
200     }
201
202     public void setEeProfile(String JavaDoc eeProfile) {
203         this.eeProfile = eeProfile;
204     }
205
206     public String JavaDoc getExtractUsernameComponent() {
207         return extractUsernameComponent;
208     }
209
210     public void setExtractUsernameComponent(String JavaDoc extractUsernameComponent) {
211         this.extractUsernameComponent = extractUsernameComponent;
212     }
213
214     public String JavaDoc getRaNameGenerationParameters() {
215         return raNameGenerationParameters;
216     }
217
218     public void setRaNameGenerationParameters(String JavaDoc mode) {
219         this.raNameGenerationParameters = mode;
220     }
221
222     public String JavaDoc getPostfix() {
223         return postfix;
224     }
225
226     public void setPostfix(String JavaDoc postfix) {
227         this.postfix = postfix;
228     }
229
230     public String JavaDoc getPrefix() {
231         return prefix;
232     }
233
234     public void setPrefix(String JavaDoc prefix) {
235         this.prefix = prefix;
236     }
237
238     public String JavaDoc getResponseProtection() {
239         return responseProtection;
240     }
241     
242     public void setResponseProtection(String JavaDoc responseProtection) {
243         this.responseProtection = responseProtection;
244     }
245     
246     public String JavaDoc getRaAuthenticationSecret() {
247         return raAuthenticationSecret;
248     }
249
250     public void setRaAuthenticationSecret(String JavaDoc raAuthenticationSecret) {
251         this.raAuthenticationSecret = raAuthenticationSecret;
252     }
253
254     public String JavaDoc getOperationMode() {
255         return operationMode;
256     }
257
258     public void setOperationMode(String JavaDoc operationMode) {
259         this.operationMode = operationMode;
260     }
261     public String JavaDoc getPortNo() {
262         return portNo;
263     }
264     
265     public void setPortNo(String JavaDoc port) {
266         this.portNo = port;
267     }
268     
269     public String JavaDoc getLogDir() {
270         return logDir;
271     }
272     
273     public void setLogDir(String JavaDoc dir) {
274         this.logDir = dir;
275     }
276
277     public String JavaDoc getConfFile() {
278         return this.confFile;
279     }
280     
281     public void setConfFile(String JavaDoc file) {
282         this.confFile = file;
283     }
284
285     
286 }
Popular Tags