Author: ningjiang Date: Thu Apr 7 13:06:52 2011 New Revision: 1089865 URL: http://svn.apache.org/viewvc?rev=1089865&view=rev Log: Fixed the build error after upgrading to CXF 2.4.0-SNAPSHOT
Modified: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/security/KeystorePasswordCallback.java Modified: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/security/KeystorePasswordCallback.java URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/security/KeystorePasswordCallback.java?rev=1089865&r1=1089864&r2=1089865&view=diff ============================================================================== --- camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/security/KeystorePasswordCallback.java (original) +++ camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/security/KeystorePasswordCallback.java Thu Apr 7 13:06:52 2011 @@ -17,6 +17,8 @@ package org.apache.camel.itest.security; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; @@ -47,13 +49,14 @@ public class KeystorePasswordCallback im for (int i = 0; i < callbacks.length; i++) { WSPasswordCallback pc = (WSPasswordCallback)callbacks[i]; String pass = passwords.get(pc.getIdentifier()); - if (WSConstants.PASSWORD_DIGEST.equals(pc.getPasswordType())) { + String type = getPasswordType(pc); + if (WSConstants.PASSWORD_DIGEST.equals(type)) { if (pass != null) { pc.setPassword(pass); return; } } - if (WSConstants.PASSWORD_TEXT.equals(pc.getPasswordType())) { + if (WSConstants.PASSWORD_TEXT.equals(type)) { // As the PasswordType is PasswordDigest, we need to do the authentication in the call back if (!pc.getPassword().equals(pass)) { throw new IOException("Wrong password!"); @@ -68,4 +71,23 @@ public class KeystorePasswordCallback im public void setAliasPassword(String alias, String password) { passwords.put(alias, password); } + + private String getPasswordType(WSPasswordCallback pc) { + try { + Method getType = null; + try { + getType = pc.getClass().getMethod("getPasswordType", new Class[0]); + } catch (NoSuchMethodException ex) { + // keep looking + } catch (SecurityException ex) { + // keep looking + } + if (getType == null) { + getType = pc.getClass().getMethod("getType", new Class[0]); + } + return (String)getType.invoke(pc, new Object[0]); + } catch (Exception ex) { + return null; + } + } }