[jboss-user] [JBossWS] - Re: how to secure web services in jboss?

shashankjain do-not-reply at jboss.com
Sun Feb 10 11:25:30 EST 2008


Hi,
I have configured all files for JBoss WS Security..Using JBoss WS 2.0.3 stack.
The Web service is defined as
@WebService(name = "SecureService", targetNamespace = "http://org.jboss.ws/samples/wssecurity")
@SOAPBinding(style = Style.RPC)
public interface SecureService {


    /**
     * 
     * @param name
     * @return
     *     returns java.lang.String
     */
    @WebMethod
    @WebResult(partName = "return")
    public String getName(
        @WebParam(name = "name", partName = "name")
        String name);

}

The standalone java client is 


public class NewClient {
    
    /** Creates a new instance of NewClient */
    public NewClient() {
         try { // Call Web Service Operation
            System.setProperty("org.jboss.wsse.keyStore","c://wsse.keystore");
            System.setProperty("org.jboss.wsse.keyStorePassword","jbossws");        
            System.setProperty("org.jboss.wsse.keyStoreType","x509v3");
                    System.setProperty("org.jboss.wsse.trustStore","c://wsse.truststore");
                    System.setProperty("org.jboss.wsse.trustStorePassword","jbossws");
                    System.setProperty("org.jboss.wsse.trustStoreType","x509v3");
            
                    
            
//List handlerChain = new ArrayList();
            //HandlerInfo handler=new HandlerInfo();
            
            //handler.setHandlerClassName("WSSecurityHandlerOutbound");
            
            //handlerChain.add(handler);
com.hp.security.client.SecureService_Service ser=new com.hp.security.client.SecureService_Service();


            com.hp.security.client.SecureService port = getPort();//ser.getSecureServicePort();//getPort();
            //BindingProvider bindingProvider = (BindingProvider) port;
//  bindingProvider.getBinding().setHandlerChain(handlerChain);
            //((StubExt)port).setConfigName("Standard WSSecurity Client");
            // TODO initialize WS operation arguments here
            java.lang.String name = "";
            // TODO process result here
            java.lang.String result = port.getName("Shashank");
            System.out.println("Result = "+result);
        } catch (Exception ex) {
            ex.printStackTrace();
            System.out.println(ex.getMessage());
            // TODO handle custom exceptions here
        }
        
        
    }
    
    
    private static com.hp.security.client.SecureService getPort() throws Exception
    {
        
         URL wsdlURL = new URL("http://127.0.0.1:8080/TestSecure/SecureService?wsdl");
         URL securityURL = new File("web//META-INF//jboss-wsse-client.xml").toURL();
         System.out.println(securityURL.getPath());
         QName serviceName = new QName("http://org.jboss.ws/samples/wssecurity", "SecureService");
         System.out.println(serviceName.toString());
         Service service = Service.create(wsdlURL, serviceName);
         
         SecureService port = (SecureService)service.getPort(SecureService.class);
         //((ServiceExt)service)setSecurityConfig(securityURL.toExternalForm());
         
         //((StubExt)port).setSecurityConfig(securityURL.toExternalForm());
         //((StubExt)port).setConfigName("Standard WSSecurity Client");
   
         Map<String, Object> reqContext = 
((BindingProvider)port).getRequestContext();
         reqContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, 
"http://127.0.0.1:8080/TestSecure/SecureService");
   
         return port;
      }

I have all the configuration files on server as well as client....
On client I have
META-INF/standard-jaxws-client-config.xml
META-INF/jboss-wsse-client.xml
META-INF/wsse.keystore
META-INF/wsse.truststore

On server I have
under
web-inf /jboss-wsse-server.xml
web-inf/wsse.keystore
web-inf/wsse.truststore

I dont see any changes as configured in samples...Still I tried everything I am unable to get it working.Pls help





I created a standalone client. I get the following errors
Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/util/NotImplementedException
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
        at java.lang.Class.getConstructor0(Class.java:2671)
        at java.lang.Class.newInstance0(Class.java:321)
        at java.lang.Class.newInstance(Class.java:303)
        at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:36)
        at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:95)
        at javax.xml.ws.spi.Provider.provider(Provider.java:83)
        at javax.xml.ws.Service.(Service.java:56)
        at com.hp.security.client.SecureService_Service.(SecureService_Service.java:40)
        at com.hp.standalone.NewClient.(NewClient.java:44)
        at com.hp.standalone.NewClient.main(NewClient.java:94)

Pls help.
Shashank

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4128179#4128179

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4128179



More information about the jboss-user mailing list