Author: alessio.soldano(a)jboss.com
Date: 2008-07-28 11:38:54 -0400 (Mon, 28 Jul 2008)
New Revision: 7921
Added:
stack/metro/trunk/modules/testsuite/metro-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/CustomPasswordHandler.java
Modified:
stack/metro/trunk/modules/testsuite/metro-tests/src/test/resources/jaxws/samples/wsse/username/META-INF/wsit-client.xml
Log:
[JBWS-2211] Providing an example with a custom handler to set username/pwd from the code
Added:
stack/metro/trunk/modules/testsuite/metro-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/CustomPasswordHandler.java
===================================================================
---
stack/metro/trunk/modules/testsuite/metro-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/CustomPasswordHandler.java
(rev 0)
+++
stack/metro/trunk/modules/testsuite/metro-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/CustomPasswordHandler.java 2008-07-28
15:38:54 UTC (rev 7921)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.wsse;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * A simple password callback handler showing how to set password from the code
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 28-Jul-2008
+ *
+ */
+public class CustomPasswordHandler implements CallbackHandler
+{
+ public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException
+ {
+ PasswordCallback pwdCallback = null;
+ if (callbacks != null)
+ {
+ for (int i=0; i < callbacks.length; i++)
+ {
+ Callback cb = callbacks[i];
+ if (cb instanceof PasswordCallback)
+ pwdCallback = (PasswordCallback)cb;
+ }
+ if (pwdCallback != null)
+ {
+ pwdCallback.setPassword("thefrog".toCharArray());
+ }
+ }
+ }
+
+}
Property changes on:
stack/metro/trunk/modules/testsuite/metro-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/CustomPasswordHandler.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
stack/metro/trunk/modules/testsuite/metro-tests/src/test/resources/jaxws/samples/wsse/username/META-INF/wsit-client.xml
===================================================================
---
stack/metro/trunk/modules/testsuite/metro-tests/src/test/resources/jaxws/samples/wsse/username/META-INF/wsit-client.xml 2008-07-28
14:13:48 UTC (rev 7920)
+++
stack/metro/trunk/modules/testsuite/metro-tests/src/test/resources/jaxws/samples/wsse/username/META-INF/wsit-client.xml 2008-07-28
15:38:54 UTC (rev 7921)
@@ -21,10 +21,12 @@
<wsp:ExactlyOne>
<wsp:All>
<sc:CallbackHandlerConfiguration>
+ <!-- This shows how to set the username from the
descriptor -->
<sc:CallbackHandler name="usernameHandler"
default="kermit"/>
- <sc:CallbackHandler name="passwordHandler"
default="thefrog"/>
+ <!-- This shows how to set the password from the code instead -->
+ <sc:CallbackHandler name="passwordHandler"
classname="org.jboss.test.ws.jaxws.samples.wsse.CustomPasswordHandler"/>
</sc:CallbackHandlerConfiguration>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
-</definitions>
\ No newline at end of file
+</definitions>