Enterprise Java Development@TOPIC@

Chapter 115. run-as

115.1. Default security-identity: use-caller-identity
115.2. Run-as security-identity: role-name
115.3. Run-as principal: identity
115.4. Invoking Protected EJB thru Run-as Proxy
115.5. Summary
import javax.annotation.security.RunAs;


@Stateless
@PermitAll
@RunAs("admin")
public class SecurePingClientEJB 
    implements SecurePingClientRemote, SecurePingClientLocal {
    @EJB(lookup="ejb:securePingEAR/securePingEJB/SecurePingEJB!info.ejava.examples.secureping.ejb.SecurePingRemote")
    SecurePingRemote securePingServer;

# jboss-web.xml
<assembly-descriptor>
    <sec:security>
        <ejb-name>*</ejb-name>
        <sec:security-domain>other</sec:security-domain>
        <sec:run-as-principal>admin1</sec:run-as-principal>
    </sec:security>
</assembly-descriptor>