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

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

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

import java.io.IOException;

import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;

import org.apache.ws.security.WSPasswordCallback;
import org.skyway.spring.util.webservice.WebServiceInvocationCredentials;
import org.skyway.spring.util.webservice.WebServiceInvocationCredentialsHolder;

/**
 * CallbackHandler used to apply credentials to outgoing web service calls that
 * require ws-security authentication.
 *  
 * @author jperkins
 *
 */
public class ApplyCredentialsHandler implements CallbackHandler {

	public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
		WebServiceInvocationCredentials parameters = WebServiceInvocationCredentialsHolder.get();
		WSPasswordCallback passwordCallback = (WSPasswordCallback) callbacks[0];

		if (parameters != null && parameters.isAuthenticationWsSecurity()) {
			passwordCallback.setPassword(parameters.getPassword());
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy