0N/A/*
2362N/A * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.jndi.ldap;
0N/A
0N/Aimport javax.naming.ldap.UnsolicitedNotification;
0N/Aimport javax.naming.NamingException;
0N/Aimport javax.naming.ldap.Control;
0N/Aimport java.util.Vector;
0N/A
0N/A/**
0N/A * A concrete implementation of an UnsolicitedNotification.
0N/A * @author Rosanna Lee
0N/A */
0N/Afinal class UnsolicitedResponseImpl implements UnsolicitedNotification {
0N/A private String oid;
0N/A private String[] referrals;
0N/A private byte[] extensionValue;
0N/A private NamingException exception;
0N/A private Control[] controls;
0N/A
0N/A UnsolicitedResponseImpl(String oid, byte[] berVal, Vector ref,
0N/A int status, String msg, String matchedDN, Control[] controls) {
0N/A this.oid = oid;
0N/A this.extensionValue = berVal;
0N/A
0N/A if (ref != null && ref.size() > 0) {
0N/A int len = ref.size();
0N/A referrals = new String[len];
0N/A for (int i = 0; i < len; i++) {
0N/A referrals[i] = (String)ref.elementAt(i);
0N/A }
0N/A }
0N/A exception = LdapCtx.mapErrorCode(status, msg);
0N/A // matchedDN ignored for now; could be used to set resolvedName
0N/A // exception.setResolvedName(new CompositeName().add(matchedDN));
0N/A
0N/A this.controls = controls;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the object identifier of the response.
0N/A *
0N/A * @return A possibly null object identifier string representing the LDAP
0N/A * <tt>ExtendedResponse.responseName</tt> component.
0N/A */
0N/A public String getID() {
0N/A return oid;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the ASN.1 BER encoded value of the LDAP extended operation
0N/A * response. Null is returned if the value is absent from the response
0N/A * sent by the LDAP server.
0N/A * The result is the raw BER bytes including the tag and length of
0N/A * the response value. It does not include the response OID.
0N/A *
0N/A * @return A possibly null byte array representing the ASN.1 BER encoded
0N/A * contents of the LDAP <tt>ExtendedResponse.response</tt>
0N/A * component.
0N/A */
0N/A public byte[] getEncodedValue() {
0N/A return extensionValue;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the referral(s) sent by the server.
0N/A *
0N/A * @return A possibly null array of referrals, each of which is represented
0N/A * by a URL string. If null, no referral was sent by the server.
0N/A */
0N/A public String[] getReferrals() {
0N/A return referrals;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the exception as constructed using information
0N/A * sent by the server.
0N/A * @return A possibly null exception as constructed using information
0N/A * sent by the server. If null, a "success" status was indicated by
0N/A * the server.
0N/A */
0N/A public NamingException getException() {
0N/A return exception;
0N/A }
0N/A
0N/A public Control[] getControls() throws NamingException {
0N/A return controls;
0N/A }
0N/A
0N/A private static final long serialVersionUID = 5913778898401784775L;
0N/A}