KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jcorporate > expresso > services > controller > configuration > CreateSettingsBean


1 package com.jcorporate.expresso.services.controller.configuration;
2
3 /* ====================================================================
4  * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
5  *
6  * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by Jcorporate Ltd.
23  * (http://www.jcorporate.com/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. "Jcorporate" and product names such as "Expresso" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written permission,
30  * please contact info@jcorporate.com.
31  *
32  * 5. Products derived from this software may not be called "Expresso",
33  * or other Jcorporate product names; nor may "Expresso" or other
34  * Jcorporate product names appear in their name, without prior
35  * written permission of Jcorporate Ltd.
36  *
37  * 6. No product derived from this software may compete in the same
38  * market space, i.e. framework, without prior written permission
39  * of Jcorporate Ltd. For written permission, please contact
40  * partners@jcorporate.com.
41  *
42  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
43  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
44  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
45  * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
46  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
47  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
48  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
49  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
50  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
51  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
52  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53  * SUCH DAMAGE.
54  * ====================================================================
55  *
56  * This software consists of voluntary contributions made by many
57  * individuals on behalf of the Jcorporate Ltd. Contributions back
58  * to the project(s) are encouraged when you make modifications.
59  * Please send them to support@jcorporate.com. For more information
60  * on Jcorporate Ltd. and its products, please see
61  * <http://www.jcorporate.com/>.
62  *
63  * Portions of this software are based upon other open source
64  * products and are subject to their respective licenses.
65  */

66
67 import com.jcorporate.expresso.core.misc.Base64;
68 import com.jcorporate.expresso.kernel.exception.ChainedException;
69 import org.apache.log4j.Logger;
70 import org.apache.struts.action.ActionForm;
71
72 import java.io.Serializable JavaDoc;
73 import java.util.Random JavaDoc;
74
75 /**
76  * This bean contains all the settings used by the create settings wizard
77  *
78  * @author Michael Rimov
79  * @version $Revision: 1.6 $ on $Date: 2004/11/17 20:48:17 $
80  */

81
82 public class CreateSettingsBean extends ActionForm implements Serializable JavaDoc {
83
84     private static final Logger log = Logger.getLogger(CreateSettingsBean.class);
85
86     private String JavaDoc dbConfig = "hypersonic.xml";
87     private String JavaDoc loginName = "sa";
88     private String JavaDoc databaseURL = "jdbc:hsqldb:%web-app%WEB-INF/db/default/default";
89     private String JavaDoc password = "";
90     private boolean useJNDI = false;
91     private JNDIBean jndiConfig;
92     private String JavaDoc runtimeName = "default";
93     private boolean useCaching = true;
94     private boolean useStrongEncryption = false;
95     private String JavaDoc tempFileLocation;
96     private String JavaDoc secretKey;
97
98     /**
99      * Initializes the default values of the bean.
100      */

101     public CreateSettingsBean() {
102         String JavaDoc cwd = System.getProperty("user.dir", "");
103         String JavaDoc separator = System.getProperty("file.separator", "");
104         tempFileLocation = cwd + separator + "temp";
105         Random JavaDoc r = new java.util.Random JavaDoc();
106         byte theBytes[] = new byte[32];
107         r.nextBytes(theBytes);
108         try {
109             int numTimes = r.nextInt(256);
110             //Hash it x many times to help whiten the crypto that we used java.util
111
//rather than a secure random number
112
for (int i = 0; i < numTimes; i++) {
113                 theBytes = new com.jcorporate.expresso.core.security.StringHash().produceHash(theBytes);
114             }
115
116             secretKey = Base64.encode(theBytes);
117         } catch (ChainedException ex) {
118             log.warn("Unable to load SHA1 Hash", ex);
119         }
120     }
121
122     public String JavaDoc getDbConfig() {
123         return dbConfig;
124     }
125
126     public void setDbConfig(String JavaDoc dbConfig) {
127         this.dbConfig = dbConfig;
128     }
129
130     public void setLoginName(String JavaDoc loginName) {
131         this.loginName = loginName;
132     }
133
134     public String JavaDoc getLoginName() {
135         return loginName;
136     }
137
138     public void setDatabaseURL(String JavaDoc databaseURL) {
139         this.databaseURL = databaseURL;
140     }
141
142     public String JavaDoc getDatabaseURL() {
143         return databaseURL;
144     }
145
146     public void setPassword(String JavaDoc password) {
147         this.password = password;
148     }
149
150     public String JavaDoc getPassword() {
151         return password;
152     }
153
154     public void setUseJNDI(boolean useJNDI) {
155         this.useJNDI = useJNDI;
156     }
157
158     public boolean isUseJNDI() {
159         return useJNDI;
160     }
161
162     public void setJndiConfig(JNDIBean jndiConfig) {
163         this.jndiConfig = jndiConfig;
164     }
165
166     public JNDIBean getJndiConfig() {
167         return jndiConfig;
168     }
169
170     public void setRuntimeName(String JavaDoc runtimeName) {
171         this.runtimeName = runtimeName;
172     }
173
174     public String JavaDoc getRuntimeName() {
175         return runtimeName;
176     }
177
178     public boolean isUseCaching() {
179         return useCaching;
180     }
181
182     public void setUseCaching(boolean useCaching) {
183         this.useCaching = useCaching;
184     }
185
186     public void setUseStrongEncryption(boolean useStrongEncryption) {
187         this.useStrongEncryption = useStrongEncryption;
188     }
189
190     public boolean isUseStrongEncryption() {
191         return useStrongEncryption;
192     }
193
194     public void setTempFileLocation(String JavaDoc randomSeedLocation) {
195         this.tempFileLocation = randomSeedLocation;
196     }
197
198     public String JavaDoc getTempFileLocation() {
199         return tempFileLocation;
200     }
201
202     public void setSecretKey(String JavaDoc secretKey) {
203         this.secretKey = secretKey;
204     }
205
206     public String JavaDoc getSecretKey() {
207         return secretKey;
208     }
209
210
211 }
Popular Tags