1 Reply Latest reply on Nov 18, 2012 11:33 PM by User696-Oracle

    JAXWS EJB3.0 Based WebService Authentication and Authorization - Weblogic

    Prateek Agarwal-Oracle
      Hi Experts,

      I need to Create a EJB3.0 WS where this Service has static Authentication and Authorization. How can I achieve it, any pointer.

        • 1. Re: JAXWS EJB3.0 Based WebService Authentication and Authorization - Weblogic
          The below sample is for basic authentication and authorization.

          Web service
          import javax.ejb.Stateless;
          import javax.ejb.TransactionAttribute;
          import javax.ejb.Remote;
          import javax.jws.WebMethod;
          import javax.jws.WebService;
          import javax.annotation.security.RolesAllowed;
          import javax.ejb.SecurityRoles;

          @Remote( { com.bea.Service.class})
          @WebService(name="TransactionPortType", serviceName="TransactionService",

          public class ServiceBean implements Service {
          @RolesAllowed ( {"Admin","Manager"})
          public void testMethod(String s) {
          System.out.println("inside ejb method");
          System.out.println("username : " + weblogic.security.SubjectUtils.getUserPrincipal(weblogic.security.Security.getCurrentSubject()));

          import java.util.Map;
          import javax.xml.ws.BindingProvider;

          public class Test {

          public static void main(String[] args) {

          TransactionService simple = new TransactionService();
          TransactionPortType port = simple.getTransactionPortTypePort();

          BindingProvider bindingProvider = (BindingProvider) port;
          Map<String, Object> reqContext = bindingProvider.getRequestContext();
          reqContext.put(BindingProvider.USERNAME_PROPERTY, "XXXXXX");
          reqContext.put(BindingProvider.PASSWORD_PROPERTY, "XXXXXX");



          Sunil P