1 2 Previous Next 17 Replies Latest reply on Jun 17, 2010 12:26 PM by zurchman

    Problem with WS Security encryption

    samb1985

        I'm starting to do some test with WS Security Encryption.
      I follow this article: http://www.developer.com/java/other/article.php/10936_3802631_1/Securing-Web-Services-in-JBoss-Application-Server-with-WS-Security.htm


      When I run the client (with Eclipse as Java Application)throw this Exception:
      Exception in thread "main" javax.xml.ws.  soap.SOAPFaultEx ception: This service requires <wsse:Security>,  which is missing.
          at com.sun.xml. ws.fault. SOAP11Fault.  getProtocolExcep tion(SOAP11Fault .java:188)
           at com.sun.xml. ws.fault. SOAPFaultBuilder .createException  (SOAPFaultBuilde r.java:108)
          at  com.sun.xml. ws.client. sei.SyncMethodHa ndler.invoke( SyncMethodHandle  r.java:119)
          at com.sun.xml. ws.client. sei.SyncMethodHa  ndler.invoke( SyncMethodHandle r.java:89)
          at com.sun.xml.  ws.client. sei.SEIStub. invoke(SEIStub. java:118)
           at $Proxy22.sayHello( Unknown Source)
          at org.jbia.ws.  clientsample. ClientSample. main(ClientSampl e.java:14)

       

      As the client don't know to use Security. Before run client I must set something on Eclipse ?

       

      In client META-INF I insert truststore, keystore, jboss-wsse-client and standard-jaxws-client-config.

        • 1. Re: Problem with WS Security encryption
          peterj

          Grab the free chapter 9 download (it is on web services) for JBoss in Action at http://www.manning.com/jamae, it should help you with both this issue and the other one you posted at http://community.jboss.org/message/546520#546520.

          • 2. Re: Problem with WS Security encryption
            samb1985

            I'm already using JBoss in Action book, I follow chapter 9.4 but it don't work in my ws realized in Eclipse.

            • 3. Re: Problem with WS Security encryption
              peterj

              Do not use Eclipse to build your web service for you - I think that Eclipse bases its web services on Axis.

               

              Did you install JBoss Tools into Eclipse? You could use that to build your web services (I think I did that once).

               

              Have you built an run target 07 in project ch09? That builds a secured web client but uses the properties file (rather than a database) for login. Target 05 in ch08 builds a messaging client using the database for login, so you could use that as an example of switching the web service to using the database for login.

               

              Also, try setting the log to TRACE for org.jboss.security.auth, that should give you some details of exactly what is going on. (From what you have provided I cannot tell if your code is incorrect (you did not provide the code), or if your database is not set up correctly. The trace might provide some insight into that.)

               

              [Shoot, I wrote this based on your other question. But did you try traget 09 thru 12 in project ch09?]

              • 4. Re: Problem with WS Security encryption
                samb1985

                I create POJO Web Service with a simple java class plus annotation, under Eclipse IDE. To test WS I use Eclipse Wizard to create test WS client specifyng JBossWS runtime and not Axis.

                Yes I installed JBoss Tools.

                 

                Secured web service with file properties for login work well. With database authentication I forget to define the DataSource on JBoss AS, in which xml should I define it ?

                 

                For encryption test I follow chapter 9.5 of the book until 9.5.3 but the client don't work as written above.

                • 5. Re: Problem with WS Security encryption
                  peterj

                  >>Secured web service with file properties for login work well. With  database authentication I forget to define the DataSource on JBoss AS,  in which xml should I define it ?

                  Yes, you need a *-ds.xml file to define the database. It should use the same JNDI name (TestWSSecurityDS) that you used in login-config.xml.

                  • 6. Re: Problem with WS Security encryption
                    samb1985

                    Ok I create a postgre-ds.xml file in folder deploy.

                     

                    <?xml version="1.0" encoding="UTF-8"?> 
                    <datasources> 
                    <local-tx-datasource> 
                    <jndi-name>TestWSSecurityDS</jndi-name>
                    <connection-url>jdbc:postgresql://localhost:5432/table</connection-url> 
                    <driver-class>org.postgresql.Driver</driver-class> 
                    <user-name>postgres</user-name> 
                    <password>password</password> 
                    </local-tx-datasource> 
                    </datasources>

                     

                    But when I try to use WS with client still remain: com.sun.xml.ws.client.ClientTransportException: request requires HTTP authentication: Unauthorized

                    • 7. Re: Problem with WS Security encryption
                      peterj

                      Did you set the logging to TRACE? What did it show?

                      • 8. Re: Problem with WS Security encryption
                        samb1985

                        I set in jboss-log4j.xml to trace JBossWS, but in server.log there isn't any information about org.jboss.ws.core.MessageTrace.

                        • 9. Re: Problem with WS Security encryption
                          peterj

                          I had actually suggested setting TRACE for org.jboss.security.auth because it is the authentication that its failing.

                          • 10. Re: Problem with WS Security encryption
                            samb1985

                            Thanks a lot !

                             

                            Tracing security.auth I note that the issue was the syntax of second sql statement.

                             

                            I correct it with: select userroles,'Roles' from "public"."UserRoles" where username = ?  and now authentication with postgre sql database works well.

                             

                            Now still remain the other problem of encryption in first post of this discussion.

                            The Web Service security implemented is as the chapter 9.5 (until 9.5.3 included of JBoss in Action), but I use a pojo java as client to consume and test the WS. I created the pojo with Eclipse Wizard to create a Web Service Client with JBossWS runtime (not Axis).

                            Then I add to client java all files indicated in chapter 9.5.3, but when I run it throw an exception that indicate wsse security required as it don't know the descriptor in META-INF.

                             

                            So I found a discussion that indicate to use in client the follow code:

                            URL securityURL = Main.class.getResource("META-INF/jboss-wsse-client.xml");
                            ((StubExt) port1).setSecurityConfig(securityURL.toExternalForm());

                            ((StubExt) port1).setConfigName("Standard WSSecurity Client", "META-INF/standard-jaxws-client-config.xml");

                             

                            But when I run it:

                             

                            Exception in thread "main" java.lang.ClassCastException: $Proxy23 cannot be cast to org.jboss.ws.core.StubExt

                            • 11. Re: Problem with WS Security encryption
                              jplistero

                              do you find a solution ?

                               

                              I have the same error, similar ...

                               

                              11-jun-2010 10:50:20 com.sun.enterprise.transaction.JavaEETransactionManagerSimplified initDelegates
                              INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
                              java.lang.ClassCastException: $Proxy49 cannot be cast to org.jboss.ws.core.StubExt

                              I have to sing de the soap message

                              I ' am follow the free chapter 9 of jboss in action, and  not mention modifications in the Client class if you need ws-security.

                               

                              thanks!

                              • 12. Re: Problem with WS Security encryption
                                samb1985

                                I still searching for a solution....I don't know how solve it.

                                I also followed chapter 9 of JBoss in Action.

                                • 13. Re: Problem with WS Security encryption
                                  jplistero

                                  are you using netbeans ?

                                  May be its bad imports o bad classpath to jars ...

                                   

                                  I'am searching too.

                                  • 14. Re: Problem with WS Security encryption
                                    samb1985

                                    I'm using Eclipse.

                                    1 2 Previous Next