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