//
// SessionBean interface methods
//================================
protected void testAllowedOperations(final String methodName) {
final OperationsPolicy policy = new OperationsPolicy();
/*[0] Test getEJBHome /////////////////*/
try {
mdbContext.getEJBHome();
policy.allow(OperationsPolicy.Context_getEJBHome);
} catch (final IllegalStateException ignored) {
}
/*[1] Test getCallerPrincipal /////////*/
try {
mdbContext.getCallerPrincipal();
policy.allow(OperationsPolicy.Context_getCallerPrincipal);
} catch (final IllegalStateException ignored) {
}
/*[2] Test isCallerInRole /////////////*/
try {
mdbContext.isCallerInRole("TheMan");
policy.allow(OperationsPolicy.Context_isCallerInRole);
} catch (final IllegalStateException ignored) {
}
/*[3] Test getRollbackOnly ////////////*/
try {
mdbContext.getRollbackOnly();
policy.allow(OperationsPolicy.Context_getRollbackOnly);
} catch (final IllegalStateException ignored) {
}
/*[4] Test setRollbackOnly ////////////*/
// Rollback causes message redelivery
/*[5] Test getUserTransaction /////////*/
try {
mdbContext.getUserTransaction();
policy.allow(OperationsPolicy.Context_getUserTransaction);
} catch (final IllegalStateException ignored) {
}
/*[6] Test getEJBObject ///////////////
*
* MDBs don't have an ejbObject
*/
/*[7] Test Context_getPrimaryKey ///////////////
*
* Can't really do this
*/
/*[8] Test JNDI_access_to_java_comp_env ///////////////*/
try {
final InitialContext jndiContext = new InitialContext();
final String actual = (String) jndiContext.lookup("java:comp/env/stateless/references/JNDI_access_to_java_comp_env");
policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
} catch (final IllegalStateException ignored) {
} catch (final javax.naming.NamingException ignored) {
}
/*[11] Test lookup /////////*/
try {
mdbContext.lookup("stateless/references/JNDI_access_to_java_comp_env");
policy.allow(OperationsPolicy.Context_lookup);
} catch (final IllegalArgumentException ignored) {
}
allowedOperationsTable.put(methodName, policy);