View Javadoc

1   /*
2    * $Id: CryptoFailureException.java 7963 2007-08-21 08:53:15Z 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  public class CryptoFailureException extends MuleException
27  {
28      /**
29       * Serial version
30       */
31      private static final long serialVersionUID = 1336343718508294379L;
32  
33      private transient UMOEncryptionStrategy encryptionStrategy;
34  
35      public CryptoFailureException(Message message, UMOEncryptionStrategy strategy)
36      {
37          super(message);
38          String s = (strategy == null ? "null" : strategy.toString());
39          addInfo("Encryption", s);
40          this.encryptionStrategy = strategy;
41      }
42  
43      public CryptoFailureException(Message message, UMOEncryptionStrategy strategy, Throwable cause)
44      {
45          super(message, cause);
46          String s = (strategy == null ? "null" : strategy.toString());
47          addInfo("Encryption", s);
48          this.encryptionStrategy = strategy;
49      }
50  
51      public CryptoFailureException(UMOEncryptionStrategy strategy, Throwable cause)
52      {
53          super(CoreMessages.cryptoFailure(), cause);
54          String s = (strategy == null ? "null" : strategy.toString());
55          addInfo("Encryption", s);
56          this.encryptionStrategy = strategy;
57  
58      }
59  
60      public UMOEncryptionStrategy getEncryptionStrategy()
61      {
62          return encryptionStrategy;
63      }
64  }