-
Notifications
You must be signed in to change notification settings - Fork 188
/
DummyConfiguration.java
451 lines (373 loc) · 14.7 KB
/
DummyConfiguration.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
/*
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.icf.dummy.connector;
import org.apache.commons.lang.StringUtils;
import org.identityconnectors.common.logging.Log;
import org.identityconnectors.common.security.GuardedString;
import org.identityconnectors.framework.common.exceptions.ConfigurationException;
import org.identityconnectors.framework.spi.AbstractConfiguration;
import org.identityconnectors.framework.spi.ConfigurationProperty;
/**
* Extends the {@link AbstractConfiguration} class to provide all the necessary
* parameters to initialize the Test Connector.
*
*/
public class DummyConfiguration extends AbstractConfiguration {
public static final String UID_MODE_NAME = "name";
public static final String UID_MODE_UUID = "uuid";
public static final String PASSWORD_READABILITY_MODE_UNREADABLE = "unreadable";
public static final String PASSWORD_READABILITY_MODE_INCOMPLETE = "incomplete";
public static final String PASSWORD_READABILITY_MODE_READABLE = "readable";
public static final String PAGING_STRATEGY_NONE = "none";
public static final String PAGING_STRATEGY_OFFSET = "offset";
private static final Log log = Log.getLog(DummyConfiguration.class);
private String instanceId;
private boolean supportSchema = true;
private boolean supportActivation = true;
private boolean supportValidity = false;
private boolean supportRunAs = true;
private String uidMode = UID_MODE_NAME;
private boolean enforceUniqueName = true;
private String passwordReadabilityMode = PASSWORD_READABILITY_MODE_UNREADABLE;
private boolean requireExplicitEnable = false;
private boolean caseIgnoreId = false;
private boolean caseIgnoreValues = false;
private boolean upCaseName = false;
private boolean generateDefaultValues = false;
private boolean tolerateDuplicateValues = true;
private boolean varyLetterCase = false;
private boolean referentialIntegrity = false;
private String uselessString;
private GuardedString uselessGuardedString;
private boolean requireUselessString = false;
private boolean generateAccountDescriptionOnCreate = false; // simulates volatile behavior (on create)
private boolean generateAccountDescriptionOnUpdate = false; // simulates volatile behavior (on update)
private String[] forbiddenNames = new String[0];
private boolean useLegacySchema = true;
private String requiredBaseContextOrgName = null;
private Integer minPasswordLength = null;
private boolean addConnectorStateAttributes = false;
private boolean supportReturnDefaultAttributes = false; // used e.g. for livesync vs. auxiliary object classes test
private boolean requireNameHint = false;
private boolean monsterized = false;
private String pagingStrategy = PAGING_STRATEGY_OFFSET;
private String connectorInstanceNumberAttribute = null;
private String connectorInstanceNameAttribute = null;
/**
* Defines name of the dummy resource instance. There may be several dummy resource running in
* parallel. This ID selects one of them. If not set a default instance will be selected.
*/
@ConfigurationProperty(displayMessageKey = "UI_INSTANCE_ID",
helpMessageKey = "UI_INSTANCE_ID_HELP")
public String getInstanceId() {
return instanceId;
}
public void setInstanceId(String config) {
this.instanceId = config;
}
/**
* If set to false the connector will return UnsupportedOperationException when trying to
* get the schema.
*/
@ConfigurationProperty(displayMessageKey = "UI_SUPPORT_SCHEMA",
helpMessageKey = "UI_SUPPORT_SCHEMA_HELP")
public boolean getSupportSchema() {
return supportSchema;
}
public void setSupportSchema(boolean supportSchema) {
this.supportSchema = supportSchema;
}
/**
* If set to true the connector will expose activation special attribute (ENABLED). True is the default.
*/
@ConfigurationProperty(displayMessageKey = "UI_SUPPORT_ACTIVATION",
helpMessageKey = "UI_SUPPORT_ACTIVATION_HELP")
public boolean getSupportActivation() {
return supportActivation;
}
public void setSupportActivation(boolean supportActivation) {
this.supportActivation = supportActivation;
}
/**
* If set to true the connector will expose the validity ICF special attributes.
*/
@ConfigurationProperty(displayMessageKey = "UI_SUPPORT_VALIDITY",
helpMessageKey = "UI_SUPPORT_VALIDITY_HELP")
public boolean getSupportValidity() {
return supportValidity;
}
public void setSupportValidity(boolean supportValidity) {
this.supportValidity = supportValidity;
}
@ConfigurationProperty(displayMessageKey = "UI_SUPPORT_RUN_AS",
helpMessageKey = "UI_SUPPORT_RUN_AS_HELP")
public boolean getSupportRunAs() {
return supportRunAs;
}
public void setSupportRunAs(boolean supportRunAs) {
this.supportRunAs = supportRunAs;
}
@ConfigurationProperty(displayMessageKey = "UI_UID_MODE",
helpMessageKey = "UI_UID_MODE_HELP")
public String getUidMode() {
return uidMode;
}
public void setUidMode(String uidMode) {
this.uidMode = uidMode;
}
@ConfigurationProperty(displayMessageKey = "UI_ENFORCE_UNIQUE_NAME",
helpMessageKey = "UI_ENFORCE_UNIQUE_NAME")
public boolean isEnforceUniqueName() {
return enforceUniqueName;
}
public void setEnforceUniqueName(boolean enforceUniqueName) {
this.enforceUniqueName = enforceUniqueName;
}
/**
* If set to true then the password can be read from the resource.
*/
@ConfigurationProperty(displayMessageKey = "UI_INSTANCE_READABLE_PASSWORD",
helpMessageKey = "UI_INSTANCE_READABLE_PASSWORD_HELP")
public String getPasswordReadabilityMode() {
return passwordReadabilityMode;
}
public void setPasswordReadabilityMode(String passwordReadabilityMode) {
this.passwordReadabilityMode = passwordReadabilityMode;
}
/**
* If set to true then explicit value for ENABLE attribute must be provided to create an account.
*/
@ConfigurationProperty(displayMessageKey = "UI_INSTANCE_REQUIRE_EXPLICIT_ENABLE",
helpMessageKey = "UI_INSTANCE_REQUIRE_EXPLICIT_ENABLE")
public boolean getRequireExplicitEnable() {
return requireExplicitEnable;
}
public void setRequireExplicitEnable(boolean requireExplicitEnable) {
this.requireExplicitEnable = requireExplicitEnable;
}
/**
* If set to true then the identifiers will be considered case-insensitive
*/
@ConfigurationProperty(displayMessageKey = "UI_CASE_IGNORE_ID",
helpMessageKey = "UI_CASE_IGNORE_ID")
public boolean getCaseIgnoreId() {
return caseIgnoreId;
}
public void setCaseIgnoreId(boolean caseIgnoreId) {
this.caseIgnoreId = caseIgnoreId;
}
/**
* If set to true then the "home dir" will be generated
*/
@ConfigurationProperty(displayMessageKey = "UI_GENERATE_DEFAULT_VALUES",
helpMessageKey = "UI_GENERATE_DEFAULT_VALUES_HELP")
public boolean isGenerateDefaultValues() {
return generateDefaultValues;
}
public void setGenerateDefaultValues(boolean generateDefaultValues) {
this.generateDefaultValues = generateDefaultValues;
}
/**
* If set to true then the attribute values will be considered case-insensitive
*/
@ConfigurationProperty(displayMessageKey = "UI_CASE_IGNORE_VALUES",
helpMessageKey = "UI_CASE_IGNORE_VALUES_HELP")
public boolean getCaseIgnoreValues() {
return caseIgnoreValues;
}
public void setCaseIgnoreValues(boolean caseIgnoreValues) {
this.caseIgnoreValues = caseIgnoreValues;
}
/**
* If set to true then the connector will convert names of all objects to upper case.
*/
@ConfigurationProperty(displayMessageKey = "UI_UPCASE_NAME",
helpMessageKey = "UI_UPCASE_NAME_HELP")
public boolean getUpCaseName() {
return upCaseName;
}
public void setUpCaseName(boolean upCaseName) {
this.upCaseName = upCaseName;
}
@ConfigurationProperty(displayMessageKey = "UI_TOLERATE_DUPLICATE_VALUES",
helpMessageKey = "UI_TOLERATE_DUPLICATE_VALUES_HELP")
public boolean getTolerateDuplicateValues() {
return tolerateDuplicateValues;
}
public void setTolerateDuplicateValues(boolean tolerateDuplicateValues) {
this.tolerateDuplicateValues = tolerateDuplicateValues;
}
/**
* Useless string-value configuration variable. It is used for testing the configuration schema
* and things like that.
*/
@ConfigurationProperty(displayMessageKey = "UI_INSTANCE_USELESS_STRING",
helpMessageKey = "UI_INSTANCE_USELESS_STRING_HELP")
public String getUselessString() {
return uselessString;
}
public void setUselessString(String uselessString) {
this.uselessString = uselessString;
}
/**
* Useless GuardedString-value configuration variable. It is used for testing the configuration schema
* and things like that.
*/
@ConfigurationProperty(displayMessageKey = "UI_INSTANCE_USELESS_GUARDED_STRING",
helpMessageKey = "UI_INSTANCE_USELESS_GUARDED_STRING_HELP")
public GuardedString getUselessGuardedString() {
return uselessGuardedString;
}
public void setUselessGuardedString(GuardedString uselessGuardedString) {
this.uselessGuardedString = uselessGuardedString;
}
@ConfigurationProperty(displayMessageKey = "UI_REQUIRE_USELESS_STRING",
helpMessageKey = "UI_REQUIRE_USELESS_STRING_HELP")
public boolean isRequireUselessString() {
return requireUselessString;
}
public void setRequireUselessString(boolean requireUselessString) {
this.requireUselessString = requireUselessString;
}
@ConfigurationProperty(displayMessageKey = "UI_VARY_LETTER_CASE",
helpMessageKey = "UI_VARY_LETTER_CASE_HELP")
public boolean isVaryLetterCase() {
return varyLetterCase;
}
public void setVaryLetterCase(boolean value) {
this.varyLetterCase = value;
}
@ConfigurationProperty(displayMessageKey = "UI_REFERENTIAL_INTEGRITY",
helpMessageKey = "UI_REFERENTIAL_INTEGRITY_HELP")
public boolean isReferentialIntegrity() {
return referentialIntegrity;
}
public void setReferentialIntegrity(boolean referentialIntegrity) {
this.referentialIntegrity = referentialIntegrity;
}
@ConfigurationProperty(displayMessageKey = "UI_GENERATE_ACCOUNT_DESCRIPTION_ON_CREATE",
helpMessageKey = "UI_GENERATE_ACCOUNT_DESCRIPTION_ON_CREATE_HELP")
public boolean getGenerateAccountDescriptionOnCreate() {
return generateAccountDescriptionOnCreate;
}
public void setGenerateAccountDescriptionOnCreate(boolean generateAccountDescriptionOnCreate) {
this.generateAccountDescriptionOnCreate = generateAccountDescriptionOnCreate;
}
@ConfigurationProperty(displayMessageKey = "UI_GENERATE_ACCOUNT_DESCRIPTION_ON_UPDATE",
helpMessageKey = "UI_GENERATE_ACCOUNT_DESCRIPTION_ON_UPDATE_HELP")
public boolean getGenerateAccountDescriptionOnUpdate() {
return generateAccountDescriptionOnUpdate;
}
public void setGenerateAccountDescriptionOnUpdate(boolean generateAccountDescriptionOnUpdate) {
this.generateAccountDescriptionOnUpdate = generateAccountDescriptionOnUpdate;
}
@ConfigurationProperty(displayMessageKey = "UI_FORBIDDEN_NAMES",
helpMessageKey = "UI_FORBIDDEN_NAMES_HELP")
public String[] getForbiddenNames() {
return forbiddenNames.clone();
}
public void setForbiddenNames(String[] forbiddenNames) {
this.forbiddenNames = forbiddenNames.clone();
}
@ConfigurationProperty(displayMessageKey = "UI_USE_LEGACY_SCHEMA",
helpMessageKey = "UI_USE_LEGACY_SCHEMA_HELP")
public boolean getUseLegacySchema() {
return useLegacySchema;
}
public void setUseLegacySchema(boolean useLegacySchema) {
this.useLegacySchema = useLegacySchema;
}
@ConfigurationProperty(displayMessageKey = "UI_REQUIRED_BASE_CONTEXT_ORG_NAME",
helpMessageKey = "UI_REQUIRED_BASE_CONTEXT_ORG_NAME_HELP")
public String getRequiredBaseContextOrgName() {
return requiredBaseContextOrgName;
}
public void setRequiredBaseContextOrgName(String requiredBaseContextOrgName) {
this.requiredBaseContextOrgName = requiredBaseContextOrgName;
}
public Integer getMinPasswordLength() {
return minPasswordLength;
}
public void setMinPasswordLength(Integer minPasswordLength) {
this.minPasswordLength = minPasswordLength;
}
public boolean isAddConnectorStateAttributes() {
return addConnectorStateAttributes;
}
public void setAddConnectorStateAttributes(boolean addConnectorStateAttributes) {
this.addConnectorStateAttributes = addConnectorStateAttributes;
}
@ConfigurationProperty
public boolean isSupportReturnDefaultAttributes() {
return supportReturnDefaultAttributes;
}
public void setSupportReturnDefaultAttributes(boolean supportReturnDefaultAttributes) {
this.supportReturnDefaultAttributes = supportReturnDefaultAttributes;
}
@ConfigurationProperty
public boolean isRequireNameHint() {
return requireNameHint;
}
public void setRequireNameHint(boolean requireNameHint) {
this.requireNameHint = requireNameHint;
}
@ConfigurationProperty
public boolean isMonsterized() {
return monsterized;
}
public void setMonsterized(boolean monsterized) {
this.monsterized = monsterized;
}
@ConfigurationProperty
public String getPagingStrategy() {
return pagingStrategy;
}
public void setPagingStrategy(String pagingStrategy) {
this.pagingStrategy = pagingStrategy;
}
@ConfigurationProperty
public String getConnectorInstanceNumberAttribute() {
return connectorInstanceNumberAttribute;
}
public void setConnectorInstanceNumberAttribute(String connectorInstanceNumberAttribute) {
this.connectorInstanceNumberAttribute = connectorInstanceNumberAttribute;
}
/**
* Name of the attribute where the connector copies instanceName. So this can be used as assert in the tests.
*/
@ConfigurationProperty
public String getConnectorInstanceNameAttribute() {
return connectorInstanceNameAttribute;
}
public void setConnectorInstanceNameAttribute(String connectorInstanceNameAttribute) {
this.connectorInstanceNameAttribute = connectorInstanceNameAttribute;
}
/**
* {@inheritDoc}
*/
@Override
public void validate() {
log.info("begin");
if (uidMode.equals(UID_MODE_NAME) && !enforceUniqueName) {
throw new IllegalArgumentException("Cannot use name UID mode without enforceUniqueName");
}
log.info("uselessString: {0}", uselessString);
if (requireUselessString && StringUtils.isBlank(uselessString)) {
throw new ConfigurationException("No useless string");
}
log.info("end");
}
}