All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.skyway.spring.util.webservice.cxf.HttpBasicAuthenticationSupplier Maven / Gradle / Ivy

The newest version!
/**
* Copyright 2007 - 2011 Skyway Software, Inc.
*/
package org.skyway.spring.util.webservice.cxf;

import java.net.URL;

import org.apache.cxf.message.Message;
import org.apache.cxf.transport.http.HttpBasicAuthSupplier;
import org.skyway.spring.util.webservice.WebServiceInvocationCredentials;
import org.skyway.spring.util.webservice.WebServiceInvocationCredentialsHolder;

/**
 * Supplies credentials to outgoing web service calls that require basic http authentication.
 * 
 * @author jperkins
 *
 */
public class HttpBasicAuthenticationSupplier extends HttpBasicAuthSupplier {
	public HttpBasicAuthenticationSupplier() {
	}

	@Override
	public UserPass getPreemptiveUserPass(String conduitName, URL currentURL, Message message) {
		return getUserPass(message);
	}

	@Override
	public UserPass getUserPassForRealm(String arg0, URL arg1, Message arg2, String arg3) {
		return getUserPass(arg2);
	}

	private UserPass getUserPass(Message message) {
		if (Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE))) {
			WebServiceInvocationCredentials parameters = WebServiceInvocationCredentialsHolder.get();

			if (parameters != null && parameters.isAuthenticationBasic()) {
				return createUserPass(parameters.getUserId(), parameters.getPassword());
			}
		}

		return null;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy