diff --git a/infra/ws-util/src/main/java/com/evolveum/midpoint/infra/wsutil/AbstractWebServiceClient.java b/infra/ws-util/src/main/java/com/evolveum/midpoint/infra/wsutil/AbstractWebServiceClient.java index dc4d70606b6..5d0af12d6fb 100644 --- a/infra/ws-util/src/main/java/com/evolveum/midpoint/infra/wsutil/AbstractWebServiceClient.java +++ b/infra/ws-util/src/main/java/com/evolveum/midpoint/infra/wsutil/AbstractWebServiceClient.java @@ -94,6 +94,7 @@ public void main(String[] args) { } protected void init(String[] args) throws ParseException { + options.addOption("a", "authentication", true, "Authentication type ("+WSHandlerConstants.USERNAME_TOKEN+", none)"); options.addOption("u", "user", true, "Username"); options.addOption("p", "password", true, "Password"); options.addOption("P", "password-type", true, "Password type (text or digest)"); @@ -164,14 +165,22 @@ protected P createPort() throws Exception { Map wssProps = new HashMap(); - wssProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN); - wssProps.put(WSHandlerConstants.USER, username); - wssProps.put(WSHandlerConstants.PASSWORD_TYPE, getPasswordType()); - wssProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName()); - ClientPasswordHandler.setPassword(password); + if (!commandLine.hasOption('a') || + (commandLine.hasOption('a') && WSHandlerConstants.USERNAME_TOKEN.equals(commandLine.getOptionValue('a')))) { - WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(wssProps); - cxfEndpoint.getOutInterceptors().add(wssOut); + wssProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN); + wssProps.put(WSHandlerConstants.USER, username); + wssProps.put(WSHandlerConstants.PASSWORD_TYPE, getPasswordType()); + wssProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName()); + ClientPasswordHandler.setPassword(password); + + WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(wssProps); + cxfEndpoint.getOutInterceptors().add(wssOut); + } else if (commandLine.hasOption('a') && "none".equals(commandLine.getOptionValue('a'))) { + // Nothing to do + } else { + throw new IllegalArgumentException("Unknown authentication mechanism '"+commandLine.getOptionValue('a')+"'"); + } if (commandLine.hasOption('m')) { cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor());