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 128 bit encryption
31   *
32   * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
33   */
34  public class AES128Cryptor extends AESCryptorAbstract {
35  
36          /**
37           * Constructor for DefaultCryptor.
38           */
39          public AES128Cryptor()
40               throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException {
41                  super();
42          }
43  
44          @Override
45          protected String getKey() {
46                  //JUDDI-808
47                  String key = CryptorFactory.loadKeyFromFile("AES128Cryptor");
48                  if (key != null) {
49                          return key;
50                  } else {
51                          return "72d93747ba0162f2f2985f5cb3e24b30";
52                  }
53          }
54  
55          @Override
56          public String encrypt(String str) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException {
57                  return super.encrypt(str);
58          }
59  
60          @Override
61          public String decrypt(String str) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException {
62                  return super.decrypt(str);
63          }
64  
65          @Override
66          public String newKey() {
67                  return GEN(128);
68          }
69  
70  }