src/java.naming/share/classes/javax/naming/ldap/StartTlsRequest.java
author stefank
Mon, 25 Nov 2019 15:00:32 +0100
changeset 59255 a74627659f96
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234602: ZGC: Windows compile error in ZHeuristic Reviewed-by: pliden, eosterlund
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) 2000, 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 javax.naming.ldap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.security.PrivilegedAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.naming.ConfigurationException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.naming.NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import com.sun.naming.internal.VersionHelper;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.ServiceLoader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.ServiceConfigurationError;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * This class implements the LDAPv3 Extended Request for StartTLS as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * defined in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <a href="http://www.ietf.org/rfc/rfc2830.txt">Lightweight Directory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Access Protocol (v3): Extension for Transport Layer Security</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * The object identifier for StartTLS is 1.3.6.1.4.1.1466.20037
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * and no extended request value is defined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *<p>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    46
 * {@code StartTlsRequest}/{@code StartTlsResponse} are used to establish
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * a TLS connection over the existing LDAP connection associated with
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    48
 * the JNDI context on which {@code extendedOperation()} is invoked.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * Typically, a JNDI program uses these classes as follows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * import javax.naming.ldap.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * // Open an LDAP association
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * LdapContext ctx = new InitialLdapContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * // Perform a StartTLS extended operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * StartTlsResponse tls =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *     (StartTlsResponse) ctx.extendedOperation(new StartTlsRequest());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * // Open a TLS connection (over the existing LDAP association) and get details
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * // of the negotiated TLS session: cipher suite, peer certificate, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * SSLSession session = tls.negotiate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * // ... use ctx to perform protected LDAP operations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * // Close the TLS connection (revert back to the underlying LDAP association)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * tls.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * // ... use ctx to perform unprotected LDAP operations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * // Close the LDAP association
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * ctx.close;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * @see StartTlsResponse
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * @author Vincent Ryan
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
public class StartTlsRequest implements ExtendedRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    // Constant
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * The StartTLS extended request's assigned object identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * is 1.3.6.1.4.1.1466.20037.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    public static final String OID = "1.3.6.1.4.1.1466.20037";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    // Constructors
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * Constructs a StartTLS extended request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public StartTlsRequest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    // ExtendedRequest methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * Retrieves the StartTLS request's object identifier string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @return The object identifier string, "1.3.6.1.4.1.1466.20037".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    public String getID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        return OID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * Retrieves the StartTLS request's ASN.1 BER encoded value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * Since the request has no defined value, null is always
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @return The null value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public byte[] getEncodedValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * Creates an extended response object that corresponds to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * LDAP StartTLS extended request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * The result must be a concrete subclass of StartTlsResponse
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * and must have a public zero-argument constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * This method locates the implementation class by locating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * configuration files that have the name:
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   130
     * <blockquote>{@code
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     *     META-INF/services/javax.naming.ldap.StartTlsResponse
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   132
     * }</blockquote>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * The configuration files and their corresponding implementation classes must
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * be accessible to the calling thread's context class loader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * Each configuration file should contain a list of fully-qualified class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * names, one per line.  Space and tab characters surrounding each name, as
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   138
     * well as blank lines, are ignored.  The comment character is {@code '#'}
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   139
     * ({@code 0x23}); on each line all characters following the first comment
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * character are ignored.  The file must be encoded in UTF-8.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * This method will return an instance of the first implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * class that it is able to load and instantiate successfully from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * the list of class names collected from the configuration files.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * This method uses the calling thread's context classloader to find the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * configuration files and to load the implementation class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * If no class can be found in this way, this method will use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * an implementation-specific way to locate an implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * If none is found, a NamingException is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @param id         The object identifier of the extended response.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     *                   Its value must be "1.3.6.1.4.1.1466.20037" or null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *                   Both values are equivalent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @param berValue   The possibly null ASN.1 BER encoded value of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *                   extended response. This is the raw BER bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     *                   including the tag and length of the response value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *                   It does not include the response OID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     *                   Its value is ignored because a Start TLS response
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     *                   is not expected to contain any response value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @param offset     The starting position in berValue of the bytes to use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *                   Its value is ignored because a Start TLS response
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *                   is not expected to contain any response value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @param length     The number of bytes in berValue to use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *                   Its value is ignored because a Start TLS response
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     *                   is not expected to contain any response value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @return           The StartTLS extended response object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @exception        NamingException If a naming exception was encountered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     *                   while creating the StartTLS extended response object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    public ExtendedResponse createExtendedResponse(String id, byte[] berValue,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        int offset, int length) throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        // Confirm that the object identifier is correct
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        if ((id != null) && (!id.equals(OID))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            throw new ConfigurationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                "Start TLS received the following response instead of " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                OID + ": " + id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        StartTlsResponse resp = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        ServiceLoader<StartTlsResponse> sl = ServiceLoader.load(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                StartTlsResponse.class, getContextClassLoader());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        Iterator<StartTlsResponse> iter = sl.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        while (resp == null && privilegedHasNext(iter)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            resp = iter.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        if (resp != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            return resp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            VersionHelper helper = VersionHelper.getVersionHelper();
37782
ad8fe7507ecc 6850612: Deprecate Class.newInstance since it violates the checked exception language contract
darcy
parents: 32029
diff changeset
   195
            @SuppressWarnings("deprecation")
ad8fe7507ecc 6850612: Deprecate Class.newInstance since it violates the checked exception language contract
darcy
parents: 32029
diff changeset
   196
            Object o = helper.loadClass(
ad8fe7507ecc 6850612: Deprecate Class.newInstance since it violates the checked exception language contract
darcy
parents: 32029
diff changeset
   197
                "com.sun.jndi.ldap.ext.StartTlsResponseImpl").newInstance();
ad8fe7507ecc 6850612: Deprecate Class.newInstance since it violates the checked exception language contract
darcy
parents: 32029
diff changeset
   198
            resp = (StartTlsResponse) o;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
37782
ad8fe7507ecc 6850612: Deprecate Class.newInstance since it violates the checked exception language contract
darcy
parents: 32029
diff changeset
   200
        } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            throw wrapException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        return resp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * Wrap an exception, thrown while attempting to load the StartTlsResponse
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * class, in a configuration exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    private ConfigurationException wrapException(Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        ConfigurationException ce = new ConfigurationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            "Cannot load implementation of javax.naming.ldap.StartTlsResponse");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        ce.setRootCause(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        return ce;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * Acquire the class loader associated with this thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    private final ClassLoader getContextClassLoader() {
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   223
        return AccessController.doPrivileged(
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   224
            new PrivilegedAction<ClassLoader>() {
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   225
                public ClassLoader run() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                    return Thread.currentThread().getContextClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   232
    private final static boolean privilegedHasNext(final Iterator<StartTlsResponse> iter) {
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   233
        Boolean answer = AccessController.doPrivileged(
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   234
            new PrivilegedAction<Boolean>() {
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   235
            public Boolean run() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                return Boolean.valueOf(iter.hasNext());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        return answer.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    private static final long serialVersionUID = 4441679576360753397L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
}