[jboss-user] [JBossWS] - Re: MTOM + WS Security = problem
davideling
do-not-reply at jboss.com
Fri Jun 22 11:50:56 EDT 2007
Ehm... sorry my last reply was only a code snippet...
Service implementation
| @WebService(endpointInterface="serviceJBossCipheredSigned.ServiceJBossCipheredSigned",
| portName="ServiceJBossCipheredSignedSOAP",
| serviceName="ServiceJBossCipheredSigned"
| )
| @BindingType(javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING)
| @EndpointConfig(configName = "Standard WSSecurity Endpoint")
| public class ServiceJBossCipheredSignedImpl implements
| ServiceJBossCipheredSigned {
| // bla bla ...
| }
|
Service configuration (jboss-wsse-service.xml):
| <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>WEB-INF/wsse.keystore</key-store-file>
| <key-store-password>jbossws</key-store-password>
| <trust-store-file>WEB-INF/wsse.truststore</trust-store-file>
| <trust-store-password>jbossws</trust-store-password>
| <config>
| <encrypt type="x509v3" alias="wsseClient"/>
| <sign type="x509v3" alias="wsseServer" />
| <requires>
| <signature />
| <encryption />
| <username />
| </requires>
| </config>
| </jboss-ws-security>
|
Client implementation:
| public void testInvocation() throws Exception {
|
| // 1) Service
| Service service = Service.create(
| new File("wsdl/mywsdl.wsdl").toURL(),
| new QName("http://serviceJBossCipheredSigned/",
| "ServiceJBossCipheredSigned")
| );
|
| // Configuration file WS-Security
| ((ServiceExt) service).setSecurityConfig(
| "META-INF/jboss-wsse-client.xml");
|
| // 2) Port Creation
| ServiceJBossCipheredSigned port = (ServiceJBossCipheredSigned)
| service.getPort(
| new QName("http://serviceJBossCipheredSigned/",
| "ServiceJBossCipheredSignedSOAP"),
| ServiceJBossCipheredSigned.class);
|
| // Enable MTOM
| SOAPBinding binding =
| (SOAPBinding) ((BindingProvider) port).getBinding();
| binding.setMTOMEnabled(true);
|
| // Enable WS-Security on port
| ((StubExt) port).setConfigName("Standard WSSecurity Client");
|
| // Set endpoint address
| Map<String, Object> reqContext =
| ((BindingProvider)port).getRequestContext();
| reqContext.put(
| BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
| "http://bla bla"
| );
|
| // Set username e password
| reqContext.put(Stub.USERNAME_PROPERTY, "myUsername");
| reqContext.put(Stub.PASSWORD_PROPERTY, "myPassword");
|
| ... bla bla and invocation
|
| );
|
Client configuration
| <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>META-INF/wsse.keystore</key-store-file>
| <key-store-password>jbossws</key-store-password>
| <trust-store-file>META-INF/wsse.truststore</trust-store-file>
| <trust-store-password>jbossws</trust-store-password>
|
| <config>
| <username/>
| <encrypt type="x509v3" alias="wsseServer"/>
| <sign type="x509v3" alias="wsseClient"/>
| <requires>
| <signature />
| <encryption />
| </requires>
| </config>
|
| </jboss-ws-security>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4056935#4056935
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056935
More information about the jboss-user
mailing list