| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package com.forgerock.opendj.util; |
| | |
| | | |
| | | private final boolean isKeyChar; |
| | | |
| | | private final boolean isCompatKeyChar; |
| | | |
| | | private final boolean isHexChar; |
| | | |
| | | private final int hexValue; |
| | |
| | | this.isDigit = false; |
| | | this.isLetter = true; |
| | | this.isKeyChar = true; |
| | | this.isCompatKeyChar = true; |
| | | this.decimalValue = -1; |
| | | if (c >= 'a' && c <= 'f') |
| | | { |
| | |
| | | this.isDigit = false; |
| | | this.isLetter = true; |
| | | this.isKeyChar = true; |
| | | this.isCompatKeyChar = true; |
| | | this.decimalValue = -1; |
| | | if (c >= 'A' && c <= 'F') |
| | | { |
| | |
| | | this.isDigit = true; |
| | | this.isLetter = false; |
| | | this.isKeyChar = true; |
| | | this.isCompatKeyChar = true; |
| | | this.isHexChar = true; |
| | | this.hexValue = c - 48; |
| | | this.decimalValue = c - 48; |
| | |
| | | this.isDigit = false; |
| | | this.isLetter = false; |
| | | this.isKeyChar = c == '-'; |
| | | this.isCompatKeyChar = (c == '-') || (c == '.') || (c == '_'); |
| | | this.isHexChar = false; |
| | | this.hexValue = -1; |
| | | this.decimalValue = -1; |
| | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether or not the char value associated with this {@code |
| | | * ASCIICharProp} is a {@code keychar} as defined in RFC 4512. A {@code |
| | | * keychar} is a letter, a digit, or a hyphen. |
| | | * Indicates whether or not the char value associated with this |
| | | * {@code ASCIICharProp} is a {@code keychar} as defined in RFC 4512. A |
| | | * {@code keychar} is a letter, a digit, or a hyphen. When |
| | | * {@code allowCompatChars} is {@code true} the following illegal characters |
| | | * will be permitted: |
| | | * |
| | | * @return {@code true} if the char value associated with this {@code |
| | | * ASCIICharProp} is a {@code keychar}. |
| | | * <pre> |
| | | * USCORE = %x5F ; underscore ("_") |
| | | * DOT = %x2E ; period (".") |
| | | * </pre> |
| | | * |
| | | * @param allowCompatChars |
| | | * {@code true} if certain illegal characters should be allowed for |
| | | * compatibility reasons. |
| | | * @return {@code true} if the char value associated with this |
| | | * {@code ASCIICharProp} is a {@code keychar}. |
| | | */ |
| | | public boolean isKeyChar() |
| | | public boolean isKeyChar(final boolean allowCompatChars) |
| | | { |
| | | return isKeyChar; |
| | | return allowCompatChars ? isCompatKeyChar : isKeyChar; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the provided character is a keychar. |
| | | * |
| | | * @param c |
| | | * The character for which to make the determination. |
| | | * @param allowCompatChars |
| | | * {@code true} if certain illegal characters should be allowed for |
| | | * compatibility reasons. |
| | | * @return <CODE>true</CODE> if the provided character represents a |
| | | * keychar, or <CODE>false</CODE> if not. |
| | | */ |
| | | public static boolean isKeyChar(final char c, final boolean allowCompatChars) |
| | | { |
| | | final ASCIICharProp cp = ASCIICharProp.valueOf(c); |
| | | return cp != null ? cp.isKeyChar(allowCompatChars) : false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns a string whose content is the string representation of the objects |
| | | * contained in the provided collection concatenated together using the |
| | | * provided separator. |
| | |
| | | final String attributeDescription, final Schema schema) |
| | | throws LocalizedIllegalArgumentException |
| | | { |
| | | final boolean allowMalformedNamesAndOptions = schema |
| | | .allowMalformedNamesAndOptions(); |
| | | int i = 0; |
| | | final int length = attributeDescription.length(); |
| | | char c = 0; |
| | |
| | | } |
| | | |
| | | cp = ASCIICharProp.valueOf(c); |
| | | if (!cp.isKeyChar()) |
| | | if (!cp.isKeyChar(allowMalformedNamesAndOptions)) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTRIBUTE_DESCRIPTION_ILLEGAL_CHARACTER |
| | | .get(attributeDescription, c, i); |
| | |
| | | } |
| | | |
| | | // Get the attribute type from the schema. |
| | | AttributeType attributeType; |
| | | final AttributeType attributeType; |
| | | try |
| | | { |
| | | attributeType = schema.getAttributeType(oid); |
| | |
| | | } |
| | | |
| | | cp = ASCIICharProp.valueOf(c); |
| | | if (!cp.isKeyChar()) |
| | | if (!cp.isKeyChar(allowMalformedNamesAndOptions)) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTRIBUTE_DESCRIPTION_ILLEGAL_CHARACTER |
| | | .get(attributeDescription, c, i); |
| | |
| | | } |
| | | |
| | | cp = ASCIICharProp.valueOf(c); |
| | | if (!cp.isKeyChar()) |
| | | if (!cp.isKeyChar(allowMalformedNamesAndOptions)) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTRIBUTE_DESCRIPTION_ILLEGAL_CHARACTER |
| | | .get(attributeDescription, c, i); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | reader.skipWhitespaces(); |
| | | |
| | | // The next set of characters must be the OID. |
| | | final String oid = SchemaUtils.readOID(reader); |
| | | final String oid = SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | |
| | | // At this point, we should have a pretty specific syntax that |
| | | // describes what may come next, but some of the components are |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("name")) |
| | | { |
| | | SchemaUtils.readNameDescriptors(reader); |
| | | SchemaUtils.readNameDescriptors(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("desc")) |
| | | { |
| | |
| | | // This specifies the name or OID of the superior attribute |
| | | // type from which this attribute type should inherit its |
| | | // properties. |
| | | SchemaUtils.readOID(reader); |
| | | SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("equality")) |
| | | { |
| | | // This specifies the name or OID of the equality matching |
| | | // rule to use for this attribute type. |
| | | SchemaUtils.readOID(reader); |
| | | SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("ordering")) |
| | | { |
| | | // This specifies the name or OID of the ordering matching |
| | | // rule to use for this attribute type. |
| | | SchemaUtils.readOID(reader); |
| | | SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("substr")) |
| | | { |
| | | // This specifies the name or OID of the substring matching |
| | | // rule to use for this attribute type. |
| | | SchemaUtils.readOID(reader); |
| | | SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("syntax")) |
| | | { |
| | |
| | | // implementation will ignore any such length because it does |
| | | // not impose any practical limit on the length of attribute |
| | | // values. |
| | | SchemaUtils.readOIDLen(reader); |
| | | SchemaUtils.readOIDLen(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("single-definition")) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | reader.skipWhitespaces(); |
| | | |
| | | // The next set of characters must be the OID. |
| | | SchemaUtils.readOID(reader); |
| | | SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | |
| | | // At this point, we should have a pretty specific syntax that |
| | | // describes what may come next, but some of the components are |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("name")) |
| | | { |
| | | SchemaUtils.readNameDescriptors(reader); |
| | | SchemaUtils.readNameDescriptors(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("desc")) |
| | | { |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("aux")) |
| | | { |
| | | SchemaUtils.readOIDs(reader); |
| | | SchemaUtils.readOIDs(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("must")) |
| | | { |
| | | SchemaUtils.readOIDs(reader); |
| | | SchemaUtils.readOIDs(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("may")) |
| | | { |
| | | SchemaUtils.readOIDs(reader); |
| | | SchemaUtils.readOIDs(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("not")) |
| | | { |
| | | SchemaUtils.readOIDs(reader); |
| | | SchemaUtils.readOIDs(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.matches("^X-[A-Za-z_-]+$")) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("name")) |
| | | { |
| | | SchemaUtils.readNameDescriptors(reader); |
| | | SchemaUtils.readNameDescriptors(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("desc")) |
| | | { |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("form")) |
| | | { |
| | | nameForm = SchemaUtils.readOID(reader); |
| | | nameForm = SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("sup")) |
| | | { |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opendj3/legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opendj3/legal-notices/CDDLv1_0.txt. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class is used to maintain a reference to the default schema and avoid |
| | | * having to reference the core schema in the {@link Schema} class since this |
| | | * can cause initialization errors because the CoreSchema depends on Schema. |
| | | */ |
| | | final class DefaultSchema |
| | | { |
| | | private DefaultSchema() |
| | | { |
| | | // Prevent instantiation. |
| | | } |
| | | |
| | | |
| | | |
| | | static volatile Schema schema = Schema.getCoreSchema(); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | |
| | | try |
| | | { |
| | | SchemaUtils.readOID(new SubstringReader(ocName.substring(ocLength))); |
| | | SchemaUtils.readOID(new SubstringReader(ocName.substring(ocLength)), |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | catch (final DecodeException de) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | |
| | | return GuideSyntaxImpl.criteriaIsValid(criteria, valueStr, invalidReason); |
| | | return GuideSyntaxImpl.criteriaIsValid(schema, criteria, |
| | | valueStr, invalidReason); |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | * Determines whether the provided string represents a valid criteria |
| | | * according to the guide syntax. |
| | | * |
| | | * @param schema |
| | | * The schema in which this syntax is defined. |
| | | * @param criteria |
| | | * The portion of the criteria for which to make the determination. |
| | | * @param valueStr |
| | |
| | | * @return <CODE>true</CODE> if the provided string does contain a valid |
| | | * criteria, or <CODE>false</CODE> if not. |
| | | */ |
| | | static boolean criteriaIsValid(final String criteria, final String valueStr, |
| | | static boolean criteriaIsValid(final Schema schema, |
| | | final String criteria, final String valueStr, |
| | | final LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // See if the criteria starts with a '!'. If so, then just evaluate |
| | |
| | | char c = criteria.charAt(0); |
| | | if (c == '!') |
| | | { |
| | | return criteriaIsValid(criteria.substring(1), valueStr, invalidReason); |
| | | return criteriaIsValid(schema, criteria.substring(1), valueStr, |
| | | invalidReason); |
| | | } |
| | | |
| | | // See if the criteria starts with a '('. If so, then find the |
| | |
| | | if (depth == 0) |
| | | { |
| | | final String subCriteria = criteria.substring(1, i); |
| | | if (!criteriaIsValid(subCriteria, valueStr, invalidReason)) |
| | | if (!criteriaIsValid(schema, subCriteria, valueStr, invalidReason)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | c = criteria.charAt(i + 1); |
| | | if (c == '|' || c == '&') |
| | | { |
| | | return criteriaIsValid(criteria.substring(i + 2), valueStr, |
| | | return criteriaIsValid(schema, |
| | | criteria.substring(i + 2), valueStr, |
| | | invalidReason); |
| | | } |
| | | else |
| | |
| | | c = criteria.charAt(5); |
| | | if (c == '|' || c == '&') |
| | | { |
| | | return criteriaIsValid(criteria.substring(6), valueStr, |
| | | return criteriaIsValid(schema, criteria.substring(6), valueStr, |
| | | invalidReason); |
| | | } |
| | | else |
| | |
| | | c = criteria.charAt(6); |
| | | if (c == '|' || c == '&') |
| | | { |
| | | return criteriaIsValid(criteria.substring(7), valueStr, |
| | | return criteriaIsValid(schema, criteria.substring(7), valueStr, |
| | | invalidReason); |
| | | } |
| | | else |
| | |
| | | try |
| | | { |
| | | SchemaUtils.readOID(new SubstringReader(criteria |
| | | .substring(0, dollarPos))); |
| | | .substring(0, dollarPos)), |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | catch (final DecodeException de) |
| | | { |
| | |
| | | c = criteria.charAt(endPos); |
| | | if (c == '|' || c == '&') |
| | | { |
| | | return criteriaIsValid(criteria.substring(endPos + 1), valueStr, |
| | | invalidReason); |
| | | return criteriaIsValid(schema, |
| | | criteria.substring(endPos + 1), valueStr, invalidReason); |
| | | } |
| | | else |
| | | { |
| | |
| | | final int sharpPos = valueStr.indexOf('#'); |
| | | if (sharpPos < 0) |
| | | { |
| | | return criteriaIsValid(valueStr, valueStr, invalidReason); |
| | | return criteriaIsValid(schema, valueStr, valueStr, invalidReason); |
| | | } |
| | | |
| | | // Get the objectclass and see if it is a valid name or OID. |
| | |
| | | |
| | | try |
| | | { |
| | | SchemaUtils.readOID(new SubstringReader(ocName.substring(0, ocLength))); |
| | | SchemaUtils.readOID(new SubstringReader(ocName.substring(0, ocLength)), |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | catch (final DecodeException de) |
| | | { |
| | |
| | | } |
| | | |
| | | // The rest of the value must be the criteria. |
| | | return criteriaIsValid(valueStr.substring(sharpPos + 1), valueStr, |
| | | invalidReason); |
| | | return criteriaIsValid(schema, valueStr.substring(sharpPos + 1), |
| | | valueStr, invalidReason); |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | reader.skipWhitespaces(); |
| | | |
| | | // The next set of characters must be the OID. |
| | | final String oid = SchemaUtils.readOID(reader); |
| | | final String oid = SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | |
| | | Map<String, List<String>> extraProperties = Collections.emptyMap(); |
| | | // At this point, we should have a pretty specific syntax that |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | reader.skipWhitespaces(); |
| | | |
| | | // The next set of characters must be the OID. |
| | | SchemaUtils.readOID(reader); |
| | | SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | String syntax = null; |
| | | |
| | | // At this point, we should have a pretty specific syntax that |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("name")) |
| | | { |
| | | SchemaUtils.readNameDescriptors(reader); |
| | | SchemaUtils.readNameDescriptors(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("desc")) |
| | | { |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("syntax")) |
| | | { |
| | | syntax = SchemaUtils.readOID(reader); |
| | | syntax = SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.matches("^X-[A-Za-z_-]+$")) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | reader.skipWhitespaces(); |
| | | |
| | | // The next set of characters must be the OID. |
| | | SchemaUtils.readOID(reader); |
| | | SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | |
| | | // At this point, we should have a pretty specific syntax that |
| | | // describes what may come next, but some of the components are |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("name")) |
| | | { |
| | | SchemaUtils.readNameDescriptors(reader); |
| | | SchemaUtils.readNameDescriptors(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("desc")) |
| | | { |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("applies")) |
| | | { |
| | | attributes = SchemaUtils.readOIDs(reader); |
| | | attributes = SchemaUtils.readOIDs(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.matches("^X-[A-Za-z_-]+$")) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | reader.skipWhitespaces(); |
| | | |
| | | // The next set of characters must be the OID. |
| | | SchemaUtils.readOID(reader); |
| | | SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | |
| | | String structuralClass = null; |
| | | Set<String> requiredAttributes = null; |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("name")) |
| | | { |
| | | SchemaUtils.readNameDescriptors(reader); |
| | | SchemaUtils.readNameDescriptors(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("desc")) |
| | | { |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("oc")) |
| | | { |
| | | structuralClass = SchemaUtils.readOID(reader); |
| | | structuralClass = SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("must")) |
| | | { |
| | | requiredAttributes = SchemaUtils.readOIDs(reader); |
| | | requiredAttributes = SchemaUtils.readOIDs(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("may")) |
| | | { |
| | | SchemaUtils.readOIDs(reader); |
| | | SchemaUtils.readOIDs(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.matches("^X-[A-Za-z_-]+$")) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | { |
| | | try |
| | | { |
| | | SchemaUtils.readOID(new SubstringReader(value.toString())); |
| | | SchemaUtils.readOID(new SubstringReader(value.toString()), |
| | | schema.allowMalformedNamesAndOptions()); |
| | | return true; |
| | | } |
| | | catch (final DecodeException de) |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | reader.skipWhitespaces(); |
| | | |
| | | // The next set of characters must be the OID. |
| | | SchemaUtils.readOID(reader); |
| | | SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | |
| | | // At this point, we should have a pretty specific syntax that |
| | | // describes what may come next, but some of the components are |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("name")) |
| | | { |
| | | SchemaUtils.readNameDescriptors(reader); |
| | | SchemaUtils.readNameDescriptors(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("desc")) |
| | | { |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("sup")) |
| | | { |
| | | SchemaUtils.readOIDs(reader); |
| | | SchemaUtils.readOIDs(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("abstract")) |
| | | { |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("must")) |
| | | { |
| | | SchemaUtils.readOIDs(reader); |
| | | SchemaUtils.readOIDs(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("may")) |
| | | { |
| | | SchemaUtils.readOIDs(reader); |
| | | SchemaUtils.readOIDs(reader, |
| | | schema.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.matches("^X-[A-Za-z_-]+$")) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | { |
| | | final String definition = value.toString(); |
| | | final SubstringReader reader = new SubstringReader(definition); |
| | | final String normalized = resolveNames(schema, SchemaUtils.readOID(reader)); |
| | | final String normalized = resolveNames(schema, SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions())); |
| | | |
| | | return new OIDAssertion(normalized); |
| | | } |
| | |
| | | { |
| | | final String definition = value.toString(); |
| | | final SubstringReader reader = new SubstringReader(definition); |
| | | final String normalized = resolveNames(schema, SchemaUtils.readOID(reader)); |
| | | final String normalized = resolveNames(schema, SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions())); |
| | | return ByteString.valueOf(normalized); |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | final String definition = value.toString(); |
| | | final SubstringReader reader = new SubstringReader(definition); |
| | | final String normalized = ObjectIdentifierEqualityMatchingRuleImpl |
| | | .resolveNames(schema, SchemaUtils.readOID(reader)); |
| | | .resolveNames(schema, SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions())); |
| | | |
| | | return new ObjectIdentifierEqualityMatchingRuleImpl.OIDAssertion(normalized); |
| | | } |
| | |
| | | |
| | | // The next set of characters must be the OID. |
| | | final String normalized = ObjectIdentifierEqualityMatchingRuleImpl |
| | | .resolveNames(schema, SchemaUtils.readOID(reader)); |
| | | .resolveNames(schema, SchemaUtils.readOID(reader, |
| | | schema.allowMalformedNamesAndOptions())); |
| | | return ByteString.valueOf(normalized); |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import com.forgerock.opendj.util.FutureResultTransformer; |
| | | import com.forgerock.opendj.util.RecursiveFutureResult; |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | private static final Schema CORE_SCHEMA = CoreSchemaImpl.getInstance(); |
| | | /* |
| | | * WARNING: do not reference the core schema in the following declarations. |
| | | */ |
| | | |
| | | private static final Schema EMPTY_SCHEMA = new Schema(new EmptyImpl()); |
| | | |
| | | private static volatile Schema defaultSchema = CoreSchemaImpl.getInstance(); |
| | | |
| | | static final String ATTR_ATTRIBUTE_TYPES = "attributeTypes"; |
| | | |
| | | static final String ATTR_DIT_CONTENT_RULES = "dITContentRules"; |
| | |
| | | private static final String ATTR_SUBSCHEMA_SUBENTRY = "subschemaSubentry"; |
| | | |
| | | private static final String[] SUBSCHEMA_ATTRS = new String[] { |
| | | ATTR_LDAP_SYNTAXES.toString(), ATTR_ATTRIBUTE_TYPES.toString(), |
| | | ATTR_DIT_CONTENT_RULES.toString(), ATTR_DIT_STRUCTURE_RULES.toString(), |
| | | ATTR_MATCHING_RULE_USE.toString(), ATTR_MATCHING_RULES.toString(), |
| | | ATTR_NAME_FORMS.toString(), ATTR_OBJECT_CLASSES.toString() }; |
| | | ATTR_LDAP_SYNTAXES, ATTR_ATTRIBUTE_TYPES, |
| | | ATTR_DIT_CONTENT_RULES, ATTR_DIT_STRUCTURE_RULES, |
| | | ATTR_MATCHING_RULE_USE, ATTR_MATCHING_RULES, |
| | | ATTR_NAME_FORMS, ATTR_OBJECT_CLASSES }; |
| | | |
| | | private static final Filter SUBSCHEMA_FILTER = Filter.newEqualityMatchFilter( |
| | | CoreSchema.getObjectClassAttributeType().getNameOrOID(), CoreSchema |
| | | .getSubschemaObjectClass().getNameOrOID()); |
| | | private static final Filter SUBSCHEMA_FILTER = Filter |
| | | .valueOf("(objectClass=subschema)"); |
| | | |
| | | private static final String[] SUBSCHEMA_SUBENTRY_ATTRS = new String[] { ATTR_SUBSCHEMA_SUBENTRY |
| | | .toString() }; |
| | | private static final String[] SUBSCHEMA_SUBENTRY_ATTRS = |
| | | new String[] { ATTR_SUBSCHEMA_SUBENTRY }; |
| | | |
| | | |
| | | |
| | |
| | | */ |
| | | public static Schema getCoreSchema() |
| | | { |
| | | return CORE_SCHEMA; |
| | | return CoreSchemaImpl.getInstance(); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public static Schema getDefaultSchema() |
| | | { |
| | | return defaultSchema; |
| | | return DefaultSchema.schema; |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public static void setDefaultSchema(final Schema schema) |
| | | { |
| | | defaultSchema = schema; |
| | | Validator.ensureNotNull(schema); |
| | | DefaultSchema.schema = schema; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Returns {@code true} if this schema allows certain illegal characters |
| | | * in OIDs and attribute options. When this compatibility option is set to |
| | | * {@code true} the following illegal characters will be permitted: |
| | | * |
| | | * <pre> |
| | | * USCORE = %x5F ; underscore ("_") |
| | | * DOT = %x2E ; period (".") |
| | | * </pre> |
| | | * |
| | | * By default this compatibility option is set to {@code false}. |
| | | * |
| | | * @return {@code true} if this schema allows certain illegal characters |
| | | * in OIDs and attribute options. |
| | | * @see <a href="http://tools.ietf.org/html/rfc4512">RFC 4512 - Lightweight |
| | | * Directory Access Protocol (LDAP): Directory Information Models </a> |
| | | */ |
| | | public boolean allowMalformedNamesAndOptions() |
| | | { |
| | | return impl.getSchemaCompatOptions().allowMalformedNamesAndOptions(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns {@code true} if the Telephone Number syntax defined for this schema |
| | | * allows values which do not conform to the E.123 international telephone |
| | | * number format. |
| | | * <p> |
| | | * By default this compatibility option is set to {@code true}. |
| | | * |
| | | * @return {@code true} if the Telephone Number syntax defined for this schema |
| | | * allows values which do not conform to the E.123 international |
| | | * telephone number format. |
| | | */ |
| | | public boolean allowNonStandardTelephoneNumbers() |
| | | { |
| | | return impl.getSchemaCompatOptions() |
| | | .allowNonStandardTelephoneNumbers(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns {@code true} if zero-length values will be allowed by the Directory |
| | | * String syntax defined for this schema. This is technically forbidden by the |
| | | * LDAP specification, but it was allowed in earlier versions of the server, |
| | | * and the discussion of the directory string syntax in RFC 2252 does not |
| | | * explicitly state that they are not allowed. |
| | | * <p> |
| | | * By default this compatibility option is set to {@code false}. |
| | | * |
| | | * @return {@code true} if zero-length values will be allowed by the Directory |
| | | * String syntax defined for this schema, or {@code false} if not. |
| | | */ |
| | | public boolean allowZeroLengthDirectoryStrings() |
| | | { |
| | | return impl.getSchemaCompatOptions() |
| | | .allowZeroLengthDirectoryStrings(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the attribute type with the specified name or numeric OID. |
| | | * |
| | | * @param name |
| | |
| | | reader.skipWhitespaces(); |
| | | |
| | | // The next set of characters must be the OID. |
| | | final String oid = SchemaUtils.readOID(reader); |
| | | final String oid = SchemaUtils.readOID(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | |
| | | List<String> names = Collections.emptyList(); |
| | | String description = "".intern(); |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("name")) |
| | | { |
| | | names = SchemaUtils.readNameDescriptors(reader); |
| | | names = SchemaUtils.readNameDescriptors(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("desc")) |
| | | { |
| | |
| | | // This specifies the name or OID of the superior attribute |
| | | // type from which this attribute type should inherit its |
| | | // properties. |
| | | superiorType = SchemaUtils.readOID(reader); |
| | | superiorType = SchemaUtils.readOID(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("equality")) |
| | | { |
| | | // This specifies the name or OID of the equality matching |
| | | // rule to use for this attribute type. |
| | | equalityMatchingRule = SchemaUtils.readOID(reader); |
| | | equalityMatchingRule = SchemaUtils.readOID(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("ordering")) |
| | | { |
| | | // This specifies the name or OID of the ordering matching |
| | | // rule to use for this attribute type. |
| | | orderingMatchingRule = SchemaUtils.readOID(reader); |
| | | orderingMatchingRule = SchemaUtils.readOID(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("substr")) |
| | | { |
| | | // This specifies the name or OID of the substring matching |
| | | // rule to use for this attribute type. |
| | | substringMatchingRule = SchemaUtils.readOID(reader); |
| | | substringMatchingRule = SchemaUtils.readOID(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("syntax")) |
| | | { |
| | |
| | | // implementation will ignore any such length because it does |
| | | // not impose any practical limit on the length of attribute |
| | | // values. |
| | | syntax = SchemaUtils.readOIDLen(reader); |
| | | syntax = SchemaUtils.readOIDLen(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("single-definition")) |
| | | { |
| | |
| | | reader.skipWhitespaces(); |
| | | |
| | | // The next set of characters must be the OID. |
| | | final String structuralClass = SchemaUtils.readOID(reader); |
| | | final String structuralClass = SchemaUtils.readOID(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | |
| | | List<String> names = Collections.emptyList(); |
| | | String description = "".intern(); |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("name")) |
| | | { |
| | | names = SchemaUtils.readNameDescriptors(reader); |
| | | names = SchemaUtils.readNameDescriptors(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("desc")) |
| | | { |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("aux")) |
| | | { |
| | | auxiliaryClasses = SchemaUtils.readOIDs(reader); |
| | | auxiliaryClasses = SchemaUtils.readOIDs(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("must")) |
| | | { |
| | | requiredAttributes = SchemaUtils.readOIDs(reader); |
| | | requiredAttributes = SchemaUtils.readOIDs(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("may")) |
| | | { |
| | | optionalAttributes = SchemaUtils.readOIDs(reader); |
| | | optionalAttributes = SchemaUtils.readOIDs(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("not")) |
| | | { |
| | | prohibitedAttributes = SchemaUtils.readOIDs(reader); |
| | | prohibitedAttributes = SchemaUtils.readOIDs(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.matches("^X-[A-Za-z_-]+$")) |
| | | { |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("name")) |
| | | { |
| | | names = SchemaUtils.readNameDescriptors(reader); |
| | | names = SchemaUtils.readNameDescriptors(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("desc")) |
| | | { |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("form")) |
| | | { |
| | | nameForm = SchemaUtils.readOID(reader); |
| | | nameForm = SchemaUtils.readOID(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("sup")) |
| | | { |
| | |
| | | reader.skipWhitespaces(); |
| | | |
| | | // The next set of characters must be the OID. |
| | | final String oid = SchemaUtils.readOID(reader); |
| | | final String oid = SchemaUtils.readOID(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | |
| | | List<String> names = Collections.emptyList(); |
| | | String description = "".intern(); |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("name")) |
| | | { |
| | | names = SchemaUtils.readNameDescriptors(reader); |
| | | names = SchemaUtils.readNameDescriptors(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("desc")) |
| | | { |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("syntax")) |
| | | { |
| | | syntax = SchemaUtils.readOID(reader); |
| | | syntax = SchemaUtils.readOID(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.matches("^X-[A-Za-z_-]+$")) |
| | | { |
| | |
| | | reader.skipWhitespaces(); |
| | | |
| | | // The next set of characters must be the OID. |
| | | final String oid = SchemaUtils.readOID(reader); |
| | | final String oid = SchemaUtils.readOID(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | |
| | | List<String> names = Collections.emptyList(); |
| | | String description = "".intern(); |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("name")) |
| | | { |
| | | names = SchemaUtils.readNameDescriptors(reader); |
| | | names = SchemaUtils.readNameDescriptors(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("desc")) |
| | | { |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("applies")) |
| | | { |
| | | attributes = SchemaUtils.readOIDs(reader); |
| | | attributes = SchemaUtils.readOIDs(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.matches("^X-[A-Za-z_-]+$")) |
| | | { |
| | |
| | | reader.skipWhitespaces(); |
| | | |
| | | // The next set of characters must be the OID. |
| | | final String oid = SchemaUtils.readOID(reader); |
| | | final String oid = SchemaUtils.readOID(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | |
| | | List<String> names = Collections.emptyList(); |
| | | String description = "".intern(); |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("name")) |
| | | { |
| | | names = SchemaUtils.readNameDescriptors(reader); |
| | | names = SchemaUtils.readNameDescriptors(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("desc")) |
| | | { |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("oc")) |
| | | { |
| | | structuralClass = SchemaUtils.readOID(reader); |
| | | structuralClass = SchemaUtils.readOID(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("must")) |
| | | { |
| | | requiredAttributes = SchemaUtils.readOIDs(reader); |
| | | requiredAttributes = SchemaUtils.readOIDs(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("may")) |
| | | { |
| | | optionalAttributes = SchemaUtils.readOIDs(reader); |
| | | optionalAttributes = SchemaUtils.readOIDs(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.matches("^X-[A-Za-z_-]+$")) |
| | | { |
| | |
| | | reader.skipWhitespaces(); |
| | | |
| | | // The next set of characters must be the OID. |
| | | final String oid = SchemaUtils.readOID(reader); |
| | | final String oid = SchemaUtils.readOID(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | |
| | | List<String> names = Collections.emptyList(); |
| | | String description = "".intern(); |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("name")) |
| | | { |
| | | names = SchemaUtils.readNameDescriptors(reader); |
| | | names = SchemaUtils.readNameDescriptors(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("desc")) |
| | | { |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("sup")) |
| | | { |
| | | superiorClasses = SchemaUtils.readOIDs(reader); |
| | | superiorClasses = SchemaUtils.readOIDs(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("abstract")) |
| | | { |
| | |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("must")) |
| | | { |
| | | requiredAttributes = SchemaUtils.readOIDs(reader); |
| | | requiredAttributes = SchemaUtils.readOIDs(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.equalsIgnoreCase("may")) |
| | | { |
| | | optionalAttributes = SchemaUtils.readOIDs(reader); |
| | | optionalAttributes = SchemaUtils.readOIDs(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | } |
| | | else if (tokenName.matches("^X-[A-Za-z_-]+$")) |
| | | { |
| | |
| | | reader.skipWhitespaces(); |
| | | |
| | | // The next set of characters must be the OID. |
| | | final String oid = SchemaUtils.readOID(reader); |
| | | final String oid = SchemaUtils.readOID(reader, |
| | | options.allowMalformedNamesAndOptions()); |
| | | |
| | | String description = "".intern(); |
| | | Map<String, List<String>> extraProperties = Collections.emptyMap(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | |
| | | import static com.forgerock.opendj.util.StaticUtils.isAlpha; |
| | | import static com.forgerock.opendj.util.StaticUtils.isDigit; |
| | | import static com.forgerock.opendj.util.StaticUtils.isKeyChar; |
| | | import static org.forgerock.opendj.ldap.CoreMessages.*; |
| | | |
| | | import java.util.*; |
| | |
| | | |
| | | |
| | | |
| | | static List<String> readNameDescriptors(final SubstringReader reader) |
| | | static List<String> readNameDescriptors( |
| | | final SubstringReader reader, final boolean allowCompatChars) |
| | | throws DecodeException |
| | | { |
| | | int length = 0; |
| | | List<String> values; |
| | | |
| | | // Skip over any spaces at the beginning of the value. |
| | |
| | | |
| | | try |
| | | { |
| | | reader.mark(); |
| | | char c = reader.read(); |
| | | if (c == '\'') |
| | | { |
| | | reader.mark(); |
| | | // Parse until the closing quote. |
| | | while (reader.read() != '\'') |
| | | { |
| | | length++; |
| | | } |
| | | |
| | | reader.reset(); |
| | | values = Collections.singletonList(reader.read(length)); |
| | | values = Collections.singletonList(readQuotedDescriptor( |
| | | reader, allowCompatChars)); |
| | | reader.read(); |
| | | } |
| | | else if (c == '(') |
| | |
| | | do |
| | | { |
| | | reader.reset(); |
| | | values.add(readQuotedDescriptor(reader)); |
| | | values.add(readQuotedDescriptor(reader, allowCompatChars)); |
| | | reader.skipWhitespaces(); |
| | | reader.mark(); |
| | | } |
| | |
| | | * |
| | | * @param reader |
| | | * The string representation of the definition. |
| | | * @param allowCompatChars |
| | | * {@code true} if certain illegal characters should be allowed for |
| | | * compatibility reasons. |
| | | * @return The attribute description or numeric OID read from the definition. |
| | | * @throws DecodeException |
| | | * If a problem is encountered while reading the name or OID. |
| | | */ |
| | | static String readOID(final SubstringReader reader) throws DecodeException |
| | | static String readOID(final SubstringReader reader, |
| | | final boolean allowCompatChars) throws DecodeException |
| | | { |
| | | int length = 0; |
| | | boolean enclosingQuote = false; |
| | |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | if (!isAlpha(c) && !isDigit(c) && c != '-' && c != '.' && c != '_') |
| | | if (!isKeyChar(c, allowCompatChars)) |
| | | { |
| | | // This is an illegal character. |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID |
| | |
| | | * |
| | | * @param reader |
| | | * The string representation of the definition. |
| | | * @param allowCompatChars |
| | | * {@code true} if certain illegal characters should be allowed for |
| | | * compatibility reasons. |
| | | * @return The OID read from the definition. |
| | | * @throws DecodeException |
| | | * If a problem is encountered while reading the token name. |
| | | */ |
| | | static String readOIDLen(final SubstringReader reader) throws DecodeException |
| | | static String readOIDLen(final SubstringReader reader, |
| | | final boolean allowCompatChars) throws DecodeException |
| | | { |
| | | int length = 1; |
| | | boolean enclosingQuote = false; |
| | |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | if (!isAlpha(c) && !isDigit(c) && c != '-' && c != '.' && c != '_') |
| | | if (!isKeyChar(c, allowCompatChars)) |
| | | { |
| | | // This is an illegal character. |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID |
| | |
| | | |
| | | |
| | | |
| | | static Set<String> readOIDs(final SubstringReader reader) |
| | | throws DecodeException |
| | | static Set<String> readOIDs(final SubstringReader reader, |
| | | final boolean allowCompatChars) throws DecodeException |
| | | { |
| | | Set<String> values; |
| | | |
| | |
| | | values = new LinkedHashSet<String>(); |
| | | do |
| | | { |
| | | values.add(readOID(reader)); |
| | | values.add(readOID(reader, allowCompatChars)); |
| | | |
| | | // Skip over any trailing spaces; |
| | | reader.skipWhitespaces(); |
| | |
| | | else |
| | | { |
| | | reader.reset(); |
| | | values = Collections.singleton(readOID(reader)); |
| | | values = Collections.singleton(readOID(reader, allowCompatChars)); |
| | | } |
| | | |
| | | return values; |
| | |
| | | * |
| | | * @param reader |
| | | * The string representation of the definition. |
| | | * @param allowCompatChars |
| | | * {@code true} if certain illegal characters should be allowed for |
| | | * compatibility reasons. |
| | | * @return The string value read from the definition. |
| | | * @throws DecodeException |
| | | * If a problem is encountered while reading the quoted string. |
| | | */ |
| | | private static String readQuotedDescriptor(final SubstringReader reader) |
| | | private static String readQuotedDescriptor( |
| | | final SubstringReader reader, final boolean allowCompatChars) |
| | | throws DecodeException |
| | | { |
| | | int length = 0; |
| | |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | if (!isAlpha(c) && !isDigit(c) && c != '-' && c != '_' && c != '.') |
| | | if (!isKeyChar(c, allowCompatChars)) |
| | | { |
| | | // This is an illegal character. |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package com.forgerock.opendj.util; |
| | |
| | | |
| | | |
| | | import static org.testng.Assert.assertEquals; |
| | | import static org.testng.Assert.assertTrue; |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | |
| | | @DataProvider(name = "validasciidata") |
| | | public Object[][] createValidASCIIData() |
| | | { |
| | | // @formatter:off |
| | | return new Object[][] { |
| | | { (char) 1,/* uppercase */false,/* hex value */0,/* decimal value */0,/* |
| | | * is |
| | | * letter |
| | | */ |
| | | false,/* is digit */false,/* is keychar */false }, |
| | | { '-',/* uppercase */false,/* hex value */-1,/* decimal value */-1,/* |
| | | * is |
| | | * letter |
| | | */ |
| | | false,/* is digit */false,/* is keychar */true }, |
| | | { 'a',/* uppercase */false,/* hex value */10,/* decimal value */-1,/* |
| | | * is |
| | | * letter |
| | | */ |
| | | true,/* is digit */false,/* is keychar */true }, |
| | | { 'A',/* uppercase */true,/* hex value */10,/* decimal value */-1,/* |
| | | * is |
| | | * letter |
| | | */ |
| | | true,/* is digit */false,/* is keychar */true }, |
| | | { '1',/* uppercase */false,/* hex value */1,/* decimal value */1,/* |
| | | * is |
| | | * letter |
| | | */ |
| | | false,/* is digit */true,/* is keychar */true }, }; |
| | | { |
| | | (char) 1, |
| | | false, // uppercase |
| | | -1, // hex |
| | | -1, // decimal |
| | | false, // is letter |
| | | false, // is digit |
| | | false, // is key char |
| | | false // is compat key char |
| | | }, |
| | | { |
| | | '-', |
| | | false, // uppercase |
| | | -1, // hex |
| | | -1, // decimal |
| | | false, // is letter |
| | | false, // is digit |
| | | true, // is key char |
| | | true // is compat key char |
| | | }, |
| | | { |
| | | '_', |
| | | false, // uppercase |
| | | -1, // hex |
| | | -1, // decimal |
| | | false, // is letter |
| | | false, // is digit |
| | | false, // is key char |
| | | true // is compat key char |
| | | }, |
| | | { |
| | | '.', |
| | | false, // uppercase |
| | | -1, // hex |
| | | -1, // decimal |
| | | false, // is letter |
| | | false, // is digit |
| | | false, // is key char |
| | | true // is compat key char |
| | | }, |
| | | { |
| | | '+', |
| | | false, // uppercase |
| | | -1, // hex |
| | | -1, // decimal |
| | | false, // is letter |
| | | false, // is digit |
| | | false, // is key char |
| | | false // is compat key char |
| | | }, |
| | | { |
| | | 'a', |
| | | false, // uppercase |
| | | 10, // hex |
| | | -1, // decimal |
| | | true, // is letter |
| | | false, // is digit |
| | | true, // is key char |
| | | true // is compat key char |
| | | }, |
| | | { |
| | | 'A', |
| | | true, // uppercase |
| | | 10, // hex |
| | | -1, // decimal |
| | | true, // is letter |
| | | false, // is digit |
| | | true, // is key char |
| | | true // is compat key char |
| | | }, |
| | | { |
| | | 'f', |
| | | false, // uppercase |
| | | 15, // hex |
| | | -1, // decimal |
| | | true, // is letter |
| | | false, // is digit |
| | | true, // is key char |
| | | true // is compat key char |
| | | }, |
| | | { |
| | | 'F', |
| | | true, // uppercase |
| | | 15, // hex |
| | | -1, // decimal |
| | | true, // is letter |
| | | false, // is digit |
| | | true, // is key char |
| | | true // is compat key char |
| | | }, |
| | | { |
| | | 'z', |
| | | false, // uppercase |
| | | -1, // hex |
| | | -1, // decimal |
| | | true, // is letter |
| | | false, // is digit |
| | | true, // is key char |
| | | true // is compat key char |
| | | }, |
| | | { |
| | | 'Z', |
| | | true, // uppercase |
| | | -1, // hex |
| | | -1, // decimal |
| | | true, // is letter |
| | | false, // is digit |
| | | true, // is key char |
| | | true // is compat key char |
| | | }, |
| | | { |
| | | '0', |
| | | false, // uppercase |
| | | 0, // hex |
| | | 0, // decimal |
| | | false, // is letter |
| | | true, // is digit |
| | | true, // is key char |
| | | true // is compat key char |
| | | }, |
| | | { |
| | | '9', |
| | | false, // uppercase |
| | | 9, // hex |
| | | 9, // decimal |
| | | false, // is letter |
| | | true, // is digit |
| | | true, // is key char |
| | | true // is compat key char |
| | | }, |
| | | }; |
| | | // @formatter:on |
| | | } |
| | | |
| | | |
| | |
| | | * In case of any errors. |
| | | */ |
| | | @Test(dataProvider = "invalidasciidata") |
| | | public void testEncode(final char myChar) throws Exception |
| | | public void testValueOf(final char myChar) throws Exception |
| | | { |
| | | assertEquals(ASCIICharProp.valueOf(myChar), null); |
| | | } |
| | |
| | | * Whether the character is a digit |
| | | * @param isKeyChar |
| | | * Whether the character is a key char. |
| | | * @param isCompatKeyChar |
| | | * Whether the character is a compat key char. |
| | | * @throws Exception |
| | | * In case of any errors. |
| | | */ |
| | | @Test(dataProvider = "validasciidata") |
| | | public void testEncode(final char myChar, final Boolean isUpper, |
| | | final Integer hexValue, final Integer decimalValue, |
| | | final Boolean isLetter, final Boolean isDigit, final Boolean isKeyChar) |
| | | public void testValueOf(final char myChar, final boolean isUpper, |
| | | final int hexValue, final int decimalValue, |
| | | final boolean isLetter, final boolean isDigit, |
| | | final boolean isKeyChar, final boolean isCompatKeyChar) |
| | | throws Exception |
| | | { |
| | | final ASCIICharProp myProp = ASCIICharProp.valueOf(myChar); |
| | | |
| | | // check letter. |
| | | if (isLetter) |
| | | { |
| | | assertTrue(myProp.isLetter()); |
| | | // Check case. |
| | | if (isUpper) |
| | | { |
| | | assertTrue(myProp.isUpperCase()); |
| | | } |
| | | else |
| | | { |
| | | assertTrue(myProp.isLowerCase()); |
| | | } |
| | | } |
| | | assertEquals(isLetter, myProp.isLetter()); |
| | | |
| | | // Check case. |
| | | assertEquals(isLetter & isUpper, myProp.isUpperCase()); |
| | | assertEquals(isLetter & !isUpper, myProp.isLowerCase()); |
| | | |
| | | // check digit. |
| | | if (isDigit) |
| | | { |
| | | assertTrue(myProp.isDigit()); |
| | | } |
| | | assertEquals(isDigit, myProp.isDigit()); |
| | | |
| | | if (isLetter || isDigit) |
| | | { |
| | | // Check hex. |
| | | final int hex = myProp.hexValue(); |
| | | final int hex1 = hexValue.intValue(); |
| | | assertEquals(myProp.hexValue(), hexValue.intValue()); |
| | | // Decimal value. |
| | | assertEquals(myProp.decimalValue(), decimalValue.intValue()); |
| | | // Check if it is equal to itself. |
| | | assertEquals(myProp.charValue(), myChar); |
| | | assertEquals(myProp.compareTo(ASCIICharProp.valueOf(myChar)), 0); |
| | | } |
| | | // Check hex. |
| | | assertEquals(myProp.hexValue(), hexValue); |
| | | |
| | | // Decimal value. |
| | | assertEquals(myProp.decimalValue(), decimalValue); |
| | | |
| | | // Check if it is equal to itself. |
| | | assertEquals(myProp.charValue(), myChar); |
| | | assertEquals(myProp.compareTo(ASCIICharProp.valueOf(myChar)), 0); |
| | | |
| | | // keychar. |
| | | if (isKeyChar) |
| | | { |
| | | assertTrue(myProp.isKeyChar()); |
| | | } |
| | | assertEquals(isKeyChar, myProp.isKeyChar(false)); |
| | | assertEquals(isCompatKeyChar, myProp.isKeyChar(true)); |
| | | } |
| | | } |
| | |
| | | "( 2.5.6.4 DESC 'content rule for organization' NOT " |
| | | + "( x121Address $ telexNumber ) )", true }, |
| | | { |
| | | "( 2.5.6.4 NAME 'full rule' DESC 'rule with all possible fields' " |
| | | "( 2.5.6.4 NAME 'fullRule' DESC 'rule with all possible fields' " |
| | | + " OBSOLETE" + " AUX ( posixAccount )" + " MUST ( cn $ sn )" |
| | | + " MAY ( dc )" + " NOT ( x121Address $ telexNumber ) )", true }, |
| | | { |
| | | "( 2.5.6.4 NAME 'full rule' DESC 'ommit parenthesis' " |
| | | "( 2.5.6.4 NAME 'fullRule' DESC 'ommit parenthesis' " |
| | | + " OBSOLETE" + " AUX posixAccount " + " MUST cn " + " MAY dc " |
| | | + " NOT x121Address )", true }, |
| | | { |
| | | "( 2.5.6.4 NAME 'full rule' DESC 'use numeric OIDs' " + " OBSOLETE" |
| | | "( 2.5.6.4 NAME 'fullRule' DESC 'use numeric OIDs' " + " OBSOLETE" |
| | | + " AUX 1.3.6.1.1.1.2.0" + " MUST cn " + " MAY dc " |
| | | + " NOT x121Address )", true }, |
| | | { |
| | | "( 2.5.6.4 NAME 'full rule' DESC 'illegal OIDs' " + " OBSOLETE" |
| | | "( 2.5.6.4 NAME 'fullRule' DESC 'illegal OIDs' " + " OBSOLETE" |
| | | + " AUX 2.5.6.." + " MUST cn " + " MAY dc " |
| | | + " NOT x121Address )", false }, |
| | | { |
| | | "( 2.5.6.4 NAME 'full rule' DESC 'illegal OIDs' " + " OBSOLETE" |
| | | "( 2.5.6.4 NAME 'fullRule' DESC 'illegal OIDs' " + " OBSOLETE" |
| | | + " AUX 2.5.6.x" + " MUST cn " + " MAY dc " |
| | | + " NOT x121Address )", false }, |
| | | { |
| | | "( 2.5.6.4 NAME 'full rule' DESC 'missing closing parenthesis' " |
| | | "( 2.5.6.4 NAME 'fullRule' DESC 'missing closing parenthesis' " |
| | | + " OBSOLETE" + " AUX posixAccount" + " MUST cn " + " MAY dc " |
| | | + " NOT x121Address", false }, |
| | | { |
| | | "( 2.5.6.4 NAME 'full rule' DESC 'extra parameterss' " |
| | | "( 2.5.6.4 NAME 'fullRule' DESC 'extra parameterss' " |
| | | + " MUST cn " + " X-name ( 'this is an extra parameter' ) )", |
| | | true }, |
| | | |
| | |
| | | { |
| | | return new Object[][] { |
| | | { |
| | | "( 1.2.3.4 NAME 'full matching rule' " |
| | | "( 1.2.3.4 NAME 'fullMatchingRule' " |
| | | + " DESC 'description of matching rule' OBSOLETE " |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 " |
| | | + " X-name ( 'this is an extension' ) )", true }, |
| | | { |
| | | "( 1.2.3.4 NAME 'missing closing parenthesis' " |
| | | "( 1.2.3.4 NAME 'missingClosingParenthesis' " |
| | | + " DESC 'description of matching rule' " |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 " |
| | | + " X-name ( 'this is an extension' ) ", false }, }; |
| | |
| | | { |
| | | return new Object[][] { |
| | | { |
| | | "( 2.5.13.10 NAME 'full matching rule' " |
| | | "( 2.5.13.10 NAME 'fullMatchingRule' " |
| | | + " DESC 'description of matching rule' OBSOLETE " |
| | | + " APPLIES 2.5.4.3 " + " X-name 'this is an extension' )", |
| | | true }, |
| | | { |
| | | "( 2.5.13.10 NAME 'missing closing parenthesis' " |
| | | "( 2.5.13.10 NAME 'missingClosingParenthesis' " |
| | | + " DESC 'description of matching rule' " + " SYNTAX 2.5.4.3 " |
| | | + " X-name ( 'this is an extension' ) ", false }, }; |
| | | } |
| | |
| | | * {@code true} if the attribute description requires the |
| | | * compatibility option to be set. |
| | | */ |
| | | @Test(enabled = false, dataProvider = "validAttributeDescriptions") |
| | | @Test(dataProvider = "validAttributeDescriptions") |
| | | public void testValidAttributeDescriptions(String atd, |
| | | boolean allowIllegalCharacters) |
| | | { |
| | |
| | | * {@code true} if the attribute description requires the |
| | | * compatibility option to be set. |
| | | */ |
| | | @Test(enabled = false, dataProvider = "invalidAttributeDescriptions", |
| | | expectedExceptions = LocalizedIllegalArgumentException.class) |
| | | public void testinvalidAttributeDescriptions(String atd, |
| | | @Test(dataProvider = "invalidAttributeDescriptions", expectedExceptions = LocalizedIllegalArgumentException.class) |
| | | public void testInvalidAttributeDescriptions(String atd, |
| | | boolean allowIllegalCharacters) |
| | | { |
| | | SchemaBuilder builder = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | Schema schema = builder.toSchema().nonStrict(); |
| | | AttributeDescription.valueOf(atd, schema); |
| | | } |
| | | |
| | | |
| | | |
| | | private static final Syntax ATD_SYNTAX = CoreSchema |
| | | .getAttributeTypeDescriptionSyntax(); |
| | | private static final Syntax OCD_SYNTAX = CoreSchema |
| | | .getObjectClassDescriptionSyntax(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns test data for invalid schema elements. |
| | | * |
| | | * @return The test data. |
| | | */ |
| | | @DataProvider |
| | | public Object[][] invalidSchemaElements() |
| | | { |
| | | // @formatter:off |
| | | return new Object[][] { |
| | | { "(testtype+oid NAME 'testtype' DESC 'full type' OBSOLETE SUP cn " |
| | | + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" |
| | | + " SUBSTR caseIgnoreSubstringsMatch" |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" |
| | | + " USAGE userApplications )", |
| | | ATD_SYNTAX, |
| | | false |
| | | }, |
| | | { "(testtype_oid NAME 'testtype' DESC 'full type' OBSOLETE SUP cn " |
| | | + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" |
| | | + " SUBSTR caseIgnoreSubstringsMatch" |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" |
| | | + " USAGE userApplications )", |
| | | ATD_SYNTAX, |
| | | false |
| | | }, |
| | | { "(testtype.oid NAME 'testtype' DESC 'full type' OBSOLETE SUP cn " |
| | | + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" |
| | | + " SUBSTR caseIgnoreSubstringsMatch" |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" |
| | | + " USAGE userApplications )", |
| | | ATD_SYNTAX, |
| | | false |
| | | }, |
| | | { "(1.2.8.5 NAME 'test+type' DESC 'full type' OBSOLETE SUP cn " |
| | | + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" |
| | | + " SUBSTR caseIgnoreSubstringsMatch" |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" |
| | | + " USAGE userApplications )", |
| | | ATD_SYNTAX, |
| | | false |
| | | }, |
| | | { "(1.2.8.5 NAME 'test.type' DESC 'full type' OBSOLETE SUP cn " |
| | | + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" |
| | | + " SUBSTR caseIgnoreSubstringsMatch" |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" |
| | | + " USAGE userApplications )", |
| | | ATD_SYNTAX, |
| | | false |
| | | }, |
| | | { "(1.2.8.5 NAME 'test_type' DESC 'full type' OBSOLETE SUP cn " |
| | | + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" |
| | | + " SUBSTR caseIgnoreSubstringsMatch" |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" |
| | | + " USAGE userApplications )", |
| | | ATD_SYNTAX, |
| | | false |
| | | }, |
| | | { "(1.2.8.5 NAME 'test+type' DESC 'full type' OBSOLETE SUP cn " |
| | | + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" |
| | | + " SUBSTR caseIgnoreSubstringsMatch" |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" |
| | | + " USAGE userApplications )", |
| | | ATD_SYNTAX, |
| | | true |
| | | }, |
| | | }; |
| | | // @formatter:on |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test schema builder schema element parsing with compat chars. |
| | | * |
| | | * @param element |
| | | * The schema element. |
| | | * @param syntax |
| | | * The type of element. |
| | | * @param allowIllegalCharacters |
| | | * {@code true} if the element requires the compatibility option to |
| | | * be set. |
| | | */ |
| | | @Test(dataProvider = "invalidSchemaElements", expectedExceptions = LocalizedIllegalArgumentException.class) |
| | | public void testInvalidSchemaBuilderElementParsers(String element, |
| | | Syntax syntax, boolean allowIllegalCharacters) |
| | | { |
| | | SchemaBuilder builder = new SchemaBuilder() |
| | | .setSchemaCompatOptions(SchemaCompatOptions.defaultOptions() |
| | | .allowMalformedNamesAndOptions(allowIllegalCharacters)); |
| | | |
| | | if (syntax == ATD_SYNTAX) |
| | | { |
| | | builder.addAttributeType(element, false); |
| | | } |
| | | else if (syntax == OCD_SYNTAX) |
| | | { |
| | | builder.addObjectClass(element, false); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns test data for valid schema elements. |
| | | * |
| | | * @return The test data. |
| | | */ |
| | | @DataProvider |
| | | public Object[][] validSchemaElements() |
| | | { |
| | | // @formatter:off |
| | | return new Object[][] { |
| | | { "(1.2.8.5 NAME 'testtype' DESC 'full type' OBSOLETE SUP cn " |
| | | + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" |
| | | + " SUBSTR caseIgnoreSubstringsMatch" |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" |
| | | + " USAGE userApplications )", |
| | | ATD_SYNTAX, |
| | | false |
| | | }, |
| | | { "(testtype-oid NAME 'testtype' DESC 'full type' OBSOLETE SUP cn " |
| | | + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" |
| | | + " SUBSTR caseIgnoreSubstringsMatch" |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" |
| | | + " USAGE userApplications )", |
| | | ATD_SYNTAX, |
| | | false |
| | | }, |
| | | { "(testtype_oid NAME 'testtype' DESC 'full type' OBSOLETE SUP cn " |
| | | + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" |
| | | + " SUBSTR caseIgnoreSubstringsMatch" |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" |
| | | + " USAGE userApplications )", |
| | | ATD_SYNTAX, |
| | | true |
| | | }, |
| | | { "(testtype.oid NAME 'testtype' DESC 'full type' OBSOLETE SUP cn " |
| | | + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" |
| | | + " SUBSTR caseIgnoreSubstringsMatch" |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" |
| | | + " USAGE userApplications )", |
| | | ATD_SYNTAX, |
| | | true |
| | | }, |
| | | { "(1.2.8.5 NAME 'test-type' DESC 'full type' OBSOLETE SUP cn " |
| | | + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" |
| | | + " SUBSTR caseIgnoreSubstringsMatch" |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" |
| | | + " USAGE userApplications )", |
| | | ATD_SYNTAX, |
| | | false |
| | | }, |
| | | { "(1.2.8.5 NAME 'test.type' DESC 'full type' OBSOLETE SUP cn " |
| | | + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" |
| | | + " SUBSTR caseIgnoreSubstringsMatch" |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" |
| | | + " USAGE userApplications )", |
| | | ATD_SYNTAX, |
| | | true |
| | | }, |
| | | { "(1.2.8.5 NAME 'test_type' DESC 'full type' OBSOLETE SUP cn " |
| | | + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" |
| | | + " SUBSTR caseIgnoreSubstringsMatch" |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" |
| | | + " USAGE userApplications )", |
| | | ATD_SYNTAX, |
| | | true |
| | | }, |
| | | }; |
| | | // @formatter:on |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test schema builder schema element parsing with compat chars. |
| | | * |
| | | * @param element |
| | | * The schema element. |
| | | * @param syntax |
| | | * The type of element. |
| | | * @param allowIllegalCharacters |
| | | * {@code true} if the element requires the compatibility option to |
| | | * be set. |
| | | */ |
| | | @Test(dataProvider = "validSchemaElements") |
| | | public void testValidSchemaBuilderElementParsers(String element, |
| | | Syntax syntax, boolean allowIllegalCharacters) |
| | | { |
| | | SchemaBuilder builder = new SchemaBuilder() |
| | | .setSchemaCompatOptions(SchemaCompatOptions.defaultOptions() |
| | | .allowMalformedNamesAndOptions(allowIllegalCharacters)); |
| | | |
| | | if (syntax == ATD_SYNTAX) |
| | | { |
| | | builder.addAttributeType(element, false); |
| | | } |
| | | else if (syntax == OCD_SYNTAX) |
| | | { |
| | | builder.addObjectClass(element, false); |
| | | } |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | { |
| | | return new Object[][] { { "" }, { ".0" }, { "0." }, { "100." }, { ".999" }, |
| | | { "1one" }, { "one+two+three" }, |
| | | { "one.two.three" }, |
| | | // AD puts quotes around OIDs - test mismatched quotes. |
| | | { "'0" }, { "'10" }, { "999'" }, { "0.0'" }, }; |
| | | } |
| | |
| | | // Not strictly legal, but we'll be lenient with what we accept. |
| | | { "0" }, { "1" }, { "2" }, { "3" }, { "4" }, { "5" }, { "6" }, { "7" }, |
| | | { "8" }, { "9" }, { "00" }, { "01" }, { "01.0" }, { "0.01" }, |
| | | { "one.two.three" }, }; |
| | | }; |
| | | } |
| | | |
| | | |
| | |
| | | public void testReadOIDInvalid(final String oid) throws DecodeException |
| | | { |
| | | final SubstringReader reader = new SubstringReader(oid); |
| | | SchemaUtils.readOID(reader); |
| | | SchemaUtils.readOID(reader, false); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | final SubstringReader reader = new SubstringReader(oid); |
| | | Assert.assertEquals(SchemaUtils.readOID(reader), expected); |
| | | Assert.assertEquals(SchemaUtils.readOID(reader, false), expected); |
| | | } |
| | | } |