1 22 package org.jboss.test.security.managers; 23 24 import java.util.HashSet ; 25 import java.util.Set ; 26 27 import org.jboss.security.AuthorizationManager; 28 import org.jboss.security.SimplePrincipal; 29 import org.jboss.security.plugins.JBossAuthorizationManager; 30 31 33 39 public class AuthorizationManagerUnitTestCase extends JASPISecurityManagerUnitTestCase 40 { 41 public AuthorizationManagerUnitTestCase(String name) 42 { 43 super(name); 44 } 45 46 public void testSuccessfulValidation() throws Exception 47 { 48 super.testSuccessfulValidation(); 49 50 JBossAuthorizationManager jsm = new JBossAuthorizationManager("java:/jaas/other",null); 52 assertNotNull("JBossAuthorizationManager != null?", jsm); 53 assertTrue("JBossAuthorizationManager instanceof AuthorizationManager", 54 jsm instanceof AuthorizationManager); 55 assertNotNull("Principal from super class != null", id); 56 Set roles = jsm.getUserRoles(id); 57 assertTrue("admin has roles?", roles != null); 58 assertTrue("admin has roles?", roles.size() > 0); 59 HashSet set = new HashSet (); 60 set.add(new SimplePrincipal("TestRole")); 61 boolean hasRole = jsm.doesUserHaveRole(id,set); 62 assertTrue("admin has TestRole?", hasRole); 63 set.clear(); 64 set.add(new SimplePrincipal("BadRole")); 65 hasRole = jsm.doesUserHaveRole(id,set); 66 assertFalse("admin should not have BadRole?", hasRole); 67 } 68 69 } 70 | Popular Tags |