AutoRefactored code.
Collapsed else { if (...){...} } into else if (...) {...}
Reversed boolean equals conditions using constants.
In tests, used the correct assert*() methods.
| | |
| | | if (!canWrite(file)) { |
| | | println(ERR_DSCFG_CANNOT_WRITE_EQUIVALENT_COMMAND_LINE_FILE.get(file)); |
| | | return ReturnCode.ERROR_UNEXPECTED.get(); |
| | | } else { |
| | | if (new File(file).isDirectory()) { |
| | | println(ERR_DSCFG_EQUIVALENT_COMMAND_LINE_FILE_DIRECTORY.get(file)); |
| | | return ReturnCode.ERROR_UNEXPECTED.get(); |
| | | } |
| | | } else if (new File(file).isDirectory()) { |
| | | println(ERR_DSCFG_EQUIVALENT_COMMAND_LINE_FILE_DIRECTORY.get(file)); |
| | | return ReturnCode.ERROR_UNEXPECTED.get(); |
| | | } |
| | | } |
| | | // Creates the management context factory which is based on the connection |
| | |
| | | |
| | | // Reset the command builder |
| | | getCommandBuilder().clearArguments(); |
| | | |
| | | setCommandBuilderUseful(false); |
| | | |
| | | // Update the command builder. |
| | |
| | | public LocalizableMessage visitAlias(AliasDefaultBehaviorProvider<T> d, Void p) { |
| | | if (app.isVerbose()) { |
| | | return d.getSynopsis(); |
| | | } else { |
| | | return null; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public LocalizableMessage visitDefined(DefinedDefaultBehaviorProvider<T> d, Void p) { |
| | |
| | | } else { |
| | | builder.appendCell(content); |
| | | } |
| | | } else if (isRecordMode()) { |
| | | for (T value : values) { |
| | | builder.startRow(); |
| | | builder.appendCell(pd.getName()); |
| | | builder.appendCell(valuePrinter.print(pd, value)); |
| | | } |
| | | } else { |
| | | if (isRecordMode()) { |
| | | builder.startRow(); |
| | | builder.appendCell(pd.getName()); |
| | | |
| | | if (app.isScriptFriendly()) { |
| | | for (T value : values) { |
| | | builder.startRow(); |
| | | builder.appendCell(pd.getName()); |
| | | builder.appendCell(valuePrinter.print(pd, value)); |
| | | } |
| | | } else { |
| | | builder.startRow(); |
| | | builder.appendCell(pd.getName()); |
| | | |
| | | if (app.isScriptFriendly()) { |
| | | for (T value : values) { |
| | | builder.appendCell(valuePrinter.print(pd, value)); |
| | | StringBuilder sb = new StringBuilder(); |
| | | boolean isFirst = true; |
| | | for (T value : values) { |
| | | if (!isFirst) { |
| | | sb.append(", "); |
| | | } |
| | | } else { |
| | | StringBuilder sb = new StringBuilder(); |
| | | boolean isFirst = true; |
| | | for (T value : values) { |
| | | if (!isFirst) { |
| | | sb.append(", "); |
| | | } |
| | | sb.append(valuePrinter.print(pd, value)); |
| | | isFirst = false; |
| | | } |
| | | |
| | | builder.appendCell(sb.toString()); |
| | | sb.append(valuePrinter.print(pd, value)); |
| | | isFirst = false; |
| | | } |
| | | |
| | | builder.appendCell(sb.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (!oldValues.equals(currentValues)) { |
| | | result = MenuResult.success(true); |
| | | } else { |
| | | result = MenuResult.<Boolean> cancel(); |
| | | result = MenuResult.cancel(); |
| | | } |
| | | |
| | | LocalizableMessage option = getKeepDefaultValuesMenuOption(d, defaultValues, oldValues, currentValues); |
| | |
| | | |
| | | // The second (and possibly third) option is to always change |
| | | // the property's value. |
| | | if (currentValue == null || !currentValue) { |
| | | if (!Boolean.TRUE.equals(currentValue)) { |
| | | LocalizableMessage svalue = getPropertyValues(d, Collections.singleton(true)); |
| | | |
| | | if (defaultValue != null && defaultValue) { |
| | | if (Boolean.TRUE.equals(defaultValue)) { |
| | | option = INFO_EDITOR_OPTION_CHANGE_TO_DEFAULT_VALUE.get(svalue); |
| | | } else { |
| | | option = INFO_EDITOR_OPTION_CHANGE_TO_VALUE.get(svalue); |
| | |
| | | builder.addNumberedOption(option, MenuResult.success(true)); |
| | | } |
| | | |
| | | if (currentValue == null || currentValue) { |
| | | if (!Boolean.FALSE.equals(currentValue)) { |
| | | LocalizableMessage svalue = getPropertyValues(d, Collections.singleton(false)); |
| | | |
| | | if (defaultValue != null && !defaultValue) { |
| | | if (Boolean.FALSE.equals(defaultValue)) { |
| | | option = INFO_EDITOR_OPTION_CHANGE_TO_DEFAULT_VALUE.get(svalue); |
| | | } else { |
| | | option = INFO_EDITOR_OPTION_CHANGE_TO_VALUE.get(svalue); |
| | |
| | | |
| | | // Create the appropriate property action. |
| | | MenuCallback<Boolean> callback; |
| | | if (pd.hasOption(PropertyOption.MULTI_VALUED)) { |
| | | if (isReadOnly) { |
| | | callback = new ReadOnlyPropertyViewer(mo, pd); |
| | | } else { |
| | | callback = new MultiValuedPropertyEditor(mo, pd); |
| | | } |
| | | if (isReadOnly) { |
| | | callback = new ReadOnlyPropertyViewer(mo, pd); |
| | | } else if (pd.hasOption(PropertyOption.MULTI_VALUED)) { |
| | | callback = new MultiValuedPropertyEditor(mo, pd); |
| | | } else { |
| | | if (isReadOnly) { |
| | | callback = new ReadOnlyPropertyViewer(mo, pd); |
| | | } else { |
| | | callback = new SingleValuedPropertyEditor(mo, pd); |
| | | } |
| | | callback = new SingleValuedPropertyEditor(mo, pd); |
| | | } |
| | | |
| | | // Create the numeric option. |
| | |
| | | |
| | | if (result.isSuccess()) { |
| | | if (result.getValue()) { |
| | | return MenuResult.<Void> success(); |
| | | return MenuResult.success(); |
| | | } |
| | | } else if (result.isCancel()) { |
| | | return MenuResult.cancel(); |
| | |
| | | int firstPos = asteriskPositions.removeFirst(); |
| | | if (firstPos == 0) { |
| | | subInitial = null; |
| | | } else if (hasEscape) { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(firstPos); |
| | | escapeHexChars(buffer, attrType, valueBytes, 0, firstPos, equalPos); |
| | | subInitial = buffer.toByteString(); |
| | | } else { |
| | | if (hasEscape) { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(firstPos); |
| | | escapeHexChars(buffer, attrType, valueBytes, 0, firstPos, equalPos); |
| | | subInitial = buffer.toByteString(); |
| | | } else { |
| | | subInitial = ByteString.wrap(valueBytes, 0, firstPos); |
| | | } |
| | | subInitial = ByteString.wrap(valueBytes, 0, firstPos); |
| | | } |
| | | |
| | | // Next, process through the rest of the asterisks to get the subAny |
| | |
| | | this.isCollective = collective; |
| | | this.isNoUserModification = noUserModification; |
| | | this.attributeUsage = attributeUsage; |
| | | this.isObjectClassType = oid.equals("2.5.4.0"); |
| | | this.isObjectClassType = "2.5.4.0".equals(oid); |
| | | this.isPlaceHolder = false; |
| | | this.normalizedName = StaticUtils.toLowerCase(getNameOrOID()); |
| | | } |
| | |
| | | if (tokenName == null) { |
| | | // No more tokens. |
| | | break; |
| | | } else if (tokenName.equalsIgnoreCase("name")) { |
| | | } else if ("name".equalsIgnoreCase(tokenName)) { |
| | | SchemaUtils.readNameDescriptors(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("desc")) { |
| | | } else if ("desc".equalsIgnoreCase(tokenName)) { |
| | | // This specifies the description for the attribute type. It |
| | | // is an arbitrary string of characters enclosed in single |
| | | // quotes. |
| | | SchemaUtils.readQuotedString(reader); |
| | | } else if (tokenName.equalsIgnoreCase("obsolete")) { |
| | | } else if ("obsolete".equalsIgnoreCase(tokenName)) { |
| | | // This indicates whether the attribute type should be |
| | | // considered obsolete. We do not need to do any more |
| | | // parsing |
| | | // for this token. |
| | | } else if (tokenName.equalsIgnoreCase("sup")) { |
| | | // parsing for this token. |
| | | } else if ("sup".equalsIgnoreCase(tokenName)) { |
| | | // This specifies the name or OID of the superior attribute |
| | | // type from which this attribute type should inherit its |
| | | // properties. |
| | | SchemaUtils.readOID(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("equality")) { |
| | | } else if ("equality".equalsIgnoreCase(tokenName)) { |
| | | // This specifies the name or OID of the equality matching |
| | | // rule to use for this attribute type. |
| | | SchemaUtils.readOID(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("ordering")) { |
| | | } else if ("ordering".equalsIgnoreCase(tokenName)) { |
| | | // This specifies the name or OID of the ordering matching |
| | | // rule to use for this attribute type. |
| | | SchemaUtils.readOID(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("substr")) { |
| | | } else if ("substr".equalsIgnoreCase(tokenName)) { |
| | | // This specifies the name or OID of the substring matching |
| | | // rule to use for this attribute type. |
| | | SchemaUtils.readOID(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("syntax")) { |
| | | } else if ("syntax".equalsIgnoreCase(tokenName)) { |
| | | // This specifies the numeric OID of the syntax for this |
| | | // matching rule. It may optionally be immediately followed |
| | | // by |
| | |
| | | // not impose any practical limit on the length of attribute |
| | | // values. |
| | | SchemaUtils.readOIDLen(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("single-definition")) { |
| | | // This indicates that attributes of this type are allowed |
| | | // to |
| | | } else if ("single-definition".equalsIgnoreCase(tokenName)) { |
| | | // This indicates that attributes of this type are allowed to |
| | | // have at most one definition. We do not need any more |
| | | // parsing for this token. |
| | | } else if (tokenName.equalsIgnoreCase("single-value")) { |
| | | } else if ("single-value".equalsIgnoreCase(tokenName)) { |
| | | // This indicates that attributes of this type are allowed |
| | | // to |
| | | // have at most one value. We do not need any more parsing |
| | | // for |
| | | // this token. |
| | | } else if (tokenName.equalsIgnoreCase("collective")) { |
| | | // This indicates that attributes of this type are |
| | | // collective |
| | | // (i.e., have their values generated dynamically in some |
| | | // way). We do not need any more parsing for this token. |
| | | } else if (tokenName.equalsIgnoreCase("no-user-modification")) { |
| | | // to have at most one value. |
| | | // We do not need any more parsing for this token. |
| | | } else if ("collective".equalsIgnoreCase(tokenName)) { |
| | | // This indicates that attributes of this type are collective |
| | | // (i.e., have their values generated dynamically in some way). |
| | | // We do not need any more parsing for this token. |
| | | } else if ("no-user-modification".equalsIgnoreCase(tokenName)) { |
| | | // This indicates that the values of attributes of this type |
| | | // are not to be modified by end users. We do not need any |
| | | // more parsing for this token. |
| | | } else if (tokenName.equalsIgnoreCase("usage")) { |
| | | } else if ("usage".equalsIgnoreCase(tokenName)) { |
| | | // This specifies the usage string for this attribute type. |
| | | // It |
| | | // should be followed by one of the strings |
| | | // It should be followed by one of the strings |
| | | // "userApplications", "directoryOperation", |
| | | // "distributedOperation", or "dSAOperation". |
| | | int length = 0; |
| | |
| | | |
| | | reader.reset(); |
| | | final String usageStr = reader.read(length); |
| | | if (!usageStr.equalsIgnoreCase("userapplications") |
| | | && !usageStr.equalsIgnoreCase("directoryoperation") |
| | | && !usageStr.equalsIgnoreCase("distributedoperation") |
| | | && !usageStr.equalsIgnoreCase("dsaoperation")) { |
| | | if (!"userapplications".equalsIgnoreCase(usageStr) |
| | | && !"directoryoperation".equalsIgnoreCase(usageStr) |
| | | && !"distributedoperation".equalsIgnoreCase(usageStr) |
| | | && !"dsaoperation".equalsIgnoreCase(usageStr)) { |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_ATTRTYPE_INVALID_ATTRIBUTE_USAGE1.get(definition, |
| | | usageStr); |
| | |
| | | } else if (tokenName.matches("^X-[A-Za-z_-]+$")) { |
| | | // This must be a non-standard property and it must be |
| | | // followed by either a single definition in single quotes |
| | | // or |
| | | // an open parenthesis followed by one or more values in |
| | | // or an open parenthesis followed by one or more values in |
| | | // single quotes separated by spaces followed by a close |
| | | // parenthesis. |
| | | SchemaUtils.readExtensions(reader); |
| | |
| | | try { |
| | | // the first namedValue is serialNumber |
| | | identifier = parser.nextNamedValueIdentifier(); |
| | | if (!identifier.equals(GSER_ID_SERIALNUMBER)) { |
| | | LocalizableMessage message = |
| | | ERR_MR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND.get(GSER_ID_SERIALNUMBER); |
| | | throw DecodeException.error(message); |
| | | if (!GSER_ID_SERIALNUMBER.equals(identifier)) { |
| | | throw DecodeException.error( |
| | | ERR_MR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND.get(GSER_ID_SERIALNUMBER)); |
| | | } |
| | | |
| | | // The value for the serialNumber |
| | |
| | | |
| | | // the next namedValue is issuer |
| | | identifier = parser.nextNamedValueIdentifier(); |
| | | if (!identifier.equals(GSER_ID_ISSUER)) { |
| | | LocalizableMessage message = |
| | | ERR_MR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND.get(GSER_ID_ISSUER); |
| | | throw DecodeException.error(message); |
| | | if (!GSER_ID_ISSUER.equals(identifier)) { |
| | | throw DecodeException.error( |
| | | ERR_MR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND.get(GSER_ID_ISSUER)); |
| | | } |
| | | |
| | | // expecting "rdnSequence:" |
| | | identifier = parser.nextChoiceValueIdentifier(); |
| | | if (!identifier.equals(GSER_ID_RDNSEQUENCE)) { |
| | | LocalizableMessage message = |
| | | ERR_MR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND.get(GSER_ID_RDNSEQUENCE); |
| | | throw DecodeException.error(message); |
| | | if (!GSER_ID_RDNSEQUENCE.equals(identifier)) { |
| | | throw DecodeException.error( |
| | | ERR_MR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND.get(GSER_ID_RDNSEQUENCE)); |
| | | } |
| | | |
| | | // now the issuer dn |
| | |
| | | if (tokenName == null) { |
| | | // No more tokens. |
| | | break; |
| | | } else if (tokenName.equalsIgnoreCase("name")) { |
| | | } else if ("name".equalsIgnoreCase(tokenName)) { |
| | | SchemaUtils.readNameDescriptors(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("desc")) { |
| | | } else if ("desc".equalsIgnoreCase(tokenName)) { |
| | | // This specifies the description for the attribute type. It |
| | | // is an arbitrary string of characters enclosed in single |
| | | // quotes. |
| | | SchemaUtils.readQuotedString(reader); |
| | | } else if (tokenName.equalsIgnoreCase("obsolete")) { |
| | | } else if ("obsolete".equalsIgnoreCase(tokenName)) { |
| | | // This indicates whether the attribute type should be |
| | | // considered obsolete. We do not need to do any more |
| | | // parsing |
| | | // for this token. |
| | | } else if (tokenName.equalsIgnoreCase("aux")) { |
| | | // parsing for this token. |
| | | } else if ("aux".equalsIgnoreCase(tokenName)) { |
| | | SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("must")) { |
| | | } else if ("must".equalsIgnoreCase(tokenName)) { |
| | | SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("may")) { |
| | | } else if ("may".equalsIgnoreCase(tokenName)) { |
| | | SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("not")) { |
| | | } else if ("not".equalsIgnoreCase(tokenName)) { |
| | | SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.matches("^X-[A-Za-z_-]+$")) { |
| | | // This must be a non-standard property and it must be |
| | | // followed by either a single definition in single quotes |
| | | // or |
| | | // an open parenthesis followed by one or more values in |
| | | // or an open parenthesis followed by one or more values in |
| | | // single quotes separated by spaces followed by a close |
| | | // parenthesis. |
| | | SchemaUtils.readExtensions(reader); |
| | |
| | | if (tokenName == null) { |
| | | // No more tokens. |
| | | break; |
| | | } else if (tokenName.equalsIgnoreCase("name")) { |
| | | } else if ("name".equalsIgnoreCase(tokenName)) { |
| | | SchemaUtils.readNameDescriptors(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("desc")) { |
| | | } else if ("desc".equalsIgnoreCase(tokenName)) { |
| | | // This specifies the description for the attribute type. It |
| | | // is an arbitrary string of characters enclosed in single |
| | | // quotes. |
| | | SchemaUtils.readQuotedString(reader); |
| | | } else if (tokenName.equalsIgnoreCase("obsolete")) { |
| | | } else if ("obsolete".equalsIgnoreCase(tokenName)) { |
| | | // This indicates whether the attribute type should be |
| | | // considered obsolete. We do not need to do any more |
| | | // parsing |
| | | // for this token. |
| | | } else if (tokenName.equalsIgnoreCase("form")) { |
| | | // parsing for this token. |
| | | } else if ("form".equalsIgnoreCase(tokenName)) { |
| | | nameForm = SchemaUtils.readOID(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("sup")) { |
| | | } else if ("sup".equalsIgnoreCase(tokenName)) { |
| | | SchemaUtils.readRuleIDs(reader); |
| | | } else if (tokenName.matches("^X-[A-Za-z_-]+$")) { |
| | | // This must be a non-standard property and it must be |
| | | // followed by either a single definition in single quotes |
| | | // or |
| | | // an open parenthesis followed by one or more values in |
| | | // or an open parenthesis followed by one or more values in |
| | | // single quotes separated by spaces followed by a close |
| | | // parenthesis. |
| | | SchemaUtils.readExtensions(reader); |
| | |
| | | } |
| | | |
| | | final String scopeStr = valueStr.substring(lastSharpPos + 1).trim(); |
| | | if (!(scopeStr.equals("baseobject") || scopeStr.equals("onelevel") |
| | | || scopeStr.equals("wholesubtree") || scopeStr.equals("subordinatesubtree"))) { |
| | | if (!"baseobject".equals(scopeStr) && !"onelevel".equals(scopeStr) |
| | | && !"wholesubtree".equals(scopeStr) && !"subordinatesubtree".equals(scopeStr)) { |
| | | if (scopeStr.length() == 0) { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_ENHANCEDGUIDE_NO_SCOPE.get(valueStr)); |
| | | } else { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_ENHANCEDGUIDE_INVALID_SCOPE.get(valueStr, |
| | | scopeStr)); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | |
| | | if (c == '$') { |
| | | pos++; |
| | | break; |
| | | } else { |
| | | if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_NOT_PRINTABLE.get(valueString, |
| | | String.valueOf(c), pos)); |
| | | } |
| | | } else if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_NOT_PRINTABLE.get(valueString, c, pos)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // See if the criteria is either "true" or "false". If so, then it |
| | | // is valid. |
| | | if (criteria.equals("true") || criteria.equals("false")) { |
| | | if ("true".equals(criteria) || "false".equals(criteria)) { |
| | | return true; |
| | | } |
| | | |
| | |
| | | if (tokenName == null) { |
| | | // No more tokens. |
| | | break; |
| | | } else if (tokenName.equalsIgnoreCase("desc")) { |
| | | } else if ("desc".equalsIgnoreCase(tokenName)) { |
| | | // This specifies the description for the syntax. It is an |
| | | // arbitrary string of characters enclosed in single quotes. |
| | | SchemaUtils.readQuotedString(reader); |
| | | } else if (tokenName.matches("^X-[A-Za-z_-]+$")) { |
| | | // This must be a non-standard property and it must be |
| | | // followed by either a single definition in single quotes |
| | | // or |
| | | // an open parenthesis followed by one or more values in |
| | | // or an open parenthesis followed by one or more values in |
| | | // single quotes separated by spaces followed by a close |
| | | // parenthesis. |
| | | if (extraProperties.isEmpty()) { |
| | |
| | | } |
| | | |
| | | for (final Map.Entry<String, List<String>> property : extraProperties.entrySet()) { |
| | | if (property.getKey().equalsIgnoreCase("x-pattern")) { |
| | | if ("x-pattern".equalsIgnoreCase(property.getKey())) { |
| | | final Iterator<String> values = property.getValue().iterator(); |
| | | if (values.hasNext()) { |
| | | final String pattern = values.next(); |
| | |
| | | } |
| | | break; |
| | | } |
| | | } else if (property.getKey().equalsIgnoreCase("x-enum")) { |
| | | } else if ("x-enum".equalsIgnoreCase(property.getKey())) { |
| | | final List<String> values = property.getValue(); |
| | | for (int i = 0; i < values.size() - 1; i++) { |
| | | final String entry = values.get(i); |
| | |
| | | if (tokenName == null) { |
| | | // No more tokens. |
| | | break; |
| | | } else if (tokenName.equalsIgnoreCase("name")) { |
| | | } else if ("name".equalsIgnoreCase(tokenName)) { |
| | | SchemaUtils.readNameDescriptors(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("desc")) { |
| | | } else if ("desc".equalsIgnoreCase(tokenName)) { |
| | | // This specifies the description for the matching rule. It |
| | | // is |
| | | // an arbitrary string of characters enclosed in single |
| | | // quotes. |
| | | SchemaUtils.readQuotedString(reader); |
| | | } else if (tokenName.equalsIgnoreCase("obsolete")) { |
| | | } else if ("obsolete".equalsIgnoreCase(tokenName)) { |
| | | // This indicates whether the matching rule should be |
| | | // considered obsolete. We do not need to do any more |
| | | // parsing |
| | | // for this token. |
| | | } else if (tokenName.equalsIgnoreCase("syntax")) { |
| | | // parsing for this token. |
| | | } else if ("syntax".equalsIgnoreCase(tokenName)) { |
| | | syntax = SchemaUtils.readOID(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.matches("^X-[A-Za-z_-]+$")) { |
| | | // This must be a non-standard property and it must be |
| | | // followed by either a single definition in single quotes |
| | | // or |
| | | // an open parenthesis followed by one or more values in |
| | | // or an open parenthesis followed by one or more values in |
| | | // single quotes separated by spaces followed by a close |
| | | // parenthesis. |
| | | SchemaUtils.readExtensions(reader); |
| | |
| | | if (tokenName == null) { |
| | | // No more tokens. |
| | | break; |
| | | } else if (tokenName.equalsIgnoreCase("name")) { |
| | | } else if ("name".equalsIgnoreCase(tokenName)) { |
| | | SchemaUtils.readNameDescriptors(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("desc")) { |
| | | } else if ("desc".equalsIgnoreCase(tokenName)) { |
| | | // This specifies the description for the attribute type. It |
| | | // is an arbitrary string of characters enclosed in single |
| | | // quotes. |
| | | SchemaUtils.readQuotedString(reader); |
| | | } else if (tokenName.equalsIgnoreCase("obsolete")) { |
| | | } else if ("obsolete".equalsIgnoreCase(tokenName)) { |
| | | // This indicates whether the attribute type should be |
| | | // considered obsolete. We do not need to do any more |
| | | // parsing |
| | | // for this token. |
| | | } else if (tokenName.equalsIgnoreCase("applies")) { |
| | | // parsing for this token. |
| | | } else if ("applies".equalsIgnoreCase(tokenName)) { |
| | | attributes = |
| | | SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.matches("^X-[A-Za-z_-]+$")) { |
| | | // This must be a non-standard property and it must be |
| | | // followed by either a single definition in single quotes |
| | | // or |
| | | // an open parenthesis followed by one or more values in |
| | | // or an open parenthesis followed by one or more values in |
| | | // single quotes separated by spaces followed by a close |
| | | // parenthesis. |
| | | SchemaUtils.readExtensions(reader); |
| | |
| | | if (tokenName == null) { |
| | | // No more tokens. |
| | | break; |
| | | } else if (tokenName.equalsIgnoreCase("name")) { |
| | | } else if ("name".equalsIgnoreCase(tokenName)) { |
| | | SchemaUtils.readNameDescriptors(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("desc")) { |
| | | } else if ("desc".equalsIgnoreCase(tokenName)) { |
| | | // This specifies the description for the attribute type. It |
| | | // is an arbitrary string of characters enclosed in single |
| | | // quotes. |
| | | SchemaUtils.readQuotedString(reader); |
| | | } else if (tokenName.equalsIgnoreCase("obsolete")) { |
| | | } else if ("obsolete".equalsIgnoreCase(tokenName)) { |
| | | // This indicates whether the attribute type should be |
| | | // considered obsolete. We do not need to do any more |
| | | // parsing |
| | | // for this token. |
| | | } else if (tokenName.equalsIgnoreCase("oc")) { |
| | | // parsing for this token. |
| | | } else if ("oc".equalsIgnoreCase(tokenName)) { |
| | | structuralClass = |
| | | SchemaUtils.readOID(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("must")) { |
| | | } else if ("must".equalsIgnoreCase(tokenName)) { |
| | | requiredAttributes = |
| | | SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("may")) { |
| | | } else if ("may".equalsIgnoreCase(tokenName)) { |
| | | SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.matches("^X-[A-Za-z_-]+$")) { |
| | | // This must be a non-standard property and it must be |
| | | // followed by either a single definition in single quotes |
| | | // or |
| | | // an open parenthesis followed by one or more values in |
| | | // or an open parenthesis followed by one or more values in |
| | | // single quotes separated by spaces followed by a close |
| | | // parenthesis. |
| | | SchemaUtils.readExtensions(reader); |
| | |
| | | if (tokenName == null) { |
| | | // No more tokens. |
| | | break; |
| | | } else if (tokenName.equalsIgnoreCase("name")) { |
| | | } else if ("name".equalsIgnoreCase(tokenName)) { |
| | | SchemaUtils.readNameDescriptors(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("desc")) { |
| | | } else if ("desc".equalsIgnoreCase(tokenName)) { |
| | | // This specifies the description for the attribute type. It |
| | | // is an arbitrary string of characters enclosed in single |
| | | // quotes. |
| | | SchemaUtils.readQuotedString(reader); |
| | | } else if (tokenName.equalsIgnoreCase("obsolete")) { |
| | | } else if ("obsolete".equalsIgnoreCase(tokenName)) { |
| | | // This indicates whether the attribute type should be |
| | | // considered obsolete. We do not need to do any more |
| | | // parsing |
| | | // for this token. |
| | | } else if (tokenName.equalsIgnoreCase("sup")) { |
| | | // parsing for this token. |
| | | } else if ("sup".equalsIgnoreCase(tokenName)) { |
| | | SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("abstract")) { |
| | | } else if ("abstract".equalsIgnoreCase(tokenName)) { |
| | | // This indicates that entries must not include this |
| | | // objectclass unless they also include a non-abstract |
| | | // objectclass that inherits from this class. We do not need |
| | | // any more parsing for this token. |
| | | } else if (tokenName.equalsIgnoreCase("structural")) { |
| | | } else if ("structural".equalsIgnoreCase(tokenName)) { |
| | | // This indicates that this is a structural objectclass. |
| | | // We do not need any more parsing for this token. |
| | | } else if (tokenName.equalsIgnoreCase("auxiliary")) { |
| | | } else if ("auxiliary".equalsIgnoreCase(tokenName)) { |
| | | // This indicates that this is an auxiliary objectclass. |
| | | // We do not need any more parsing for this token. |
| | | } else if (tokenName.equalsIgnoreCase("must")) { |
| | | } else if ("must".equalsIgnoreCase(tokenName)) { |
| | | SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.equalsIgnoreCase("may")) { |
| | | } else if ("may".equalsIgnoreCase(tokenName)) { |
| | | SchemaUtils.readOIDs(reader, schema.allowMalformedNamesAndOptions()); |
| | | } else if (tokenName.matches("^X-[A-Za-z_-]+$")) { |
| | | // This must be a non-standard property and it must be |
| | | // followed by either a single definition in single quotes |
| | | // or |
| | | // an open parenthesis followed by one or more values in |
| | | // or an open parenthesis followed by one or more values in |
| | | // single quotes separated by spaces followed by a close |
| | | // parenthesis. |
| | | SchemaUtils.readExtensions(reader); |
| | |
| | | // See if we need to override the implementation of the syntax |
| | | for (final Map.Entry<String, List<String>> property : getExtraProperties().entrySet()) { |
| | | // Enums are handled in the schema builder. |
| | | if (property.getKey().equalsIgnoreCase("x-subst")) { |
| | | if ("x-subst".equalsIgnoreCase(property.getKey())) { |
| | | /** |
| | | * One unimplemented syntax can be substituted by another |
| | | * defined syntax. A substitution syntax is an |
| | |
| | | } |
| | | impl = subSyntax.impl; |
| | | } |
| | | } else if (property.getKey().equalsIgnoreCase("x-pattern")) { |
| | | } else if ("x-pattern".equalsIgnoreCase(property.getKey())) { |
| | | final Iterator<String> values = property.getValue().iterator(); |
| | | if (values.hasNext()) { |
| | | final String value = values.next(); |
| | |
| | | if (c == '$') { |
| | | pos++; |
| | | break; |
| | | } else { |
| | | if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_NOT_PRINTABLE.get(valueString, |
| | | String.valueOf(c), pos)); |
| | | } |
| | | } else if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_NOT_PRINTABLE.get(valueString, c, pos)); |
| | | } |
| | | } |
| | | |
| | |
| | | if (c == '$') { |
| | | pos++; |
| | | break; |
| | | } else { |
| | | if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEX_ILLEGAL_CHAR.get(valueString, String |
| | | .valueOf(c), pos)); |
| | | } |
| | | } else if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEX_ILLEGAL_CHAR.get(valueString, c, pos)); |
| | | } |
| | | } |
| | | |
| | |
| | | if (c == '$') { |
| | | pos++; |
| | | break; |
| | | } else { |
| | | if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEX_ILLEGAL_CHAR.get(valueString, String |
| | | .valueOf(c), pos)); |
| | | return false; |
| | | } |
| | | } else if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEX_ILLEGAL_CHAR.get(valueString, c, pos)); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | String attrName = toLowerCase(ldifLine.substring(0, colonPos)); |
| | | if (attrName.equals("version")) { |
| | | if ("version".equals(attrName)) { |
| | | // This is the version line, try the next line if there is one. |
| | | if (!record.iterator.hasNext()) { |
| | | return null; |
| | |
| | | attrName = toLowerCase(ldifLine.substring(0, colonPos)); |
| | | } |
| | | |
| | | if (!attrName.equals("dn")) { |
| | | if (!"dn".equals(attrName)) { |
| | | throw DecodeException.error(ERR_LDIF_NO_DN.get(record.lineNumber, ldifLine)); |
| | | } |
| | | |
| | |
| | | } else { |
| | | final Entry filteredEntry = new LinkedHashMapEntry(entry.getName()); |
| | | for (final String atd : search.getAttributes()) { |
| | | if (atd.equals("*")) { |
| | | if ("*".equals(atd)) { |
| | | for (final Attribute attribute : entry.getAllAttributes()) { |
| | | if (attribute.getAttributeDescription().getAttributeType() |
| | | .getUsage() == AttributeUsage.USER_APPLICATIONS) { |
| | |
| | | } |
| | | } |
| | | } |
| | | } else if (atd.equals("+")) { |
| | | } else if ("+".equals(atd)) { |
| | | for (final Attribute attribute : entry.getAllAttributes()) { |
| | | if (attribute.getAttributeDescription().getAttributeType() |
| | | .getUsage() != AttributeUsage.USER_APPLICATIONS) { |
| | |
| | | // "sequential" or "random". If there isn't one, then we should |
| | | // assume "random". |
| | | if (arguments.length == 2) { |
| | | if (arguments[1].equalsIgnoreCase("sequential")) { |
| | | if ("sequential".equalsIgnoreCase(arguments[1])) { |
| | | isSequential = true; |
| | | nextIndex = 0; |
| | | } else if (arguments[1].equalsIgnoreCase("random")) { |
| | | } else if ("random".equalsIgnoreCase(arguments[1])) { |
| | | isSequential = false; |
| | | } else { |
| | | LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_FILE_ACCESS_MODE.get(arguments[1], |
| | | getName(), lineNumber); |
| | | throw DecodeException.fatalError(message); |
| | | throw DecodeException.fatalError( |
| | | ERR_ENTRY_GENERATOR_TAG_INVALID_FILE_ACCESS_MODE.get(arguments[1], getName(), lineNumber)); |
| | | } |
| | | } else { |
| | | isSequential = false; |
| | |
| | | int numArgs = arguments.length; |
| | | String randomTypeString = arguments[0].toLowerCase(); |
| | | |
| | | if (randomTypeString.equals("alpha")) { |
| | | if ("alpha".equals(randomTypeString)) { |
| | | characterSet = ALPHA_CHARS; |
| | | decodeLength(arguments, 1, lineNumber, warnings); |
| | | } else if (randomTypeString.equals("numeric")) { |
| | | } else if ("numeric".equals(randomTypeString)) { |
| | | if (numArgs == 2) { |
| | | randomType = RandomType.CHARS_FIXED; |
| | | characterSet = NUMERIC_CHARS; |
| | |
| | | lineNumber, 2, 4, numArgs); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | } else if (randomTypeString.equals("alphanumeric")) { |
| | | } else if ("alphanumeric".equals(randomTypeString)) { |
| | | characterSet = ALPHANUMERIC_CHARS; |
| | | decodeLength(arguments, 1, lineNumber, warnings); |
| | | } else if (randomTypeString.equals("chars")) { |
| | | } else if ("chars".equals(randomTypeString)) { |
| | | if (numArgs < 3 || numArgs > 4) { |
| | | LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), |
| | | lineNumber, 3, 4, numArgs); |
| | |
| | | |
| | | characterSet = arguments[1].toCharArray(); |
| | | decodeLength(arguments, 2, lineNumber, warnings); |
| | | } else if (randomTypeString.equals("hex")) { |
| | | } else if ("hex".equals(randomTypeString)) { |
| | | characterSet = HEX_CHARS; |
| | | decodeLength(arguments, 1, lineNumber, warnings); |
| | | } else if (randomTypeString.equals("base64")) { |
| | | } else if ("base64".equals(randomTypeString)) { |
| | | characterSet = BASE64_CHARS; |
| | | decodeLength(arguments, 1, lineNumber, warnings); |
| | | } else if (randomTypeString.equals("month")) { |
| | | } else if ("month".equals(randomTypeString)) { |
| | | randomType = RandomType.MONTH; |
| | | |
| | | if (numArgs == 1) { |
| | |
| | | lineNumber, 1, 2, numArgs); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | } else if (randomTypeString.equals("telephone")) { |
| | | } else if ("telephone".equals(randomTypeString)) { |
| | | randomType = RandomType.TELEPHONE; |
| | | } else { |
| | | LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_UNKNOWN_RANDOM_TYPE.get(lineNumber, |
| | |
| | | } |
| | | |
| | | private void initializeReset(String resetValue, int lineNumber) throws DecodeException { |
| | | if (resetValue.equalsIgnoreCase("true")) { |
| | | if ("true".equalsIgnoreCase(resetValue)) { |
| | | resetOnNewParents = true; |
| | | } else if (resetValue.equalsIgnoreCase("false")) { |
| | | } else if ("false".equalsIgnoreCase(resetValue)) { |
| | | resetOnNewParents = false; |
| | | } else { |
| | | throw DecodeException.fatalError(ERR_ENTRY_GENERATOR_TAG_CANNOT_PARSE_AS_BOOLEAN.get( |
| | |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap.controls; |
| | | |
| | | import static org.testng.Assert.assertTrue; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.responses.SearchResultEntry; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Tests the account usability request control. |
| | | */ |
| | |
| | | assertTrue(entries.size() > 0); |
| | | final SearchResultEntry entry = entries.get(0); |
| | | final Control ctrl = entry.getControls().get(0); |
| | | if (!ctrl.getOID().equals("1.3.6.1.4.1.42.2.27.9.5.8")) { |
| | | throw new Exception("expected control response 1.3.6.1.4.1.42.2.27.9.5.8"); |
| | | } |
| | | assertEquals(ctrl.getOID(), "1.3.6.1.4.1.42.2.27.9.5.8", "expected control response 1.3.6.1.4.1.42.2.27.9.5.8"); |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.forgerock.opendj.io; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * An abstract base class for all ASN1Writer test cases. |
| | | */ |
| | |
| | | public void testEncodeDecodeOctetString(final String s) throws Exception { |
| | | getWriter().writeOctetString(s); |
| | | |
| | | final String expected = s != null ? s : ""; |
| | | final ASN1Reader r = getReader(getEncodedBytes()); |
| | | if (s == null) { |
| | | assertEquals(r.peekLength(), 0); |
| | | } else { |
| | | assertEquals(r.peekLength(), StaticUtils.getBytes(s).length); |
| | | } |
| | | assertEquals(r.peekLength(), StaticUtils.getBytes(expected).length); |
| | | assertEquals(r.peekType(), ASN1.UNIVERSAL_OCTET_STRING_TYPE); |
| | | if (s == null) { |
| | | assertTrue(r.readOctetStringAsString().equals("")); |
| | | } else { |
| | | assertTrue(s.equals(r.readOctetStringAsString())); |
| | | } |
| | | assertEquals(r.readOctetStringAsString(), expected); |
| | | } |
| | | |
| | | /** |
| | |
| | | for (final byte type : testTypes) { |
| | | getWriter().writeOctetString(type, s); |
| | | |
| | | final String expected = s != null ? s : ""; |
| | | final ASN1Reader r = getReader(getEncodedBytes()); |
| | | if (s == null) { |
| | | assertEquals(r.peekLength(), 0); |
| | | } else { |
| | | assertEquals(r.peekLength(), StaticUtils.getBytes(s).length); |
| | | } |
| | | assertEquals(r.peekLength(), StaticUtils.getBytes(expected).length); |
| | | assertEquals(r.peekType(), type); |
| | | if (s == null) { |
| | | assertTrue(r.readOctetStringAsString().equals("")); |
| | | } else { |
| | | assertTrue(s.equals(r.readOctetStringAsString())); |
| | | } |
| | | assertEquals(r.readOctetStringAsString(), expected); |
| | | } |
| | | } |
| | | |
| | |
| | | .setServerSASLCredentials(ByteString.wrap(challenge))); |
| | | |
| | | String qop = (String) saslServer.getNegotiatedProperty(Sasl.QOP); |
| | | if (qop != null |
| | | && (qop.equalsIgnoreCase("auth-int") || qop |
| | | .equalsIgnoreCase("auth-conf"))) { |
| | | if ("auth-int".equalsIgnoreCase(qop) || "auth-conf".equalsIgnoreCase(qop)) { |
| | | ConnectionSecurityLayer csl = new ConnectionSecurityLayer() { |
| | | @Override |
| | | public void dispose() { |
| | |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | | final ResultHandler<R> resultHandler) throws UnsupportedOperationException { |
| | | if (request.getOID().equals(StartTLSExtendedRequest.OID)) { |
| | | final R result = |
| | | request.getResultDecoder().newExtendedErrorResult(ResultCode.SUCCESS, "", |
| | | ""); |
| | | final R result = request.getResultDecoder().newExtendedErrorResult(ResultCode.SUCCESS, "", ""); |
| | | resultHandler.handleResult(result); |
| | | clientContext.enableTLS(sslContext, null, sslContext.getSocketFactory() |
| | | .getSupportedCipherSuites(), false, false); |
| | |
| | | |
| | | assertThat(((ModifyRequest) cr).getModifications().size()).isEqualTo(3); |
| | | for (Modification mod : ((ModifyRequest) cr).getModifications()) { |
| | | final String attrDescription = mod.getAttribute().getAttributeDescription().toString(); |
| | | final String firstValueAsString = mod.getAttribute().firstValueAsString(); |
| | | if (mod.getModificationType() == ModificationType.ADD) { |
| | | assertThat(mod.getAttribute().getAttributeDescription().toString().equals("description") |
| | | || mod.getAttribute().getAttributeDescription().toString().equals("userPassword")); |
| | | assertThat(mod.getAttribute().firstValueAsString().equals("A new description.") |
| | | || mod.getAttribute().firstValueAsString().equals("secret12")); |
| | | } |
| | | if (mod.getModificationType() == ModificationType.DELETE) { |
| | | assertThat(mod.getAttribute().getAttributeDescription().toString()).isEqualTo("userPassword"); |
| | | assertThat(mod.getAttribute().firstValueAsString()).isEqualTo("changeme"); |
| | | assertThat(attrDescription).isIn("description", "userPassword"); |
| | | assertThat(firstValueAsString).isIn("A new description.", "secret12"); |
| | | } else if (mod.getModificationType() == ModificationType.DELETE) { |
| | | assertThat(attrDescription).isEqualTo("userPassword"); |
| | | assertThat(firstValueAsString).isEqualTo("changeme"); |
| | | } |
| | | } |
| | | reader.close(); |
| | |
| | | if (ldapConnection != null) { |
| | | if (messageID == 0) { |
| | | // Unsolicited notification received. |
| | | if (result.getOID() != null && result.getOID().equals(LDAP.OID_NOTICE_OF_DISCONNECTION)) { |
| | | if (LDAP.OID_NOTICE_OF_DISCONNECTION.equals(result.getOID())) { |
| | | // Treat this as a connection error. |
| | | final Result errorResult = newResult(result.getResultCode()).setDiagnosticMessage( |
| | | result.getDiagnosticMessage()); |
| | |
| | | final ExtendedResult result) throws DecodeException { |
| | | final R decodedResponse = promise.decodeResult(result, conn.getLDAPOptions().getDecodeOptions()); |
| | | |
| | | if (promise.getRequest() instanceof StartTLSExtendedRequest) { |
| | | if (result.getResultCode() == ResultCode.SUCCESS) { |
| | | try { |
| | | final StartTLSExtendedRequest request = (StartTLSExtendedRequest) promise.getRequest(); |
| | | conn.startTLS(request.getSSLContext(), request.getEnabledProtocols(), |
| | | request.getEnabledCipherSuites(), |
| | | new EmptyCompletionHandler<SSLEngine>() { |
| | | @Override |
| | | public void completed(final SSLEngine result) { |
| | | conn.setBindOrStartTLSInProgress(false); |
| | | promise.setResultOrError(decodedResponse); |
| | | } |
| | | if (result.getResultCode() == ResultCode.SUCCESS |
| | | && promise.getRequest() instanceof StartTLSExtendedRequest) { |
| | | try { |
| | | final StartTLSExtendedRequest request = (StartTLSExtendedRequest) promise.getRequest(); |
| | | conn.startTLS(request.getSSLContext(), request.getEnabledProtocols(), |
| | | request.getEnabledCipherSuites(), |
| | | new EmptyCompletionHandler<SSLEngine>() { |
| | | @Override |
| | | public void completed(final SSLEngine result) { |
| | | conn.setBindOrStartTLSInProgress(false); |
| | | promise.setResultOrError(decodedResponse); |
| | | } |
| | | |
| | | @Override |
| | | public void failed(final Throwable throwable) { |
| | | final Result errorResult = newResult(CLIENT_SIDE_LOCAL_ERROR) |
| | | .setCause(throwable).setDiagnosticMessage("SSL handshake failed"); |
| | | conn.setBindOrStartTLSInProgress(false); |
| | | conn.close(null, false, errorResult); |
| | | promise.adaptErrorResult(errorResult); |
| | | } |
| | | }); |
| | | return; |
| | | } catch (final IOException e) { |
| | | final Result errorResult = newResult(CLIENT_SIDE_LOCAL_ERROR).setCause(e) |
| | | .setDiagnosticMessage(e.getMessage()); |
| | | promise.adaptErrorResult(errorResult); |
| | | conn.close(null, false, errorResult); |
| | | return; |
| | | } |
| | | @Override |
| | | public void failed(final Throwable throwable) { |
| | | final Result errorResult = newResult(CLIENT_SIDE_LOCAL_ERROR) |
| | | .setCause(throwable).setDiagnosticMessage("SSL handshake failed"); |
| | | conn.setBindOrStartTLSInProgress(false); |
| | | conn.close(null, false, errorResult); |
| | | promise.adaptErrorResult(errorResult); |
| | | } |
| | | }); |
| | | return; |
| | | } catch (final IOException e) { |
| | | final Result errorResult = newResult(CLIENT_SIDE_LOCAL_ERROR).setCause(e) |
| | | .setDiagnosticMessage(e.getMessage()); |
| | | promise.adaptErrorResult(errorResult); |
| | | conn.close(null, false, errorResult); |
| | | return; |
| | | } |
| | | } |
| | | |
| | |
| | | connection.bind("", "".toCharArray()); // Anonymous bind |
| | | |
| | | final String attributeList; |
| | | if (infoType.toLowerCase().equals("controls")) { |
| | | if ("controls".equals(infoType.toLowerCase())) { |
| | | attributeList = "supportedControl"; |
| | | } else if (infoType.toLowerCase().equals("extops")) { |
| | | } else if ("extops".equals(infoType.toLowerCase())) { |
| | | attributeList = "supportedExtension"; |
| | | } else { |
| | | attributeList = "+"; // All operational attributes |
| | |
| | | |
| | | host = args[0]; |
| | | port = Integer.parseInt(args[1]); |
| | | infoType = args[2]; // all, controls, or extops |
| | | if (!(infoType.toLowerCase().equals("all") |
| | | || infoType.toLowerCase().equals("controls") |
| | | || infoType.toLowerCase().equals("extops"))) { |
| | | infoType = args[2]; |
| | | final String infoTypeLc = infoType.toLowerCase(); |
| | | if (!("all".equals(infoTypeLc) |
| | | || "controls".equals(infoTypeLc) |
| | | || "extops".equals(infoTypeLc))) { |
| | | giveUp(); |
| | | } |
| | | } |
| | |
| | | Requests.newModifyRequest(DN.valueOf(targetDN)); |
| | | String passwordAttribute = "unicodePwd"; |
| | | |
| | | if (mode.equalsIgnoreCase("admin")) { |
| | | if ("admin".equalsIgnoreCase(mode)) { |
| | | // Request modify, replacing the password with the new. |
| | | |
| | | request.addModification( |
| | |
| | | passwordAttribute, |
| | | encodePassword(newPassword) |
| | | ); |
| | | } else if (mode.equalsIgnoreCase("self")) { |
| | | } else if ("self".equalsIgnoreCase(mode)) { |
| | | // Request modify, deleting the old password, adding the new. |
| | | |
| | | // The default password policy for Active Directory domain |
| | |
| | | attributes = new String[0]; |
| | | } |
| | | |
| | | SearchScope scope; |
| | | if (scopeString.equalsIgnoreCase("base")) { |
| | | scope = SearchScope.BASE_OBJECT; |
| | | } else if (scopeString.equalsIgnoreCase("one")) { |
| | | scope = SearchScope.SINGLE_LEVEL; |
| | | } else if (scopeString.equalsIgnoreCase("sub")) { |
| | | scope = SearchScope.WHOLE_SUBTREE; |
| | | } else if (scopeString.equalsIgnoreCase("subordinates")) { |
| | | scope = SearchScope.SUBORDINATES; |
| | | } else { |
| | | final SearchScope scope = SearchScope.valueOf(scopeString); |
| | | if (scope == null) { |
| | | System.err.println("Unknown scope: " + scopeString); |
| | | System.exit(ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue()); |
| | | return; |
| | |
| | | attributes = new String[0]; |
| | | } |
| | | |
| | | if (scopeString.equalsIgnoreCase("base")) { |
| | | scope = SearchScope.BASE_OBJECT; |
| | | } else if (scopeString.equalsIgnoreCase("one")) { |
| | | scope = SearchScope.SINGLE_LEVEL; |
| | | } else if (scopeString.equalsIgnoreCase("sub")) { |
| | | scope = SearchScope.WHOLE_SUBTREE; |
| | | } else if (scopeString.equalsIgnoreCase("subordinates")) { |
| | | scope = SearchScope.SUBORDINATES; |
| | | } else { |
| | | final SearchScope scope = SearchScope.valueOf(scopeString); |
| | | if (scope == null) { |
| | | System.err.println("Unknown scope: " + scopeString); |
| | | System.exit(ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue()); |
| | | return; |
| | |
| | | bindPassword = args[3]; |
| | | |
| | | if (args.length == 5) { |
| | | if (args[4].toLowerCase().equals("use-starttls")) { |
| | | if ("use-starttls".equals(args[4].toLowerCase())) { |
| | | useStartTLS = true; |
| | | useSSL = false; |
| | | } else if (args[4].toLowerCase().equals("use-ssl")) { |
| | | } else if ("use-ssl".equals(args[4].toLowerCase())) { |
| | | useStartTLS = false; |
| | | useSSL = true; |
| | | } else { |
| | |
| | | * @param operation Operation specified as an argument (add or del). |
| | | */ |
| | | private static ModificationType getModificationType(String operation) { |
| | | final boolean isAdd = operation.equalsIgnoreCase("add"); |
| | | if (!(isAdd || operation.equalsIgnoreCase("del"))) { |
| | | final boolean isAdd = "add".equalsIgnoreCase(operation); |
| | | if (!(isAdd || "del".equalsIgnoreCase(operation))) { |
| | | printUsage(); |
| | | } |
| | | return isAdd ? ModificationType.ADD : ModificationType.DELETE; |