1. /*
  2. * @(#)CertPathBuilderException.java 1.4 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 java.security.cert;
  8. import java.io.PrintStream;
  9. import java.io.PrintWriter;
  10. /**
  11. * An exception indicating one of a variety of problems encountered when
  12. * building a certification path with a <code>CertPathBuilder</code>.
  13. * <p>
  14. * A <code>CertPathBuilderException</code> provides support for wrapping
  15. * exceptions. The {@link #getCause getCause} method returns the throwable,
  16. * if any, that caused this exception to be thrown.
  17. * <p>
  18. * <b>Concurrent Access</b>
  19. * <p>
  20. * Unless otherwise specified, the methods defined in this class are not
  21. * thread-safe. Multiple threads that need to access a single
  22. * object concurrently should synchronize amongst themselves and
  23. * provide the necessary locking. Multiple threads each manipulating
  24. * separate objects need not synchronize.
  25. *
  26. * @see CertPathBuilder
  27. *
  28. * @version 1.4 01/23/03
  29. * @since 1.4
  30. * @author Sean Mullan
  31. */
  32. public class CertPathBuilderException extends
  33. java.security.GeneralSecurityException {
  34. /**
  35. * Creates a <code>CertPathBuilderException</code> with <code>null</code>
  36. * as its detail message.
  37. */
  38. public CertPathBuilderException() {
  39. super();
  40. }
  41. /**
  42. * Creates a <code>CertPathBuilderException</code> with the given
  43. * detail message. The detail message is a <code>String</code> that
  44. * describes this particular exception in more detail.
  45. *
  46. * @param msg the detail message
  47. */
  48. public CertPathBuilderException(String msg) {
  49. super(msg);
  50. }
  51. /**
  52. * Creates a <code>CertPathBuilderException</code> that wraps the specified
  53. * throwable. This allows any exception to be converted into a
  54. * <code>CertPathBuilderException</code>, while retaining information
  55. * about the wrapped exception, which may be useful for debugging. The
  56. * detail message is set to (<code>cause==null ? null : cause.toString()
  57. * </code>) (which typically contains the class and detail message of
  58. * cause).
  59. *
  60. * @param cause the cause (which is saved for later retrieval by the
  61. * {@link #getCause getCause()} method). (A <code>null</code> value is
  62. * permitted, and indicates that the cause is nonexistent or unknown.)
  63. */
  64. public CertPathBuilderException(Throwable cause) {
  65. super();
  66. initCause(cause);
  67. }
  68. /**
  69. * Creates a <code>CertPathBuilderException</code> with the specified
  70. * detail message and cause.
  71. *
  72. * @param msg the detail message
  73. * @param cause the cause (which is saved for later retrieval by the
  74. * {@link #getCause getCause()} method). (A <code>null</code> value is
  75. * permitted, and indicates that the cause is nonexistent or unknown.)
  76. */
  77. public CertPathBuilderException(String msg, Throwable cause) {
  78. super(msg);
  79. initCause(cause);
  80. }
  81. /**
  82. * Returns the internal (wrapped) cause, or <code>null</code>
  83. * if the cause is nonexistent or unknown.
  84. *
  85. * @return the cause of this throwable or <code>null</code> if the cause
  86. * is nonexistent or unknown.
  87. */
  88. public Throwable getCause() {
  89. return super.getCause();
  90. }
  91. /**
  92. * Returns the detail message for this
  93. * <code>CertPathBuilderException</code>.
  94. *
  95. * @return the detail message, or <code>null</code> if neither the message
  96. * nor internal cause were specified
  97. */
  98. public String getMessage() {
  99. return super.getMessage();
  100. }
  101. /**
  102. * Returns a string describing this exception, including a description
  103. * of the internal (wrapped) cause if there is one.
  104. *
  105. * @return a string representation of this
  106. * <code>CertPathBuilderException</code>
  107. */
  108. public String toString() {
  109. if (getCause() == null)
  110. return super.toString();
  111. else
  112. return super.toString() +
  113. "; internal cause is: \n\t" +
  114. getCause().toString();
  115. }
  116. /**
  117. * Prints a stack trace to <code>System.err</code>, including the backtrace
  118. * of the cause, if any.
  119. */
  120. public void printStackTrace() {
  121. printStackTrace(System.err);
  122. }
  123. /**
  124. * Prints a stack trace to a <code>PrintStream</code>, including the
  125. * backtrace of the cause, if any.
  126. *
  127. * @param ps the <code>PrintStream</code> to use for output
  128. */
  129. public void printStackTrace(PrintStream ps) {
  130. super.printStackTrace(ps);
  131. }
  132. /**
  133. * Prints a stack trace to a <code>PrintWriter</code>, including the
  134. * backtrace of the cause, if any.
  135. *
  136. * @param pw the <code>PrintWriter</code> to use for output
  137. */
  138. public void printStackTrace(PrintWriter pw) {
  139. super.printStackTrace(pw);
  140. }
  141. }