Author: rmannibucau
Date: Thu Aug 16 21:52:48 2012
New Revision: 1374076

URL: http://svn.apache.org/viewvc?rev=1374076&view=rev
Log:
example with resources.xml to configure wss4j

Added:
    
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/MapFactory.java
      - copied, changed from r1373814, 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/MapService.java
    openejb/trunk/openejb/examples/webservice-ws-with-resources-config/
    openejb/trunk/openejb/examples/webservice-ws-with-resources-config/pom.xml
    openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/
    openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/Calculator.java
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/CalculatorBean.java
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/PasswordCallbackHandler.java
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/resources/
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/resources/META-INF/
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/resources/META-INF/resources.xml
    openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/test/
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/test/java/
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/test/java/org/
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/test/java/org/superbiz/
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/test/java/org/superbiz/ws/
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/test/java/org/superbiz/ws/security/
    
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/test/java/org/superbiz/ws/security/CalculatorTest.java
Removed:
    
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/MapService.java
Modified:
    
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/util/ServiceInfos.java
    openejb/trunk/openejb/examples/pom.xml

Modified: 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/util/ServiceInfos.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/util/ServiceInfos.java?rev=1374076&r1=1374075&r2=1374076&view=diff
==============================================================================
--- 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/util/ServiceInfos.java
 (original)
+++ 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/util/ServiceInfos.java
 Thu Aug 16 21:52:48 2012
@@ -20,6 +20,7 @@ import org.apache.openejb.OpenEJBExcepti
 import org.apache.openejb.OpenEJBRuntimeException;
 import org.apache.openejb.assembler.classic.Assembler;
 import org.apache.openejb.assembler.classic.ServiceInfo;
+import org.apache.openejb.config.sys.MapFactory;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.xbean.recipe.ObjectRecipe;
 import org.apache.xbean.recipe.Option;
@@ -105,12 +106,16 @@ public final class ServiceInfos {
         serviceRecipe.allow(Option.FIELD_INJECTION);
         serviceRecipe.allow(Option.PRIVATE_PROPERTIES);
 
-        for (Map.Entry<Object, Object> entry : info.properties.entrySet()) { 
// manage links
-            final Object value = entry.getValue();
-            if (value instanceof String && value.toString().startsWith("&")) {
-                serviceRecipe.setProperty(entry.getKey().toString(), 
resolve(services, value.toString().substring(1)));
-            } else {
-                serviceRecipe.setProperty(entry.getKey().toString(), 
entry.getValue());
+        if (MapFactory.class.getName().equals(info.className)) {
+            serviceRecipe.setProperty("prop", info.properties);
+        } else {
+            for (Map.Entry<Object, Object> entry : info.properties.entrySet()) 
{ // manage links
+                final Object value = entry.getValue();
+                if (value instanceof String && 
value.toString().startsWith("$")) {
+                    serviceRecipe.setProperty(entry.getKey().toString(), 
resolve(services, value.toString().substring(1)));
+                } else {
+                    serviceRecipe.setProperty(entry.getKey().toString(), 
entry.getValue());
+                }
             }
         }
 

Copied: 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/MapFactory.java
 (from r1373814, 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/MapService.java)
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/MapFactory.java?p2=openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/MapFactory.java&p1=openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/MapService.java&r1=1373814&r2=1374076&rev=1374076&view=diff
==============================================================================
--- 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/MapService.java
 (original)
+++ 
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/MapFactory.java
 Thu Aug 16 21:52:48 2012
@@ -16,75 +16,15 @@
  */
 package org.apache.openejb.config.sys;
 
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-import java.util.Collection;
 import java.util.Map;
-import java.util.Set;
+import java.util.Properties;
 
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "")
-@XmlRootElement(name = "Maps")
-public class MapService extends AbstractService implements Map<Object, Object> 
{
-    @Override
-    public int size() {
-        return getProperties().size();
+public final class MapFactory {
+    private MapFactory() {
+        // no-op
     }
 
-    @Override
-    public boolean isEmpty() {
-        return getProperties().isEmpty();
-    }
-
-    @Override
-    public boolean containsKey(Object key) {
-        return getProperties().containsKey(key);
-    }
-
-    @Override
-    public boolean containsValue(Object value) {
-        return getProperties().containsValue(value);
-    }
-
-    @Override
-    public Object get(Object key) {
-        return getProperties().get(key);
-    }
-
-    @Override
-    public Object put(Object key, Object value) {
-        return getProperties().put(key, value);
-    }
-
-    @Override
-    public Object remove(Object key) {
-        return getProperties().remove(key);
-    }
-
-    @Override
-    public void putAll(Map<? extends Object, ? extends Object> m) {
-        getProperties().putAll(m);
-    }
-
-    @Override
-    public void clear() {
-        getProperties().clear();
-    }
-
-    @Override
-    public Set<Object> keySet() {
-        return getProperties().keySet();
-    }
-
-    @Override
-    public Collection<Object> values() {
-        return getProperties().values();
-    }
-
-    @Override
-    public Set<Entry<Object, Object>> entrySet() {
-        return getProperties().entrySet();
+    public static Map<?, ?> create(final Properties props) {
+        return props;
     }
 }

Modified: openejb/trunk/openejb/examples/pom.xml
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/pom.xml?rev=1374076&r1=1374075&r2=1374076&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/pom.xml (original)
+++ openejb/trunk/openejb/examples/pom.xml Thu Aug 16 21:52:48 2012
@@ -133,6 +133,7 @@
     <module>webservice-inheritance</module>
     <module>webservice-security</module>
     <module>webservice-ws-security</module>
+    <module>webservice-ws-with-resources-config</module>
     <module>webservice-handlerchain</module>
     <module>webservice-holder</module>
   </modules>

Added: 
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/pom.xml
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/webservice-ws-with-resources-config/pom.xml?rev=1374076&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/webservice-ws-with-resources-config/pom.xml 
(added)
+++ openejb/trunk/openejb/examples/webservice-ws-with-resources-config/pom.xml 
Thu Aug 16 21:52:48 2012
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.superbiz</groupId>
+  <artifactId>webservice-ws-with-resources-config</artifactId>
+  <packaging>jar</packaging>
+  <version>1.1-SNAPSHOT</version>
+  <name>OpenEJB :: Web Examples :: EJB WebService WS Security with 
resources.xml</name>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-cxf</artifactId>
+      <version>4.1.0-SNAPSHOT</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.10</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <defaultGoal>install</defaultGoal>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.4</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <!--
+  This section allows you to configure where to publish libraries for sharing.
+  It is not required and may be deleted.  For more information see:
+  http://maven.apache.org/plugins/maven-deploy-plugin/
+  -->
+  <distributionManagement>
+    <repository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/repo/</url>
+    </repository>
+    <snapshotRepository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/snapshot-repo/</url>
+    </snapshotRepository>
+  </distributionManagement>
+</project>

Added: 
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/Calculator.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/Calculator.java?rev=1374076&view=auto
==============================================================================
--- 
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/Calculator.java
 (added)
+++ 
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/Calculator.java
 Thu Aug 16 21:52:48 2012
@@ -0,0 +1,24 @@
+/**
+ * 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);
+}

Added: 
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/CalculatorBean.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/CalculatorBean.java?rev=1374076&view=auto
==============================================================================
--- 
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/CalculatorBean.java
 (added)
+++ 
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/CalculatorBean.java
 Thu Aug 16 21:52:48 2012
@@ -0,0 +1,29 @@
+/**
+ * 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;
+    }
+}

Added: 
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/PasswordCallbackHandler.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/PasswordCallbackHandler.java?rev=1374076&view=auto
==============================================================================
--- 
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/PasswordCallbackHandler.java
 (added)
+++ 
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/PasswordCallbackHandler.java
 Thu Aug 16 21:52:48 2012
@@ -0,0 +1,34 @@
+/**
+ * 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.ws.security.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 {
+    @Override
+    public void handle(final Callback[] callbacks) throws IOException, 
UnsupportedCallbackException {
+        final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+        if (pc.getIdentifier().equals("openejb")) {
+            pc.setPassword("tomee");
+        }
+    }
+}

Added: 
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/resources/META-INF/resources.xml
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/resources/META-INF/resources.xml?rev=1374076&view=auto
==============================================================================
--- 
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/resources/META-INF/resources.xml
 (added)
+++ 
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/main/resources/META-INF/resources.xml
 Thu Aug 16 21:52:48 2012
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+-->
+<resources>
+  <!-- our bean config -->
+  <Service class-name="org.superbiz.ws.security.CalculatorBean">
+    cxf.jaxws.in-interceptors = wss4j-in
+  </Service>
+
+  <!-- the interceptors -->
+  <Service id="wss4j-in" 
class-name="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
+    properties = $in-prop
+  </Service>
+
+  <!-- the properties for saaj interceptors -->
+  <Service id="in-prop" class-name="org.apache.openejb.config.sys.MapFactory" 
factory-name="create" constructor="prop">
+    action = UsernameToken
+    passwordType = PasswordText
+    passwordCallbackClass = org.superbiz.ws.security.PasswordCallbackHandler
+  </Service>
+</resources>

Added: 
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/test/java/org/superbiz/ws/security/CalculatorTest.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/test/java/org/superbiz/ws/security/CalculatorTest.java?rev=1374076&view=auto
==============================================================================
--- 
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/test/java/org/superbiz/ws/security/CalculatorTest.java
 (added)
+++ 
openejb/trunk/openejb/examples/webservice-ws-with-resources-config/src/test/java/org/superbiz/ws/security/CalculatorTest.java
 Thu Aug 16 21:52:48 2012
@@ -0,0 +1,97 @@
+/**
+ * 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.cxf.frontend.ClientProxy;
+import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
+import org.apache.openejb.OpenEjbContainer;
+import org.apache.ws.security.WSPasswordCallback;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+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.SOAPFaultException;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+public class CalculatorTest {
+    @Test
+    public void call() throws MalformedURLException {
+        final EJBContainer container = EJBContainer.createEJBContainer(new 
Properties() {{
+            setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
+        }});
+
+        // normal call
+
+        final Service service = Service.create(
+                new 
URL("http://127.0.0.1:4204/webservice-ws-with-resources-config/CalculatorBean?wsdl";),
+                new QName("http://security.ws.superbiz.org/";, 
"CalculatorBeanService"));
+
+        final Calculator calculator = service.getPort(Calculator.class);
+        ClientProxy.getClient(calculator).getOutInterceptors().add(
+                new WSS4JOutInterceptor(new HashMap<String, Object>() {{
+                    put("action", "UsernameToken");
+                    put("user", "openejb");
+                    put("passwordType", "PasswordText");
+                    put("passwordCallbackRef", new CallbackHandler() {
+                        @Override
+                        public void handle(Callback[] callbacks) throws 
IOException, UnsupportedCallbackException {
+                            final WSPasswordCallback pc = (WSPasswordCallback) 
callbacks[0];
+                            pc.setPassword("tomee");
+                        }
+                    });
+                }}));
+
+        assertEquals(5, calculator.add(2, 3));
+
+        // bad auth
+
+        final Calculator calculator2 = service.getPort(Calculator.class);
+        ClientProxy.getClient(calculator2).getOutInterceptors().add(
+                new WSS4JOutInterceptor(new HashMap<String, Object>() {{
+                    put("action", "UsernameToken");
+                    put("user", "openejb");
+                    put("passwordType", "PasswordText");
+                    put("passwordCallbackRef", new CallbackHandler() {
+                        @Override
+                        public void handle(Callback[] callbacks) throws 
IOException, UnsupportedCallbackException {
+                            final WSPasswordCallback pc = (WSPasswordCallback) 
callbacks[0];
+                            pc.setPassword("wrong");
+                        }
+                    });
+                }}));
+
+        try {
+            assertEquals(5, calculator2.add(2, 3));
+        } catch (SOAPFaultException sfe) {
+            assertThat(sfe.getMessage(), containsString("The security token 
could not be authenticated or authorized"));
+        }
+
+        container.close();
+    }
+}


Reply via email to