Path: blob/master/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignatureException.java
41161 views
/*1* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24/*25* $Id: XMLSignatureException.java,v 1.5 2005/05/10 16:03:48 mullan Exp $26*/27package javax.xml.crypto.dsig;2829import java.io.PrintStream;30import java.io.PrintWriter;3132/**33* Indicates an exceptional condition that occurred during the XML34* signature generation or validation process.35*36* <p>An {@code XMLSignatureException} can contain a cause: another37* throwable that caused this {@code XMLSignatureException} to get thrown.38*39* @since 1.640*/41public class XMLSignatureException extends Exception {4243private static final long serialVersionUID = -3438102491013869995L;4445/**46* The throwable that caused this exception to get thrown, or null if this47* exception was not caused by another throwable or if the causative48* throwable is unknown.49*50* @serial51*/52private Throwable cause;5354/**55* Constructs a new {@code XMLSignatureException} with56* {@code null} as its detail message.57*/58public XMLSignatureException() {59super();60}6162/**63* Constructs a new {@code XMLSignatureException} with the specified64* detail message.65*66* @param message the detail message67*/68public XMLSignatureException(String message) {69super(message);70}7172/**73* Constructs a new {@code XMLSignatureException} with the74* specified detail message and cause.75* <p>Note that the detail message associated with76* {@code cause} is <i>not</i> automatically incorporated in77* this exception's detail message.78*79* @param message the detail message80* @param cause the cause (A {@code null} value is permitted, and81* indicates that the cause is nonexistent or unknown.)82*/83public XMLSignatureException(String message, Throwable cause) {84super(message);85this.cause = cause;86}8788/**89* Constructs a new {@code XMLSignatureException} with the specified90* cause and a detail message of91* {@code (cause==null ? null : cause.toString())}92* (which typically contains the class and detail message of93* {@code cause}).94*95* @param cause the cause (A {@code null} value is permitted, and96* indicates that the cause is nonexistent or unknown.)97*/98public XMLSignatureException(Throwable cause) {99super(cause==null ? null : cause.toString());100this.cause = cause;101}102103/**104* Returns the cause of this {@code XMLSignatureException} or105* {@code null} if the cause is nonexistent or unknown. (The106* cause is the throwable that caused this107* {@code XMLSignatureException} to get thrown.)108*109* @return the cause of this {@code XMLSignatureException} or110* {@code null} if the cause is nonexistent or unknown.111*/112public Throwable getCause() {113return cause;114}115116/**117* Prints this {@code XMLSignatureException}, its backtrace and118* the cause's backtrace to the standard error stream.119*/120public void printStackTrace() {121super.printStackTrace();122if (cause != null) {123cause.printStackTrace();124}125}126127/**128* Prints this {@code XMLSignatureException}, its backtrace and129* the cause's backtrace to the specified print stream.130*131* @param s {@code PrintStream} to use for output132*/133public void printStackTrace(PrintStream s) {134super.printStackTrace(s);135if (cause != null) {136cause.printStackTrace(s);137}138}139140/**141* Prints this {@code XMLSignatureException}, its backtrace and142* the cause's backtrace to the specified print writer.143*144* @param s {@code PrintWriter} to use for output145*/146public void printStackTrace(PrintWriter s) {147super.printStackTrace(s);148if (cause != null) {149cause.printStackTrace(s);150}151}152}153154155