Commit 236739a0 authored by Quxl's avatar Quxl

x

parent 91bf6c59
......@@ -2,6 +2,7 @@ package com.egolm.sso.clients.SI_004_INVENTORY_SyncOutService;
import java.io.File;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -59,11 +60,11 @@ public class SI004INVENTORYSyncOutServiceTask {
private String xmlRoot;
@Scheduled(cron="${cronSi004}")
public void execute() {
public void execute() throws MalformedURLException {
this.runTask();
}
public void runTask() {
public void runTask() throws MalformedURLException {
ApplicationHome home = new ApplicationHome(getClass());
File jarFile = home.getSource();
File folder = jarFile.getParentFile();
......
......@@ -21,28 +21,41 @@ public class ServiceFactory {
public static <T> T create(Class<T> requiredType, String wsdlLocation, QName serviceQName, QName portQName, String username, String password, PasswordType passwordType) {
try {
Map<String, Object> pro = new HashMap<String, Object>();
pro.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
pro.put(WSHandlerConstants.USER, username);
pro.put(WSHandlerConstants.PASSWORD_TYPE, passwordType == null ? PasswordType.PasswordText.name() : passwordType.name());
pro.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
public void handle(Callback[] callbacks) {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
pc.setPassword(password);
}
}
});
URL WSDL_URL = new URL(wsdlLocation);
Service dyService = Service.create(WSDL_URL, serviceQName);
T service = dyService.getPort(portQName, requiredType);
ClientProxy.getClient(service).getOutInterceptors().add(new WSS4JOutInterceptor(pro));
ClientProxy.getClient(service).getOutInterceptors().add(getWSS4JOutInterceptor(username, password, passwordType));
return service;
} catch (MalformedURLException e) {
throw new XRException(e);
}
}
private static WSS4JOutInterceptor wss4JOutInterceptor = null;
public static WSS4JOutInterceptor getWSS4JOutInterceptor(String username, String password, PasswordType passwordType) {
if(wss4JOutInterceptor == null) {
synchronized (wss4JOutInterceptor) {
if(wss4JOutInterceptor == null) {
Map<String, Object> pro = new HashMap<String, Object>();
pro.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
pro.put(WSHandlerConstants.USER, username);
pro.put(WSHandlerConstants.PASSWORD_TYPE, passwordType == null ? PasswordType.PasswordText.name() : passwordType.name());
pro.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
public void handle(Callback[] callbacks) {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
pc.setPassword(password);
}
}
});
wss4JOutInterceptor = new WSS4JOutInterceptor(pro);
}
}
}
return wss4JOutInterceptor;
}
public enum PasswordType {
PasswordText, PasswordNone, PasswordDigest
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment