3 Replies Latest reply on May 22, 2013 7:59 AM by Nicklas Karlsson

    how to implement jaas with jboss web service?

    Joseph Hwang Novice

      This is my BASIC web authentication with Java web service.

       

      ==== IHelloPort.java

      @WebService

      public interface IHelloPort {

       

        @WebMethod

        @WebResult

        public String sayHello(@WebParam String name);

      }

       

      ==== HelloBean.java

      @WebService
      public class HelloBean implements IHelloPort {

      @Override
      @WebMethod
      @WebResult
      public String sayHello(@WebParam String name) {
        // TODO Auto-generated method stub
        return "Hello " + name;
      }

      }

       

      ===== web.xml

        <security-constraint>

          <web-resource-collection>

            <web-resource-name>joseph</web-resource-name>

            <url-pattern>/*</url-pattern>

            <http-method>GET</http-method>

            <http-method>POST</http-method>

          </web-resource-collection>

          <auth-constraint>

            <role-name>administrator</role-name>

          </auth-constraint>

        </security-constraint>

        <security-role>

          <role-name>administrator</role-name>

        </security-role>

        <login-config>

          <auth-method>BASIC</auth-method>

          <realm-name>JBOSS7DigestRealm</realm-name>

        </login-config>

       

      ====== index.jsp

      <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">

      <title>Insert title here</title>

      </head>

      <body>

      <%

      HelloBeanService service = new HelloBeanService();

      IHelloPort port = service.getHelloBeanPort();

      out.println(port.sayHello("joseph")); // throws Exception!!

      %>

      </body>

      </html>

       

      BASIC web login-config is successful when calling index.jsp file. But Invoking web service port throws Exception.

       

      Caused by: org.apache.cxf.transport.http.HTTPException: HTTP response '401: Unauthorized' when communicating with http://localhost:8080/SecurityTestWS/HelloBean

       

      With googling I found I had to put username and pssword into web service client. But I don't know how to do.

      Pls, inform me of any doc. or reference site. Thanks in advanced.