3 Replies Latest reply on Mar 3, 2015 8:02 PM by rafalex

    Error trying the WS-Securuty example

    rafalex

      Hi everyone,

       

      Im triying to make run the example (this) for signing, but I have an error but I dont know why. After developing the service and the client this is what I getting:

       

      Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: These policy alternatives can not be satisfied:

      {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}AsymmetricBinding: Received Timestamp does not match the requirements

      {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}X509Token: The received token does not match the token inclusion requirement

      {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}InitiatorToken

      {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}RecipientToken

      {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}IncludeTimestamp: Received Timestamp does not match the requirements

      {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}Layout

      {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SignedParts: {http://schemas.xmlsoap.org/soap/envelope/}Body not SIGNED

      {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EncryptedParts: {http://schemas.xmlsoap.org/soap/envelope/}Body not ENCRYPTED

          at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)    at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)

          at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)

          at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:117)

          at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)

          at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)

          at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:135)

          at com.sun.proxy.$Proxy18.sayHello(Unknown Source)

          at jbcli.JBCLI.sayHello(JBCLI.java:36)

          at jbcli.JBCLI.main(JBCLI.java:23)


      I think the error is on the client side, but I dont know why, this is my client class:


      package jbcli;

       

      import javax.xml.ws.BindingProvider;

      import org.apache.cxf.ws.security.SecurityConstants;

       

      /**

      *

      * @author Rafa

      */

      public class JBCLI {

       

          /**

           * @param args the command line arguments

           */

          public static void main(String[] args) {

              // TODO code application logic here

              System.out.println(sayHello());

          }

       

          private static String sayHello() {

              org.jboss.jbossws.ws_extensions.wssecuritypolicy.SecurityService service = new org.jboss.jbossws.ws_extensions.wssecuritypolicy.SecurityService();

              org.jboss.jbossws.ws_extensions.wssecuritypolicy.ServiceIface port = service.getSecurityServicePort();

              ((BindingProvider)port).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new KeystorePasswordCallback());

              ((BindingProvider)port).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,

                   Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties"));

              ((BindingProvider)port).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,

                   Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties"));

              ((BindingProvider)port).getRequestContext().put(SecurityConstants.SIGNATURE_USERNAME, "alice");

              ((BindingProvider)port).getRequestContext().put(SecurityConstants.ENCRYPT_USERNAME, "bob");

              return port.sayHello();

          }

      }


      Thank you!!