Class SecurePingEJB
- java.lang.Object
-
- info.ejava.examples.secureping.ejb.SecurePingEJB
-
- All Implemented Interfaces:
SecurePing
,SecurePingLocal
,SecurePingRemote
public class SecurePingEJB extends Object implements SecurePingRemote, SecurePingLocal
This session bean provides several methods; each of which will require some type of role associated with the user in order to successfully invoke them.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) SessionContext
ctx
private static org.slf4j.Logger
logger
-
Constructor Summary
Constructors Constructor Description SecurePingEJB()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private String
getInfo(String prefix)
This method creates a status string based on security information obtained from the SessionContext.void
init()
boolean
isCallerInRole(String role)
This method allows the RMI Test to check whether the current subject has a specific role.String
pingAdmin()
Callers of this method must have the "admin" role.String
pingAll()
This method is permitted to be called by anyone.String
pingExcluded()
No one should be allowed to call this method.String
pingUser()
Callers of this method must have the "user" role.String
whoAmI()
-
-
-
Field Detail
-
logger
private static final org.slf4j.Logger logger
-
ctx
SessionContext ctx
-
-
Method Detail
-
init
@PostConstruct public void init()
-
getInfo
private String getInfo(String prefix)
This method creates a status string based on security information obtained from the SessionContext.
-
pingAll
@PermitAll public String pingAll()
This method is permitted to be called by anyone.- Specified by:
pingAll
in interfaceSecurePing
-
pingUser
@RolesAllowed("user") public String pingUser()
Callers of this method must have the "user" role.- Specified by:
pingUser
in interfaceSecurePing
-
pingAdmin
@RolesAllowed("admin") public String pingAdmin()
Callers of this method must have the "admin" role.- Specified by:
pingAdmin
in interfaceSecurePing
-
pingExcluded
@DenyAll public String pingExcluded()
No one should be allowed to call this method.- Specified by:
pingExcluded
in interfaceSecurePing
-
isCallerInRole
@PermitAll public boolean isCallerInRole(String role)
This method allows the RMI Test to check whether the current subject has a specific role. This type of method would normally be used within an EJB to perform object-level access control.- Specified by:
isCallerInRole
in interfaceSecurePing
-
whoAmI
@PermitAll public String whoAmI()
- Specified by:
whoAmI
in interfaceSecurePing
-
-