This project has retired. For details please refer to its Attic page.
CryptoConfigTest xref
View Javadoc
1   /*
2    * Copyright 2013 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.juddi.v3.client.cryptor;
17  
18  import org.apache.juddi.v3.client.config.UDDIClerk;
19  import org.apache.juddi.v3.client.config.UDDIClient;
20  import org.apache.juddi.v3.client.cryptor.CryptorFactory;
21  import org.junit.Assert;
22  import org.junit.Test;
23  
24  /**
25   *
26   * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
27   */
28  public class CryptoConfigTest {
29  
30      @Test()
31      public void EncryptedCredentialsAES128Test() throws Exception {
32          UDDIClient clerkManager = new UDDIClient("META-INF/uddi3-enc-aes128.xml");
33          // Now you create a reference to the UDDI API
34          UDDIClerk c = clerkManager.getClerk("default");
35          UDDIClerk c2 = clerkManager.getClerk("medroot");
36          Assert.assertNotSame(c.getPassword(), c2.getPassword());
37          Assert.assertEquals("root", CryptorFactory.getCryptor(c.getCryptoProvider()).decrypt(c.getRawPassword()));
38          Assert.assertEquals("root", c.getPassword());
39  
40          Assert.assertEquals("password", CryptorFactory.getCryptor(c2.getCryptoProvider()).decrypt(c2.getRawPassword()));
41          Assert.assertEquals("password", c2.getPassword());
42  
43  
44      }
45  }