1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.ldap.server.configuration;
20
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.Iterator;
24 import java.util.List;
25 import java.io.File;
26
27 import org.apache.ldap.server.protocol.ExtendedOperationHandler;
28 import org.apache.mina.registry.ServiceRegistry;
29 import org.apache.mina.registry.SimpleServiceRegistry;
30 import org.apache.protocol.common.store.LdifLoadFilter;
31
32
33 /***
34 * A {@link StartupConfiguration} that starts up ApacheDS with network layer support.
35 *
36 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
37 * @version $Rev: 329335 $, $Date: 2005-10-28 20:57:58 -0400 (Fri, 28 Oct 2005) $
38 */
39 public class ServerStartupConfiguration extends StartupConfiguration
40 {
41 private static final long serialVersionUID = -7138616822614155454L;
42
43 private boolean enableNetworking = true;
44 private ServiceRegistry minaServiceRegistry = new SimpleServiceRegistry();
45 private int ldapPort = 389;
46 private int ldapsPort = 636;
47 private boolean enableKerberos = false;
48 private boolean enableChangePassword = false;
49 private boolean enableNtp = false;
50 private final Collection extendedOperationHandlers = new ArrayList();
51 private File ldifDirectory = null;
52 private final List ldifFilters = new ArrayList();
53
54 protected ServerStartupConfiguration()
55 {
56 }
57
58 /***
59 * Returns <tt>true</tt> if networking (LDAP, LDAPS, and Kerberos) is enabled.
60 */
61 public boolean isEnableNetworking()
62 {
63 return enableNetworking;
64 }
65
66 /***
67 * Sets whether to enable networking (LDAP, LDAPS, and Kerberos) or not.
68 */
69 public void setEnableNetworking( boolean enableNetworking )
70 {
71 this.enableNetworking = enableNetworking;
72 }
73
74 /***
75 * Returns <tt>true</tt> if Kerberos support is enabled.
76 */
77 public boolean isEnableKerberos()
78 {
79 return enableKerberos;
80 }
81
82 /***
83 * Returns <tt>true</tt> if Change Password support is enabled.
84 */
85 public boolean isEnableChangePassword()
86 {
87 return enableChangePassword;
88 }
89
90 /***
91 * Returns <tt>true</tt> if Kerberos support is enabled.
92 */
93 public boolean isEnableNtp()
94 {
95 return enableNtp;
96 }
97
98 /***
99 * Sets whether to enable Kerberos support or not.
100 */
101 protected void setEnableKerberos( boolean enableKerberos )
102 {
103 this.enableKerberos = enableKerberos;
104 }
105
106 /***
107 * Sets whether to enable Change Password support or not.
108 */
109 protected void setEnableChangePassword( boolean enableChangePassword )
110 {
111 this.enableChangePassword = enableChangePassword;
112 }
113
114 /***
115 * Sets whether to enable Ntp support or not.
116 */
117 protected void setEnableNtp( boolean enableNtp )
118 {
119 this.enableNtp = enableNtp;
120 }
121
122 /***
123 * Returns LDAP TCP/IP port number to listen to.
124 */
125 public int getLdapPort()
126 {
127 return ldapPort;
128 }
129
130 /***
131 * Sets LDAP TCP/IP port number to listen to.
132 */
133 protected void setLdapPort( int ldapPort )
134 {
135 ConfigurationUtil.validatePortNumber( ldapPort );
136 this.ldapPort = ldapPort;
137 }
138
139 /***
140 * Returns LDAPS TCP/IP port number to listen to.
141 */
142 public int getLdapsPort()
143 {
144 return ldapsPort;
145 }
146
147 /***
148 * Sets LDAPS TCP/IP port number to listen to.
149 */
150 protected void setLdapsPort( int ldapsPort )
151 {
152 ConfigurationUtil.validatePortNumber( ldapsPort );
153 this.ldapsPort = ldapsPort;
154 }
155
156 /***
157 * Returns <a href="http://directory.apache.org/subprojects/network/">MINA</a>
158 * {@link ServiceRegistry} that will be used by ApacheDS.
159 */
160 public ServiceRegistry getMinaServiceRegistry()
161 {
162 return minaServiceRegistry;
163 }
164
165 /***
166 * Sets <a href="http://directory.apache.org/subprojects/network/">MINA</a>
167 * {@link ServiceRegistry} that will be used by ApacheDS.
168 */
169 protected void setMinaServiceRegistry( ServiceRegistry minaServiceRegistry )
170 {
171 if( minaServiceRegistry == null )
172 {
173 throw new ConfigurationException( "MinaServiceRegistry cannot be null" );
174 }
175 this.minaServiceRegistry = minaServiceRegistry;
176 }
177
178 public Collection getExtendedOperationHandlers()
179 {
180 return new ArrayList( extendedOperationHandlers );
181 }
182
183 protected void setExtendedOperationHandlers( Collection handlers )
184 {
185 for( Iterator i = handlers.iterator(); i.hasNext(); )
186 {
187 if( !( i.next() instanceof ExtendedOperationHandler ) )
188 {
189 throw new IllegalArgumentException(
190 "The specified handler collection contains an element which is not an ExtendedOperationHandler." );
191 }
192 }
193
194 this.extendedOperationHandlers.clear();
195 this.extendedOperationHandlers.addAll( handlers );
196 }
197
198 public File getLdifDirectory()
199 {
200 return this.ldifDirectory;
201 }
202
203 protected void setLdifDirectory( File ldifDirectory )
204 {
205 this.ldifDirectory = ldifDirectory;
206 }
207
208 public List getLdifFilters()
209 {
210 return new ArrayList( ldifFilters );
211 }
212
213 protected void setLdifFilters( List filters )
214 {
215 for( int ii = 0; ii < filters.size(); ii++ )
216 {
217 if( !( filters.get( ii ) instanceof LdifLoadFilter ) )
218 {
219 throw new IllegalArgumentException(
220 "The specified filter collection contains an element which is not an LdifLoadFilter." );
221 }
222 }
223
224 this.ldifFilters.clear();
225 this.ldifFilters.addAll( filters );
226 }
227 }