Search in sources :

Example 21 with SecurityClient

use of org.jboss.security.client.SecurityClient in project wildfly by wildfly.

the class EJBServletEar method processRequest.

protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    SecurityClient client = null;
    try {
        InitialContext ctx = new InitialContext();
        client = SecurityClientFactory.getSecurityClient();
        client.setSimple("user1", "password1");
        client.login();
        injectedSession.hello();
        injectedSession.goodbye();
        injectedStateless.hello();
        injectedStateless.goodbye();
        String lookupString = "java:app/ejb3-ear-servlet-ejbs/Session30!";
        EJBServletHelper test = new EJBServletHelper();
        test.processRequest(lookupString, ctx);
    } catch (Exception e) {
        log.error(e);
        throw new ServletException("Failed to call EJBs/Session30 through remote and local interfaces", e);
    } finally {
        client.logout();
    }
    response.setContentType("text/plain");
    PrintWriter out = response.getWriter();
    out.print("EJBServlet OK");
    out.close();
}
Also used : ServletException(javax.servlet.ServletException) SecurityClient(org.jboss.security.client.SecurityClient) InitialContext(javax.naming.InitialContext) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Aggregations

SecurityClient (org.jboss.security.client.SecurityClient)21 Test (org.junit.Test)18 InitialContext (javax.naming.InitialContext)7 EJBAccessException (javax.ejb.EJBAccessException)4 WhoAmI (org.jboss.as.test.integration.ejb.security.runasprincipal.WhoAmI)4 IOException (java.io.IOException)2 PrintWriter (java.io.PrintWriter)2 Principal (java.security.Principal)2 ServletException (javax.servlet.ServletException)2 Message (javax.jms.Message)1 MessageConsumer (javax.jms.MessageConsumer)1 MessageProducer (javax.jms.MessageProducer)1 ObjectMessage (javax.jms.ObjectMessage)1 Queue (javax.jms.Queue)1 QueueConnection (javax.jms.QueueConnection)1 QueueConnectionFactory (javax.jms.QueueConnectionFactory)1 QueueSession (javax.jms.QueueSession)1 Session (javax.jms.Session)1 TemporaryQueue (javax.jms.TemporaryQueue)1 TextMessage (javax.jms.TextMessage)1