Path: blob/master/src/java.naming/share/classes/javax/naming/ldap/BasicControl.java
41159 views
/*1* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.naming.ldap;2627/**28* This class provides a basic implementation of the {@code Control}29* interface. It represents an LDAPv3 Control as defined in30* <a href="http://www.ietf.org/rfc/rfc2251.txt">RFC 2251</a>.31*32* @since 1.533* @author Vincent Ryan34*/35public class BasicControl implements Control {3637/**38* The control's object identifier string.39*40* @serial41*/42protected String id;4344/**45* The control's criticality.46*47* @serial48*/49protected boolean criticality = false; // default5051/**52* The control's ASN.1 BER encoded value.53*54* @serial55*/56protected byte[] value = null;5758private static final long serialVersionUID = -4233907508771791687L;5960/**61* Constructs a non-critical control.62*63* @param id The control's object identifier string.64*65*/66public BasicControl(String id) {67this.id = id;68}6970/**71* Constructs a control using the supplied arguments.72*73* @param id The control's object identifier string.74* @param criticality The control's criticality.75* @param value The control's ASN.1 BER encoded value.76* It is not cloned - any changes to value77* will affect the contents of the control.78* It may be null.79*/80public BasicControl(String id, boolean criticality, byte[] value) {81this.id = id;82this.criticality = criticality;83this.value = value;84}8586/**87* Retrieves the control's object identifier string.88*89* @return The non-null object identifier string.90*/91public String getID() {92return id;93}9495/**96* Determines the control's criticality.97*98* @return true if the control is critical; false otherwise.99*/100public boolean isCritical() {101return criticality;102}103104/**105* Retrieves the control's ASN.1 BER encoded value.106* The result includes the BER tag and length for the control's value but107* does not include the control's object identifier and criticality setting.108*109* @return A possibly null byte array representing the control's110* ASN.1 BER encoded value. It is not cloned - any changes to the111* returned value will affect the contents of the control.112*/113public byte[] getEncodedValue() {114return value;115}116}117118119