1 25 package org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.security; 26 27 import static org.testng.Assert.fail; 28 29 import javax.annotation.security.RunAs; 30 import javax.ejb.EJBAccessException ; 31 32 import org.objectweb.easybeans.log.JLog; 33 import org.objectweb.easybeans.log.JLogFactory; 34 import org.objectweb.easybeans.tests.common.ejbs.base.security.ItfSecurityRoles; 35 36 42 @RunAs("secondaryrole") 43 public abstract class SecurityPermissionTester implements ItfSecurityPermissionTester { 44 45 48 private static JLog logger = JLogFactory.getLog(SecurityPermissionTester.class); 49 50 51 55 public abstract ItfSecurityRoles getBean(); 56 57 58 61 public void testPermitAll() { 62 getBean().permitAllAttribute(); 63 } 64 65 68 public void testDenyAll() { 69 try{ 70 getBean().denyAllAttribute(); 71 fail("The method has a denyAll annotation, so the bean cannot call this method."); 72 }catch(EJBAccessException e){ 73 logger.debug("The bean threw an expected exception {0}", e); 74 } 75 } 76 77 81 public void testAllowedRolesWithTwoRoles() { 82 getBean().permitTwoRoles(); 83 } 84 85 89 public void testAllowedRolesWithOneRole() { 90 try { 91 getBean().permitOneRole(); 92 fail("The method has an allowsRoles annotation that does not contains the value " 93 + "in secondaryrole defined, so the bean cannot call this method."); 94 } catch (EJBAccessException e) { 95 logger.debug("The bean threw an expected exception {0}", e); 96 } 97 } 98 99 100 } 101 | Popular Tags |