1 25 package org.objectweb.easybeans.tests.common.ejbs.base.security; 26 27 import java.security.Principal ; 28 29 import javax.annotation.Resource; 30 import javax.annotation.security.DeclareRoles; 31 import javax.annotation.security.DenyAll; 32 import javax.annotation.security.PermitAll; 33 import javax.annotation.security.RolesAllowed; 34 import javax.ejb.EJB ; 35 import javax.ejb.SessionContext ; 36 37 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.security.ItfEJBContextMethods; 38 39 45 @DeclareRoles({"mainrole", "secondaryrole"}) 46 public class SecurityRolesBase implements ItfSecurityRoles { 47 48 52 @Resource 53 private SessionContext sessionContext; 54 55 58 @EJB 59 private ItfEJBContextMethods bean; 60 61 64 @PermitAll 65 public void permitAllAttribute() { 66 67 } 68 69 72 @DenyAll 73 public void denyAllAttribute() { 74 75 } 76 77 80 @RolesAllowed(value = {"mainrole", "secondaryrole"}) 81 public void permitTwoRoles() { 82 83 } 84 85 88 @RolesAllowed(value = {"mainrole"}) 89 public void permitOneRole() { 90 91 } 92 93 100 @PermitAll 101 public boolean testCallerPrincipal() { 102 Principal principalCaller = sessionContext.getCallerPrincipal(); 103 return principalCaller.equals(bean.getCallerPrincipal()); 104 } 105 106 110 public Principal getCallerPrincipal() { 111 return sessionContext.getCallerPrincipal(); 112 } 113 114 120 public boolean isCallerinRole(final String role) { 121 return sessionContext.isCallerInRole(role); 122 } 123 124 } 125 | Popular Tags |