/* * 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 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 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 2010 Sun Microsystems, Inc. * Portions copyright 2011-2012 ForgeRock AS */ package org.forgerock.opendj.ldap.controls; import static com.forgerock.opendj.util.StaticUtils.getExceptionMessage; import static org.forgerock.opendj.ldap.CoreMessages.ERR_SUBENTRIES_CANNOT_DECODE_VALUE; import static org.forgerock.opendj.ldap.CoreMessages.ERR_SUBENTRIES_CONTROL_BAD_OID; import static org.forgerock.opendj.ldap.CoreMessages.ERR_SUBENTRIES_NO_CONTROL_VALUE; import java.io.IOException; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.asn1.ASN1; import org.forgerock.opendj.asn1.ASN1Reader; import org.forgerock.opendj.asn1.ASN1Writer; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.ByteStringBuilder; import org.forgerock.opendj.ldap.DecodeException; import org.forgerock.opendj.ldap.DecodeOptions; import com.forgerock.opendj.util.StaticUtils; import com.forgerock.opendj.util.Validator; /** * The sub-entries request control as defined in RFC 3672. This control may be * included in a search request to indicate that sub-entries should be included * in the search results. *
* In the absence of the sub-entries request control, sub-entries are not * visible to search operations unless the target/base of the operation is a * sub-entry. In the presence of the sub-entry request control, sub-entries are * visible if and only if the control's value is {@code TRUE}. *
* Consider "Class of Service" sub-entries such as the following: * *
* dn: cn=Gold Class of Service,dc=example,dc=com
* objectClass: collectiveAttributeSubentry
* objectClass: extensibleObject
* objectClass: subentry
* objectClass: top
* cn: Gold Class of Service
* diskQuota;collective: 100 GB
* mailQuota;collective: 10 GB
* subtreeSpecification: { base "ou=People", specificationFilter "(classOfService=
* gold)" }
*
*
* To access the sub-entries in your search, use the control with value
* {@code TRUE}.
*
*
* Connection connection = ...;
*
* SearchRequest request = Requests.newSearchRequest("dc=example,dc=com",
* SearchScope.WHOLE_SUBTREE, "cn=*Class of Service", "cn", "subtreeSpecification")
* .addControl(SubentriesRequestControl.newControl(true, true));
*
* ConnectionEntryReader reader = connection.search(request);
* while (reader.hasNext()) {
* if (reader.isEntry()) {
* SearchResultEntry entry = reader.readEntry();
* // ...
* }
* }
*
*
* @see RFC 3672 - Subentries in
* the Lightweight Directory Access Protocol
*/
public final class SubentriesRequestControl implements Control {
/**
* The OID for the sub-entries request control.
*/
public static final String OID = "1.3.6.1.4.1.4203.1.10.1";
private static final SubentriesRequestControl CRITICAL_VISIBLE_INSTANCE =
new SubentriesRequestControl(true, true);
private static final SubentriesRequestControl NONCRITICAL_VISIBLE_INSTANCE =
new SubentriesRequestControl(false, true);
private static final SubentriesRequestControl CRITICAL_INVISIBLE_INSTANCE =
new SubentriesRequestControl(true, false);
private static final SubentriesRequestControl NONCRITICAL_INVISIBLE_INSTANCE =
new SubentriesRequestControl(false, false);
/**
* A decoder which can be used for decoding the sub-entries request control.
*/
public static final ControlDecoder