001: /*
002: * Copyright 1999-2002 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.jndi.ldap;
027:
028: import javax.naming.ldap.UnsolicitedNotification;
029: import javax.naming.NamingException;
030: import javax.naming.ldap.Control;
031: import java.util.Vector;
032:
033: /**
034: * A concrete implementation of an UnsolicitedNotification.
035: * @author Rosanna Lee
036: */
037: final class UnsolicitedResponseImpl implements UnsolicitedNotification {
038: private String oid;
039: private String[] referrals;
040: private byte[] extensionValue;
041: private NamingException exception;
042: private Control[] controls;
043:
044: UnsolicitedResponseImpl(String oid, byte[] berVal, Vector ref,
045: int status, String msg, String matchedDN, Control[] controls) {
046: this .oid = oid;
047: this .extensionValue = berVal;
048:
049: if (ref != null && ref.size() > 0) {
050: int len = ref.size();
051: referrals = new String[len];
052: for (int i = 0; i < len; i++) {
053: referrals[i] = (String) ref.elementAt(i);
054: }
055: }
056: exception = LdapCtx.mapErrorCode(status, msg);
057: // matchedDN ignored for now; could be used to set resolvedName
058: // exception.setResolvedName(new CompositeName().add(matchedDN));
059:
060: this .controls = controls;
061: }
062:
063: /**
064: * Retrieves the object identifier of the response.
065: *
066: * @return A possibly null object identifier string representing the LDAP
067: * <tt>ExtendedResponse.responseName</tt> component.
068: */
069: public String getID() {
070: return oid;
071: }
072:
073: /**
074: * Retrieves the ASN.1 BER encoded value of the LDAP extended operation
075: * response. Null is returned if the value is absent from the response
076: * sent by the LDAP server.
077: * The result is the raw BER bytes including the tag and length of
078: * the response value. It does not include the response OID.
079: *
080: * @return A possibly null byte array representing the ASN.1 BER encoded
081: * contents of the LDAP <tt>ExtendedResponse.response</tt>
082: * component.
083: */
084: public byte[] getEncodedValue() {
085: return extensionValue;
086: }
087:
088: /**
089: * Retrieves the referral(s) sent by the server.
090: *
091: * @return A possibly null array of referrals, each of which is represented
092: * by a URL string. If null, no referral was sent by the server.
093: */
094: public String[] getReferrals() {
095: return referrals;
096: }
097:
098: /**
099: * Retrieves the exception as constructed using information
100: * sent by the server.
101: * @return A possibly null exception as constructed using information
102: * sent by the server. If null, a "success" status was indicated by
103: * the server.
104: */
105: public NamingException getException() {
106: return exception;
107: }
108:
109: public Control[] getControls() throws NamingException {
110: return controls;
111: }
112:
113: private static final long serialVersionUID = 5913778898401784775L;
114: }
|