KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > security > bridge > ConfiguredIdentityUserPasswordBridgeTest


1 /**
2  *
3  * Copyright 2003-2004 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.security.bridge;
19
20 import java.util.Set JavaDoc;
21 import javax.security.auth.Subject JavaDoc;
22
23 import org.apache.geronimo.security.ContextManager;
24 import org.apache.geronimo.security.IdentificationPrincipal;
25
26
27 /**
28  * @version $Rev: 154957 $ $Date: 2005-02-22 21:07:36 -0800 (Tue, 22 Feb 2005) $
29  */

30 public class ConfiguredIdentityUserPasswordBridgeTest extends AbstractBridgeTest {
31
32     private ConfiguredIdentityUserPasswordRealmBridge bridge;
33
34     protected void setUp() throws Exception JavaDoc {
35         super.setUp();
36         bridge = new ConfiguredIdentityUserPasswordRealmBridge(TestLoginModule.JAAS_NAME, AbstractBridgeTest.USER, AbstractBridgeTest.PASSWORD);
37     }
38
39     public void testConfiguredIdentityBridge() throws Exception JavaDoc {
40         Subject JavaDoc sourceSubject = new Subject JavaDoc();
41         Subject JavaDoc targetSubject = bridge.mapSubject(sourceSubject);
42
43         assertTrue("expected non-null client subject", targetSubject != null);
44         Set JavaDoc set = targetSubject.getPrincipals(IdentificationPrincipal.class);
45         assertEquals("client subject should have one ID principal", set.size(), 1);
46         IdentificationPrincipal idp = (IdentificationPrincipal)set.iterator().next();
47         targetSubject = ContextManager.getRegisteredSubject(idp.getId());
48
49         checkValidSubject(targetSubject);
50     }
51
52 }
53
Popular Tags