/rg/pkg/kaffe/libraries/javalib/gnu/crypto/key/KeyAgreementException.java

https://github.com/GunioRobot/MI424WR_GEN2_Rev_E-F · Java · 178 lines · 47 code · 15 blank · 116 comment · 8 complexity · 7c78287c806710e1ebe35c6662692fea MD5 · raw file

  1. package gnu.crypto.key;
  2. // ----------------------------------------------------------------------------
  3. // $Id: KeyAgreementException.java,v 1.2 2005/10/20 12:05:01 alexa Exp $
  4. //
  5. // Copyright (C) 2003 Free Software Foundation, Inc.
  6. //
  7. // This file is part of GNU Crypto.
  8. //
  9. // GNU Crypto is free software; you can redistribute it and/or modify
  10. // it under the terms of the GNU General Public License as published by
  11. // the Free Software Foundation; either version 2, or (at your option)
  12. // any later version.
  13. //
  14. // GNU Crypto is distributed in the hope that it will be useful, but
  15. // WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. // General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public License
  20. // along with this program; see the file COPYING. If not, write to the
  21. //
  22. // Free Software Foundation Inc.,
  23. // 51 Franklin Street, Fifth Floor,
  24. // Boston, MA 02110-1301
  25. // USA
  26. //
  27. // Linking this library statically or dynamically with other modules is
  28. // making a combined work based on this library. Thus, the terms and
  29. // conditions of the GNU General Public License cover the whole
  30. // combination.
  31. //
  32. // As a special exception, the copyright holders of this library give
  33. // you permission to link this library with independent modules to
  34. // produce an executable, regardless of the license terms of these
  35. // independent modules, and to copy and distribute the resulting
  36. // executable under terms of your choice, provided that you also meet,
  37. // for each linked independent module, the terms and conditions of the
  38. // license of that module. An independent module is a module which is
  39. // not derived from or based on this library. If you modify this
  40. // library, you may extend this exception to your version of the
  41. // library, but you are not obligated to do so. If you do not wish to
  42. // do so, delete this exception statement from your version.
  43. // ----------------------------------------------------------------------------
  44. import java.io.PrintStream;
  45. import java.io.PrintWriter;
  46. import java.io.Serializable;
  47. import java.security.KeyManagementException;
  48. /**
  49. * A generic exception indicating that an unexpected condition has been detected
  50. * during the setup and/or processing of a key agreement protocol exchange.
  51. *
  52. * @version $Revision: 1.2 $
  53. */
  54. public class KeyAgreementException extends KeyManagementException implements Serializable {
  55. // Constants and variables
  56. // -------------------------------------------------------------------------
  57. /** @serial The possibly <code>null</code> <i>root</i> cause exception. */
  58. private Throwable cause = null;
  59. // Constructor(s)
  60. // -------------------------------------------------------------------------
  61. /**
  62. * <p>Constructs a new instance of <code>KeyAgreementException</code>. The
  63. * root exception and the detailed message are <code>null</code>.</p>
  64. */
  65. public KeyAgreementException() {
  66. super();
  67. }
  68. /**
  69. * <p>Constructs a new instance of <code>KeyAgreementException</code> with a
  70. * detailed message. The <i>root</i> exception is <code>null</code>.</p>
  71. *
  72. * @param detail a possibly <code>null</code> string containing details of
  73. * the exception.
  74. * @see Throwable#getMessage()
  75. */
  76. public KeyAgreementException(String detail) {
  77. super(detail);
  78. }
  79. /**
  80. * <p>Constructs a new instance of <code>KeyAgreementException</code> with a
  81. * detailed message and a <i>root</i> exception.</p>
  82. *
  83. * @param detail a possibly <code>null</code> string containing details of
  84. * the exception.
  85. * @param cause a possibly <code>null</code> root exception that caused this
  86. * exception.
  87. * @see Throwable#getMessage()
  88. * @see #getCause()
  89. */
  90. public KeyAgreementException(String detail, Throwable cause) {
  91. super(detail);
  92. this.cause = cause;
  93. }
  94. // Class methods
  95. // -------------------------------------------------------------------------
  96. // Instance methods
  97. // -------------------------------------------------------------------------
  98. /**
  99. * <p>Returns the cause of this throwable or <code>null</code> if the cause
  100. * is nonexistent or unknown. The <i>cause</i> is the throwable that caused
  101. * this exception to be thrown.</p>
  102. *
  103. * @return the possibly <code>null</code> exception that caused this one.
  104. */
  105. public Throwable getCause() {
  106. return cause;
  107. }
  108. /**
  109. * <p>Prints this exception's stack trace to <code>System.err</code>. If this
  110. * exception has a <i>root</i> exception; the stack trace of the <i>root</i>
  111. * exception is also printed to <code>System.err</code>.</p>
  112. */
  113. public void printStackTrace() {
  114. super.printStackTrace();
  115. if (cause != null) {
  116. cause.printStackTrace();
  117. }
  118. }
  119. /**
  120. * <p>Prints this exception's stack trace to a print stream. If this
  121. * exception has a <i>root</i> exception; the stack trace of the <i>root</i>
  122. * exception is also printed to the print stream.</p>
  123. *
  124. * @param ps the non-null print stream to which to print.
  125. */
  126. public void printStackTrace(PrintStream ps) {
  127. super.printStackTrace(ps);
  128. if (cause != null) {
  129. cause.printStackTrace(ps);
  130. }
  131. }
  132. /**
  133. * <p>Prints this exception's stack trace to a print writer. If this
  134. * exception has a <i>root</i> exception; the stack trace of the <i>root</i>
  135. * exception is also printed to the print writer.</p>
  136. *
  137. * @param pw the non-null print writer to use for output.
  138. */
  139. public void printStackTrace(PrintWriter pw) {
  140. super.printStackTrace(pw);
  141. if (cause != null) {
  142. cause.printStackTrace(pw);
  143. }
  144. }
  145. /**
  146. * <p>Returns the string representation of this exception. The string
  147. * representation contains this exception's class name, its detailed
  148. * messsage, and if it has a <i>root</i> exception, the string representation
  149. * of the root exception. This string representation is meant for debugging
  150. * and is not meant to be interpreted programmatically.</p>
  151. *
  152. * @return the non-null string representation of this exception.
  153. * @see Throwable#getMessage()
  154. */
  155. public String toString() {
  156. StringBuffer sb = new StringBuffer(this.getClass().getName())
  157. .append(": ").append(super.toString());
  158. if (cause != null) {
  159. sb.append("; caused by: ").append(cause.toString());
  160. }
  161. return sb.toString();
  162. }
  163. }