use of org.jboss.as.test.integration.security.common.ejb3.Hello in project wildfly by wildfly.
the class HelloEJBCallServlet method doGet.
/**
* Writes simple text response.
*
* @param req
* @param resp
* @throws ServletException
* @throws IOException
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/plain");
final PrintWriter writer = resp.getWriter();
final String jndiName = req.getParameter(PARAM_JNDI_NAME);
try {
final Context ctx = new InitialContext();
final Hello ejbObject = (Hello) ctx.lookup(jndiName);
final String msg = ejbObject.sayHello();
LOGGER.trace(msg);
writer.append(msg);
ctx.close();
} catch (NamingException ex) {
LOGGER.warn("Unable to get EJB.", ex);
writer.append(ex.getMessage());
}
writer.close();
}
use of org.jboss.as.test.integration.security.common.ejb3.Hello in project wildfly by wildfly.
the class RemotingLoginModuleUseNewClientCertTestCase method testAuthorizedClient.
/**
* Tests that an authorized user has access to an EJB method.
*
* @throws Exception
*/
@Test
public void testAuthorizedClient() throws Exception {
final Properties env = configureEjbClient(CLIENT_AUTHORIZED_NAME);
InitialContext ctx = new InitialContext(env);
final Hello helloBean = (Hello) ctx.lookup(HELLOBEAN_LOOKUP_NAME);
assertEquals(HelloBean.HELLO_WORLD, helloBean.sayHelloWorld());
ctx.close();
}
use of org.jboss.as.test.integration.security.common.ejb3.Hello in project wildfly by wildfly.
the class RemotingLoginModuleTestCase method testNotAuthorizedClient.
/**
* Tests if role check is done correctly for authenticated user.
*
* @throws Exception
*/
@Test
public void testNotAuthorizedClient() throws Exception {
final Properties env = configureEjbClient(CLIENT_NOT_AUTHORIZED_NAME);
InitialContext ctx = new InitialContext(env);
final Hello helloBean = (Hello) ctx.lookup(HELLOBEAN_LOOKUP_NAME);
try {
helloBean.sayHelloWorld();
fail("The EJB call should fail for unauthorized client.");
} catch (EJBAccessException e) {
//OK
}
ctx.close();
}
use of org.jboss.as.test.integration.security.common.ejb3.Hello in project wildfly by wildfly.
the class RemotingLoginModuleTestCase method testAuthorizedClient.
/**
* Tests that an authorized user has access to an EJB method.
*
* @throws Exception
*/
@Test
public void testAuthorizedClient() throws Exception {
final Properties env = configureEjbClient(CLIENT_AUTHORIZED_NAME);
InitialContext ctx = new InitialContext(env);
final Hello helloBean = (Hello) ctx.lookup(HELLOBEAN_LOOKUP_NAME);
assertEquals(HelloBean.HELLO_WORLD, helloBean.sayHelloWorld());
ctx.close();
}
use of org.jboss.as.test.integration.security.common.ejb3.Hello in project wildfly by wildfly.
the class RemotingLoginModuleUseNewClientCertTestCase method testNotAuthorizedClient.
/**
* Tests if role check is done correctly for authenticated user.
*
* @throws Exception
*/
@Test
public void testNotAuthorizedClient() throws Exception {
final Properties env = configureEjbClient(CLIENT_NOT_AUTHORIZED_NAME);
InitialContext ctx = new InitialContext(env);
final Hello helloBean = (Hello) ctx.lookup(HELLOBEAN_LOOKUP_NAME);
try {
helloBean.sayHelloWorld();
fail("The EJB call should fail for unauthorized client.");
} catch (EJBAccessException e) {
//OK
}
ctx.close();
}
Aggregations