[jbossws-issues] [JBoss JIRA] (JBWS-3748) Wildfly 8 ws-security client throws exception

Joseph Hwang (JIRA) issues at jboss.org
Mon Dec 30 20:49:32 EST 2013


    [ https://issues.jboss.org/browse/JBWS-3748?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12933290#comment-12933290 ] 

Joseph Hwang edited comment on JBWS-3748 at 12/30/13 8:47 PM:
--------------------------------------------------------------

I try to implement WS-Security with WildFly 8 JBossWS libraries files. My reference site is https://docs.jboss.org/author/display/JBWS/WS-Security#WS-Security-Authenticationandauthorization. My developemnt ide is eclipse kepler with JBossTools for kepler. But client function throws exception. 
This is @PolicySets annotation and @EndpointConfig annotation of Service Endpoint Interface and Service Bean Class.

@WebService(targetNamespace = "http://www.aaa.com/jbossws/ws-extensions/wssecurity")
@PolicySets({"WS-SP-EX223_WSS11_Anonymous_X509_Sign_Encrypt"})
public interface IHelloWorld {

	@WebMethod
	@WebResult
	public String sayHello(@WebParam String name);
}
======
import org.jboss.ws.api.annotation.EndpointConfig;

@WebService(
		portName = "HelloWorldServicePort",
		serviceName = "HelloWorldService",
		targetNamespace = "http://www.aaa.com/jbossws/ws-extensions/wssecurity",
		endpointInterface = "com.aaa.wss.IHelloWorld"
)
@EndpointConfig(configFile = "WEB-INF/jaxws-endpoint-config.xml", configName = "Custom WS-Security Endpoint")
public class HelloWorld implements IHelloWorld {

	@Override
	public String sayHello(String name) {
		// TODO Auto-generated method stub
		return "Hello " + name;
	}

}

The contents of jaxws-endpoint-config.xml are like below:

<jaxws-config xmlns="urn:jboss:jbossws-jaxws-config:4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
	xmlns:javaee="http://java.sun.com/xml/ns/javaee" 
	xsi:schemaLocation="urn:jboss:jbossws-jaxws-config:4.0 schema/jbossws-jaxws-config_4_0.xsd">  
	
	<endpoint-config>    
		<config-name>Custom WS-Security Endpoint</config-name>    
		
		<property>      
			<property-name>ws-security.signature.properties</property-name>      
			<property-value>META-INF/server.properties</property-value>    
		</property>    
		
		<property>      
			<property-name>ws-security.encryption.properties</property-name>      
			<property-value>META-INF/server.properties</property-value>    
		</property>    
		
		<property>      
			<property-name>ws-security.signature.username</property-name>      
			<property-value>server</property-value>    
		</property>    
		
		<property>      
			<property-name>ws-security.encryption.username</property-name>      
			<property-value>client</property-value>    
		</property>    
		
		<property>      
			<property-name>ws-security.callback-handler</property-name>      
			<property-value>com.aaa.wss.KeystorePasswordCallback</property-value>    
		</property>  
	</endpoint-config>
</jaxws-config>

Deployment is successful. And Below is client code.

public class WSSClient {

 

   private final String serviceURL="http://localhost:8080/WSSHelloWorld/HelloWorld";

   private IHelloWorld proxy;

 

   public WSSClient() throws IOException {

      QName serviceName = new QName("http://www.aaa.com/jbossws/ws-extensions/wssecurity", "HelloWorldService");

      URL wsdlURL = new URL(serviceURL + "?wsdl");

      Service service = Service.create(wsdlURL, serviceName);

  proxy = (IHelloWorld)service.getPort(IHelloWorld.class);

 

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

      ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,  Thread.currentThread().getContextClassLoader().getResource("META-INF/client.properties"));

      ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,  Thread.currentThread().getContextClassLoader().getResource("META-INF/client.properties"));

      ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.SIGNATURE_USERNAME, "client");

      ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_USERNAME, "server");

   } // the constructor throws no exception.

 

   public String callMethd(String name) {

      return proxy.sayHello(name); // this method throws exception
   }
 
	public static void main(String[] args) throws Exception {
		
		WSClient tc= new WSClient();
		
		String result=tc.callMethd("Joseph");
                            
    System.out.println(result);
	}
	
}
But the client function throws following exception.

ct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
 WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SymmetricBinding" was evaluated as "UNKNOWN".
Oct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}Wss11" was evaluated as "UNKNOWN".
Oct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
WARNING: WSP0019: Suboptimal policy alternative selected on the client side with fitness "UNKNOWN".
 Oct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EncryptedParts" was evaluated as "UNKNOWN".
Oct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SignedParts" was evaluated as "UNKNOWN".
Oct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
WARNING: WSP0019: Suboptimal policy alternative selected on the client side with fitness "UNKNOWN".
 Oct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EncryptedParts" was evaluated as "UNKNOWN".
Oct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SignedParts" was evaluated as "UNKNOWN".
Oct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
WARNING: WSP0019: Suboptimal policy alternative selected on the client side with fitness "UNKNOWN".
 Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: com.aaa.ws.KeystorePasswordCallback from [Module "org.apache.cxf.impl:main" from local module loader @562ca0db (finder: local module finder @bf4b610 (roots: /home/jooho/Applications/JBoss/EAP/wildfly-8.0.0.Alpha4/modules,/home/jooho/Applications/JBoss/EAP/wildfly-8.0.0.Alpha4/modules/system/layers/base))]
    at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
     at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:111)
    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:129)
    at com.sun.proxy.$Proxy23.sayHello(Unknown Source)
    at test.WSClient.callMethd(WSClient.java:53)
    at test.WSClient.main(WSClient.java:60)

However, the end function of this project throws no exception and returns good result value with Eclipse kepler ,JBoss tool for kepler and JBoss EAP 6.1.1. 

I attach project zip file for your convenience.
                
      was (Author: aupres):
    I try to implement WS-Security with WildFly 8 JBossWS libraries files. My reference site is https://docs.jboss.org/author/display/JBWS/WS-Security#WS-Security-Authenticationandauthorization. My developemnt ide is eclipse kepler with JBossTools for kepler. But client function throws exception. 
This is @PolicySets annotation and @EndpointConfig annotation of Service Endpoint Interface and Service Bean Class.

@WebService(targetNamespace = "http://www.aaa.com/jbossws/ws-extensions/wssecurity")
@PolicySets({"WS-SP-EX223_WSS11_Anonymous_X509_Sign_Encrypt"})
public interface IHelloWorld {

	@WebMethod
	@WebResult
	public String sayHello(@WebParam String name);
}
======
import org.jboss.ws.api.annotation.EndpointConfig;

@WebService(
		portName = "HelloWorldServicePort",
		serviceName = "HelloWorldService",
		targetNamespace = "http://www.aaa.com/jbossws/ws-extensions/wssecurity",
		endpointInterface = "com.aaa.wss.IHelloWorld"
)
@EndpointConfig(configFile = "WEB-INF/jaxws-endpoint-config.xml", configName = "Custom WS-Security Endpoint")
public class HelloWorld implements IHelloWorld {

	@Override
	public String sayHello(String name) {
		// TODO Auto-generated method stub
		return "Hello " + name;
	}

}

The contents of jaxws-endpoint-config.xml are like below:

<jaxws-config xmlns="urn:jboss:jbossws-jaxws-config:4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
	xmlns:javaee="http://java.sun.com/xml/ns/javaee" 
	xsi:schemaLocation="urn:jboss:jbossws-jaxws-config:4.0 schema/jbossws-jaxws-config_4_0.xsd">  
	
	<endpoint-config>    
		<config-name>Custom WS-Security Endpoint</config-name>    
		
		<property>      
			<property-name>ws-security.signature.properties</property-name>      
			<property-value>META-INF/server.properties</property-value>    
		</property>    
		
		<property>      
			<property-name>ws-security.encryption.properties</property-name>      
			<property-value>META-INF/server.properties</property-value>    
		</property>    
		
		<property>      
			<property-name>ws-security.signature.username</property-name>      
			<property-value>server</property-value>    
		</property>    
		
		<property>      
			<property-name>ws-security.encryption.username</property-name>      
			<property-value>client</property-value>    
		</property>    
		
		<property>      
			<property-name>ws-security.callback-handler</property-name>      
			<property-value>com.aaa.wss.KeystorePasswordCallback</property-value>    
		</property>  
	</endpoint-config>
</jaxws-config>

Deployment is successful. And Below is client code.

public class WSSClient {

 

   private final String serviceURL="http://localhost:8080/WSSHelloWorld/HelloWorld";

   private IHelloWorld proxy;

 

   public WSSClient() throws IOException {

      QName serviceName = new QName("http://www.aaa.com/jbossws/ws-extensions/wssecurity", "HelloWorldService");

      URL wsdlURL = new URL(serviceURL + "?wsdl");

      Service service = Service.create(wsdlURL, serviceName);

  proxy = (IHelloWorld)service.getPort(IHelloWorld.class);

 

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

      ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,  Thread.currentThread().getContextClassLoader().getResource("META-INF/client.properties"));

      ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,  Thread.currentThread().getContextClassLoader().getResource("META-INF/client.properties"));

      ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.SIGNATURE_USERNAME, "client");

      ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_USERNAME, "server");

   } // the constructor throws no exception.

 

   public String callMethd(String name) {

      return proxy.sayHello(name); // this method throws exception
   }
 
	public static void main(String[] args) throws Exception {
		
		WSClient tc= new WSClient();
		
		String result=tc.callMethd("Joseph");
                            
    System.out.println(result);
	}
	
}
But the client function throws following exception.

ct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
 WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SymmetricBinding" was evaluated as "UNKNOWN".
Oct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}Wss11" was evaluated as "UNKNOWN".
Oct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
WARNING: WSP0019: Suboptimal policy alternative selected on the client side with fitness "UNKNOWN".
 Oct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EncryptedParts" was evaluated as "UNKNOWN".
Oct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SignedParts" was evaluated as "UNKNOWN".
Oct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
WARNING: WSP0019: Suboptimal policy alternative selected on the client side with fitness "UNKNOWN".
 Oct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EncryptedParts" was evaluated as "UNKNOWN".
Oct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SignedParts" was evaluated as "UNKNOWN".
Oct 24, 2013 3:54:49 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives
WARNING: WSP0019: Suboptimal policy alternative selected on the client side with fitness "UNKNOWN".
 Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: com.aaa.ws.KeystorePasswordCallback from [Module "org.apache.cxf.impl:main" from local module loader @562ca0db (finder: local module finder @bf4b610 (roots: /home/jooho/Applications/JBoss/EAP/wildfly-8.0.0.Alpha4/modules,/home/jooho/Applications/JBoss/EAP/wildfly-8.0.0.Alpha4/modules/system/layers/base))]
    at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
     at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:111)
    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:129)
    at com.sun.proxy.$Proxy23.sayHello(Unknown Source)
    at test.WSClient.callMethd(WSClient.java:53)
    at test.WSClient.main(WSClient.java:60)

However, the end function of this project throws no exception and returns good result value with Eclipse kepler ,JBoss tool for kepler and JBoss EAP 6.1.1. 

I attach for project zip file for your convenience.
                  
> Wildfly 8 ws-security client throws exception
> ---------------------------------------------
>
>                 Key: JBWS-3748
>                 URL: https://issues.jboss.org/browse/JBWS-3748
>             Project: JBoss Web Services
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: ws-security
>            Reporter: Joseph Hwang
>         Attachments: WSSHelloWorld.zip
>
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jbossws-issues mailing list