1. /*
  2. * @(#)LdapReferralException.java 1.9 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.naming.ldap;
  8. import javax.naming.ReferralException;
  9. import javax.naming.Context;
  10. import javax.naming.NamingException;
  11. import java.util.Hashtable;
  12. /**
  13. * This abstract class is used to represent an LDAP referral exception.
  14. * It extends the base <tt>ReferralException</tt> by providing a
  15. * <tt>getReferralContext()</tt> method that accepts request controls.
  16. * LdapReferralException is an abstract class. Concrete implementations of it
  17. * determine its synchronization and serialization properties.
  18. *<p>
  19. * A <tt>Control[]</tt> array passed as a parameter to
  20. * the <tt>getReferralContext()</tt> method is owned by the caller.
  21. * The service provider will not modify the array or keep a reference to it,
  22. * although it may keep references to the individual <tt>Control</tt> objects
  23. * in the array.
  24. *
  25. * @author Rosanna Lee
  26. * @author Scott Seligman
  27. * @author Vincent Ryan
  28. * @version 1.9 03/01/23
  29. * @since 1.3
  30. */
  31. public abstract class LdapReferralException extends ReferralException {
  32. /**
  33. * Constructs a new instance of LdapReferralException using the
  34. * explanation supplied. All other fields are set to null.
  35. *
  36. * @param explanation Additional detail about this exception. Can be null.
  37. * @see java.lang.Throwable#getMessage
  38. */
  39. protected LdapReferralException(String explanation) {
  40. super(explanation);
  41. }
  42. /**
  43. * Constructs a new instance of LdapReferralException.
  44. * All fields are set to null.
  45. */
  46. protected LdapReferralException() {
  47. super();
  48. }
  49. /**
  50. * Retrieves the context at which to continue the method using the
  51. * context's environment and no controls.
  52. * The referral context is created using the environment properties of
  53. * the context that threw the <tt>ReferralException</tt> and no controls.
  54. *<p>
  55. * This method is equivalent to
  56. *<blockquote><pre>
  57. * getReferralContext(ctx.getEnvironment(), null);
  58. *</pre></blockquote>
  59. * where <tt>ctx</tt> is the context that threw the <tt>ReferralException.</tt>
  60. *<p>
  61. * It is overridden in this class for documentation purposes only.
  62. * See <tt>ReferralException</tt> for how to use this method.
  63. *
  64. * @return The non-null context at which to continue the method.
  65. * @exception NamingException If a naming exception was encountered.
  66. * Call either <tt>retryReferral()</tt> or <tt>skipReferral()</tt>
  67. * to continue processing referrals.
  68. */
  69. public abstract Context getReferralContext() throws NamingException;
  70. /**
  71. * Retrieves the context at which to continue the method using
  72. * environment properties and no controls.
  73. * The referral context is created using <tt>env</tt> as its environment
  74. * properties and no controls.
  75. *<p>
  76. * This method is equivalent to
  77. *<blockquote><pre>
  78. * getReferralContext(env, null);
  79. *</pre></blockquote>
  80. *<p>
  81. * It is overridden in this class for documentation purposes only.
  82. * See <tt>ReferralException</tt> for how to use this method.
  83. *
  84. * @param env The possibly null environment to use when retrieving the
  85. * referral context. If null, no environment properties will be used.
  86. *
  87. * @return The non-null context at which to continue the method.
  88. * @exception NamingException If a naming exception was encountered.
  89. * Call either <tt>retryReferral()</tt> or <tt>skipReferral()</tt>
  90. * to continue processing referrals.
  91. */
  92. public abstract Context getReferralContext(Hashtable env) throws NamingException;
  93. /**
  94. * Retrieves the context at which to continue the method using
  95. * request controls and environment properties.
  96. * Regardless of whether a referral is encountered directly during a
  97. * context operation, or indirectly, for example, during a search
  98. * enumeration, the referral exception should provide a context
  99. * at which to continue the operation.
  100. * To continue the operation, the client program should re-invoke
  101. * the method using the same arguments as the original invocation.
  102. *<p>
  103. * <tt>reqCtls</tt> is used when creating the connection to the referred
  104. * server. These controls will be used as the connection request controls for
  105. * the context and context instances
  106. * derived from the context.
  107. * <tt>reqCtls</tt> will also be the context's request controls for
  108. * subsequent context operations. See the <tt>LdapContext</tt> class
  109. * description for details.
  110. *<p>
  111. * This method should be used instead of the other two overloaded forms
  112. * when the caller needs to supply request controls for creating
  113. * the referral context. It might need to do this, for example, when
  114. * it needs to supply special controls relating to authentication.
  115. *<p>
  116. * Service provider implementors should read the "Service Provider" section
  117. * in the <tt>LdapContext</tt> class description for implementation details.
  118. *
  119. * @param reqCtls The possibly null request controls to use for the new context.
  120. * If null or the empty array means use no request controls.
  121. * @param env The possibly null environment properties to use when
  122. * for the new context. If null, the context is initialized with no environment
  123. * properties.
  124. * @return The non-null context at which to continue the method.
  125. * @exception NamingException If a naming exception was encountered.
  126. * Call either <tt>retryReferral()</tt> or <tt>skipReferral()</tt>
  127. * to continue processing referrals.
  128. */
  129. public abstract Context getReferralContext(
  130. Hashtable env, Control[] reqCtls) throws NamingException;
  131. private static final long serialVersionUID = -1668992791764950804L;
  132. }