src/java.naming/share/classes/com/sun/jndi/ldap/UnsolicitedResponseImpl.java
author lmesnik
Tue, 02 Apr 2019 17:11:04 -0700
changeset 54389 772f62a13376
parent 47216 71c04702a3d5
permissions -rw-r--r--
8221437: assert(java_lang_invoke_ResolvedMethodName::vmtarget(resolved_method()) == m()) failed: Should not change after link resolution Reviewed-by: coleenp, sspitsyn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
     2
 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.jndi.ldap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.naming.ldap.UnsolicitedNotification;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.naming.NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.naming.ldap.Control;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * A concrete implementation of an UnsolicitedNotification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * @author Rosanna Lee
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
final class UnsolicitedResponseImpl implements UnsolicitedNotification {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    private String oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    private String[] referrals;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    private byte[] extensionValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    private NamingException exception;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    private Control[] controls;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
    44
    UnsolicitedResponseImpl(String oid, byte[] berVal, Vector<Vector<String>> ref,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        int status, String msg, String matchedDN, Control[] controls) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        this.oid = oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        this.extensionValue = berVal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        if (ref != null && ref.size() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
            int len = ref.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
            referrals = new String[len];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            for (int i = 0; i < len; i++) {
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
    53
                // ref is a list of single-String Vectors
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
    54
                referrals[i] = ref.elementAt(i).elementAt(0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        exception = LdapCtx.mapErrorCode(status, msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        // matchedDN ignored for now; could be used to set resolvedName
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        // exception.setResolvedName(new CompositeName().add(matchedDN));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        this.controls = controls;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
      * Retrieves the object identifier of the response.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
      * @return A possibly null object identifier string representing the LDAP
30655
d83f50188ca9 8080422: some docs cleanup for core libs
avstepan
parents: 25859
diff changeset
    68
      *         {@code ExtendedResponse.responseName} component.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    public String getID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        return oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
      * Retrieves the ASN.1 BER encoded value of the LDAP extended operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
      * response. Null is returned if the value is absent from the response
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
      * sent by the LDAP server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
      * The result is the raw BER bytes including the tag and length of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
      * the response value. It does not include the response OID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
      * @return A possibly null byte array representing the ASN.1 BER encoded
30655
d83f50188ca9 8080422: some docs cleanup for core libs
avstepan
parents: 25859
diff changeset
    82
      *         contents of the LDAP {@code ExtendedResponse.response}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
      *         component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public byte[] getEncodedValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        return extensionValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * Retrieves the referral(s) sent by the server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @return A possibly null array of referrals, each of which is represented
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * by a URL string. If null, no referral was sent by the server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public String[] getReferrals() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        return referrals;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Retrieves the exception as constructed using information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * sent by the server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @return A possibly null exception as constructed using information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * sent by the server. If null, a "success" status was indicated by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * the server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    public NamingException getException() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        return exception;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public Control[] getControls() throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        return controls;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    private static final long serialVersionUID = 5913778898401784775L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
}