View Javadoc

1   /*
2    * Copyright 2004-2006 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  package org.apache.myfaces.shared.util;
17  
18  import junit.framework.Test;
19  
20  /**
21   * <p>This TestCase uses the Advanced Encryption Standard with
22   * Cipher Block Chaining mode and PKCS5 padding.</p>
23   * <p/>
24   * <p/>
25   * If you are getting a SecurityException complaining about keysize,
26   * you most likely need to get the unlimited strength jurisdiction
27   * policy files from a place like http://java.sun.com/j2se/1.4.2/download.html .
28   * </p>
29   *
30   * @see pom.xml <excludes>
31   */
32  
33  public class StateUtilsAES_CBCTest extends AbstractStateUtilsTest
34  {
35  
36      public StateUtilsAES_CBCTest(String name) {
37          super(name);
38      }
39  
40      // No longer necessary using junit 4 to run tests
41      //public static Test suite() {
42      //    return null; // keep this method or maven won't run it
43      //}
44  
45      public void setUp() throws Exception
46      {
47          super.setUp();
48  
49          servletContext.addInitParameter(StateUtils.INIT_SECRET, BASE64_KEY_SIZE_16);
50          servletContext.addInitParameter(StateUtils.INIT_ALGORITHM, "AES");
51          servletContext.addInitParameter(StateUtils.INIT_ALGORITHM_PARAM, "CBC/PKCS5Padding");
52          servletContext.addInitParameter(StateUtils.INIT_ALGORITHM_IV, BASE64_KEY_SIZE_16);
53          servletContext.addInitParameter(StateUtils.INIT_SECRET_KEY_CACHE, "false");
54          servletContext.addInitParameter(StateUtils.INIT_MAC_SECRET, AbstractStateUtilsTest.BASE64_KEY_SIZE_8);
55          StateUtils.initSecret(servletContext);// should do nothing
56  
57      }
58  }