Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jul 7, 2014
2 parents 88ce940 + ff39101 commit 7931dfc
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 17 deletions.
Expand Up @@ -30,6 +30,8 @@
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.handler.WSHandlerConstants;
Expand Down Expand Up @@ -59,7 +61,18 @@ public void setVerbose(boolean verbose) {
protected abstract String getDefaultUsername();

protected String getPasswordType() {
return WSConstants.PW_DIGEST;
if (commandLine.hasOption('P')) {
String optionValue = commandLine.getOptionValue('P');
if ("text".equals(optionValue)) {
return WSConstants.PW_TEXT;
} else if ("digest".equals(optionValue)) {
return WSConstants.PW_DIGEST;
} else {
throw new IllegalArgumentException("Unknown password type "+optionValue);
}
} else {
return WSConstants.PW_TEXT;
}
}

protected abstract String getDefaultPassword();
Expand All @@ -83,8 +96,10 @@ public void main(String[] args) {
protected void init(String[] args) throws ParseException {
options.addOption("u", "user", true, "Username");
options.addOption("p", "password", true, "Password");
options.addOption("P", "password-type", true, "Password type (text or digest)");
options.addOption("e", "endpoint", true, "Endpoint URL");
options.addOption("v", "verbose", false, "Verbose mode");
options.addOption("m", "messages", false, "Log SOAP messages");
options.addOption("h", "help", false, "Usage help");
extendOptions(options);
parseCommandLine(args);
Expand Down Expand Up @@ -157,9 +172,11 @@ protected P createPort() throws Exception {

WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(wssProps);
cxfEndpoint.getOutInterceptors().add(wssOut);
// enable the following to get client-side logging of outgoing requests and incoming responses
//cxfEndpoint.getOutInterceptors().add(new LoggingOutInterceptor());
//cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor());

if (commandLine.hasOption('m')) {
cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor());
cxfEndpoint.getOutInterceptors().add(new LoggingOutInterceptor());
}

return modelPort;
}
Expand Down
@@ -0,0 +1 @@
org.apache.cxf.common.logging.Slf4jLogger
Expand Up @@ -26,6 +26,8 @@
import com.evolveum.midpoint.security.api.MidPointPrincipal;
import com.evolveum.midpoint.security.api.UserProfileService;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
Expand All @@ -36,6 +38,8 @@
* @author Igor Farinic
*/
public class PasswordCallback implements CallbackHandler {

private static final Trace LOGGER = TraceManager.getTrace(PasswordCallback.class);

private UserProfileService userDetailsService;
private Protector protector;
Expand All @@ -46,8 +50,12 @@ public PasswordCallback(UserProfileService userDetailsService, Protector protect
}

public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
LOGGER.trace("Invoked PasswordCallback with {} callbacks: {}", callbacks.length, callbacks);
WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];

String wssPasswordType = pc.getType();
LOGGER.trace("Password type: {}", wssPasswordType);

MidPointPrincipal user;
try {
user = userDetailsService.getPrincipal(pc.getIdentifier());
Expand Down
3 changes: 1 addition & 2 deletions model/model-impl/src/main/resources/ctx-model.xml
Expand Up @@ -407,14 +407,13 @@
<constructor-arg>
<map>
<entry key="action" value="UsernameToken"/>
<entry key="passwordType" value="PasswordDigest"/>
<entry key="passwordCallbackRef">
<ref bean="passwordCallback"/>
</entry>
</map>
</constructor-arg>
</bean>

<bean id="springAuthenticationInjector" class="com.evolveum.midpoint.model.impl.security.SpringAuthenticationInjectorInterceptor">
<constructor-arg name="userDetailsService" ref="userDetailsService"/>
<constructor-arg name="securityEnforcer" ref="securityEnforcer"/>
Expand Down
Expand Up @@ -35,10 +35,6 @@

<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/reconciliation/handler-3</handlerUri>
<objectRef oid="10000000-0000-0000-0000-00000000a204" type="ResourceType"/>
<recurrence>recurring</recurrence>
<binding>tight</binding>
<schedule>
<interval>5</interval>
</schedule>
<recurrence>single</recurrence>

</task>
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Evolveum
* Copyright (c) 2010-2014 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,11 +17,7 @@
package com.evolveum.midpoint.task.api;

/**
* Created with IntelliJ IDEA.
* User: mederly
* Date: 3.5.2012
* Time: 21:50
* To change this template use File | Settings | File Templates.
* @author mederly
*/
public class TaskCategory {

Expand All @@ -36,4 +32,5 @@ public class TaskCategory {
public static final String WORKFLOW = "Workflow";
public static final String SYSTEM = "System";
public static final String REPORT = "Report";
public static final String CUSTOM = "Custom";
}

0 comments on commit 7931dfc

Please sign in to comment.