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

Matthew Swift
14.49.2013 f9782e0ddb8f40d5f9c249366aa0ad5c2d6cc127
Minor fix to prevent attempts to create resources with a client provided resource ID when resource IDs are server generated.
1 files modified
12 ■■■■ changed files
opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAP.java 12 ●●●● patch | view | raw | blame | history
opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAP.java
@@ -282,8 +282,13 @@
        @Override
        void setResourceId(final Context c, final DN baseDN, final String resourceId,
                final Entry entry) {
            if (!isServerProvided) {
                final Entry entry) throws ResourceException {
            if (isServerProvided) {
                if (resourceId != null) {
                    throw new BadRequestException("Resources cannot be created with a "
                            + "client provided resource ID");
                }
            } else {
                entry.addAttribute(new LinkedAttribute(idAttribute, ByteString.valueOf(resourceId)));
            }
            final String rdnValue = entry.parseAttribute(dnAttribute).asString();
@@ -325,7 +330,8 @@
            } else if (entry.getAttribute(attribute) != null) {
                entry.setName(baseDN.child(rdn(entry.parseAttribute(attribute).asString())));
            } else {
                throw new BadRequestException("Unable to set the resource ID");
                throw new BadRequestException("Resources cannot be created without a "
                        + "client provided resource ID");
            }
        }