This project has retired. For details please refer to its Attic page.
Cryptor xref
View Javadoc
1   /*
2    * Copyright 2001-2008 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   */
17  package org.apache.juddi.v3.client.cryptor;
18  
19  import java.io.UnsupportedEncodingException;
20  import java.security.InvalidAlgorithmParameterException;
21  import java.security.InvalidKeyException;
22  import java.security.NoSuchAlgorithmException;
23  
24  import javax.crypto.BadPaddingException;
25  import javax.crypto.IllegalBlockSizeException;
26  import javax.crypto.NoSuchPaddingException;
27  
28  /**
29   * @author Anou Manavalan
30   */
31  public interface Cryptor {
32  
33          /**
34           * Encrypt the string, if unable to encrypt, return null
35           *
36           * @param str
37           * @return encrypted text
38           * @throws NoSuchPaddingException
39           * @throws NoSuchAlgorithmException
40           * @throws InvalidAlgorithmParameterException
41           * @throws InvalidKeyException
42           * @throws IllegalBlockSizeException
43           * @throws BadPaddingException
44           * @throws java.io.UnsupportedEncodingException
45           */
46          String encrypt(String str)
47                  throws NoSuchPaddingException,
48                  NoSuchAlgorithmException,
49                  InvalidAlgorithmParameterException,
50                  InvalidKeyException,
51                  IllegalBlockSizeException,
52                  BadPaddingException,
53                  UnsupportedEncodingException;
54  
55          /**
56           * decrypts the string
57           *
58           * @param str
59           * @return if the password can be decrypted, the decrypted value is
60           * returned, otherwise the original value is returned<br>
61           * In the event that decryption fails, the error message must be logged.
62           * @throws NoSuchPaddingException
63           * @throws NoSuchAlgorithmException
64           * @throws InvalidAlgorithmParameterException
65           * @throws InvalidKeyException
66           * @throws IllegalBlockSizeException
67           * @throws BadPaddingException
68           * @throws java.io.UnsupportedEncodingException
69           */
70          public String decrypt(String str) throws NoSuchPaddingException,
71                  NoSuchAlgorithmException,
72                  InvalidAlgorithmParameterException,
73                  InvalidKeyException,
74                  IllegalBlockSizeException,
75                  BadPaddingException,
76                  UnsupportedEncodingException;
77  
78          public String newKey();
79  }