001: /*--
002:
003: Copyright (C) 2002-2005 Adrian Price.
004: All rights reserved.
005:
006: Redistribution and use in source and binary forms, with or without
007: modification, are permitted provided that the following conditions
008: are met:
009:
010: 1. Redistributions of source code must retain the above copyright
011: notice, this list of conditions, and the following disclaimer.
012:
013: 2. Redistributions in binary form must reproduce the above copyright
014: notice, this list of conditions, and the disclaimer that follows
015: these conditions in the documentation and/or other materials
016: provided with the distribution.
017:
018: 3. The names "OBE" and "Open Business Engine" must not be used to
019: endorse or promote products derived from this software without prior
020: written permission. For written permission, please contact
021: adrianprice@sourceforge.net.
022:
023: 4. Products derived from this software may not be called "OBE" or
024: "Open Business Engine", nor may "OBE" or "Open Business Engine"
025: appear in their name, without prior written permission from
026: Adrian Price (adrianprice@users.sourceforge.net).
027:
028: THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
029: WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
030: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
031: DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
032: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
033: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
034: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
035: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
036: STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
037: IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
038: POSSIBILITY OF SUCH DAMAGE.
039:
040: For more information on OBE, please see
041: <http://obe.sourceforge.net/>.
042:
043: */
044:
045: package org.obe.client.api;
046:
047: import org.obe.util.CommonConfig;
048:
049: /**
050: * Provides access to OBE client configuration information. OBE is configured
051: * by several XML and properties files, which can either be located in the OBE
052: * configuration directory or in the <code>META-INF/services</code> directory in
053: * obeconfig.jar. Resources in the latter location are accessed via this
054: * class's ClassLoader. The OBE configuration directory can be specified by the
055: * system property <code>"obe.config.dir"</code>, defaulting to the current
056: * directory. Loose files take precedence over resources in obeconfig.jar.
057: * <p/>
058: * The <code>obe.properties</code> file contains the OBE client configuration.
059: *
060: * @author Adrian Price
061: */
062: public final class ClientConfig extends CommonConfig {
063: /**
064: * Property key for configuring an override to the default JNDI initial
065: * context factory whilst preserving the value of the latter.
066: */
067: public static final String JNDI_INITIAL_CONTEXT_FACTORY_PROP = "obe.client.java.naming.factory.initial";
068: /**
069: * Property key for the name of a JAAS callback handler class.
070: */
071: public static final String JAAS_CALLBACK_HANDLER_PROP = "obe.client.jaas.callback.handler";
072: /**
073: * Property key for the primary JAAS principal class.
074: */
075: public static final String JAAS_CALLER_PRINCIPAL_CLASS_PROP = "obe.jaas.caller.principal.class";
076: /**
077: * Property key for the JAAS login configuration entry to use.
078: */
079: public static final String JAAS_CONFIG_PROP = "obe.client.jaas.config";
080: /**
081: * Property key for whether client-side tool agents should use STDIO for
082: * user interactions.
083: */
084: public static final String USE_STDIO_PROP = "obe.client.stdio";
085: /**
086: * Property key for the public JNDI name of a JMS queue connection factory.
087: */
088: public static final String JMS_QUEUE_CON_FACTORY_PROP = "obe.jms.queue.connection.factory";
089: /**
090: * Property key for the public JNDI name of a JMS topic connection factory.
091: */
092: public static final String JMS_TOPIC_CON_FACTORY_PROP = "obe.jms.topic.connection.factory";
093: /**
094: * Property key for the OBE server host URL.
095: */
096: public static final String SERVER_HOST_URL_PROP = "obe.server.host";
097:
098: /**
099: * Whether client-side tool agents should use STDIO for user interactions.
100: * <p/>
101: * The setting reflects the boolean value of the configuration property
102: * <code>obe.client.stdio</code>. Default is <code>false</code>.
103: *
104: * @return <code>true</code> to interact via STDIO, <code>false</code> to
105: * present a graphical UI.
106: * @see #USE_STDIO_PROP
107: */
108: public static boolean useSTDIO() {
109: return getBooleanProperty(USE_STDIO_PROP, false);
110: }
111:
112: /**
113: * Returns the name of the JAAS configuration entry to use for client
114: * authentication.
115: * <p/>
116: * The setting reflects the string value of the configuration property
117: * <code>obe.client.jaas.config</code>.
118: *
119: * @return JAAS configuration entry name, defaulting to <code>"other"</code>.
120: * @see #JAAS_CONFIG_PROP
121: */
122: public static String getJAASConfig() {
123: return getStringProperty(JAAS_CONFIG_PROP, "other");
124: }
125:
126: /**
127: * Returns the JNDI name of the JMS queue connection factory for clients.
128: * <p/>
129: * The setting reflects the string value of the configuration property
130: * <code>obe.jms.queue.connection.factory</code>.
131: *
132: * @return JMS connection factory JNDI name, defaulting to
133: * <code>"ConnectionFactory"</code>.
134: * @see #JMS_QUEUE_CON_FACTORY_PROP
135: */
136: public static String getJMSQueueConnectionFactory() {
137: return getStringProperty(JMS_QUEUE_CON_FACTORY_PROP,
138: "ConnectionFactory");
139: }
140:
141: /**
142: * Returns the JNDI name of the JMS topic connection factory for clients.
143: * <p/>
144: * The setting reflects the string value of the configuration property
145: * <code>obe.jms.topic.connection.factory</code>.
146: *
147: * @return JMS connection factory JNDI name, defaulting to
148: * <code>"ConnectionFactory"</code>.
149: * @see #JMS_TOPIC_CON_FACTORY_PROP
150: */
151: public static String getJMSTopicConnectionFactory() {
152: return getStringProperty(JMS_TOPIC_CON_FACTORY_PROP,
153: "TopicConnectionFactory");
154: }
155:
156: /**
157: * Returns the name of the JAAS callback handler to use for client
158: * authentication.
159: * <p/>
160: * The setting reflects the string value of the configuration property
161: * <code>obe.client.jaas.callback.handler</code>. The implementing class
162: * must have a public constructor that takes the following arguments:
163: * <p/>
164: * <code>(String url, String username, String password)</code>
165: *
166: * @return JAAS callback handler class name, defaulting to
167: * <code>"org.obe.client.api.base.OBECallbackHandler"</code>.
168: * @see #JAAS_CALLBACK_HANDLER_PROP
169: */
170: public static String getJAASCallbackHandlerClass() {
171: return getStringProperty(JAAS_CALLBACK_HANDLER_PROP,
172: "org.obe.client.api.base.OBECallbackHandler");
173: }
174:
175: /**
176: * Returns the name of the <code>javax.security.Principal</code> class from
177: * which to infer the primary identity of an authenticated subject. If
178: * <code>null</code>, the client uses the first non-group principal in the
179: * authenticated subject.
180: * <p/>
181: * The setting reflects the string value of the configuration property
182: * <code>obe.jaas.caller.principal.class</code>.
183: *
184: * @return JAAS callback handler class name, defaulting to <code>null</code>.
185: * @see #JAAS_CALLER_PRINCIPAL_CLASS_PROP
186: */
187: public static String getJAASCallerPrincipalClass() {
188: return getStringProperty(JAAS_CALLER_PRINCIPAL_CLASS_PROP, null);
189: }
190:
191: /**
192: * Returns an override for the JNDI property
193: * <code>java.naming.factory.initial</code>. Generally speaking there is no
194: * reason to set this property. It should only be used if the OBE client
195: * needs to bypass the standard JNDI initial context factory as specified
196: * by the system property <code>java.naming.factory.initial</code>. For
197: * example, certain RPC tunnelling protocols wrap default JNDI objects with
198: * their own marshalling mechanism.
199: * <p/>
200: * The setting reflects the string value of the configuration property
201: * <code>obe.client.java.naming.factory.initial</code>.
202: *
203: * @return JAAS callback handler class name, defaulting to <code>null</code>.
204: * @see #JNDI_INITIAL_CONTEXT_FACTORY_PROP
205: */
206: public static String getJNDIInitialContextFactoryClass() {
207: return getStringProperty(JNDI_INITIAL_CONTEXT_FACTORY_PROP,
208: null);
209: }
210:
211: /**
212: * Returns the OBE server host URL.
213: * <p/>
214: * The setting reflects the string value of the configuration property
215: * <code>obe.server.host</code>.
216: *
217: * @return Server host name, defaulting to
218: * <code>"jnp://localhost:1099"</code>.
219: * @see #SERVER_HOST_URL_PROP
220: */
221: public static String getServerHostURL() {
222: return getStringProperty(SERVER_HOST_URL_PROP,
223: "jnp://localhost:1099");
224: }
225:
226: private ClientConfig() {
227: }
228: }
|