mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noël Rouvignac
07.42.2016 1aa67b085c51f71b565baece6acfc8845c024641
AttributeDescription.create(attributeName, attributeType) must respect user provided attribute name

AttributeDescription.java:
In create(attributeName, attributeType), keep user provided attribute name
In create(attributeType), restored previous code to avoid check on attributeName
2 files modified
19 ■■■■ changed files
opendj-core/src/main/java/org/forgerock/opendj/ldap/AttributeDescription.java 13 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/AttributeDescriptionTestCase.java 6 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/AttributeDescription.java
@@ -529,7 +529,14 @@
     *             If {@code attributeType} was {@code null}.
     */
    public static AttributeDescription create(final AttributeType attributeType) {
        return create(attributeType.getNameOrOID(), attributeType);
        Reject.ifNull(attributeType);
        // Use object identity in case attribute type does not come from core schema.
        if (attributeType == OBJECT_CLASS.getAttributeType()) {
            return OBJECT_CLASS;
        }
        String attributeName = attributeType.getNameOrOID();
        return new AttributeDescription(attributeName, attributeName, attributeType,          ZERO_OPTION_IMPL);
    }
    /**
@@ -549,8 +556,8 @@
    public static AttributeDescription create(final String attributeName, final AttributeType attributeType) {
        Reject.ifNull(attributeName, attributeType);
        // Use object identity in case attribute type does not come from core schema.
        if (attributeType == OBJECT_CLASS.getAttributeType()) {
        if (attributeType == OBJECT_CLASS.getAttributeType()
                && attributeName.equals(attributeType.getNameOrOID())) {
            return OBJECT_CLASS;
        }
        return new AttributeDescription(attributeName, attributeName, attributeType, ZERO_OPTION_IMPL);
opendj-core/src/test/java/org/forgerock/opendj/ldap/AttributeDescriptionTestCase.java
@@ -438,8 +438,12 @@
    @Test
    public void testCreateAttributeNameAndType() {
        testCreateAttributeNameAndType0("CN");
        testCreateAttributeNameAndType0("OBJECTCLASS");
    }
    private void testCreateAttributeNameAndType0(String name) {
        Schema schema = Schema.getCoreSchema();
        String name = "CN";
        AttributeType attributeType = schema.getAttributeType(name);
        assertAttributeDescriptionCreate(