1. /*
  2. * @(#)ExtendedRequest.java 1.7 01/02/09
  3. *
  4. * Copyright 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package javax.naming.ldap;
  11. import javax.naming.NamingException;
  12. /**
  13. * This interface represents an LDAPv3 extended operation request as defined in
  14. * <A HREF="ftp://ftp.isi.edu/in-notes/rfc2251.txt">RFC 2251</A>.
  15. * <pre>
  16. * ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
  17. * requestName [0] LDAPOID,
  18. * requestValue [1] OCTET STRING OPTIONAL }
  19. * </pre>
  20. * It comprises an object identifier string and an optional ASN.1 BER
  21. * encoded value.
  22. *<p>
  23. * The methods in this class are used by the service provider to construct
  24. * the bits to send to the LDAP server. Applications typically only deal with
  25. * the classes that implement this interface, supplying them with
  26. * any information required for a particular extended operation request.
  27. * It would then pass such a class as an argument to the
  28. * <tt>LdapContext.extendedOperation()</tt> method for performing the
  29. * LDAPv3 extended operation.
  30. *<p>
  31. * For example, suppose the LDAP server supported a 'get time' extended operation.
  32. * It would supply GetTimeRequest and GetTimeResponse classes:
  33. *<blockquote><pre>
  34. * public class GetTimeRequest implements ExtendedRequest {
  35. * public GetTimeRequest() {... };
  36. * public ExtendedResponse createExtendedResponse(String id,
  37. * byte[] berValue, int offset, int length)
  38. * throws NamingException {
  39. * return new GetTimeResponse(id, berValue, offset, length);
  40. * }
  41. * ...
  42. * }
  43. * public class GetTimeResponse implements ExtendedResponse {
  44. * long time;
  45. * public GetTimeResponse(String id, byte[] berValue, int offset,
  46. * int length) throws NamingException {
  47. * time = ... // decode berValue to get time
  48. * }
  49. * public java.util.Date getDate() { return new java.util.Date(time) };
  50. * public long getTime() { return time };
  51. * ...
  52. * }
  53. *</pre></blockquote>
  54. * A program would use then these classes as follows:
  55. *<blockquote><pre>
  56. * GetTimeResponse resp =
  57. * (GetTimeResponse) ectx.extendedOperation(new GetTimeRequest());
  58. * long time = resp.getTime();
  59. *</pre></blockquote>
  60. *
  61. * @author Rosanna Lee
  62. * @author Scott Seligman
  63. * @author Vincent Ryan
  64. * @version 1.7 01/02/09
  65. *
  66. * @see ExtendedResponse
  67. * @see LdapContext#extendedOperation
  68. * @since 1.3
  69. */
  70. public interface ExtendedRequest extends java.io.Serializable {
  71. /**
  72. * Retrieves the object identifier of the request.
  73. *
  74. * @return The non-null object identifier string representing the LDAP
  75. * <tt>ExtendedRequest.requestName</tt> component.
  76. */
  77. public String getID();
  78. /**
  79. * Retrieves the ASN.1 BER encoded value of the LDAP extended operation
  80. * request. Null is returned if the value is absent.
  81. *
  82. * The result is the raw BER bytes including the tag and length of
  83. * the request value. It does not include the request OID.
  84. * This method is called by the service provider to get the bits to
  85. * put into the extended operation to be sent to the LDAP server.
  86. *
  87. * @return A possibly null byte array representing the ASN.1 BER encoded
  88. * contents of the LDAP <tt>ExtendedRequest.requestValue</tt>
  89. * component.
  90. * @exception IllegalStateException If the encoded value cannot be retrieved
  91. * because the request contains insufficient or invalid data/state.
  92. */
  93. public byte[] getEncodedValue();
  94. /**
  95. * Creates the response object that corresponds to this request.
  96. *<p>
  97. * After the service provider has sent the extended operation request
  98. * to the LDAP server, it will receive a response from the server.
  99. * If the operation failed, the provider will throw a NamingException.
  100. * If the operation succeeded, the provider will invoke this method
  101. * using the data that it got back in the response.
  102. * It is the job of this method to return a class that implements
  103. * the ExtendedResponse interface that is appropriate for the
  104. * extended operation request.
  105. *<p>
  106. * For example, a Start TLS extended request class would need to know
  107. * how to process a Start TLS extended response. It does this by creating
  108. * a class that implements ExtendedResponse.
  109. *
  110. * @param id The possibly null object identifier of the response
  111. * control.
  112. * @param berValue The possibly null ASN.1 BER encoded value of the
  113. * response control.
  114. * This is the raw BER bytes including the tag and length of
  115. * the response value. It does not include the response OID.
  116. * @param offset The starting position in berValue of the bytes to use.
  117. * @param length The number of bytes in berValue to use.
  118. *
  119. * @return A non-null object.
  120. * @exception NamingException if cannot create extended response
  121. * due to an error.
  122. * @see ExtendedResponse
  123. */
  124. public ExtendedResponse createExtendedResponse(String id,
  125. byte[] berValue, int offset, int length) throws NamingException;
  126. // static final long serialVersionUID = -7560110759229059814L;
  127. }