173174175176177178179180181182183
InitialContext ctx = new InitialContext(env); Secured secured = (Secured)ctx.lookup("SecuredBean/local"); boolean exceptionThrown = false; try { secured.allowed(); } catch (EJBAccessException ignored) { exceptionThrown = true; }
183184185186187188189190191192193
} assertTrue("Security exception not thrown for invalid password", exceptionThrown); env.put(Context.SECURITY_CREDENTIALS, "password"); ctx = new InitialContext(env); secured.allowed(); exceptionThrown = false; try { secured.nobody();