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