View Javadoc

1   /*
2    * $Id: CryptoFailureException.java 7976 2007-08-21 14:26:13Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.umo.security;
12  
13  import org.mule.MuleException;
14  import org.mule.config.i18n.CoreMessages;
15  import org.mule.config.i18n.Message;
16  import org.mule.umo.UMOEncryptionStrategy;
17  
18  /**
19   * <code>CryptoFailureException</code> is a generic exception thrown by an
20   * CryptoStrategy if encryption or decryption fails. The constuctors of this
21   * exception accept a UMOEncryptionStrategy that will be included in the exception
22   * message. Implementors of UMOEncryptionStrategy should provide a toString method
23   * that exposes *only* information that maybe useful for debugging not passwords,
24   * secret keys, etc.
25   * 
26   * @author <a href="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
27   * @version $Revision: 7976 $
28   */
29  public class CryptoFailureException extends MuleException
30  {
31      /**
32       * Serial version
33       */
34      private static final long serialVersionUID = 1336343718508294379L;
35  
36      private transient UMOEncryptionStrategy encryptionStrategy;
37  
38      public CryptoFailureException(Message message, UMOEncryptionStrategy strategy)
39      {
40          super(message);
41          String s = (strategy == null ? "null" : strategy.toString());
42          addInfo("Encryption", s);
43          this.encryptionStrategy = strategy;
44      }
45  
46      public CryptoFailureException(Message message, UMOEncryptionStrategy strategy, Throwable cause)
47      {
48          super(message, cause);
49          String s = (strategy == null ? "null" : strategy.toString());
50          addInfo("Encryption", s);
51          this.encryptionStrategy = strategy;
52      }
53  
54      public CryptoFailureException(UMOEncryptionStrategy strategy, Throwable cause)
55      {
56          super(CoreMessages.cryptoFailure(), cause);
57          String s = (strategy == null ? "null" : strategy.toString());
58          addInfo("Encryption", s);
59          this.encryptionStrategy = strategy;
60  
61      }
62  
63      public UMOEncryptionStrategy getEncryptionStrategy()
64      {
65          return encryptionStrategy;
66      }
67  }