1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.extras;
21
22
23 import java.util.Map;
24
25 import org.apache.directory.api.i18n.I18n;
26 import org.apache.directory.api.ldap.codec.api.ControlFactory;
27 import org.apache.directory.api.ldap.codec.api.ExtendedOperationFactory;
28 import org.apache.directory.api.ldap.codec.api.IntermediateOperationFactory;
29 import org.apache.directory.api.ldap.codec.api.LdapApiService;
30 import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncRequest;
31 import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncResponse;
32 import org.apache.directory.api.ldap.extras.controls.ad.AdPolicyHints;
33 import org.apache.directory.api.ldap.extras.controls.ad.AdShowDeleted;
34 import org.apache.directory.api.ldap.extras.controls.ad.TreeDelete;
35 import org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncRequestFactory;
36 import org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncResponseFactory;
37 import org.apache.directory.api.ldap.extras.controls.ad_impl.AdPolicyHintsFactory;
38 import org.apache.directory.api.ldap.extras.controls.ad_impl.AdShowDeletedFactory;
39 import org.apache.directory.api.ldap.extras.controls.ad_impl.TreeDeleteFactory;
40 import org.apache.directory.api.ldap.extras.controls.changeNotifications.ChangeNotifications;
41 import org.apache.directory.api.ldap.extras.controls.changeNotifications_impl.ChangeNotificationsFactory;
42 import org.apache.directory.api.ldap.extras.controls.passwordExpired.PasswordExpiredResponse;
43 import org.apache.directory.api.ldap.extras.controls.passwordExpired_impl.PasswordExpiredResponseFactory;
44 import org.apache.directory.api.ldap.extras.controls.permissiveModify.PermissiveModify;
45 import org.apache.directory.api.ldap.extras.controls.permissiveModify_impl.PermissiveModifyFactory;
46 import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyRequest;
47 import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyResponse;
48 import org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyRequestFactory;
49 import org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyResponseFactory;
50 import org.apache.directory.api.ldap.extras.controls.syncrepl.syncDone.SyncDoneValue;
51 import org.apache.directory.api.ldap.extras.controls.syncrepl.syncRequest.SyncRequestValue;
52 import org.apache.directory.api.ldap.extras.controls.syncrepl.syncState.SyncStateValue;
53 import org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncDoneValueFactory;
54 import org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncRequestValueFactory;
55 import org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncStateValueFactory;
56 import org.apache.directory.api.ldap.extras.controls.transaction.TransactionSpecification;
57 import org.apache.directory.api.ldap.extras.controls.transaction_impl.TransactionSpecificationFactory;
58 import org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewRequest;
59 import org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewResponse;
60 import org.apache.directory.api.ldap.extras.controls.vlv_impl.VirtualListViewRequestFactory;
61 import org.apache.directory.api.ldap.extras.controls.vlv_impl.VirtualListViewResponseFactory;
62 import org.apache.directory.api.ldap.extras.extended.ads_impl.cancel.CancelFactory;
63 import org.apache.directory.api.ldap.extras.extended.ads_impl.certGeneration.CertGenerationFactory;
64 import org.apache.directory.api.ldap.extras.extended.ads_impl.endTransaction.EndTransactionFactory;
65 import org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulDisconnect.GracefulDisconnectFactory;
66 import org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulShutdown.GracefulShutdownFactory;
67 import org.apache.directory.api.ldap.extras.extended.ads_impl.nod.NoDFactory;
68 import org.apache.directory.api.ldap.extras.extended.ads_impl.pwdModify.PasswordModifyFactory;
69 import org.apache.directory.api.ldap.extras.extended.ads_impl.startTls.StartTlsFactory;
70 import org.apache.directory.api.ldap.extras.extended.ads_impl.startTransaction.StartTransactionFactory;
71 import org.apache.directory.api.ldap.extras.extended.ads_impl.storedProcedure.StoredProcedureFactory;
72 import org.apache.directory.api.ldap.extras.controls.relax.RelaxControl;
73 import org.apache.directory.api.ldap.extras.controls.relax_impl.RelaxControlFactory;
74 import org.apache.directory.api.ldap.extras.extended.ads_impl.whoAmI.WhoAmIFactory;
75 import org.apache.directory.api.ldap.extras.intermediate.syncrepl_impl.SyncInfoValueFactory;
76 import org.apache.directory.api.ldap.model.message.Control;
77 import org.slf4j.Logger;
78 import org.slf4j.LoggerFactory;
79
80
81
82
83
84
85
86
87 public final class ExtrasCodecFactoryUtil
88 {
89 private static final Logger LOG = LoggerFactory.getLogger( ExtrasCodecFactoryUtil.class );
90
91
92 private ExtrasCodecFactoryUtil()
93 {
94 }
95
96
97
98
99
100
101
102 public static void loadExtrasControls( LdapApiService apiService )
103 {
104 Map<String, ControlFactory<? extends Control>> requestControlFactories = apiService
105 .getRequestControlFactories();
106 Map<String, ControlFactory<? extends Control>> responseControlFactories = apiService
107 .getResponseControlFactories();
108
109
110
111 ControlFactory<AdDirSyncRequest> adDirSyncRequestFactory = new AdDirSyncRequestFactory( apiService );
112 requestControlFactories.put( adDirSyncRequestFactory.getOid(), adDirSyncRequestFactory );
113
114 if ( LOG.isInfoEnabled() )
115 {
116 LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, adDirSyncRequestFactory.getOid() ) );
117 }
118
119
120 ControlFactory<AdDirSyncResponse> adDirSyncResponseFactory = new AdDirSyncResponseFactory( apiService );
121 responseControlFactories.put( adDirSyncResponseFactory.getOid(), adDirSyncResponseFactory );
122
123 if ( LOG.isInfoEnabled() )
124 {
125 LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, adDirSyncRequestFactory.getOid() ) );
126 }
127
128
129 ControlFactory<AdPolicyHints> adPolicyHintsFactory = new AdPolicyHintsFactory( apiService );
130 requestControlFactories.put( adPolicyHintsFactory.getOid(), adPolicyHintsFactory );
131
132 if ( LOG.isInfoEnabled() )
133 {
134 LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, adPolicyHintsFactory.getOid() ) );
135 }
136
137
138 ControlFactory<AdShowDeleted> adShowDeletedFactory = new AdShowDeletedFactory( apiService );
139 requestControlFactories.put( adShowDeletedFactory.getOid(), adShowDeletedFactory );
140
141
142 ControlFactory<TreeDelete> treeDeleteFactory = new TreeDeleteFactory( apiService );
143 requestControlFactories.put( treeDeleteFactory.getOid(), treeDeleteFactory );
144
145 if ( LOG.isInfoEnabled() )
146 {
147 LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, adShowDeletedFactory.getOid() ) );
148 }
149
150
151 ControlFactory<ChangeNotifications> changeNotificationsFactory = new ChangeNotificationsFactory( apiService );
152 requestControlFactories.put( changeNotificationsFactory.getOid(), changeNotificationsFactory );
153 responseControlFactories.put( changeNotificationsFactory.getOid(), changeNotificationsFactory );
154
155 if ( LOG.isInfoEnabled() )
156 {
157 LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, changeNotificationsFactory.getOid() ) );
158 }
159
160
161 ControlFactory<PasswordExpiredResponse> passwordExpiredResponseFactory = new PasswordExpiredResponseFactory( apiService );
162 responseControlFactories.put( passwordExpiredResponseFactory.getOid(), passwordExpiredResponseFactory );
163
164 if ( LOG.isInfoEnabled() )
165 {
166 LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, passwordExpiredResponseFactory.getOid() ) );
167 }
168
169
170 ControlFactory<PasswordPolicyRequest> passwordPolicyRequestFactory = new PasswordPolicyRequestFactory( apiService );
171 requestControlFactories.put( passwordPolicyRequestFactory.getOid(), passwordPolicyRequestFactory );
172
173 if ( LOG.isInfoEnabled() )
174 {
175 LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, passwordPolicyRequestFactory.getOid() ) );
176 }
177
178
179 ControlFactory<PasswordPolicyResponse> passwordPolicyResponseFactory = new PasswordPolicyResponseFactory( apiService );
180 responseControlFactories.put( passwordPolicyResponseFactory.getOid(), passwordPolicyResponseFactory );
181
182 if ( LOG.isInfoEnabled() )
183 {
184 LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, passwordPolicyResponseFactory.getOid() ) );
185 }
186
187
188 ControlFactory<PermissiveModify> permissiveModifyFactory = new PermissiveModifyFactory( apiService );
189 requestControlFactories.put( permissiveModifyFactory.getOid(), permissiveModifyFactory );
190
191 if ( LOG.isInfoEnabled() )
192 {
193 LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, permissiveModifyFactory.getOid() ) );
194 }
195
196
197 ControlFactory<SyncDoneValue> syncDoneValueFactory = new SyncDoneValueFactory( apiService );
198 responseControlFactories.put( syncDoneValueFactory.getOid(), syncDoneValueFactory );
199
200 if ( LOG.isInfoEnabled() )
201 {
202 LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, syncDoneValueFactory.getOid() ) );
203 }
204
205
206 ControlFactory<SyncRequestValue> syncRequestValueFactory = new SyncRequestValueFactory( apiService );
207 requestControlFactories.put( syncRequestValueFactory.getOid(), syncRequestValueFactory );
208
209 if ( LOG.isInfoEnabled() )
210 {
211 LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, syncRequestValueFactory.getOid() ) );
212 }
213
214
215 ControlFactory<SyncStateValue> syncStateValueFactory = new SyncStateValueFactory( apiService );
216 requestControlFactories.put( syncStateValueFactory.getOid(), syncStateValueFactory );
217 responseControlFactories.put( syncStateValueFactory.getOid(), syncStateValueFactory );
218
219 if ( LOG.isInfoEnabled() )
220 {
221 LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, syncStateValueFactory.getOid() ) );
222 }
223
224
225 ControlFactory<TransactionSpecification> transactionSpecificationFactory = new TransactionSpecificationFactory( apiService );
226 requestControlFactories.put( transactionSpecificationFactory.getOid(), transactionSpecificationFactory );
227
228 if ( LOG.isInfoEnabled() )
229 {
230 LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, transactionSpecificationFactory.getOid() ) );
231 }
232
233
234 ControlFactory<VirtualListViewRequest> virtualListViewRequestFactory = new VirtualListViewRequestFactory(
235 apiService );
236 requestControlFactories.put( virtualListViewRequestFactory.getOid(), virtualListViewRequestFactory );
237
238 if ( LOG.isInfoEnabled() )
239 {
240 LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, virtualListViewRequestFactory.getOid() ) );
241 }
242
243
244 ControlFactory<VirtualListViewResponse> virtualListViewResponseFactory = new VirtualListViewResponseFactory(
245 apiService );
246 responseControlFactories.put( virtualListViewResponseFactory.getOid(), virtualListViewResponseFactory );
247
248 if ( LOG.isInfoEnabled() )
249 {
250 LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, virtualListViewResponseFactory.getOid() ) );
251 }
252
253
254 ControlFactory<RelaxControl> relaxControlFactory = new RelaxControlFactory( apiService );
255 requestControlFactories.put( relaxControlFactory.getOid(), relaxControlFactory );
256
257 if ( LOG.isInfoEnabled() )
258 {
259 LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, relaxControlFactory.getOid() ) );
260 }
261 }
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280 public static void loadExtrasExtendedOperations( LdapApiService apiService )
281 {
282 Map<String, ExtendedOperationFactory> extendedRequestFactories = apiService.getExtendedRequestFactories();
283 Map<String, ExtendedOperationFactory> extendedResponseFactories = apiService.getExtendedResponseFactories();
284
285 CancelFactory cancelFactory = new CancelFactory( apiService );
286 extendedRequestFactories.put( cancelFactory.getOid(), cancelFactory );
287 extendedResponseFactories.put( cancelFactory.getOid(), cancelFactory );
288
289 if ( LOG.isInfoEnabled() )
290 {
291 LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, cancelFactory.getOid() ) );
292 }
293
294 CertGenerationFactory certGenerationFactory = new CertGenerationFactory( apiService );
295 extendedRequestFactories.put( certGenerationFactory.getOid(), certGenerationFactory );
296 extendedResponseFactories.put( certGenerationFactory.getOid(), certGenerationFactory );
297
298 if ( LOG.isInfoEnabled() )
299 {
300 LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, certGenerationFactory.getOid() ) );
301 }
302
303 EndTransactionFactory endTransactionFactory = new EndTransactionFactory( apiService );
304 extendedRequestFactories.put( endTransactionFactory.getOid(), endTransactionFactory );
305 extendedResponseFactories.put( endTransactionFactory.getOid(), endTransactionFactory );
306
307 if ( LOG.isInfoEnabled() )
308 {
309 LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, endTransactionFactory.getOid() ) );
310 }
311
312 GracefulDisconnectFactory gracefulDisconnectFactory = new GracefulDisconnectFactory( apiService );
313 extendedResponseFactories.put( gracefulDisconnectFactory.getOid(), gracefulDisconnectFactory );
314
315 if ( LOG.isInfoEnabled() )
316 {
317 LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, gracefulDisconnectFactory.getOid() ) );
318 }
319
320 GracefulShutdownFactory gracefulShutdownFactory = new GracefulShutdownFactory( apiService );
321 extendedRequestFactories.put( gracefulShutdownFactory.getOid(), gracefulShutdownFactory );
322 extendedResponseFactories.put( gracefulShutdownFactory.getOid(), gracefulShutdownFactory );
323
324
325 if ( LOG.isInfoEnabled() )
326 {
327 LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, gracefulShutdownFactory.getOid() ) );
328 }
329
330 NoDFactory noticeOfDisconnectFactory = new NoDFactory( apiService );
331 extendedResponseFactories.put( noticeOfDisconnectFactory.getOid(), noticeOfDisconnectFactory );
332
333 if ( LOG.isInfoEnabled() )
334 {
335 LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, noticeOfDisconnectFactory.getOid() ) );
336 }
337
338 PasswordModifyFactory passwordModifyFactory = new PasswordModifyFactory( apiService );
339 extendedRequestFactories.put( passwordModifyFactory.getOid(), passwordModifyFactory );
340 extendedResponseFactories.put( passwordModifyFactory.getOid(), passwordModifyFactory );
341
342 if ( LOG.isInfoEnabled() )
343 {
344 LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, passwordModifyFactory.getOid() ) );
345 }
346
347 StartTlsFactory startTlsFactory = new StartTlsFactory( apiService );
348 extendedRequestFactories.put( startTlsFactory.getOid(), startTlsFactory );
349 extendedResponseFactories.put( startTlsFactory.getOid(), startTlsFactory );
350
351 if ( LOG.isInfoEnabled() )
352 {
353 LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, startTlsFactory.getOid() ) );
354 }
355
356 StartTransactionFactory startTransactionFactory = new StartTransactionFactory( apiService );
357 extendedRequestFactories.put( startTransactionFactory.getOid(), startTransactionFactory );
358 extendedResponseFactories.put( startTransactionFactory.getOid(), startTransactionFactory );
359
360 if ( LOG.isInfoEnabled() )
361 {
362 LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, startTransactionFactory.getOid() ) );
363 }
364
365 StoredProcedureFactory storedProcedureFactory = new StoredProcedureFactory( apiService );
366 extendedRequestFactories.put( storedProcedureFactory.getOid(), storedProcedureFactory );
367 extendedResponseFactories.put( storedProcedureFactory.getOid(), storedProcedureFactory );
368
369 if ( LOG.isInfoEnabled() )
370 {
371 LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, storedProcedureFactory.getOid() ) );
372 }
373
374 WhoAmIFactory whoAmIFactory = new WhoAmIFactory( apiService );
375 extendedRequestFactories.put( whoAmIFactory.getOid(), whoAmIFactory );
376 extendedResponseFactories.put( whoAmIFactory.getOid(), whoAmIFactory );
377
378 if ( LOG.isInfoEnabled() )
379 {
380 LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, whoAmIFactory.getOid() ) );
381 }
382 }
383
384
385
386
387
388
389
390
391
392
393 public static void loadExtrasIntermediateResponses( LdapApiService apiService )
394 {
395 Map<String, IntermediateOperationFactory> intermediateResponseFactories = apiService
396 .getIntermediateResponseFactories();
397
398 SyncInfoValueFactory syncInfoValueFactory = new SyncInfoValueFactory();
399 intermediateResponseFactories.put( syncInfoValueFactory.getOid(), syncInfoValueFactory );
400
401 if ( LOG.isInfoEnabled() )
402 {
403 LOG.info( I18n.msg( I18n.MSG_06002_REGISTERED_INTERMEDIATE_FACTORY, syncInfoValueFactory.getOid() ) );
404 }
405 }
406 }