tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andygumbre...@apache.org
Subject [01/33] tomee git commit: Align SNAPSHOT versions & reformat examples
Date Fri, 25 Sep 2015 10:42:36 GMT
Repository: tomee
Updated Branches:
  refs/heads/master 9abcc3988 -> f9f1b8ad0


http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java
----------------------------------------------------------------------
diff --git a/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java
b/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java
index b15d478..b6a6e18 100644
--- a/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java
+++ b/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java
@@ -1,318 +1,318 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.calculator;
-
-import junit.framework.TestCase;
-import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
-import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
-import org.apache.cxf.endpoint.Client;
-import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.frontend.ClientProxy;
-import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
-import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
-import org.apache.wss4j.common.ext.WSPasswordCallback;
-import org.apache.wss4j.dom.WSConstants;
-import org.apache.wss4j.dom.handler.WSHandlerConstants;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.xml.namespace.QName;
-import javax.xml.ws.Service;
-import javax.xml.ws.soap.SOAPBinding;
-import java.io.IOException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-public class CalculatorTest extends TestCase {
-
-    //START SNIPPET: setup
-	
-	//Random port to avoid test conflicts
-    private static final int port = Integer.parseInt(System.getProperty("httpejbd.port",
"" + org.apache.openejb.util.NetworkUtil.getNextAvailablePort()));
-	
-    @Override
-    protected void setUp() throws Exception {
-        final Properties properties = new Properties();
-        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
-        properties.setProperty("openejb.embedded.remotable", "true");
-		
-		//Just for this test we change the default port from 4204 to avoid conflicts
-		properties.setProperty("httpejbd.port", "" + port);
-
-        new InitialContext(properties);
-    }
-    //END SNIPPET: setup
-
-    //START SNIPPET: webservice
-    public void testCalculatorViaWsInterface() throws Exception {
-        final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImpl?wsdl"),
-                                                   new QName("http://superbiz.org/wsdl",
"CalculatorWsService"));
-        assertNotNull(calcService);
-
-        final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
-
-        final Client client = ClientProxy.getClient(calc);
-        final Endpoint endpoint = client.getEndpoint();
-        endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
-
-        final Map<String, Object> outProps = new HashMap<>();
-        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
-        outProps.put(WSHandlerConstants.USER, "jane");
-        outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
-        outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
-
-            @Override
-            public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
-                final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
-                pc.setPassword("waterfall");
-            }
-        });
-
-        final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
-        endpoint.getOutInterceptors().add(wssOut);
-
-        assertEquals(10, calc.sum(4, 6));
-    }
-
-    public void testCalculatorViaWsInterfaceWithTimestamp1way() throws Exception {
-        final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplTimestamp1way?wsdl"),
-                                                   new QName("http://superbiz.org/wsdl",
"CalculatorWsService"));
-        assertNotNull(calcService);
-
-        // for debugging (ie. TCPMon)
-        calcService.addPort(new QName("http://superbiz.org/wsdl",
-                                      "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
-                            "http://127.0.0.1:8204/CalculatorImplTimestamp1way");
-
-        //        CalculatorWs calc = calcService.getPort(
-        //        	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
-        //		CalculatorWs.class);
-
-        final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
-
-        final Client client = ClientProxy.getClient(calc);
-        final Endpoint endpoint = client.getEndpoint();
-        endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
-
-        final Map<String, Object> outProps = new HashMap<String, Object>();
-        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
-        final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
-        endpoint.getOutInterceptors().add(wssOut);
-
-        assertEquals(12, calc.multiply(3, 4));
-    }
-
-    public void testCalculatorViaWsInterfaceWithTimestamp2ways() throws Exception {
-        final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplTimestamp2ways?wsdl"),
-                                                   new QName("http://superbiz.org/wsdl",
"CalculatorWsService"));
-        assertNotNull(calcService);
-
-        // for debugging (ie. TCPMon)
-        calcService.addPort(new QName("http://superbiz.org/wsdl",
-                                      "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
-                            "http://127.0.0.1:8204/CalculatorImplTimestamp2ways");
-
-        //        CalculatorWs calc = calcService.getPort(
-        //        	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
-        //		CalculatorWs.class);
-
-        final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
-
-        final Client client = ClientProxy.getClient(calc);
-        final Endpoint endpoint = client.getEndpoint();
-        endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
-        endpoint.getInInterceptors().add(new SAAJInInterceptor());
-
-        final Map<String, Object> outProps = new HashMap<String, Object>();
-        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
-        final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
-        endpoint.getOutInterceptors().add(wssOut);
-
-        final Map<String, Object> inProps = new HashMap<String, Object>();
-        inProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
-        final WSS4JInInterceptor wssIn = new WSS4JInInterceptor(inProps);
-        endpoint.getInInterceptors().add(wssIn);
-
-        assertEquals(12, calc.multiply(3, 4));
-    }
-
-    public void testCalculatorViaWsInterfaceWithUsernameTokenPlainPassword() throws Exception
{
-        final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplUsernameTokenPlainPassword?wsdl"),
-                                                   new QName("http://superbiz.org/wsdl",
"CalculatorWsService"));
-        assertNotNull(calcService);
-
-        // for debugging (ie. TCPMon)
-        calcService.addPort(new QName("http://superbiz.org/wsdl",
-                                      "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
-                            "http://127.0.0.1:8204/CalculatorImplUsernameTokenPlainPassword");
-
-        //        CalculatorWs calc = calcService.getPort(
-        //        	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
-        //        	CalculatorWs.class);
-
-        final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
-
-        final Client client = ClientProxy.getClient(calc);
-        final Endpoint endpoint = client.getEndpoint();
-        endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
-
-        final Map<String, Object> outProps = new HashMap<String, Object>();
-        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
-        outProps.put(WSHandlerConstants.USER, "jane");
-        outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
-        outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
-
-            @Override
-            public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
-                final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
-                pc.setPassword("waterfall");
-            }
-        });
-
-        final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
-        endpoint.getOutInterceptors().add(wssOut);
-
-        assertEquals(10, calc.sum(4, 6));
-    }
-
-    public void testCalculatorViaWsInterfaceWithUsernameTokenHashedPassword() throws Exception
{
-        final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplUsernameTokenHashedPassword?wsdl"),
-                                                   new QName("http://superbiz.org/wsdl",
"CalculatorWsService"));
-        assertNotNull(calcService);
-
-        // for debugging (ie. TCPMon)
-        calcService.addPort(new QName("http://superbiz.org/wsdl",
-                                      "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
-                            "http://127.0.0.1:8204/CalculatorImplUsernameTokenHashedPassword");
-
-        //        CalculatorWs calc = calcService.getPort(
-        //        	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
-        //        	CalculatorWs.class);
-
-        final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
-
-        final Client client = ClientProxy.getClient(calc);
-        final Endpoint endpoint = client.getEndpoint();
-        endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
-
-        final Map<String, Object> outProps = new HashMap<String, Object>();
-        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
-        outProps.put(WSHandlerConstants.USER, "jane");
-        outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
-        outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
-
-            @Override
-            public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
-                final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
-                pc.setPassword("waterfall");
-            }
-        });
-
-        final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
-        endpoint.getOutInterceptors().add(wssOut);
-
-        assertEquals(10, calc.sum(4, 6));
-    }
-
-    public void testCalculatorViaWsInterfaceWithUsernameTokenPlainPasswordEncrypt() throws
Exception {
-        final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplUsernameTokenPlainPasswordEncrypt?wsdl"),
-                                                   new QName("http://superbiz.org/wsdl",
"CalculatorWsService"));
-        assertNotNull(calcService);
-
-        // for debugging (ie. TCPMon)
-        calcService.addPort(new QName("http://superbiz.org/wsdl",
-                                      "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
-                            "http://127.0.0.1:8204/CalculatorImplUsernameTokenPlainPasswordEncrypt");
-
-        //        CalculatorWs calc = calcService.getPort(
-        //        	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
-        //        	CalculatorWs.class);
-
-        final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
-
-        final Client client = ClientProxy.getClient(calc);
-        final Endpoint endpoint = client.getEndpoint();
-        endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
-
-        final Map<String, Object> outProps = new HashMap<String, Object>();
-        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN
-                                                + " " + WSHandlerConstants.ENCRYPT);
-        outProps.put(WSHandlerConstants.USER, "jane");
-        outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
-        outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
-
-            @Override
-            public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
-                final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
-                pc.setPassword("waterfall");
-            }
-        });
-        outProps.put(WSHandlerConstants.ENC_PROP_FILE, "META-INF/CalculatorImplUsernameTokenPlainPasswordEncrypt-client.properties");
-        outProps.put(WSHandlerConstants.ENCRYPTION_USER, "serveralias");
-
-        final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
-        endpoint.getOutInterceptors().add(wssOut);
-
-        assertEquals(10, calc.sum(4, 6));
-    }
-
-    public void testCalculatorViaWsInterfaceWithSign() throws Exception {
-        final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplSign?wsdl"),
-                                                   new QName("http://superbiz.org/wsdl",
"CalculatorWsService"));
-        assertNotNull(calcService);
-
-        // for debugging (ie. TCPMon)
-        calcService.addPort(new QName("http://superbiz.org/wsdl",
-                                      "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
-                            "http://127.0.0.1:8204/CalculatorImplSign");
-
-        //      CalculatorWs calc = calcService.getPort(
-        //	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
-        //	CalculatorWs.class);
-
-        final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
-
-        final Client client = ClientProxy.getClient(calc);
-        final Endpoint endpoint = client.getEndpoint();
-        endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
-
-        final Map<String, Object> outProps = new HashMap<String, Object>();
-        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
-        outProps.put(WSHandlerConstants.USER, "clientalias");
-        outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
-
-            @Override
-            public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
-                final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
-                pc.setPassword("clientPassword");
-            }
-        });
-        outProps.put(WSHandlerConstants.SIG_PROP_FILE, "META-INF/CalculatorImplSign-client.properties");
-        outProps.put(WSHandlerConstants.SIG_KEY_ID, "IssuerSerial");
-
-        final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
-        endpoint.getOutInterceptors().add(wssOut);
-
-        assertEquals(24, calc.multiply(4, 6));
-    }
-    //END SNIPPET: webservice
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+import junit.framework.TestCase;
+import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
+import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
+import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
+import org.apache.wss4j.common.ext.WSPasswordCallback;
+import org.apache.wss4j.dom.WSConstants;
+import org.apache.wss4j.dom.handler.WSHandlerConstants;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+public class CalculatorTest extends TestCase {
+
+    //START SNIPPET: setup
+
+    //Random port to avoid test conflicts
+    private static final int port = Integer.parseInt(System.getProperty("httpejbd.port",
"" + org.apache.openejb.util.NetworkUtil.getNextAvailablePort()));
+
+    @Override
+    protected void setUp() throws Exception {
+        final Properties properties = new Properties();
+        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+        properties.setProperty("openejb.embedded.remotable", "true");
+
+        //Just for this test we change the default port from 4204 to avoid conflicts
+        properties.setProperty("httpejbd.port", "" + port);
+
+        new InitialContext(properties);
+    }
+    //END SNIPPET: setup
+
+    //START SNIPPET: webservice
+    public void testCalculatorViaWsInterface() throws Exception {
+        final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImpl?wsdl"),
+                new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+        assertNotNull(calcService);
+
+        final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+        final Client client = ClientProxy.getClient(calc);
+        final Endpoint endpoint = client.getEndpoint();
+        endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+        final Map<String, Object> outProps = new HashMap<>();
+        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+        outProps.put(WSHandlerConstants.USER, "jane");
+        outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+        outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+            @Override
+            public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
+                final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+                pc.setPassword("waterfall");
+            }
+        });
+
+        final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+        endpoint.getOutInterceptors().add(wssOut);
+
+        assertEquals(10, calc.sum(4, 6));
+    }
+
+    public void testCalculatorViaWsInterfaceWithTimestamp1way() throws Exception {
+        final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplTimestamp1way?wsdl"),
+                new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+        assertNotNull(calcService);
+
+        // for debugging (ie. TCPMon)
+        calcService.addPort(new QName("http://superbiz.org/wsdl",
+                        "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+                "http://127.0.0.1:8204/CalculatorImplTimestamp1way");
+
+        //        CalculatorWs calc = calcService.getPort(
+        //        	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+        //		CalculatorWs.class);
+
+        final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+        final Client client = ClientProxy.getClient(calc);
+        final Endpoint endpoint = client.getEndpoint();
+        endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+        final Map<String, Object> outProps = new HashMap<String, Object>();
+        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
+        final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+        endpoint.getOutInterceptors().add(wssOut);
+
+        assertEquals(12, calc.multiply(3, 4));
+    }
+
+    public void testCalculatorViaWsInterfaceWithTimestamp2ways() throws Exception {
+        final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplTimestamp2ways?wsdl"),
+                new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+        assertNotNull(calcService);
+
+        // for debugging (ie. TCPMon)
+        calcService.addPort(new QName("http://superbiz.org/wsdl",
+                        "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+                "http://127.0.0.1:8204/CalculatorImplTimestamp2ways");
+
+        //        CalculatorWs calc = calcService.getPort(
+        //        	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+        //		CalculatorWs.class);
+
+        final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+        final Client client = ClientProxy.getClient(calc);
+        final Endpoint endpoint = client.getEndpoint();
+        endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+        endpoint.getInInterceptors().add(new SAAJInInterceptor());
+
+        final Map<String, Object> outProps = new HashMap<String, Object>();
+        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
+        final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+        endpoint.getOutInterceptors().add(wssOut);
+
+        final Map<String, Object> inProps = new HashMap<String, Object>();
+        inProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
+        final WSS4JInInterceptor wssIn = new WSS4JInInterceptor(inProps);
+        endpoint.getInInterceptors().add(wssIn);
+
+        assertEquals(12, calc.multiply(3, 4));
+    }
+
+    public void testCalculatorViaWsInterfaceWithUsernameTokenPlainPassword() throws Exception
{
+        final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplUsernameTokenPlainPassword?wsdl"),
+                new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+        assertNotNull(calcService);
+
+        // for debugging (ie. TCPMon)
+        calcService.addPort(new QName("http://superbiz.org/wsdl",
+                        "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+                "http://127.0.0.1:8204/CalculatorImplUsernameTokenPlainPassword");
+
+        //        CalculatorWs calc = calcService.getPort(
+        //        	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+        //        	CalculatorWs.class);
+
+        final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+        final Client client = ClientProxy.getClient(calc);
+        final Endpoint endpoint = client.getEndpoint();
+        endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+        final Map<String, Object> outProps = new HashMap<String, Object>();
+        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+        outProps.put(WSHandlerConstants.USER, "jane");
+        outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+        outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+            @Override
+            public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
+                final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+                pc.setPassword("waterfall");
+            }
+        });
+
+        final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+        endpoint.getOutInterceptors().add(wssOut);
+
+        assertEquals(10, calc.sum(4, 6));
+    }
+
+    public void testCalculatorViaWsInterfaceWithUsernameTokenHashedPassword() throws Exception
{
+        final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplUsernameTokenHashedPassword?wsdl"),
+                new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+        assertNotNull(calcService);
+
+        // for debugging (ie. TCPMon)
+        calcService.addPort(new QName("http://superbiz.org/wsdl",
+                        "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+                "http://127.0.0.1:8204/CalculatorImplUsernameTokenHashedPassword");
+
+        //        CalculatorWs calc = calcService.getPort(
+        //        	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+        //        	CalculatorWs.class);
+
+        final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+        final Client client = ClientProxy.getClient(calc);
+        final Endpoint endpoint = client.getEndpoint();
+        endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+        final Map<String, Object> outProps = new HashMap<String, Object>();
+        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+        outProps.put(WSHandlerConstants.USER, "jane");
+        outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
+        outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+            @Override
+            public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
+                final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+                pc.setPassword("waterfall");
+            }
+        });
+
+        final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+        endpoint.getOutInterceptors().add(wssOut);
+
+        assertEquals(10, calc.sum(4, 6));
+    }
+
+    public void testCalculatorViaWsInterfaceWithUsernameTokenPlainPasswordEncrypt() throws
Exception {
+        final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplUsernameTokenPlainPasswordEncrypt?wsdl"),
+                new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+        assertNotNull(calcService);
+
+        // for debugging (ie. TCPMon)
+        calcService.addPort(new QName("http://superbiz.org/wsdl",
+                        "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+                "http://127.0.0.1:8204/CalculatorImplUsernameTokenPlainPasswordEncrypt");
+
+        //        CalculatorWs calc = calcService.getPort(
+        //        	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+        //        	CalculatorWs.class);
+
+        final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+        final Client client = ClientProxy.getClient(calc);
+        final Endpoint endpoint = client.getEndpoint();
+        endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+        final Map<String, Object> outProps = new HashMap<String, Object>();
+        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN
+                + " " + WSHandlerConstants.ENCRYPT);
+        outProps.put(WSHandlerConstants.USER, "jane");
+        outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+        outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+            @Override
+            public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
+                final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+                pc.setPassword("waterfall");
+            }
+        });
+        outProps.put(WSHandlerConstants.ENC_PROP_FILE, "META-INF/CalculatorImplUsernameTokenPlainPasswordEncrypt-client.properties");
+        outProps.put(WSHandlerConstants.ENCRYPTION_USER, "serveralias");
+
+        final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+        endpoint.getOutInterceptors().add(wssOut);
+
+        assertEquals(10, calc.sum(4, 6));
+    }
+
+    public void testCalculatorViaWsInterfaceWithSign() throws Exception {
+        final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplSign?wsdl"),
+                new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+        assertNotNull(calcService);
+
+        // for debugging (ie. TCPMon)
+        calcService.addPort(new QName("http://superbiz.org/wsdl",
+                        "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+                "http://127.0.0.1:8204/CalculatorImplSign");
+
+        //      CalculatorWs calc = calcService.getPort(
+        //	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+        //	CalculatorWs.class);
+
+        final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+        final Client client = ClientProxy.getClient(calc);
+        final Endpoint endpoint = client.getEndpoint();
+        endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+        final Map<String, Object> outProps = new HashMap<String, Object>();
+        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+        outProps.put(WSHandlerConstants.USER, "clientalias");
+        outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+            @Override
+            public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
+                final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+                pc.setPassword("clientPassword");
+            }
+        });
+        outProps.put(WSHandlerConstants.SIG_PROP_FILE, "META-INF/CalculatorImplSign-client.properties");
+        outProps.put(WSHandlerConstants.SIG_KEY_ID, "IssuerSerial");
+
+        final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+        endpoint.getOutInterceptors().add(wssOut);
+
+        assertEquals(24, calc.multiply(4, 6));
+    }
+    //END SNIPPET: webservice
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CustomPasswordHandler.java
----------------------------------------------------------------------
diff --git a/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CustomPasswordHandler.java
b/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CustomPasswordHandler.java
index 6605333..5539dc3 100644
--- a/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CustomPasswordHandler.java
+++ b/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CustomPasswordHandler.java
@@ -1,44 +1,44 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.calculator;
-
-import org.apache.wss4j.common.ext.WSPasswordCallback;
-
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import java.io.IOException;
-
-public class CustomPasswordHandler implements CallbackHandler {
-
-    @Override
-    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
-        WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
-
-        if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN) {
-            // TODO get the password from the users.properties if possible
-            pc.setPassword("waterfall");
-
-        } else if (pc.getUsage() == WSPasswordCallback.DECRYPT) {
-            pc.setPassword("serverPassword");
-
-        } else if (pc.getUsage() == WSPasswordCallback.SIGNATURE) {
-            pc.setPassword("serverPassword");
-
-        }
-    }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+import org.apache.wss4j.common.ext.WSPasswordCallback;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import java.io.IOException;
+
+public class CustomPasswordHandler implements CallbackHandler {
+
+    @Override
+    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
+        WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+
+        if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN) {
+            // TODO get the password from the users.properties if possible
+            pc.setPassword("waterfall");
+
+        } else if (pc.getUsage() == WSPasswordCallback.DECRYPT) {
+            pc.setPassword("serverPassword");
+
+        } else if (pc.getUsage() == WSPasswordCallback.SIGNATURE) {
+            pc.setPassword("serverPassword");
+
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/Calculator.java
----------------------------------------------------------------------
diff --git a/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/Calculator.java
b/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/Calculator.java
index f57e9cd..393a9c9 100644
--- a/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/Calculator.java
+++ b/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/Calculator.java
@@ -1,25 +1,25 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.ws.security;
-
-import javax.jws.WebService;
-
-@WebService
-public interface Calculator {
-
-    int add(int op1, int op2);
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ws.security;
+
+import javax.jws.WebService;
+
+@WebService
+public interface Calculator {
+
+    int add(int op1, int op2);
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/CalculatorBean.java
----------------------------------------------------------------------
diff --git a/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/CalculatorBean.java
b/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/CalculatorBean.java
index 2a406fc..8854d06 100644
--- a/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/CalculatorBean.java
+++ b/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/CalculatorBean.java
@@ -1,30 +1,30 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.ws.security;
-
-import javax.ejb.Singleton;
-import javax.jws.WebService;
-
-@Singleton
-@WebService
-public class CalculatorBean implements Calculator {
-
-    @Override
-    public int add(int op1, int op2) {
-        return op1 + op2;
-    }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ws.security;
+
+import javax.ejb.Singleton;
+import javax.jws.WebService;
+
+@Singleton
+@WebService
+public class CalculatorBean implements Calculator {
+
+    @Override
+    public int add(int op1, int op2) {
+        return op1 + op2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/PasswordCallbackHandler.java
----------------------------------------------------------------------
diff --git a/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/PasswordCallbackHandler.java
b/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/PasswordCallbackHandler.java
index c28401c..f7380a0 100644
--- a/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/PasswordCallbackHandler.java
+++ b/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/PasswordCallbackHandler.java
@@ -1,44 +1,44 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz.ws.security;
-
-import org.apache.wss4j.common.ext.WSPasswordCallback;
-
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import java.io.IOException;
-
-public class PasswordCallbackHandler implements CallbackHandler {
-
-    private static boolean called = false;
-
-    @Override
-    public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
-        called = true;
-
-        final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
-        if (pc.getIdentifier().equals("openejb")) {
-            System.out.println("logged openejb user");
-            pc.setPassword("tomee");
-        }
-    }
-
-    public static boolean wasCalled() {
-        return called;
-    }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ws.security;
+
+import org.apache.wss4j.common.ext.WSPasswordCallback;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import java.io.IOException;
+
+public class PasswordCallbackHandler implements CallbackHandler {
+
+    private static boolean called = false;
+
+    @Override
+    public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
+        called = true;
+
+        final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+        if (pc.getIdentifier().equals("openejb")) {
+            System.out.println("logged openejb user");
+            pc.setPassword("tomee");
+        }
+    }
+
+    public static boolean wasCalled() {
+        return called;
+    }
+}


Mime
View raw message