src/java.naming/share/classes/javax/naming/ldap/ExtendedRequest.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
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 5627
diff changeset
     2
 * Copyright (c) 1999, 2010, 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 javax.naming.NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
  * This interface represents an LDAPv3 extended operation request as defined in
5604
d5b97d8361d0 6952701: Use http://www.ietf.org/rfc for rfc references in jdk public APIs
sherman
parents: 2
diff changeset
    32
  * <A HREF="http://www.ietf.org/rfc/rfc2251.txt">RFC 2251</A>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
  * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
  *     ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
  *              requestName      [0] LDAPOID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
  *              requestValue     [1] OCTET STRING OPTIONAL }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
  * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
  * It comprises an object identifier string and an optional ASN.1 BER
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
  * encoded value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
  *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
  * The methods in this class are used by the service provider to construct
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
  * the bits to send to the LDAP server. Applications typically only deal with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
  * the classes that implement this interface, supplying them with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
  * any information required for a particular extended operation request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
  * It would then pass such a class as an argument to the
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    46
  * {@code LdapContext.extendedOperation()} method for performing the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
  * LDAPv3 extended operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
  *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
  * For example, suppose the LDAP server supported a 'get time' extended operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
  * It would supply GetTimeRequest and GetTimeResponse classes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
  *<blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
  * public class GetTimeRequest implements ExtendedRequest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
  *     public GetTimeRequest() {... };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
  *     public ExtendedResponse createExtendedResponse(String id,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
  *         byte[] berValue, int offset, int length)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
  *         throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
  *         return new GetTimeResponse(id, berValue, offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
  *     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
  *     ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
  * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
  * public class GetTimeResponse implements ExtendedResponse {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
  *     long time;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
  *     public GetTimeResponse(String id, byte[] berValue, int offset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
  *         int length) throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
  *         time =      ... // decode berValue to get time
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
  *     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
  *     public java.util.Date getDate() { return new java.util.Date(time) };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
  *     public long getTime() { return time };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
  *     ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
  * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
  *</pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
  * A program would use then these classes as follows:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
  *<blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
  * GetTimeResponse resp =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
  *     (GetTimeResponse) ectx.extendedOperation(new GetTimeRequest());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
  * long time = resp.getTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
  *</pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
  * @author Rosanna Lee
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
  * @author Scott Seligman
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
  * @author Vincent Ryan
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
  * @see ExtendedResponse
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
  * @see LdapContext#extendedOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
  * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
public interface ExtendedRequest extends java.io.Serializable {
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 object identifier of the request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
      * @return The non-null object identifier string representing the LDAP
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    93
      *         {@code ExtendedRequest.requestName} component.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public String getID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
      * Retrieves the ASN.1 BER encoded value of the LDAP extended operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
      * request. Null is returned if the value is absent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
      * The result is the raw BER bytes including the tag and length of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
      * the request value. It does not include the request OID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
      * This method is called by the service provider to get the bits to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
      * put into the extended operation to be sent to the LDAP server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
      * @return A possibly null byte array representing the ASN.1 BER encoded
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   107
      *         contents of the LDAP {@code ExtendedRequest.requestValue}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
      *         component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
      * @exception IllegalStateException If the encoded value cannot be retrieved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
      * because the request contains insufficient or invalid data/state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    public byte[] getEncodedValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
      * Creates the response object that corresponds to this request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
      *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
      * After the service provider has sent the extended operation request
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
      * to the LDAP server, it will receive a response from the server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
      * If the operation failed, the provider will throw a NamingException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
      * If the operation succeeded, the provider will invoke this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
      * using the data that it got back in the response.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
      * It is the job of this method to return a class that implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
      * the ExtendedResponse interface that is appropriate for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
      * extended operation request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
      *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
      * For example, a Start TLS extended request class would need to know
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
      * how to process a Start TLS extended response. It does this by creating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
      * a class that implements ExtendedResponse.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
      * @param id       The possibly null object identifier of the response
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
      *                 control.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
      * @param berValue The possibly null ASN.1 BER encoded value of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
      *                 response control.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
      * This is the raw BER bytes including the tag and length of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
      * the response value. It does not include the response OID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
      * @param offset   The starting position in berValue of the bytes to use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
      * @param length   The number of bytes in berValue to use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
      * @return A non-null object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
      * @exception NamingException if cannot create extended response
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
      *     due to an error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
      * @see ExtendedResponse
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    public ExtendedResponse createExtendedResponse(String id,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                byte[] berValue, int offset, int length) throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    // static final long serialVersionUID = -7560110759229059814L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
}