001 /*
002 * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025 /*
026 * $Id: NoSuchMechanismException.java,v 1.4 2005/05/10 15:47:42 mullan Exp $
027 */
028 package javax.xml.crypto;
029
030 import java.io.PrintStream;
031 import java.io.PrintWriter;
032 import javax.xml.crypto.dsig.Manifest;
033 import javax.xml.crypto.dsig.XMLSignature;
034 import javax.xml.crypto.dsig.XMLSignatureFactory;
035 import javax.xml.crypto.dsig.keyinfo.KeyInfo;
036 import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
037
038 /**
039 * This exception is thrown when a particular XML mechanism is requested but
040 * is not available in the environment.
041 *
042 * <p>A <code>NoSuchMechanismException</code> can contain a cause: another
043 * throwable that caused this <code>NoSuchMechanismException</code> to get
044 * thrown.
045 *
046 * @author Sean Mullan
047 * @author JSR 105 Expert Group
048 * @since 1.6
049 * @see XMLSignatureFactory#getInstance XMLSignatureFactory.getInstance
050 * @see KeyInfoFactory#getInstance KeyInfoFactory.getInstance
051 */
052 public class NoSuchMechanismException extends RuntimeException {
053
054 private static final long serialVersionUID = 4189669069570660166L;
055
056 /**
057 * The throwable that caused this exception to get thrown, or null if this
058 * exception was not caused by another throwable or if the causative
059 * throwable is unknown.
060 *
061 * @serial
062 */
063 private Throwable cause;
064
065 /**
066 * Constructs a new <code>NoSuchMechanismException</code> with
067 * <code>null</code> as its detail message.
068 */
069 public NoSuchMechanismException() {
070 super ();
071 }
072
073 /**
074 * Constructs a new <code>NoSuchMechanismException</code> with the
075 * specified detail message.
076 *
077 * @param message the detail message
078 */
079 public NoSuchMechanismException(String message) {
080 super (message);
081 }
082
083 /**
084 * Constructs a new <code>NoSuchMechanismException</code> with the
085 * specified detail message and cause.
086 * <p>Note that the detail message associated with
087 * <code>cause</code> is <i>not</i> automatically incorporated in
088 * this exception's detail message.
089 *
090 * @param message the detail message
091 * @param cause the cause (A <tt>null</tt> value is permitted, and
092 * indicates that the cause is nonexistent or unknown.)
093 */
094 public NoSuchMechanismException(String message, Throwable cause) {
095 super (message);
096 this .cause = cause;
097 }
098
099 /**
100 * Constructs a new <code>NoSuchMechanismException</code> with the
101 * specified cause and a detail message of
102 * <code>(cause==null ? null : cause.toString())</code> (which typically
103 * contains the class and detail message of <code>cause</code>).
104 *
105 * @param cause the cause (A <tt>null</tt> value is permitted, and
106 * indicates that the cause is nonexistent or unknown.)
107 */
108 public NoSuchMechanismException(Throwable cause) {
109 super (cause == null ? null : cause.toString());
110 this .cause = cause;
111 }
112
113 /**
114 * Returns the cause of this <code>NoSuchMechanismException</code> or
115 * <code>null</code> if the cause is nonexistent or unknown. (The
116 * cause is the throwable that caused this
117 * <code>NoSuchMechanismException</code> to get thrown.)
118 *
119 * @return the cause of this <code>NoSuchMechanismException</code> or
120 * <code>null</code> if the cause is nonexistent or unknown.
121 */
122 public Throwable getCause() {
123 return cause;
124 }
125
126 /**
127 * Prints this <code>NoSuchMechanismException</code>, its backtrace and
128 * the cause's backtrace to the standard error stream.
129 */
130 public void printStackTrace() {
131 super .printStackTrace();
132 //XXX print backtrace of cause
133 }
134
135 /**
136 * Prints this <code>NoSuchMechanismException</code>, its backtrace and
137 * the cause's backtrace to the specified print stream.
138 *
139 * @param s <code>PrintStream</code> to use for output
140 */
141 public void printStackTrace(PrintStream s) {
142 super .printStackTrace(s);
143 //XXX print backtrace of cause
144 }
145
146 /**
147 * Prints this <code>NoSuchMechanismException</code>, its backtrace and
148 * the cause's backtrace to the specified print writer.
149 *
150 * @param s <code>PrintWriter</code> to use for output
151 */
152 public void printStackTrace(PrintWriter s) {
153 super .printStackTrace(s);
154 //XXX print backtrace of cause
155 }
156 }
|