Path: blob/master/src/java.naming/share/classes/com/sun/jndi/ldap/BasicControl.java
41161 views
/*1* Copyright (c) 1999, 2013, 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 com.sun.jndi.ldap;2627import javax.naming.ldap.*;2829/**30* This class provides a basic implementation of the {@code Control}31* interface. It represents an LDAPv3 Control as defined in RFC-2251.32*33* @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 = -5914033725246428413L;5960/**61* Constructs a new instance of BasicControl.62* It is a non-critical control.63*64* @param id The control's object identifier string.65*66*/67public BasicControl(String id) {68this.id = id;69}7071/**72* Constructs a new instance of BasicControl.73*74* @param id The control's object identifier string.75* @param criticality The control's criticality.76* @param value The control's ASN.1 BER encoded value.77* May be null.78*/79public BasicControl(String id, boolean criticality, byte[] value) {80this.id = id;81this.criticality = criticality;82if (value != null) {83this.value = value.clone();84}85}8687/**88* Retrieves the control's object identifier string.89*90* @return The non-null object identifier string.91*/92public String getID() {93return id;94}9596/**97* Determines the control's criticality.98*99* @return true if the control is critical; false otherwise.100*/101public boolean isCritical() {102return criticality;103}104105/**106* Retrieves the control's ASN.1 BER encoded value.107* The result is the raw BER bytes including the tag and length of108* the control's value. It does not include the control's object109* identifier string or criticality.110*111* @return A possibly null byte array representing the control's112* ASN.1 BER encoded value.113*/114public byte[] getEncodedValue() {115return value == null ? null : value.clone();116}117}118119120