2 Replies Latest reply on May 4, 2007 10:58 AM by benhei

    How to use Username Token

    darkfett

      Hello,

      I'm trying to use Username Token but it's not successful for now. The Username Token is not present in the Header of my request. (Signature and Encryption work fine in both side)

      Here's my code :

      jboss-wsse-client.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-ws-security xmlns="http://www.jboss.com/ws-security/config"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.jboss.com/ws-security/config
       http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd">
      
       <key-store-file>service.jks</key-store-file>
       <key-store-password>apache</key-store-password>
      
       <trust-store-file>client.jks</trust-store-file>
       <trust-store-password>apache</trust-store-password>
       <config>
       <username/>
       <sign type="x509v3" alias="service"/>
       <requires>
       <signature/>
       </requires>
       </config>
      </jboss-ws-security>


      That's part seems to be good. But I don't know how to insert my own username and my password in MyCall.java.

      MyCall.java
      Service service = Service.create(
       new URL("http://proxiadev34:8080/SampleJBossWS/PersonneWebService?wsdl"),
       new QName("PersonneWebServiceService")
       );
      
       URL securityURL = new File("jboss-wsse-client.xml").toURL();
       ((ServiceExt)service).setSecurityConfig(securityURL.toExternalForm());
      
      
       PersonneWebService personneWS = service.getPort(PersonneWebService.class);
       ((StubExt)personneWS).setConfigName("Standard WSSecurity Client");
      
       //Appel de la Fonction getNomVille(Long codePostal)
       String ville = personneWS.getNomVille(59000);
       System.out.println(ville);


      For the server, I found the way to get the Username Token from the Request

      String username = SecurityAssociation.getPrincipal().getName();
       String password = SecurityAssociation.getCredential().toString();
      
       System.out.println(username);
       System.out.println(password);


      If anybody have an idea in order to put the username and the password, it would be welcome.

      Thank you for nay help.

      Dark Fett



        • 1. Re: How to use Username Token
          darkfett

          I just find the solution :

          MyCall.java

          Service service = Service.create(
           new URL("http://proxiadev34:8080/SampleJBossWS/PersonneWebService?wsdl"),
           new QName("PersonneWebServiceService")
           );
          
           URL securityURL = new File("jboss-wsse-client.xml").toURL();
           ((ServiceExt)service).setSecurityConfig(securityURL.toExternalForm());
           //((ServiceExt)service).
          
           PersonneWebService personneWS = service.getPort(PersonneWebService.class);
           ((StubExt)personneWS).setConfigName("Standard WSSecurity Client");
           Map<String, Object> reqContext = ((BindingProvider)personneWS).getRequestContext();
           reqContext.put(Stub.USERNAME_PROPERTY, "j.roucou");
           reqContext.put(Stub.PASSWORD_PROPERTY, "toto");
          
           //Appel de la Fonction getNomVille(Long codePostal)
           String ville = personneWS.getNomVille(59000);
           System.out.println(ville);


          • 2. Re: How to use Username Token
            benhei

            Hi,
            can you show me, how you config the serversite please..

            I've similar problems i think...

            I'm not sure if i config my server right..

            thanks a lot

            Ben