This project has retired. For details please refer to its Attic page.
AES256Cryptor 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  import java.security.spec.InvalidKeySpecException;
24  
25  import javax.crypto.BadPaddingException;
26  import javax.crypto.IllegalBlockSizeException;
27  import javax.crypto.NoSuchPaddingException;
28  
29  /**
30   * AES 256 bit encryption. <h1> Requires Unlimited Strength Java Cryptographic
31   * Extensions</h1>
32   *
33   * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
34   */
35  public class AES256Cryptor extends AESCryptorAbstract {
36  
37          /**
38           * Constructor for DefaultCryptor.
39           */
40          public AES256Cryptor()
41               throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException {
42                  super();
43          }
44  
45          @Override
46          protected String getKey() {
47                  //JUDDI-808
48                  String key = CryptorFactory.loadKeyFromFile("AES256Cryptor");
49                  if (key != null) {
50                          return key;
51                  } else {
52                          return "ef057ce3abd9dd9a161a2888c9d7025f104a42eceda5947b083186e7190fcc46";
53                  }
54          }
55  
56          @Override
57          public String encrypt(String str) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException {
58                  return super.encrypt(str);
59          }
60  
61          @Override
62          public String decrypt(String str) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException {
63                  return super.decrypt(str);
64          }
65  
66          @Override
67          public String newKey() {
68                  return GEN(256);
69  
70          }
71  }