Path: blob/master/src/java.naming/share/classes/com/sun/jndi/ldap/UnsolicitedResponseImpl.java
41161 views
/*1* Copyright (c) 1999, 2011, 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.UnsolicitedNotification;28import javax.naming.NamingException;29import javax.naming.ldap.Control;30import java.util.Vector;3132/**33* A concrete implementation of an UnsolicitedNotification.34* @author Rosanna Lee35*/36final class UnsolicitedResponseImpl implements UnsolicitedNotification {37private String oid;38private String[] referrals;39private byte[] extensionValue;40private NamingException exception;41private Control[] controls;4243UnsolicitedResponseImpl(String oid, byte[] berVal, Vector<Vector<String>> ref,44int status, String msg, String matchedDN, Control[] controls) {45this.oid = oid;46this.extensionValue = berVal;4748if (ref != null && ref.size() > 0) {49int len = ref.size();50referrals = new String[len];51for (int i = 0; i < len; i++) {52// ref is a list of single-String Vectors53referrals[i] = ref.elementAt(i).elementAt(0);54}55}56exception = LdapCtx.mapErrorCode(status, msg);57// matchedDN ignored for now; could be used to set resolvedName58// exception.setResolvedName(new CompositeName().add(matchedDN));5960this.controls = controls;61}6263/**64* Retrieves the object identifier of the response.65*66* @return A possibly null object identifier string representing the LDAP67* {@code ExtendedResponse.responseName} component.68*/69public String getID() {70return oid;71}7273/**74* Retrieves the ASN.1 BER encoded value of the LDAP extended operation75* response. Null is returned if the value is absent from the response76* sent by the LDAP server.77* The result is the raw BER bytes including the tag and length of78* the response value. It does not include the response OID.79*80* @return A possibly null byte array representing the ASN.1 BER encoded81* contents of the LDAP {@code ExtendedResponse.response}82* component.83*/84public byte[] getEncodedValue() {85return extensionValue;86}8788/**89* Retrieves the referral(s) sent by the server.90*91* @return A possibly null array of referrals, each of which is represented92* by a URL string. If null, no referral was sent by the server.93*/94public String[] getReferrals() {95return referrals;96}9798/**99* Retrieves the exception as constructed using information100* sent by the server.101* @return A possibly null exception as constructed using information102* sent by the server. If null, a "success" status was indicated by103* the server.104*/105public NamingException getException() {106return exception;107}108109public Control[] getControls() throws NamingException {110return controls;111}112113private static final long serialVersionUID = 5913778898401784775L;114}115116117