001/* 002 * Copyright 2008-2020 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2008-2020 Ping Identity Corporation 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020/* 021 * Copyright (C) 2015-2020 Ping Identity Corporation 022 * 023 * This program is free software; you can redistribute it and/or modify 024 * it under the terms of the GNU General Public License (GPLv2 only) 025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 026 * as published by the Free Software Foundation. 027 * 028 * This program is distributed in the hope that it will be useful, 029 * but WITHOUT ANY WARRANTY; without even the implied warranty of 030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 031 * GNU General Public License for more details. 032 * 033 * You should have received a copy of the GNU General Public License 034 * along with this program; if not, see <http://www.gnu.org/licenses>. 035 */ 036package com.unboundid.ldap.sdk.unboundidds.controls; 037 038 039 040import com.unboundid.ldap.sdk.Control; 041import com.unboundid.ldap.sdk.LDAPException; 042import com.unboundid.ldap.sdk.ResultCode; 043import com.unboundid.util.NotMutable; 044import com.unboundid.util.ThreadSafety; 045import com.unboundid.util.ThreadSafetyLevel; 046 047import static com.unboundid.ldap.sdk.unboundidds.controls.ControlMessages.*; 048 049 050 051/** 052 * This class provides an implementation of the real attributes only request 053 * control, which may be included in a search request to indicate that only 054 * real (i.e., non-virtual) attributes should be included in matching entries. 055 * <BR> 056 * <BLOCKQUOTE> 057 * <B>NOTE:</B> This class, and other classes within the 058 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 059 * supported for use against Ping Identity, UnboundID, and 060 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 061 * for proprietary functionality or for external specifications that are not 062 * considered stable or mature enough to be guaranteed to work in an 063 * interoperable way with other types of LDAP servers. 064 * </BLOCKQUOTE> 065 * <BR> 066 * This control is not based on any public standard, but was first introduced in 067 * the Netscape/iPlanet Directory Server. It is also supported in the Sun Java 068 * System Directory Server, OpenDS, and the Ping Identity, UnboundID, and 069 * Nokia/Alcatel-Lucent 8661 Directory Server. It does not have a value. 070 * <BR><BR> 071 * <H2>Example</H2> 072 * The following example demonstrates the use of the real attributes only 073 * request control: 074 * <PRE> 075 * SearchRequest searchRequest = new SearchRequest("dc=example,dc=com", 076 * SearchScope.SUB, Filter.createEqualityFilter("uid", "john.doe")); 077 * 078 * searchRequest.addControl(new RealAttributesOnlyRequestControl()); 079 * SearchResult searchResult = connection.search(searchRequest); 080 * </PRE> 081 */ 082@NotMutable() 083@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 084public final class RealAttributesOnlyRequestControl 085 extends Control 086{ 087 /** 088 * The OID (2.16.840.1.113730.3.4.17) for the real attributes only request 089 * control. 090 */ 091 public static final String REAL_ATTRIBUTES_ONLY_REQUEST_OID = 092 "2.16.840.1.113730.3.4.17"; 093 094 095 096 /** 097 * The serial version UID for this serializable class. 098 */ 099 private static final long serialVersionUID = -3092359699532262022L; 100 101 102 103 /** 104 * Creates a new real attributes only request control. It will not be marked 105 * critical. 106 */ 107 public RealAttributesOnlyRequestControl() 108 { 109 this(false); 110 } 111 112 113 114 /** 115 * Creates a new real attributes only request control with the specified 116 * criticality. 117 * 118 * @param isCritical Indicates whether this control should be marked 119 * critical. 120 */ 121 public RealAttributesOnlyRequestControl(final boolean isCritical) 122 { 123 super(REAL_ATTRIBUTES_ONLY_REQUEST_OID, isCritical, null); 124 } 125 126 127 128 /** 129 * Creates a new real attributes only request control which is decoded from 130 * the provided generic control. 131 * 132 * @param control The generic control to be decoded as a real attributes 133 * only request control. 134 * 135 * @throws LDAPException If the provided control cannot be decoded as a real 136 * attributes only request control. 137 */ 138 public RealAttributesOnlyRequestControl(final Control control) 139 throws LDAPException 140 { 141 super(control); 142 143 if (control.hasValue()) 144 { 145 throw new LDAPException(ResultCode.DECODING_ERROR, 146 ERR_REAL_ATTRS_ONLY_REQUEST_HAS_VALUE.get()); 147 } 148 } 149 150 151 152 /** 153 * {@inheritDoc} 154 */ 155 @Override() 156 public String getControlName() 157 { 158 return INFO_CONTROL_NAME_REAL_ATTRS_ONLY_REQUEST.get(); 159 } 160 161 162 163 /** 164 * {@inheritDoc} 165 */ 166 @Override() 167 public void toString(final StringBuilder buffer) 168 { 169 buffer.append("RealAttributesOnlyRequestControl(isCritical="); 170 buffer.append(isCritical()); 171 buffer.append(')'); 172 } 173}