KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jacc > test > portal > PortalJaccTestCase


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.test.jacc.test.portal;
8  
9 import java.security.Policy JavaDoc;
10
11 import javax.security.jacc.PolicyConfiguration JavaDoc;
12 import javax.security.jacc.PolicyContext JavaDoc;
13
14 /**
15  * JBPORTAL-565: Create Testcase for JACC Usage
16  * Tests Portal Usecase of
17  * a) PolicyConfiguration per portal component
18  *
19  * @author <mailto:Anil.Saldhana@jboss.org>Anil Saldhana
20  * @since Jan 17, 2006
21  */

22 public class PortalJaccTestCase extends BasePortalJaccTestCase
23 {
24    
25    public PortalJaccTestCase(String JavaDoc name)
26    {
27       super(name);
28    }
29    
30    public void testPolicyConfigurationPerPortalComponent() throws Exception JavaDoc
31    {
32       PolicyConfiguration JavaDoc pc = getPolicyConfiguration("portal-context");
33       
34       //Create a PortalObjectPermission
35
PortalObjectPermission portalperm = new PortalObjectPermission("/default", "view");
36       pc.addToRole("employee",portalperm);
37       
38       PortalObjectPermission windowPerm = new PortalObjectPermission("/default/default/a","view");
39       pc.addToRole("janitor", windowPerm);
40       
41       PortalObjectPermission contextPerm = new PortalObjectPermission("/","view");
42       pc.addToRole("admin", contextPerm);
43       pc.commit();
44       
45       Policy JavaDoc policy = Policy.getPolicy();
46       policy.refresh();
47       
48       //Act like the Portal Container and check perm for portal
49
PolicyContext.setContextID("portal-context");
50       checkAdminAccess(policy);
51       checkEmployeeAccess(policy);
52       checkJanitorAccess(policy);
53       checkBadEmployeeAccess(policy);
54    }
55 }
56
Popular Tags