Commit ee5c6937 authored by zhh's avatar zhh

zhh-update

parent c5beba28
import java.lang.reflect.Constructor;
import java.math.BigInteger;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.Provider;
import java.security.PublicKey;
import java.security.Security;
import java.security.spec.RSAPrivateKeySpec;
import java.security.spec.RSAPublicKeySpec;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.DESedeKeySpec;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import tohi.safety.webservice.EncodeUtil;
public class MXCipherX
{
String algorithm;
String mode;
String padding;
String key;
String spec;
String modulus;
private Cipher cipherEncrypt;
String transformation;
SecretKey secretKey;
IvParameterSpec ivSpec;
PBEParameterSpec pbeParamSpec;
SecretKeySpec secretkeySpec;
PublicKey publicKey;
PrivateKey privateKey;
boolean nonSunProviders;
Provider providerClass;
int padLen;
protected MXCipherX()
{
this.algorithm = PropertiesUtil.CRYPTOX_ALGORITHM;
this.mode = PropertiesUtil.CRYPTOX_MODE;
this.padding = PropertiesUtil.CRYPTOX_PADDING;
this.key = PropertiesUtil.CRYPTOX_KEY;
this.spec = PropertiesUtil.CRYPTOX_SPEC;
this.modulus = PropertiesUtil.CRYPTOX_MODULUS;
this.cipherEncrypt = null;
this.transformation = null;
this.secretKey = null;
this.ivSpec = null;
this.pbeParamSpec = null;
this.secretkeySpec = null;
this.publicKey = null;
this.privateKey = null;
this.nonSunProviders = false;
this.providerClass = null;
this.padLen = 8;
}
public MXCipherX(boolean isEncrypt, PropertiesUtil pu) {
this.algorithm = PropertiesUtil.CRYPTOX_ALGORITHM;
this.mode = PropertiesUtil.CRYPTOX_MODE;
this.padding = PropertiesUtil.CRYPTOX_PADDING;
this.key = PropertiesUtil.CRYPTOX_KEY;
this.spec = PropertiesUtil.CRYPTOX_SPEC;
this.modulus = PropertiesUtil.CRYPTOX_MODULUS;
this.cipherEncrypt = null;
this.transformation = null;
this.secretKey = null;
this.ivSpec = null;
this.pbeParamSpec = null;
this.secretkeySpec = null;
this.publicKey = null;
this.privateKey = null;
this.nonSunProviders = false;
this.providerClass = null;
this.padLen = 8;
String algTest = pu.getAlgorithm();
String modeTest = pu.getMode();
String paddingTest = pu.getPadding();
String keyTest = pu.getKey();
String specTest = pu.getSpec();
String modTest = pu.getModulus();
String providerTest = pu.getProvider();
init(isEncrypt, algTest, modeTest, paddingTest, keyTest, specTest,
modTest, providerTest);
}
public MXCipherX(boolean isEncrypt, String algTest, String modeTest, String paddingTest, String keyTest, String specTest)
{
this.algorithm = PropertiesUtil.CRYPTOX_ALGORITHM;
this.mode = PropertiesUtil.CRYPTOX_MODE;
this.padding = PropertiesUtil.CRYPTOX_PADDING;
this.key = PropertiesUtil.CRYPTOX_KEY;
this.spec = PropertiesUtil.CRYPTOX_SPEC;
this.modulus = PropertiesUtil.CRYPTOX_MODULUS;
this.cipherEncrypt = null;
this.transformation = null;
this.secretKey = null;
this.ivSpec = null;
this.pbeParamSpec = null;
this.secretkeySpec = null;
this.publicKey = null;
this.privateKey = null;
this.nonSunProviders = false;
this.providerClass = null;
this.padLen = 8;
init(isEncrypt, algTest, modeTest, paddingTest, keyTest, specTest,
null, null);
}
public MXCipherX(boolean isEncrypt, String algTest, String modeTest, String paddingTest, String keyTest, String specTest, String modTest, String providerTest)
{
this.algorithm = PropertiesUtil.CRYPTOX_ALGORITHM;
this.mode = PropertiesUtil.CRYPTOX_MODE;
this.padding = PropertiesUtil.CRYPTOX_PADDING;
this.key = PropertiesUtil.CRYPTOX_KEY;
this.spec = PropertiesUtil.CRYPTOX_SPEC;
this.modulus = PropertiesUtil.CRYPTOX_MODULUS;
this.cipherEncrypt = null;
this.transformation = null;
this.secretKey = null;
this.ivSpec = null;
this.pbeParamSpec = null;
this.secretkeySpec = null;
this.publicKey = null;
this.privateKey = null;
this.nonSunProviders = false;
this.providerClass = null;
this.padLen = 8;
init(isEncrypt, algTest, modeTest, paddingTest, keyTest, specTest,
modTest, providerTest);
}
protected void init(boolean isEncrypt, String algTest, String modeTest, String paddingTest, String keyTest, String specTest, String modTest, String providerTest)
{
try
{
if ((providerTest != null) && (!providerTest.equals(""))) {
Class c = Class.forName(providerTest);
Class[] paramTypes = new Class[0];
Constructor ctor = c.getConstructor(paramTypes);
Object[] params = new Object[0];
this.providerClass = ((Provider)ctor.newInstance(params));
Security.addProvider(this.providerClass);
}
} catch (Exception e) {
e.printStackTrace();
return;
}
Provider[] provs = Security.getProviders();
for (int xx = 0; xx < provs.length; xx++) {
if (!provs[xx].getName().toUpperCase().startsWith("SUN"));
this.nonSunProviders = true;
}
validateParams(algTest, modeTest, paddingTest, keyTest, specTest,
modTest);
this.transformation = this.algorithm;
if ((this.mode != null) && (!this.mode.equals("")) && (this.padding != null) &&
(!this.padding.equals("")))
this.transformation = (this.transformation + "/" + this.mode + "/" + this.padding);
try {
this.cipherEncrypt = buildCipher(isEncrypt);
} catch (Exception e) {
e.printStackTrace();
}
}
Cipher buildCipher(boolean encrypt) throws Exception {
Cipher cipher = null;
int cryptMode = 1;
if (!encrypt)
cryptMode = 2;
if ((this.algorithm.equals("DESede")) || (this.algorithm.equals("TripleDES"))) {
if ((this.secretKey == null) || (this.ivSpec == null)) {
DESedeKeySpec keyspec = new DESedeKeySpec(this.key.getBytes());
SecretKeyFactory factory =
SecretKeyFactory.getInstance(this.algorithm);
this.secretKey = factory.generateSecret(keyspec);
this.ivSpec = new IvParameterSpec(this.spec.getBytes());
}
if (this.providerClass == null)
cipher = Cipher.getInstance(this.transformation);
else
cipher = Cipher.getInstance(this.transformation, this.providerClass);
if (this.transformation.indexOf("ECB") < 0)
cipher.init(cryptMode, this.secretKey, this.ivSpec);
else
cipher.init(cryptMode, this.secretKey);
} else if (this.algorithm.equals("DES")) {
if ((this.secretKey == null) || (this.ivSpec == null)) {
DESKeySpec keyspec = new DESKeySpec(this.key.getBytes());
SecretKeyFactory factory =
SecretKeyFactory.getInstance(this.algorithm);
this.secretKey = factory.generateSecret(keyspec);
this.ivSpec = new IvParameterSpec(this.spec.getBytes());
}
if (this.providerClass == null)
cipher = Cipher.getInstance(this.transformation);
else
cipher = Cipher.getInstance(this.transformation, this.providerClass);
if (this.transformation.indexOf("ECB") < 0)
cipher.init(cryptMode, this.secretKey, this.ivSpec);
else
cipher.init(cryptMode, this.secretKey);
} else if (this.algorithm.startsWith("PBEWith")) {
if ((this.secretKey == null) || (this.pbeParamSpec == null)) {
this.pbeParamSpec = new PBEParameterSpec(this.spec.getBytes(), 20);
PBEKeySpec pbeKeySpec = new PBEKeySpec(this.spec.toCharArray());
SecretKeyFactory keyFac =
SecretKeyFactory.getInstance(this.algorithm);
this.secretKey = keyFac.generateSecret(pbeKeySpec);
}
if (this.providerClass == null)
cipher = Cipher.getInstance(this.transformation);
else
cipher = Cipher.getInstance(this.transformation, this.providerClass);
cipher.init(cryptMode, this.secretKey, this.pbeParamSpec);
} else if (this.algorithm.equals("RSA")) {
if ((this.publicKey == null) || (this.privateKey == null)) {
KeyFactory fac = KeyFactory.getInstance("RSA", this.providerClass);
this.publicKey = fac.generatePublic(new RSAPublicKeySpec(
new BigInteger(this.modulus), new BigInteger(this.key)));
this.privateKey = fac.generatePrivate(new RSAPrivateKeySpec(
new BigInteger(this.modulus), new BigInteger(this.spec)));
}
if (this.providerClass == null)
cipher = Cipher.getInstance(this.transformation);
else
cipher = Cipher.getInstance(this.transformation, this.providerClass);
if (encrypt)
cipher.init(cryptMode, this.publicKey);
else
cipher.init(cryptMode, this.privateKey);
} else {
if (this.secretkeySpec == null) {
int padLen = this.algorithm.equals("SKIPJACK") ? 10 : 16;
byte[] byteArray = this.spec.getBytes();
byteArray = pad(byteArray, padLen);
this.secretkeySpec = new SecretKeySpec(byteArray, this.algorithm);
}
if (this.providerClass == null)
cipher = Cipher.getInstance(this.transformation);
else
cipher = Cipher.getInstance(this.transformation, this.providerClass);
cipher.init(cryptMode, this.secretkeySpec);
}
return cipher;
}
private boolean validateParams(String algTest, String modeTest, String paddingTest, String keyTest, String specTest, String modTest)
{
if ((algTest != null) && (!algTest.equals("")))
this.algorithm = algTest;
if ((modeTest != null) && (!modeTest.equals("")))
this.mode = modeTest;
if ((paddingTest != null) && (!paddingTest.equals("")))
this.padding = paddingTest;
if ((keyTest != null) && (!keyTest.equals("")))
this.key = keyTest;
if ((specTest != null) && (!specTest.equals("")))
this.spec = specTest;
if ((modTest != null) && (!modTest.equals("")))
this.modulus = modTest;
if (this.algorithm == null)
return false;
if ((this.algorithm.equals("AES")) || (this.algorithm.equals("Serpent")) ||
(this.algorithm.equals("MARS")) || (this.algorithm.equals("RC6")) ||
(this.algorithm.equals("Rijndael")) || (this.algorithm.equals("Square")) ||
(this.algorithm.equals("Twofish")))
this.padLen = 16;
else if (this.algorithm.equals("RSA"))
this.padLen = 0;
if ((!this.algorithm.equals("DES")) && (!this.algorithm.equals("DESede")) &&
(!this.algorithm.equals("AES"))) {
if ((modeTest == null) || (modeTest.equals("")))
this.mode = "";
if ((paddingTest == null) || (paddingTest.equals("")))
this.padding = "";
}
if (this.nonSunProviders)
return true;
if ((!this.algorithm.equals("DESede")) && (!this.algorithm.equals("DES")) &&
(!this.algorithm.equals("AES")) &&
(!this.algorithm.equals("PBEWithMD5AndDES")))
return false;
if ((this.algorithm.equals("AES")) && ((this.mode == null) || (!this.mode.equals("ECB"))))
return false;
if (this.algorithm.equals("PBEWithMD5AndDES")) {
if ((this.mode == null) || (!this.mode.equals("CBC")))
return false;
if ((this.padding == null) || (!this.padding.equals("PKCS5Padding")))
return false;
if (this.key.getBytes().length != 8)
return false;
}
if ((this.mode != null) && (!this.mode.equals("")) && (!this.mode.equals("CBC")) &&
(!this.mode.equals("CFB")) && (!this.mode.equals("ECB")) &&
(!this.mode.equals("OFB")) && (!this.mode.equals("PCBC")))
return false;
if ((this.padding != null) && (!this.padding.equals("")) &&
(!this.padding.equals("NoPadding")) &&
(!this.padding.equals("PKCS5Padding")))
return false;
if ((this.key != null) && (!this.key.equals("")) && (!this.algorithm.equals("RSA")) &&
(this.key.length() % 24 != 0))
return false;
if ((this.spec != null) && (!this.spec.equals("")) && (!this.algorithm.equals("RSA")) &&
(this.spec.length() % 8 != 0))
return false;
return (this.mode == null) || (!this.mode.equals("OFB")) || (this.padding == null) ||
(this.padding.equals("NoPadding")) || (
(this.algorithm != null) &&
(this.algorithm.equals("DES")));
}
public synchronized String encData(String in) {
byte[] temp = in.getBytes();
temp = pad(temp);
byte[] encryptVal = (byte[])null;
try {
encryptVal = this.cipherEncrypt.doFinal(temp);
} catch (Exception e) {
e.printStackTrace();
return null;
}
return EncodeUtil.Bytes2HexString(encryptVal);
}
public synchronized String decData(String in)
{
byte[] temp = EncodeUtil.HexString2Bytes(in);
temp = pad(temp);
byte[] decryptVal = (byte[])null;
try
{
decryptVal = this.cipherEncrypt.doFinal(temp);
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
}
String value = new String(decryptVal);
return value.trim();
}
protected byte[] pad(byte[] in) {
return pad(in, this.padLen);
}
protected byte[] pad(byte[] in, int padLen) {
if (padLen == 0)
return in;
int inlen = in.length;
int outlen = inlen;
int rem = inlen % padLen;
if (rem > 0)
outlen = inlen + (padLen - rem);
byte[] out = new byte[outlen];
for (int xx = 0; xx < inlen; xx++) {
out[xx] = in[xx];
}
return out;
}
}
\ No newline at end of file
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.util.PropertyPlaceholderHelper;
public class PropertiesConfigurerUtil extends PropertyPlaceholderConfigurer
{
private static Map<String, String> properties = new HashMap();
protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)
throws BeansException
{
PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${",
"}", ":", false);
for (Map.Entry entry : props.entrySet()) {
String stringKey = String.valueOf(entry.getKey()).trim();
String stringValue = String.valueOf(entry.getValue()).trim();
stringValue = helper.replacePlaceholders(stringValue, props);
properties.put(stringKey, stringValue);
}
super.processProperties(beanFactoryToProcess, props);
}
public static Map<String, String> getProperties()
{
return properties;
}
public static String getProperty(String proName)
{
return (String)properties.get(proName);
}
}
\ No newline at end of file
public class PropertiesUtil
{
public static String CRYPTOX_MODE = "CBC";
public static String CRYPTOX_PADDING = "PKCS5Padding";
public static String CRYPTOX_KEY = "Sa#qk5usfmMI-@2dbZP9`jL3";
public static String CRYPTOX_SPEC = "beLd7$lB";
public static String CRYPTOX_ALGORITHM = "DESede";
public static String CRYPTOX_MODULUS = "";
public static String CRYPTOX_PROVIDER = null;
private String algorithm;
private String mode;
private String padding;
private String key;
private String spec;
private String modulus;
private String provider;
public PropertiesUtil()
{
try
{
this.algorithm = PropertiesConfigurerUtil.getProperty("mxe.security.cryptox.algorithm");
this.mode = PropertiesConfigurerUtil.getProperty("mxe.security.cryptox.mode");
this.padding = PropertiesConfigurerUtil.getProperty("mxe.security.cryptox.padding");
this.key = PropertiesConfigurerUtil.getProperty("mxe.security.cryptox.key");
this.spec = PropertiesConfigurerUtil.getProperty("mxe.security.cryptox.spec");
this.modulus = "";
this.provider = null;
} catch (Exception e) {
e.printStackTrace();
}
}
public void setAlgorithm(String algorithm) {
this.algorithm = algorithm;
}
public void setMode(String mode) {
this.mode = mode;
}
public void setPadding(String padding) {
this.padding = padding;
}
public void setKey(String key) {
this.key = key;
}
public void setSpec(String spec) {
this.spec = spec;
}
public void setModulus(String modulus) {
this.modulus = modulus;
}
public void setProvider(String provider) {
this.provider = provider;
}
public String getAlgorithm() {
return this.algorithm;
}
public String getMode() {
return this.mode;
}
public String getPadding() {
return this.padding;
}
public String getKey() {
return this.key;
}
public String getSpec() {
return this.spec;
}
public String getModulus() {
return this.modulus;
}
public String getProvider() {
return this.provider;
}
}
\ No newline at end of file
......@@ -30,9 +30,8 @@ public class Test {
// int weekNowNum=calendar1.get(Calendar.DAY_OF_WEEK);//获取当前星期
// System.out.println(weekNowNum);
String s=new String("\u5df2");
System.out.println(s);
}
}
import java.text.SimpleDateFormat;
import java.util.Date;
public class Test2 {
public static void main(String[] args) {
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
String d=sdf.format(new Date());
System.out.println(d +" 23:00:00");
}
}
import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
import psdi.util.MXCipher;
import psdi.util.MXSession;
public class Test2 {
private static final String SERVER = "172.20.0.93";
private static final String SUPER_USERNAME = "maxadmin";
private static final String SUPER_PASSWORD = "clpjbdev";
public static void main(String[] args) throws Exception {
Test2 test = new Test2();
test.listUser();
}
private void listUser() throws Exception {
MXSession mxSession = MXSession.getSession();
mxSession.setHost(SERVER);
mxSession.setUserName(SUPER_USERNAME);
mxSession.setPassword(SUPER_PASSWORD);
mxSession.connect();
MXCipher mxCipher = new MXCipher(mxSession.getMXServerRemote());
MboSetRemote set = (MboSetRemote)mxSession.getMboSet("MAXUSER");
set.setQbeExactMatch(true);
MboRemote mbo = (MboRemote)set.moveFirst();
while (true) {
if (mbo == null) {
break;
}
String username = mbo.getString("loginid");
byte[] bytes = mbo.getBytes("password");
String password = mxCipher.decData(bytes);
System.out.println(username + ": " + password);
mbo = set.moveNext();
}
mxSession.disconnect();
}
}
\ No newline at end of file
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
public class Test3 {
public static void main(String[] args) {
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
try {
/*
* 加载驱动有两种方式
*
* 1:会导致驱动会注册两次,过度依赖于mysql的api,脱离的mysql的开发包,程序则无法编译
* 2:驱动只会加载一次,不需要依赖具体的驱动,灵活性高
*
* 我们一般都是使用第二种方式
* */
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
//获取与数据库连接的对象-Connetcion
connection = DriverManager.getConnection("jdbc:sqlserver://;serverName=172.20.0.95;databaseName=maxdb;portNumber=1433;integratedSecurity=false;sendStringParametersAsUnicode=false;selectMethod=cursor;", "maximo", "maximo");
//获取执行sql语句的statement对象
statement = connection.createStatement();
//执行sql语句,拿到结果集
resultSet = statement.executeQuery("SELECT * FROM maxuser");
//遍历结果集,得到数据
PropertiesUtil pu = new PropertiesUtil();
MXCipherX mx = new MXCipherX(true, pu);
while (resultSet.next()) {
String pwd=resultSet.getString("password");
System.out.println("原来"+pwd);
//String spwd = mx.decData("05D3E4AE66BD4C6D0A934D9896EB2187");
String spwd1 = mx.encData("clpjbdev");
String spwd = mx.decData("170DB79B4BEE2D9670C8C117EE7862D7");
// System.out.println("spwd:"+spwd);
System.out.println("加密"+spwd1);
// System.out.println("解密"+new String(spwd.getBytes("UTF-8")));
System.out.println("解密"+spwd);
System.out.println();
}
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} finally {
/*
* 关闭资源,后调用的先关闭
*
* 关闭之前,要判断对象是否存在
* */
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
/**
* 解密
* @param String src 解密字符串
* @param String key 密钥
* @return 解密后的字符串
*/
public static String Decrypt(String src, String key) throws Exception {
try {
// 判断Key是否正确
if (key == null) {
System.out.print("Key为空null");
return null;
}
// 密钥补位
int plus= 32-key.length();
byte[] data = key.getBytes("utf-8");
byte[] raw = new byte[32];
byte[] plusbyte={ 0x08, 0x08, 0x04, 0x0b, 0x02, 0x0f, 0x0b, 0x0c,0x01, 0x03, 0x09, 0x07, 0x0c, 0x03, 0x07, 0x0a, 0x04, 0x0f,0x06, 0x0f, 0x0e, 0x09, 0x05, 0x01, 0x0a, 0x0a, 0x01, 0x09,0x06, 0x07, 0x09, 0x0d };
for(int i=0;i<32;i++)
{
if (data.length > i)
raw[i] = data[i];
else
raw[i] = plusbyte[plus];
}
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
//byte[] encrypted1 = new Base64().decode(src);//base64
byte[] encrypted1 = toByteArray(src);//十六进制
try {
byte[] original = cipher.doFinal(encrypted1);
String originalString = new String(original,"utf-8");
return originalString;
} catch (Exception e) {
System.out.println(e.toString());
return null;
}
} catch (Exception ex) {
System.out.println(ex.toString());
return null;
}
}
/**
* 将byte[]转为各种进制的字符串
* @param bytes byte[]
* @param radix 可以转换进制的范围,从Character.MIN_RADIX到Character.MAX_RADIX,超出范围后变为10进制
* @return 转换后的字符串
*/
public static String binary(byte[] bytes, int radix){
return new BigInteger(1, bytes).toString(radix); // 这里的1代表正数
}
/**
* 16进制的字符串表示转成字节数组
*
* @param hexString 16进制格式的字符串
* @return 转换后的字节数组
**/
public static byte[] toByteArray(String hexString) {
if (hexString.isEmpty())
throw new IllegalArgumentException("this hexString must not be empty");
hexString = hexString.toLowerCase();
final byte[] byteArray = new byte[hexString.length() / 2];
int k = 0;
for (int i = 0; i < byteArray.length; i++) {//因为是16进制,最多只会占用4位,转换成字节需要两个16进制的字符,高位在先
byte high = (byte) (Character.digit(hexString.charAt(k), 16) & 0xff);
byte low = (byte) (Character.digit(hexString.charAt(k + 1), 16) & 0xff);
byteArray[i] = (byte) (high << 4 | low);
k += 2;
}
return byteArray;
}
}
\ No newline at end of file
package clp.app.crontask;
import clp.app.rtinspection.RTInspcPlan;
import clp.app.rtinspection.RTInspcPlanSet;
import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.Date;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
import psdi.server.MXServer;
import psdi.server.SimpleCronTask;
import psdi.util.MXApplicationException;
import psdi.util.MXException;
import psdi.util.logging.MXLogger;
import psdi.util.logging.MXLoggerFactory;
import psdi.workflow.WorkFlowServiceRemote;
public class CLPRTInspcGenCronTask extends SimpleCronTask {
private boolean ready = false;
MXLogger logger;
public CLPRTInspcGenCronTask() {
}
public void init() throws MXException {
super.init();
this.logger = MXLoggerFactory.getLogger("maximo.crontask.CLPRTInspcGenCronTask");
}
public void start() {
this.ready = true;
}
public void cronAction() {
try {
this.startwf();
} catch (RemoteException var6) {
var6.printStackTrace();
} catch (MXException var7) {
var7.printStackTrace();
}
if (this.ready) {
this.logger.info("-- Start CLPRTInspcGenCronTask -------------------- ");
try {
MXServer mxserver = MXServer.getMXServer();
RTInspcPlanSet rtInspcPlanSet = (RTInspcPlanSet)mxserver.getMboSet("RTInspcPlan", this.getRunasUserInfo());
StringBuilder strBuffer = new StringBuilder();
strBuffer.append("status='已核准' and nextdate < dbo.GetLocalDate(DEFAULT) ").append(" and (frequnit not in ('NOON','6.乙','7.丙') ").append(" or (frequnit='NOON' and DATENAME(HOUR, dbo.GetLocalDate(DEFAULT))>=12) ").append(" or (frequnit='6.乙' and DATENAME(HOUR, dbo.GetLocalDate(DEFAULT))>=13) ").append(" or (frequnit='7.丙' and DATENAME(HOUR, dbo.GetLocalDate(DEFAULT))>=19) ) ").append(" and (not exists(select 1 from timeline where num=rtinspcplan.rtinsplnum and siteid=rtinspcplan.siteid) ").append("\t\tor exists(select 1 from timeline where num=rtinspcplan.rtinsplnum and siteid=rtinspcplan.siteid ").append("\t\tand flag=0 and (rtinspcplan.nextdate-0.02084+substring( convert(varchar,starttime,120),12,16))<(dbo.GetLocalDate(DEFAULT))) ").append("\t) ");
rtInspcPlanSet.setWhere(strBuffer.toString());
rtInspcPlanSet.reset();
RTInspcPlan rtInspcPlan = null;
for(int i = 0; (rtInspcPlan = (RTInspcPlan)rtInspcPlanSet.getMbo(i)) != null; ++i) {
this.genRTInspc(rtInspcPlan);
}
rtInspcPlanSet.save();
rtInspcPlanSet.close();
this.startwf();
} catch (Exception var8) {
var8.printStackTrace();
System.out.println(var8.getStackTrace());
this.logger.error(var8.getStackTrace());
}
this.logger.info("-- End CLPRTInspcGenCronTask ------------------------- ");
}
}
private void startwf() throws RemoteException, MXException {
MXServer mxserver = MXServer.getMXServer();
WorkFlowServiceRemote wfsr = (WorkFlowServiceRemote)mxserver.lookup("WORKFLOW");
MboSetRemote rtInspcSet = mxserver.getMboSet("RTInspection", this.getRunasUserInfo());
rtInspcSet.setWhere("RTINSPLNUM is not null and not exists(select 1 from wfassignment where ownerid=rtinspection.routinginspectionid and ownertable='RTINSPECTION' and assignstatus='ACTIVE') and historyflag=0 and status in ('草稿','已核准') and datediff(day,rtinspcdate,dbo.GetLocalDate(DEFAULT))<=1");
rtInspcSet.reset();
MboRemote rtInspc = null;
for(int i = 0; (rtInspc = rtInspcSet.getMbo(i)) != null; ++i) {
wfsr.initiateWorkflow("CLPRTINSPC", rtInspc);
}
rtInspcSet.close();
}
private void genRTInspc(RTInspcPlan rtInspcPlan) throws RemoteException, MXException {
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
Date nextdate = rtInspcPlan.getDate("nextdate");
Date sysdate = MXServer.getMXServer().getDate();
if (!ft.format(sysdate).equalsIgnoreCase(ft.format(nextdate))) {
if (sysdate.compareTo(nextdate) < 0) {
throw new MXApplicationException("提示:", "巡检日期为:" + ft.format(nextdate) + ",还没到期!");
}
if (sysdate.compareTo(nextdate) > 0) {
nextdate = sysdate;
}
}
MboSetRemote rtinspcSet = rtInspcPlan.getMboSet("NEWRTINSPECTION");
MboRemote rtinspc = rtinspcSet.add();
rtinspc.setValue("description", rtInspcPlan.getString("description"));
rtinspc.setValue("RTINSPCDATE", nextdate);
rtinspc.setValue("RTINSPECTYPE", rtInspcPlan.getString("TYPE"));
rtinspc.setValue("ROUTE", rtInspcPlan.getString("ROUTE"));
rtinspc.setValue("RTINSPLNUM", rtInspcPlan.getString("RTINSPLNUM"));
rtinspc.setValue("endtime", rtInspcPlan.getDate("endtime"));
rtinspc.setValue("status", "已核准");
MboSetRemote PersonGrpTeamSet = rtInspcPlan.getMboSet("$personGroupTeam", "personGroupTeam", "persongroup='" + rtInspcPlan.getString("OWNERGROUP") + "'");
MboSetRemote leadGrpSet = rtinspc.getMboSet("LEADGROUP");
MboRemote personGrpTeam = null;
MboRemote leadGrp = null;
for(int i = 0; (personGrpTeam = PersonGrpTeamSet.getMbo(i)) != null; ++i) {
leadGrp = leadGrpSet.add();
leadGrp.setValue("personid", personGrpTeam.getString("RESPPARTYGROUP"));
}
MboSetRemote timelineSet0 = rtInspcPlan.getMboSet("timeline");
if (timelineSet0.isEmpty()) {
rtInspcPlan.setValue("nextdate", rtInspcPlan.getNextDate(nextdate));
} else {
MboSetRemote timelineSet = rtInspcPlan.getMboSet("STARTTIMEBTCT");
MboRemote timeline = null;
int j;
if (timelineSet.isEmpty()) {
rtInspcPlan.setValue("nextdate", rtInspcPlan.getNextDate(nextdate));
timelineSet0.setOrderBy("starttime asc");
timelineSet0.reset();
for(j = 0; (timeline = timelineSet0.getMbo(j)) != null; ++j) {
timeline.setValue("flag", false);
rtinspc.setValue("endtime", timeline.getDate("endtime"));
rtinspc.setValue("description", timeline.getString("description"));
}
} else {
timelineSet = rtInspcPlan.getMboSet("STARTTIMELTCT");
for(j = 0; (timeline = timelineSet.getMbo(j)) != null; ++j) {
rtinspc.setValue("endtime", timeline.getDate("endtime"));
rtinspc.setValue("description", timeline.getString("description"));
timeline.setValue("flag", true);
}
}
}
}
}
package com.tohi.webclient.beans.pjo;
import java.rmi.RemoteException;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
import psdi.server.MXServer;
import psdi.util.MXApplicationException;
import psdi.util.MXException;
import psdi.webclient.system.beans.AppBean;
public class CustSafetyadviceAppBean extends AppBean{
/**
* 创建工单
* @throws MXException
* @throws RemoteException
*/
public void CREATEWO() throws RemoteException, MXException{
MboRemote mbo=this.getMbo();
if (!mbo.getString("WONUM").equalsIgnoreCase("")) {
throw new MXApplicationException("提示:", "当前单据已经生成了工单,工单号为["+mbo.getString("WONUM")+"]!");
}
MboSetRemote WORKORDERMboSet=MXServer.getMXServer().getMboSet("WORKORDER", mbo.getUserInfo());
MboRemote newWoMbo=WORKORDERMboSet.add(11L); //创建接班记录
newWoMbo.setValue("DESCRIPTION", mbo.getString("DESCRIPTION"),11L);
newWoMbo.setValue("CUSTDEPT", mbo.getString("DEPARTMENT"),11L); //部门
newWoMbo.setValue("CUSTFZR", mbo.getString("PERSONLIABLE"),11L);//责任人
newWoMbo.setValue("WORKTYPE","HSE",11L);//工单类型
mbo.setValue("WONUM", newWoMbo.getString("WONUM"));
WORKORDERMboSet.save();
WORKORDERMboSet.close();
this.SAVE();
}
}
package psdi.app.system;
import com.ibm.tivoli.maximo.oslc.OslcUtils;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.rmi.RemoteException;
import psdi.app.item.ToolItem;
import psdi.app.serviceitem.ServiceItem;
import psdi.mbo.Mbo;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSet;
import psdi.mbo.MboSetRemote;
import psdi.util.MXApplicationException;
import psdi.util.MXException;
public class ImgLib extends Mbo
implements ImgLibRemote
{
static final long serialVersionUID = -8133679206882304474L;
public ImgLib(MboSet ms)
throws RemoteException
{
super(ms);
}
public void add()
throws MXException, RemoteException
{
super.add();
MboRemote ownerMbo = getOwner();
if (((ownerMbo instanceof ServiceItem)) || ((ownerMbo instanceof ToolItem))) {
setValue("refobject", "ITEM", 11L);
}
else {
setValue("refobject", ownerMbo.getName(), 11L);
}
if (ownerMbo.getThisMboSet().getMboSetInfo().isPersistent()) {
setValue("refobjectid", ownerMbo.getUniqueIDValue(), 11L);
}
getMboValue("imglibid").generateUniqueID();
if ("WORKORDER".equalsIgnoreCase(ownerMbo.getName()) || "SAFETYADVICE".equalsIgnoreCase(ownerMbo.getName())) {
MboSetRemote msr1 = ownerMbo.getMboSet("IMGLIB1");
MboSetRemote msr2 = ownerMbo.getMboSet("IMGLIB2");
if (!msr1.isEmpty()) {
if (msr1.getMbo(0).toBeAdded()) {
setValue("udimagecount", 1, 11L);
setValue("refobjectid", ownerMbo.getUniqueIDValue() + 1L, 11L);
return;
}
if (msr1.getMbo(0).toBeDeleted()) {
setValue("udimagecount", 1, 11L);
setValue("refobjectid", ownerMbo.getUniqueIDValue() + 1L, 11L);
return;
}
setValue("udimagecount", 2, 11L);
setValue("refobjectid", ownerMbo.getUniqueIDValue() + 2L, 11L);
return;
}
if (msr2.getMbo(0).toBeAdded()) {
setValue("udimagecount", 2, 11L);
setValue("refobjectid", ownerMbo.getUniqueIDValue() + 2L, 11L);
return;
}
if (msr2.getMbo(0).toBeDeleted()) {
setValue("udimagecount", 2, 11L);
setValue("refobjectid", ownerMbo.getUniqueIDValue() + 2L, 11L);
return;
}
setValue("udimagecount", 1, 11L);
setValue("refobjectid", ownerMbo.getUniqueIDValue() + 1L, 11L);
return;
}
}
public void appValidate()
throws MXException, RemoteException
{
String fileName = getString("imagename");
if (fileName.indexOf("#") > -1) {
throw new MXApplicationException("\n提示:", "\n 图片文件名不能包含'#'号,请修改!");
}
byte[] image = getBytes("image");
if ((!isNull("image")) && ((isNull("imguri")) || (isNull("endpointname"))))
{
InputStream in = new ByteArrayInputStream(image);
OslcUtils.fileVirusScanner(fileName, in);
}
}
}
\ No newline at end of file
package psdi.webclient.beans.common;
import java.rmi.RemoteException;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
import psdi.util.MXException;
import psdi.webclient.system.beans.DataBean;
public class RecordImageBean extends DataBean
{
public int removeimage()
throws MXException, RemoteException
{
try
{
delete();
setValue("imageName", "");
}
catch (MXException e) {
this.mboSetRemote.deleteAndRemove(getMbo());
}
return 1;
}
public synchronized int execute() throws MXException, RemoteException
{
save();
return 1;
}
public boolean hasSigOptionAccess(int row, String sigOption)
throws RemoteException, MXException
{
if (sigOption != null)
{
MboRemote mbo = getMbo(row);
if ((mbo == null) && (sigOption.equalsIgnoreCase("SHOWDELETE")))
{
return false;
}
return super.hasSigOptionAccess(row, sigOption);
}
return false;
}
public int cancelDialog() throws MXException, RemoteException
{
getMboSet().reset();
return super.cancelDialog();
}
}
\ No newline at end of file
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package psdi.webclient.components;
import java.rmi.RemoteException;
import java.util.HashMap;
import psdi.iface.router.Router;
import psdi.iface.router.RouterHandler;
import psdi.mbo.MboRemote;
import psdi.util.MXException;
import psdi.webclient.controls.TableDataRow;
import psdi.webclient.system.beans.DataBean;
import psdi.webclient.system.controller.AppInstance;
import psdi.webclient.system.controller.BoundComponentInstance;
import psdi.webclient.system.runtime.WebClientRuntime;
import psdi.webclient.system.session.WebClientSession;
public class RecordImage extends BoundComponentInstance {
String cachedImageSrc = "";
public RecordImage() {
}
public String[] getImageSrc() {
String imageSrc = null;
String imageName = null;
String imageId = null;
String altText = "";
String[] imageSrcValue = new String[2];
String dataSrc = this.getProperty("datasrc");
WebClientSession clientSession = this.getWebClientSession();
AppInstance app = clientSession.getCurrentApp();
DataBean imagedb = app.getDataBean(dataSrc);
try {
MboRemote e;
if (this.isOnTableRow()) {
int row = Integer.parseInt(this.getControl().getParentInstance().getRowNum());
e = imagedb.getMbo(row);
} else {
e = imagedb.getMbo();
}
if (e != null) {
if ("WORKORDER".equalsIgnoreCase(e.getName()) || "SAFETYADVICE".equalsIgnoreCase(e.getName())) {
// String udimageCount = getProperty("udimagecount");
// if ("1".equals(udimageCount)) {
// imageName = e.getString("IMGLIB1.IMAGENAME");
// imageId = e.getString("IMGLIB1.IMGLIBID");
// } else if ("2".equals(udimageCount)) {
// imageName = e.getString("IMGLIB2.IMAGENAME");
// imageId = e.getString("IMGLIB2.IMGLIBID");
// } else {
// imageName = e.getString("IMGLIB1.IMAGENAME");
// imageId = e.getString("IMGLIB1.IMGLIBID");
// }
String reName =this.getId();
if(reName.indexOf("-")>=0){
reName = reName.split("-")[0];
}
System.out.println("reName:"+reName);
imageName = e.getString(reName+".IMAGENAME");
imageId = e.getString(reName+".IMGLIBID");
} else {
imageName = e.getString("IMGLIB.IMAGENAME");
imageId = e.getString("IMGLIB.IMGLIBID");
}
try {
altText = e.getString("DESCRIPTION");
} catch (Exception localException1) {
}
}
} catch (Exception var13) {
var13.printStackTrace();
}
if (imageName != null && !imageName.equals("")) {
System.out.println("imageId----"+imageId);
System.out.println("imageName----"+imageName);
imageSrc = "/recordimage/" + this.getId() + "/" + imageId + "/" + imageName;
System.out.println("imageSrc:"+imageSrc);
this.cachedImageSrc = imageSrc;
}
imageSrcValue[0] = imageSrc;
imageSrcValue[1] = altText;
return imageSrcValue;
}
public String getId(boolean useRow) {
String id = super.getId(true);
if (useRow) {
String row = this.getControl().getParentInstance().getRowNum();
int rowNum = -5;
if (!WebClientRuntime.isNull(row)) {
rowNum = Integer.parseInt(row);
}
if (this.getControl() instanceof TableDataRow || this.isOnTableRow() && rowNum >= 0) {
id = WebClientRuntime.addRowMarker(id, rowNum);
}
}
return id;
}
public String getRenderId() {
String renderId = super.getRenderId();
String row = this.getControl().getParentInstance().getRowNum();
int rowNum = -5;
if (!WebClientRuntime.isNull(row)) {
rowNum = Integer.parseInt(row);
}
if (this.getControl() instanceof TableDataRow || this.isOnTableRow() && rowNum >= 0) {
renderId = WebClientRuntime.addRowMarker(renderId, rowNum);
}
return renderId;
}
public int render() {
try {
super.render();
} catch (Exception var2) {
}
return 1;
}
public String getMIMEType() {
String mimetype = null;
String dataSrc = this.getProperty("datasrc");
WebClientSession clientSession = this.getWebClientSession();
AppInstance app = clientSession.getCurrentApp();
DataBean imagedb = app.getDataBean(dataSrc);
try {
MboRemote mbo = imagedb.getMbo();
if (this.isOnTableRow()) {
int row = Integer.parseInt(this.getControl().getParentInstance().getRowNum());
imagedb.getMbo(row);
} else {
MboRemote var7 = imagedb.getMbo();
}
if ("WORKORDER".equalsIgnoreCase(mbo.getName()) || "SAFETYADVICE".equalsIgnoreCase(mbo.getName())) {
String udimageCount = this.getProperty("udimagecount");
if ("1".equals(udimageCount)) {
mimetype = mbo.getString("IMGLIB1.MIMETYPE");
} else if ("2".equals(udimageCount)) {
mimetype = mbo.getString("IMGLIB2.MIMETYPE");
} else {
mimetype = mbo.getString("IMGLIB1.MIMETYPE");
}
} else {
mimetype = imagedb.getMbo().getString("IMGLIB.MIMETYPE");
}
} catch (MXException var9) {
var9.printStackTrace();
} catch (RemoteException var10) {
var10.printStackTrace();
}
return mimetype;
}
public byte[] getImage() {
byte[] image = null;
String dataSrc = this.getProperty("datasrc");
WebClientSession clientSession = this.getWebClientSession();
AppInstance app = clientSession.getCurrentApp();
DataBean imagedb = app.getDataBean(dataSrc);
try {
String udimageCount;
if (!imagedb.getMbo().isNull("IMGLIB.IMAGE")) {
MboRemote mbo = imagedb.getMbo();
if ("WORKORDER".equalsIgnoreCase(mbo.getName()) || "SAFETYADVICE".equalsIgnoreCase(mbo.getName())) {
udimageCount = this.getProperty("udimagecount");
if ("1".equals(udimageCount)) {
image = mbo.getBytes("IMGLIB1.IMAGE");
} else if ("2".equals(udimageCount)) {
image = mbo.getBytes("IMGLIB2.IMAGE");
} else {
image = mbo.getBytes("IMGLIB1.IMAGE");
}
} else {
image = imagedb.getMbo().getBytes("IMGLIB.IMAGE");
}
} else {
String e = imagedb.getMbo().getString("IMGLIB.IMGURI");
udimageCount = imagedb.getMbo().getString("IMGLIB.ENDPOINTNAME");
image = this.loadImageFromExternal(e, udimageCount);
}
} catch (MXException var8) {
var8.printStackTrace();
} catch (RemoteException var9) {
var9.printStackTrace();
}
return image;
}
public byte[] getImage(Integer row) {
byte[] image = null;
String dataSrc = this.getProperty("datasrc");
WebClientSession clientSession = this.getWebClientSession();
AppInstance app = clientSession.getCurrentApp();
DataBean imagedb = app.getDataBean(dataSrc);
try {
MboRemote e;
if (this.isOnTableRow()) {
e = imagedb.getMbo(row);
} else {
e = imagedb.getMbo();
}
String udimageCount;
if (!e.isNull("IMGLIB.IMAGE")) {
if ("WORKORDER".equalsIgnoreCase(e.getName()) || "SAFETYADVICE".equalsIgnoreCase(e.getName())) {
udimageCount = this.getProperty("udimagecount");
if ("1".equals(udimageCount)) {
image = e.getBytes("IMGLIB1.IMAGE");
} else if ("2".equals(udimageCount)) {
image = e.getBytes("IMGLIB2.IMAGE");
} else {
image = e.getBytes("IMGLIB1.IMAGE");
}
} else {
image = e.getBytes("IMGLIB.IMAGE");
}
} else {
udimageCount = e.getString("IMGLIB.IMGURI");
String endpointName = e.getString("IMGLIB.ENDPOINTNAME");
image = this.loadImageFromExternal(udimageCount, endpointName);
}
} catch (MXException var10) {
var10.printStackTrace();
} catch (RemoteException var11) {
var11.printStackTrace();
}
return image;
}
public String getCachedImageSrc() {
String myCachedImageSrc = this.cachedImageSrc;
this.cachedImageSrc = "";
return myCachedImageSrc;
}
public int click() throws RemoteException, MXException {
String dataSrc = this.getProperty("datasrc");
WebClientSession clientSession = this.getWebClientSession();
AppInstance app = clientSession.getCurrentApp();
DataBean imagedb = app.getDataBean(dataSrc);
MboRemote mbo = imagedb.getMbo();
if ("WORKORDER".equalsIgnoreCase(mbo.getName())) {
if (!"".equals(this.cachedImageSrc)) {
app.openURL(clientSession.getMaximoRequestContextURL() + this.cachedImageSrc + "?" + clientSession.getUISessionUrlParameter(), true);
}
return 1;
} else {
this.setProperty("mxevent", "viewimage");
return super.click();
}
}
private byte[] loadImageFromExternal(String imageURI, String endpointname) throws RemoteException, MXException {
RouterHandler handler = Router.getHandler(endpointname);
HashMap metaData = new HashMap();
metaData.put("URL", imageURI);
byte[] imageData = handler.invoke(metaData, (byte[])null);
return imageData;
}
}
......@@ -59,7 +59,6 @@ public class WFAssignment extends Mbo implements WFAssignmentRemote {
} catch (Exception var2) {
var2.printStackTrace();
}
}
}
......
......@@ -6,8 +6,13 @@
package psdi.workflow;
import java.rmi.RemoteException;
import javax.jws.WebMethod;
import psdi.common.condition.CustomCondition;
import psdi.common.parse.ParserServiceRemote;
import psdi.iface.mic.IntegrationContext;
import psdi.iface.webservices.action.WSMboKey;
import psdi.mbo.Mbo;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
......@@ -37,7 +42,9 @@ public class WorkFlowService extends AppService implements WorkFlowServiceRemote
this.getMXServer().addToMaximoCache(autoInitCachefactory.getName(), autoInitCachefactory);
WorkflowCacheFactory workflowCacheFactory = WorkflowCacheFactory.getInstance();
this.getMXServer().addToMaximoCache(workflowCacheFactory.getName(), workflowCacheFactory);
WFInstanceListener.init();
if (!MXServer.isBotcInstalled()) {
WFInstanceListener.init();
}
} catch (Throwable var3) {
MXException mxe = new MXApplicationException("system", "ServiceInitFailed", var3);
this.getServiceLogger().fatal(mxe);
......@@ -100,8 +107,8 @@ public class WorkFlowService extends AppService implements WorkFlowServiceRemote
return cc.evaluateCondition(mbo, onBehalfOf);
} catch (Exception var10) {
MXLogger log = this.getWFLogger(onBehalfOf);
String behalfOf;
Object instance;
String behalfOf;
if (onBehalfOf instanceof WFAssignment) {
instance = ((WFAssignment)onBehalfOf).getWFInstance();
behalfOf = "condition assignment with AssignID of " + onBehalfOf.getString("ASSIGNID");
......@@ -176,46 +183,9 @@ public class WorkFlowService extends AppService implements WorkFlowServiceRemote
return newWFLogger;
}
public void completeAssignmentapp(WFAssignmentRemote assign, String memo, boolean accepted, String actionid, String sfxzz) throws MXException, RemoteException {
WFInstanceRemote instance = null;
try {
if (!assign.isActive()) {
throw new MXApplicationException("workflow", "NotActiveNoComplete");
} else {
instance = assign.getWFInstance();
WFActionSetRemote actionSet = (WFActionSetRemote)assign.getMboSet("ACTIONS");
if ("Y".equalsIgnoreCase(sfxzz)) {
MboRemote actionTaken = actionSet.getAction(true);
instance.completeWorkflowAssignment(assign.getString("ASSIGNID"), actionTaken.getInt("ACTIONID"), memo);
instance.completeWorkflowAssignment(assign.getString("ASSIGNID"), Integer.parseInt(actionid), memo);
} else {
instance.completeWorkflowAssignment(assign.getString("ASSIGNID"), Integer.parseInt(actionid), memo);
}
if (!instance.atStoppingPoint()) {
throw new MXApplicationException("workflow", "BgFailure");
}
}
} catch (MXException var11) {
if (instance != null) {
instance.getThisMboSet().getMXTransaction().rollback();
}
MXLogger log = this.getWFLogger();
String processName = assign.getString("PROCESSNAME");
if (log.isErrorEnabled()) {
log.error("Completing an assignment on an instance of Workflow " + processName + " in background threw an exception.", var11);
}
Object[] param = new Object[]{processName};
throw new MXApplicationException("workflow", "BgCompFailure", param, var11);
}
}
public void completeAssignment(WFAssignmentRemote assign, String memo, boolean accepted) throws MXException, RemoteException {
@WebMethod
public void completeAssignment(@WSMboKey("WFASSIGNMENT") WFAssignmentRemote assign, String memo, boolean accepted) throws MXException, RemoteException {
WFInstanceRemote instance = null;
try {
if (!assign.isActive()) {
throw new MXApplicationException("workflow", "NotActiveNoComplete");
......@@ -224,7 +194,12 @@ public class WorkFlowService extends AppService implements WorkFlowServiceRemote
WFActionSetRemote actionSet = (WFActionSetRemote)assign.getMboSet("ACTIONS");
MboRemote actionTaken = actionSet.getAction(accepted);
instance.completeWorkflowAssignment(assign.getString("ASSIGNID"), actionTaken.getInt("ACTIONID"), memo);
if (!instance.atStoppingPoint()) {
if (instance.atStoppingPoint() || IntegrationContext.getCurrentContext() != null && IntegrationContext.getCurrentContext().getProperty("API") != null && IntegrationContext.getCurrentContext().getIntegerProperty("API") == 1) {
if (IntegrationContext.getCurrentContext() != null && IntegrationContext.getCurrentContext().getProperty("API") != null && IntegrationContext.getCurrentContext().getIntegerProperty("API") == 1) {
IntegrationContext.getCurrentContext().setProperty("wfinstance", instance);
}
} else {
throw new MXApplicationException("workflow", "BgFailure");
}
}
......@@ -296,4 +271,49 @@ public class WorkFlowService extends AppService implements WorkFlowServiceRemote
apps.setWhere(sqf.format());
return apps.isEmpty() ? null : apps.getMbo(0).getString("APP");
}
@Override
public void completeAssignmentapp(WFAssignmentRemote assign, String memo, boolean accepted, String actionid, String sfxzz) throws MXException,
RemoteException {
WFInstanceRemote instance = null;
try
{
if (!assign.isActive())
{
throw new MXApplicationException("workflow", "NotActiveNoComplete");
}
instance = assign.getWFInstance();
WFActionSetRemote actionSet = (WFActionSetRemote)assign.getMboSet("ACTIONS");
if ("Y".equalsIgnoreCase(sfxzz)) {
MboRemote actionTaken = actionSet.getAction(true);
instance.completeWorkflowAssignment(assign.getString("ASSIGNID"), actionTaken.getInt("ACTIONID"), memo);
instance.completeWorkflowAssignment(assign.getString("ASSIGNID"), Integer.parseInt(actionid), memo);
} else {
instance.completeWorkflowAssignment(assign.getString("ASSIGNID"), Integer.parseInt(actionid), memo);
}
if (!instance.atStoppingPoint())
{
throw new MXApplicationException("workflow", "BgFailure");
}
}
catch (MXException e)
{
if (instance != null)
{
instance.getThisMboSet().getMXTransaction().rollback();
}
MXLogger log = getWFLogger();
String processName = assign.getString("PROCESSNAME");
if (log.isErrorEnabled())
{
log.error("Completing an assignment on an instance of Workflow " + processName + " in background threw an exception.", e);
}
Object[] param = { processName };
throw new MXApplicationException("workflow", "BgCompFailure", param, e);
}
}
}
package tohi.app;
import java.lang.reflect.Constructor;
import java.math.BigInteger;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.Provider;
import java.security.PublicKey;
import java.security.Security;
import java.security.spec.RSAPrivateKeySpec;
import java.security.spec.RSAPublicKeySpec;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.DESedeKeySpec;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import tohi.safety.webservice.EncodeUtil;
public class MXCipherX
{
String algorithm;
String mode;
String padding;
String key;
String spec;
String modulus;
private Cipher cipherEncrypt;
String transformation;
SecretKey secretKey;
IvParameterSpec ivSpec;
PBEParameterSpec pbeParamSpec;
SecretKeySpec secretkeySpec;
PublicKey publicKey;
PrivateKey privateKey;
boolean nonSunProviders;
Provider providerClass;
int padLen;
protected MXCipherX()
{
this.algorithm = PropertiesUtil.CRYPTOX_ALGORITHM;
this.mode = PropertiesUtil.CRYPTOX_MODE;
this.padding = PropertiesUtil.CRYPTOX_PADDING;
this.key = PropertiesUtil.CRYPTOX_KEY;
this.spec = PropertiesUtil.CRYPTOX_SPEC;
this.modulus = PropertiesUtil.CRYPTOX_MODULUS;
this.cipherEncrypt = null;
this.transformation = null;
this.secretKey = null;
this.ivSpec = null;
this.pbeParamSpec = null;
this.secretkeySpec = null;
this.publicKey = null;
this.privateKey = null;
this.nonSunProviders = false;
this.providerClass = null;
this.padLen = 8;
}
public MXCipherX(boolean isEncrypt, PropertiesUtil pu) {
this.algorithm = PropertiesUtil.CRYPTOX_ALGORITHM;
this.mode = PropertiesUtil.CRYPTOX_MODE;
this.padding = PropertiesUtil.CRYPTOX_PADDING;
this.key = PropertiesUtil.CRYPTOX_KEY;
this.spec = PropertiesUtil.CRYPTOX_SPEC;
this.modulus = PropertiesUtil.CRYPTOX_MODULUS;
this.cipherEncrypt = null;
this.transformation = null;
this.secretKey = null;
this.ivSpec = null;
this.pbeParamSpec = null;
this.secretkeySpec = null;
this.publicKey = null;
this.privateKey = null;
this.nonSunProviders = false;
this.providerClass = null;
this.padLen = 8;
String algTest = pu.getAlgorithm();
String modeTest = pu.getMode();
String paddingTest = pu.getPadding();
String keyTest = pu.getKey();
String specTest = pu.getSpec();
String modTest = pu.getModulus();
String providerTest = pu.getProvider();
init(isEncrypt, algTest, modeTest, paddingTest, keyTest, specTest,
modTest, providerTest);
}
public MXCipherX(boolean isEncrypt, String algTest, String modeTest, String paddingTest, String keyTest, String specTest)
{
this.algorithm = PropertiesUtil.CRYPTOX_ALGORITHM;
this.mode = PropertiesUtil.CRYPTOX_MODE;
this.padding = PropertiesUtil.CRYPTOX_PADDING;
this.key = PropertiesUtil.CRYPTOX_KEY;
this.spec = PropertiesUtil.CRYPTOX_SPEC;
this.modulus = PropertiesUtil.CRYPTOX_MODULUS;
this.cipherEncrypt = null;
this.transformation = null;
this.secretKey = null;
this.ivSpec = null;
this.pbeParamSpec = null;
this.secretkeySpec = null;
this.publicKey = null;
this.privateKey = null;
this.nonSunProviders = false;
this.providerClass = null;
this.padLen = 8;
init(isEncrypt, algTest, modeTest, paddingTest, keyTest, specTest,
null, null);
}
public MXCipherX(boolean isEncrypt, String algTest, String modeTest, String paddingTest, String keyTest, String specTest, String modTest, String providerTest)
{
this.algorithm = PropertiesUtil.CRYPTOX_ALGORITHM;
this.mode = PropertiesUtil.CRYPTOX_MODE;
this.padding = PropertiesUtil.CRYPTOX_PADDING;
this.key = PropertiesUtil.CRYPTOX_KEY;
this.spec = PropertiesUtil.CRYPTOX_SPEC;
this.modulus = PropertiesUtil.CRYPTOX_MODULUS;
this.cipherEncrypt = null;
this.transformation = null;
this.secretKey = null;
this.ivSpec = null;
this.pbeParamSpec = null;
this.secretkeySpec = null;
this.publicKey = null;
this.privateKey = null;
this.nonSunProviders = false;
this.providerClass = null;
this.padLen = 8;
init(isEncrypt, algTest, modeTest, paddingTest, keyTest, specTest,
modTest, providerTest);
}
protected void init(boolean isEncrypt, String algTest, String modeTest, String paddingTest, String keyTest, String specTest, String modTest, String providerTest)
{
try
{
if ((providerTest != null) && (!providerTest.equals(""))) {
Class c = Class.forName(providerTest);
Class[] paramTypes = new Class[0];
Constructor ctor = c.getConstructor(paramTypes);
Object[] params = new Object[0];
this.providerClass = ((Provider)ctor.newInstance(params));
Security.addProvider(this.providerClass);
}
} catch (Exception e) {
e.printStackTrace();
return;
}
Provider[] provs = Security.getProviders();
for (int xx = 0; xx < provs.length; xx++) {
if (!provs[xx].getName().toUpperCase().startsWith("SUN"));
this.nonSunProviders = true;
}
validateParams(algTest, modeTest, paddingTest, keyTest, specTest,
modTest);
this.transformation = this.algorithm;
if ((this.mode != null) && (!this.mode.equals("")) && (this.padding != null) &&
(!this.padding.equals("")))
this.transformation = (this.transformation + "/" + this.mode + "/" + this.padding);
try {
this.cipherEncrypt = buildCipher(isEncrypt);
} catch (Exception e) {
e.printStackTrace();
}
}
Cipher buildCipher(boolean encrypt) throws Exception {
Cipher cipher = null;
int cryptMode = 1;
if (!encrypt)
cryptMode = 2;
if ((this.algorithm.equals("DESede")) || (this.algorithm.equals("TripleDES"))) {
if ((this.secretKey == null) || (this.ivSpec == null)) {
DESedeKeySpec keyspec = new DESedeKeySpec(this.key.getBytes());
SecretKeyFactory factory =
SecretKeyFactory.getInstance(this.algorithm);
this.secretKey = factory.generateSecret(keyspec);
this.ivSpec = new IvParameterSpec(this.spec.getBytes());
}
if (this.providerClass == null)
cipher = Cipher.getInstance(this.transformation);
else
cipher = Cipher.getInstance(this.transformation, this.providerClass);
if (this.transformation.indexOf("ECB") < 0)
cipher.init(cryptMode, this.secretKey, this.ivSpec);
else
cipher.init(cryptMode, this.secretKey);
} else if (this.algorithm.equals("DES")) {
if ((this.secretKey == null) || (this.ivSpec == null)) {
DESKeySpec keyspec = new DESKeySpec(this.key.getBytes());
SecretKeyFactory factory =
SecretKeyFactory.getInstance(this.algorithm);
this.secretKey = factory.generateSecret(keyspec);
this.ivSpec = new IvParameterSpec(this.spec.getBytes());
}
if (this.providerClass == null)
cipher = Cipher.getInstance(this.transformation);
else
cipher = Cipher.getInstance(this.transformation, this.providerClass);
if (this.transformation.indexOf("ECB") < 0)
cipher.init(cryptMode, this.secretKey, this.ivSpec);
else
cipher.init(cryptMode, this.secretKey);
} else if (this.algorithm.startsWith("PBEWith")) {
if ((this.secretKey == null) || (this.pbeParamSpec == null)) {
this.pbeParamSpec = new PBEParameterSpec(this.spec.getBytes(), 20);
PBEKeySpec pbeKeySpec = new PBEKeySpec(this.spec.toCharArray());
SecretKeyFactory keyFac =
SecretKeyFactory.getInstance(this.algorithm);
this.secretKey = keyFac.generateSecret(pbeKeySpec);
}
if (this.providerClass == null)
cipher = Cipher.getInstance(this.transformation);
else
cipher = Cipher.getInstance(this.transformation, this.providerClass);
cipher.init(cryptMode, this.secretKey, this.pbeParamSpec);
} else if (this.algorithm.equals("RSA")) {
if ((this.publicKey == null) || (this.privateKey == null)) {
KeyFactory fac = KeyFactory.getInstance("RSA", this.providerClass);
this.publicKey = fac.generatePublic(new RSAPublicKeySpec(
new BigInteger(this.modulus), new BigInteger(this.key)));
this.privateKey = fac.generatePrivate(new RSAPrivateKeySpec(
new BigInteger(this.modulus), new BigInteger(this.spec)));
}
if (this.providerClass == null)
cipher = Cipher.getInstance(this.transformation);
else
cipher = Cipher.getInstance(this.transformation, this.providerClass);
if (encrypt)
cipher.init(cryptMode, this.publicKey);
else
cipher.init(cryptMode, this.privateKey);
} else {
if (this.secretkeySpec == null) {
int padLen = this.algorithm.equals("SKIPJACK") ? 10 : 16;
byte[] byteArray = this.spec.getBytes();
byteArray = pad(byteArray, padLen);
this.secretkeySpec = new SecretKeySpec(byteArray, this.algorithm);
}
if (this.providerClass == null)
cipher = Cipher.getInstance(this.transformation);
else
cipher = Cipher.getInstance(this.transformation, this.providerClass);
cipher.init(cryptMode, this.secretkeySpec);
}
return cipher;
}
private boolean validateParams(String algTest, String modeTest, String paddingTest, String keyTest, String specTest, String modTest)
{
if ((algTest != null) && (!algTest.equals("")))
this.algorithm = algTest;
if ((modeTest != null) && (!modeTest.equals("")))
this.mode = modeTest;
if ((paddingTest != null) && (!paddingTest.equals("")))
this.padding = paddingTest;
if ((keyTest != null) && (!keyTest.equals("")))
this.key = keyTest;
if ((specTest != null) && (!specTest.equals("")))
this.spec = specTest;
if ((modTest != null) && (!modTest.equals("")))
this.modulus = modTest;
if (this.algorithm == null)
return false;
if ((this.algorithm.equals("AES")) || (this.algorithm.equals("Serpent")) ||
(this.algorithm.equals("MARS")) || (this.algorithm.equals("RC6")) ||
(this.algorithm.equals("Rijndael")) || (this.algorithm.equals("Square")) ||
(this.algorithm.equals("Twofish")))
this.padLen = 16;
else if (this.algorithm.equals("RSA"))
this.padLen = 0;
if ((!this.algorithm.equals("DES")) && (!this.algorithm.equals("DESede")) &&
(!this.algorithm.equals("AES"))) {
if ((modeTest == null) || (modeTest.equals("")))
this.mode = "";
if ((paddingTest == null) || (paddingTest.equals("")))
this.padding = "";
}
if (this.nonSunProviders)
return true;
if ((!this.algorithm.equals("DESede")) && (!this.algorithm.equals("DES")) &&
(!this.algorithm.equals("AES")) &&
(!this.algorithm.equals("PBEWithMD5AndDES")))
return false;
if ((this.algorithm.equals("AES")) && ((this.mode == null) || (!this.mode.equals("ECB"))))
return false;
if (this.algorithm.equals("PBEWithMD5AndDES")) {
if ((this.mode == null) || (!this.mode.equals("CBC")))
return false;
if ((this.padding == null) || (!this.padding.equals("PKCS5Padding")))
return false;
if (this.key.getBytes().length != 8)
return false;
}
if ((this.mode != null) && (!this.mode.equals("")) && (!this.mode.equals("CBC")) &&
(!this.mode.equals("CFB")) && (!this.mode.equals("ECB")) &&
(!this.mode.equals("OFB")) && (!this.mode.equals("PCBC")))
return false;
if ((this.padding != null) && (!this.padding.equals("")) &&
(!this.padding.equals("NoPadding")) &&
(!this.padding.equals("PKCS5Padding")))
return false;
if ((this.key != null) && (!this.key.equals("")) && (!this.algorithm.equals("RSA")) &&
(this.key.length() % 24 != 0))
return false;
if ((this.spec != null) && (!this.spec.equals("")) && (!this.algorithm.equals("RSA")) &&
(this.spec.length() % 8 != 0))
return false;
return (this.mode == null) || (!this.mode.equals("OFB")) || (this.padding == null) ||
(this.padding.equals("NoPadding")) || (
(this.algorithm != null) &&
(this.algorithm.equals("DES")));
}
public synchronized String encData(String in) {
byte[] temp = in.getBytes();
temp = pad(temp);
byte[] encryptVal = (byte[])null;
try {
encryptVal = this.cipherEncrypt.doFinal(temp);
} catch (Exception e) {
e.printStackTrace();
return null;
}
return EncodeUtil.Bytes2HexString(encryptVal);
}
public synchronized String decData(String in)
{
byte[] temp = EncodeUtil.HexString2Bytes(in);
temp = pad(temp);
byte[] decryptVal = (byte[])null;
try
{
decryptVal = this.cipherEncrypt.doFinal(temp);
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
}
String value = new String(decryptVal);
return value.trim();
}
protected byte[] pad(byte[] in) {
return pad(in, this.padLen);
}
protected byte[] pad(byte[] in, int padLen) {
if (padLen == 0)
return in;
int inlen = in.length;
int outlen = inlen;
int rem = inlen % padLen;
if (rem > 0)
outlen = inlen + (padLen - rem);
byte[] out = new byte[outlen];
for (int xx = 0; xx < inlen; xx++) {
out[xx] = in[xx];
}
return out;
}
}
\ No newline at end of file
package tohi.app;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.util.PropertyPlaceholderHelper;
public class PropertiesConfigurerUtil extends PropertyPlaceholderConfigurer
{
private static Map<String, String> properties = new HashMap();
protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)
throws BeansException
{
PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${",
"}", ":", false);
for (Map.Entry entry : props.entrySet()) {
String stringKey = String.valueOf(entry.getKey()).trim();
String stringValue = String.valueOf(entry.getValue()).trim();
stringValue = helper.replacePlaceholders(stringValue, props);
properties.put(stringKey, stringValue);
}
super.processProperties(beanFactoryToProcess, props);
}
public static Map<String, String> getProperties()
{
return properties;
}
public static String getProperty(String proName)
{
return (String)properties.get(proName);
}
}
\ No newline at end of file
package tohi.app;
public class PropertiesUtil
{
public static String CRYPTOX_MODE = "CBC";
public static String CRYPTOX_PADDING = "PKCS5Padding";
public static String CRYPTOX_KEY = "Sa#qk5usfmMI-@2dbZP9`jL3";
public static String CRYPTOX_SPEC = "beLd7$lB";
public static String CRYPTOX_ALGORITHM = "DESede";
public static String CRYPTOX_MODULUS = "";
public static String CRYPTOX_PROVIDER = null;
private String algorithm;
private String mode;
private String padding;
private String key;
private String spec;
private String modulus;
private String provider;
public PropertiesUtil()
{
try
{
this.algorithm = PropertiesConfigurerUtil.getProperty("mxe.security.cryptox.algorithm");
this.mode = PropertiesConfigurerUtil.getProperty("mxe.security.cryptox.mode");
this.padding = PropertiesConfigurerUtil.getProperty("mxe.security.cryptox.padding");
this.key = PropertiesConfigurerUtil.getProperty("mxe.security.cryptox.key");
this.spec = PropertiesConfigurerUtil.getProperty("mxe.security.cryptox.spec");
this.modulus = "";
this.provider = null;
} catch (Exception e) {
e.printStackTrace();
}
}
public void setAlgorithm(String algorithm) {
this.algorithm = algorithm;
}
public void setMode(String mode) {
this.mode = mode;
}
public void setPadding(String padding) {
this.padding = padding;
}
public void setKey(String key) {
this.key = key;
}
public void setSpec(String spec) {
this.spec = spec;
}
public void setModulus(String modulus) {
this.modulus = modulus;
}
public void setProvider(String provider) {
this.provider = provider;
}
public String getAlgorithm() {
return this.algorithm;
}
public String getMode() {
return this.mode;
}
public String getPadding() {
return this.padding;
}
public String getKey() {
return this.key;
}
public String getSpec() {
return this.spec;
}
public String getModulus() {
return this.modulus;
}
public String getProvider() {
return this.provider;
}
}
\ No newline at end of file
package tohi.app.cron;
import psdi.util.MXCipher;
import psdi.util.MXCipherX;
import psdi.util.MXSession;
public class A {
private static final String SERVER = "172.20.0.93/MXServer";
private static final String SUPER_USERNAME = "maxdmin";
private static final String SUPER_PASSWORD = "clpjbdev";
public static void main(String[] args) throws Exception {
A test = new A();
String password = "admin";
String encryptedPassword = test.encrypt(password);
String decryptedPassword = test.decrypt(encryptedPassword);
System.out.println("password: " + password);
System.out.println("encryptedPassword: " + encryptedPassword);
System.out.println("decryptedPassword: " + decryptedPassword);
}
private String encrypt(String password) throws Exception {
String encryptedPassword = "0x";
byte[] bytes = getMXCipherX().encData(password);
for (int i = 0; i < bytes.length; i++) {
int b = bytes[i];
String hex = Integer.toHexString(b).toUpperCase();
hex = hex.replaceAll("FFFFFF", "");
hex = (hex.length() < 2) ? "0" + hex : hex;
encryptedPassword += hex;
}
return encryptedPassword;
}
private String decrypt(String encryptedPassword) throws Exception {
encryptedPassword = encryptedPassword.substring(2, encryptedPassword.length());
int length = encryptedPassword.getBytes().length / 2;
byte[] bytes = new byte[length];
for (int i = 0; i < length; i++) {
bytes[i] = (byte)Integer.decode("0x" + encryptedPassword.substring(i * 2, i * 2 +2)).intValue();
}
String password = getMXCipher().decData(bytes);
return password;
}
private MXCipherX getMXCipherX() throws Exception {
MXSession mxSession = MXSession.getSession();
mxSession.setHost(SERVER);
mxSession.setUserName(SUPER_USERNAME);
mxSession.setPassword(SUPER_PASSWORD);
mxSession.connect();
MXCipherX mxCipherX = new MXCipherX(mxSession.getMXServerRemote());
mxSession.disconnect();
return mxCipherX;
}
private MXCipher getMXCipher() throws Exception {
MXSession mxSession = MXSession.getSession();
mxSession.setHost(SERVER);
mxSession.setUserName(SUPER_USERNAME);
mxSession.setPassword(SUPER_PASSWORD);
mxSession.connect();
MXCipher mxCipher = new MXCipher(mxSession.getMXServerRemote());
mxSession.disconnect();
return mxCipher;
}
}
\ No newline at end of file
......@@ -9,7 +9,6 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
......@@ -32,7 +31,6 @@ public class RunCronTask extends SimpleCronTask{
URL url = new URL(path);
//打开和url之间的连接
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
PrintWriter out = null;
//请求方式
conn.setRequestMethod("GET");
conn.setReadTimeout(500000);
......@@ -111,7 +109,6 @@ public class RunCronTask extends SimpleCronTask{
System.out.println(url);
interfaceUtil(url, "");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
......@@ -126,7 +123,6 @@ public class RunCronTask extends SimpleCronTask{
System.out.println(url);
interfaceUtil(url, "");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
......@@ -138,7 +134,5 @@ public class RunCronTask extends SimpleCronTask{
public String toString() {
return "Resultitfa [Id=" + Id + ", time=" + time + ", value=" + value + "]";
}
}
}
package tohi.app.pjo;
import java.rmi.RemoteException;
import psdi.mbo.Mbo;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSet;
import psdi.util.MXException;
public class FirepreventionMbo extends Mbo implements MboRemote{
public FirepreventionMbo(MboSet ms) throws RemoteException {
super(ms);
}
@Override
public void init() throws MXException {
super.init();
try {
if (getUserName().equalsIgnoreCase("maxadmin")) { //如果是管理员
return;
}
if (getString("STATUS").equalsIgnoreCase("CLOSE")) {//如果是关闭
this.setFlag(7L,true);
}
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
package tohi.app.pjo;
import java.rmi.RemoteException;
import psdi.mbo.Mbo;
import psdi.mbo.MboServerInterface;
import psdi.mbo.MboSet;
import psdi.mbo.MboSetRemote;
import psdi.util.MXException;
public class FirepreventionMboSet extends MboSet implements MboSetRemote{
public FirepreventionMboSet(MboServerInterface ms) throws RemoteException {
super(ms);
}
@Override
protected Mbo getMboInstance(MboSet arg0) throws MXException,
RemoteException {
return new FirepreventionMbo(arg0);
}
}
package tohi.app.pjo;
import java.rmi.RemoteException;
import psdi.mbo.Mbo;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSet;
import psdi.util.MXException;
public class FloodpreventionMbo extends Mbo implements MboRemote{
public FloodpreventionMbo(MboSet ms) throws RemoteException {
super(ms);
}
@Override
public void init() throws MXException {
super.init();
try {
if (getUserName().equalsIgnoreCase("maxadmin")) { //如果是管理员
return;
}
if (getString("STATUS").equalsIgnoreCase("CLOSE")) {//如果是关闭
this.setFlag(7L,true);
}
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
package tohi.app.pjo;
import java.rmi.RemoteException;
import psdi.mbo.Mbo;
import psdi.mbo.MboServerInterface;
import psdi.mbo.MboSet;
import psdi.mbo.MboSetRemote;
import psdi.util.MXException;
public class FloodpreventionMboSet extends MboSet implements MboSetRemote{
public FloodpreventionMboSet(MboServerInterface ms) throws RemoteException {
super(ms);
}
@Override
protected Mbo getMboInstance(MboSet arg0) throws MXException,
RemoteException {
return new FloodpreventionMbo(arg0);
}
}
package tohi.app.pjo;
import java.rmi.RemoteException;
import psdi.mbo.Mbo;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSet;
public class SafetyadviceMbo extends Mbo implements MboRemote{
public SafetyadviceMbo(MboSet ms) throws RemoteException {
super(ms);
}
}
package tohi.app.pjo;
import java.rmi.RemoteException;
import psdi.mbo.Mbo;
import psdi.mbo.MboServerInterface;
import psdi.mbo.MboSet;
import psdi.mbo.MboSetRemote;
import psdi.util.MXException;
public class SafetyadviceMboSet extends MboSet implements MboSetRemote{
public SafetyadviceMboSet(MboServerInterface ms) throws RemoteException {
super(ms);
// TODO Auto-generated constructor stub
}
@Override
protected Mbo getMboInstance(MboSet arg0) throws MXException,
RemoteException {
// TODO Auto-generated method stub
return null;
}
}
package tohi.app.prline;
import java.rmi.RemoteException;
import psdi.mbo.MAXTableDomain;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
import psdi.mbo.MboValue;
import psdi.util.MXException;
/**
* ҼϢ
*
*/
public class CustFldGradeLevel extends MAXTableDomain {
public CustFldGradeLevel(MboValue mbv) {
super(mbv);
String thisname = getMboValue().getAttributeName();
String[] hz = { "level" };
String[] target ={thisname};
setLookupKeyMapInOrder(target, hz);
setRelationship("GRADE", "level=:" + thisname);
}
@Override
public MboSetRemote getList() throws MXException, RemoteException {
String thisname = getMboValue().getAttributeName();
MboRemote mbo= getMboValue().getMbo();
if (thisname.equalsIgnoreCase("GRADE")) {
mbo.setValueNull("GRADE",11L);
setListCriteria("parentlevel is null");
}
if (thisname.equalsIgnoreCase("ABCTYPE")) {
String GRADE=mbo.getString("GRADE");
System.out.println("parentlevel is not null and parentlevel = '"+GRADE+"' ");
setListCriteria("parentlevel is not null and parentlevel = '"+GRADE+"' ");
}
return super.getList();
}
}
......@@ -13,10 +13,15 @@ public class CustLoadopeningMbo extends Mbo implements MboRemote{
public CustLoadopeningMbo(MboSet ms) throws RemoteException {
super(ms);
}
@Override
protected void save() throws MXException, RemoteException {
super.save();
System.out.println("========");
MboSetRemote MboSet=this.getThisMboSet();
this.getOwner().setValue("LOAD1TOTAL", MboSet.sum("LOAD1"),2L);
this.getOwner().setValue("LOAD1MAX", MboSet.max("LOAD1"),2L);
......
......@@ -6,14 +6,23 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import javax.servlet.http.HttpSession;
import clp.security.UDSecurityService;
import psdi.mbo.Mbo;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSet;
import psdi.mbo.MboSetRemote;
import psdi.security.SecurityService;
import psdi.server.MXServer;
import psdi.util.MXApplicationException;
import psdi.util.MXCipher;
import psdi.util.MXException;
import psdi.util.MXSession;
import psdi.util.MaxType;
public class CustLogMbo extends Mbo implements MboRemote{
......@@ -23,6 +32,17 @@ public class CustLogMbo extends Mbo implements MboRemote{
@Override
public void init() throws MXException {
super.init();
MaxType storedMT = MaxType.createMaxType((Locale)null, (TimeZone)null, 16);
storedMT.setValue("05D3E4AE66BD4C6D0A934D9896EB2187");
System.out.println("---------------------------"+storedMT);
try {
SecurityService ud=new SecurityService(MXServer.getMXServer());
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void add() throws MXException, RemoteException {
......
......@@ -29,9 +29,6 @@ public class FldplateNum extends MAXTableDomain{
String PROTEPLATENUM=mbo.getString("PROTEPLATENUM");
System.out.println("PROTEP"+PROTEPLATENUM);
setListCriteria("PROTEPLATENUM = '"+PROTEPLATENUM+"'");
return super.getList();
}
......
package tohi.app.rlrelaymanage;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Locale;
import java.util.TimeZone;
import psdi.mbo.MAXTableDomain;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
import psdi.mbo.MboValue;
import psdi.server.MXServer;
import psdi.util.MXException;
import psdi.util.MaxType;
/**
* 获取相关联的一级菜单信息
......@@ -36,6 +46,45 @@ public class FldproteplateNum extends MAXTableDomain{
// if (mbo.getName().equalsIgnoreCase("PLATECLOSE")) { // 如果是闭环,需要找已投退的装置
// setListCriteria(" PROTEPLATENUM in (select PROTEPLATENUM from RLRELAYMANAGE where NEEDCLOSE = 1 and PROTEPLATENUM is not null )");
// }
// Connection connection = null;
// Statement statement = null;
// ResultSet resultSet = null;
/*
* 加载驱动有两种方式
*
* 1:会导致驱动会注册两次,过度依赖于mysql的api,脱离的mysql的开发包,程序则无法编译
* 2:驱动只会加载一次,不需要依赖具体的驱动,灵活性高
*
* 我们一般都是使用第二种方式
* */
//获取与数据库连接的对象-Connetcion
// try {
//
// Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
// connection = DriverManager.getConnection("jdbc:sqlserver://;serverName=172.20.0.95;databaseName=maxdb;portNumber=1433;integratedSecurity=false;sendStringParametersAsUnicode=false;selectMethod=cursor;", "maximo", "maximo");
// //获取执行sql语句的statement对象
// statement = connection.createStatement();
// //执行sql语句,拿到结果集
// resultSet = statement.executeQuery("SELECT * FROM maxuser");
// //遍历结果集,得到数据
// PropertiesUtil pu = new PropertiesUtil();
// MXCipherX mx = new MXCipherX(true, pu);
// if (resultSet.next()) {
// System.out.println("-----"+resultSet.getString("password"));
// String spwd = mx.decData(resultSet.getString("password"));
//// mx.encData();
// System.out.println("spwd:"+spwd);
// }
// } catch (SQLException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
return super.getList();
}
......
package tohi.app.rlrelaymanage;
import java.lang.reflect.Constructor;
import java.math.BigInteger;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.Provider;
import java.security.PublicKey;
import java.security.Security;
import java.security.spec.RSAPrivateKeySpec;
import java.security.spec.RSAPublicKeySpec;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.DESedeKeySpec;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import tohi.safety.webservice.EncodeUtil;
public class MXCipherX
{
String algorithm;
String mode;
String padding;
String key;
String spec;
String modulus;
private Cipher cipherEncrypt;
String transformation;
SecretKey secretKey;
IvParameterSpec ivSpec;
PBEParameterSpec pbeParamSpec;
SecretKeySpec secretkeySpec;
PublicKey publicKey;
PrivateKey privateKey;
boolean nonSunProviders;
Provider providerClass;
int padLen;
protected MXCipherX()
{
this.algorithm = PropertiesUtil.CRYPTOX_ALGORITHM;
this.mode = PropertiesUtil.CRYPTOX_MODE;
this.padding = PropertiesUtil.CRYPTOX_PADDING;
this.key = PropertiesUtil.CRYPTOX_KEY;
this.spec = PropertiesUtil.CRYPTOX_SPEC;
this.modulus = PropertiesUtil.CRYPTOX_MODULUS;
this.cipherEncrypt = null;
this.transformation = null;
this.secretKey = null;
this.ivSpec = null;
this.pbeParamSpec = null;
this.secretkeySpec = null;
this.publicKey = null;
this.privateKey = null;
this.nonSunProviders = false;
this.providerClass = null;
this.padLen = 8;
}
public MXCipherX(boolean isEncrypt, PropertiesUtil pu) {
this.algorithm = PropertiesUtil.CRYPTOX_ALGORITHM;
this.mode = PropertiesUtil.CRYPTOX_MODE;
this.padding = PropertiesUtil.CRYPTOX_PADDING;
this.key = PropertiesUtil.CRYPTOX_KEY;
this.spec = PropertiesUtil.CRYPTOX_SPEC;
this.modulus = PropertiesUtil.CRYPTOX_MODULUS;
this.cipherEncrypt = null;
this.transformation = null;
this.secretKey = null;
this.ivSpec = null;
this.pbeParamSpec = null;
this.secretkeySpec = null;
this.publicKey = null;
this.privateKey = null;
this.nonSunProviders = false;
this.providerClass = null;
this.padLen = 8;
String algTest = pu.getAlgorithm();
String modeTest = pu.getMode();
String paddingTest = pu.getPadding();
String keyTest = pu.getKey();
String specTest = pu.getSpec();
String modTest = pu.getModulus();
String providerTest = pu.getProvider();
init(isEncrypt, algTest, modeTest, paddingTest, keyTest, specTest,
modTest, providerTest);
}
public MXCipherX(boolean isEncrypt, String algTest, String modeTest, String paddingTest, String keyTest, String specTest)
{
this.algorithm = PropertiesUtil.CRYPTOX_ALGORITHM;
this.mode = PropertiesUtil.CRYPTOX_MODE;
this.padding = PropertiesUtil.CRYPTOX_PADDING;
this.key = PropertiesUtil.CRYPTOX_KEY;
this.spec = PropertiesUtil.CRYPTOX_SPEC;
this.modulus = PropertiesUtil.CRYPTOX_MODULUS;
this.cipherEncrypt = null;
this.transformation = null;
this.secretKey = null;
this.ivSpec = null;
this.pbeParamSpec = null;
this.secretkeySpec = null;
this.publicKey = null;
this.privateKey = null;
this.nonSunProviders = false;
this.providerClass = null;
this.padLen = 8;
init(isEncrypt, algTest, modeTest, paddingTest, keyTest, specTest,
null, null);
}
public MXCipherX(boolean isEncrypt, String algTest, String modeTest, String paddingTest, String keyTest, String specTest, String modTest, String providerTest)
{
this.algorithm = PropertiesUtil.CRYPTOX_ALGORITHM;
this.mode = PropertiesUtil.CRYPTOX_MODE;
this.padding = PropertiesUtil.CRYPTOX_PADDING;
this.key = PropertiesUtil.CRYPTOX_KEY;
this.spec = PropertiesUtil.CRYPTOX_SPEC;
this.modulus = PropertiesUtil.CRYPTOX_MODULUS;
this.cipherEncrypt = null;
this.transformation = null;
this.secretKey = null;
this.ivSpec = null;
this.pbeParamSpec = null;
this.secretkeySpec = null;
this.publicKey = null;
this.privateKey = null;
this.nonSunProviders = false;
this.providerClass = null;
this.padLen = 8;
init(isEncrypt, algTest, modeTest, paddingTest, keyTest, specTest,
modTest, providerTest);
}
protected void init(boolean isEncrypt, String algTest, String modeTest, String paddingTest, String keyTest, String specTest, String modTest, String providerTest)
{
try
{
if ((providerTest != null) && (!providerTest.equals(""))) {
Class c = Class.forName(providerTest);
Class[] paramTypes = new Class[0];
Constructor ctor = c.getConstructor(paramTypes);
Object[] params = new Object[0];
this.providerClass = ((Provider)ctor.newInstance(params));
Security.addProvider(this.providerClass);
}
} catch (Exception e) {
e.printStackTrace();
return;
}
Provider[] provs = Security.getProviders();
for (int xx = 0; xx < provs.length; xx++) {
if (!provs[xx].getName().toUpperCase().startsWith("SUN"));
this.nonSunProviders = true;
}
validateParams(algTest, modeTest, paddingTest, keyTest, specTest,
modTest);
this.transformation = this.algorithm;
if ((this.mode != null) && (!this.mode.equals("")) && (this.padding != null) &&
(!this.padding.equals("")))
this.transformation = (this.transformation + "/" + this.mode + "/" + this.padding);
try {
this.cipherEncrypt = buildCipher(isEncrypt);
} catch (Exception e) {
e.printStackTrace();
}
}
Cipher buildCipher(boolean encrypt) throws Exception {
Cipher cipher = null;
int cryptMode = 1;
if (!encrypt)
cryptMode = 2;
if ((this.algorithm.equals("DESede")) || (this.algorithm.equals("TripleDES"))) {
if ((this.secretKey == null) || (this.ivSpec == null)) {
DESedeKeySpec keyspec = new DESedeKeySpec(this.key.getBytes());
SecretKeyFactory factory =
SecretKeyFactory.getInstance(this.algorithm);
this.secretKey = factory.generateSecret(keyspec);
this.ivSpec = new IvParameterSpec(this.spec.getBytes());
}
if (this.providerClass == null)
cipher = Cipher.getInstance(this.transformation);
else
cipher = Cipher.getInstance(this.transformation, this.providerClass);
if (this.transformation.indexOf("ECB") < 0)
cipher.init(cryptMode, this.secretKey, this.ivSpec);
else
cipher.init(cryptMode, this.secretKey);
} else if (this.algorithm.equals("DES")) {
if ((this.secretKey == null) || (this.ivSpec == null)) {
DESKeySpec keyspec = new DESKeySpec(this.key.getBytes());
SecretKeyFactory factory =
SecretKeyFactory.getInstance(this.algorithm);
this.secretKey = factory.generateSecret(keyspec);
this.ivSpec = new IvParameterSpec(this.spec.getBytes());
}
if (this.providerClass == null)
cipher = Cipher.getInstance(this.transformation);
else
cipher = Cipher.getInstance(this.transformation, this.providerClass);
if (this.transformation.indexOf("ECB") < 0)
cipher.init(cryptMode, this.secretKey, this.ivSpec);
else
cipher.init(cryptMode, this.secretKey);
} else if (this.algorithm.startsWith("PBEWith")) {
if ((this.secretKey == null) || (this.pbeParamSpec == null)) {
this.pbeParamSpec = new PBEParameterSpec(this.spec.getBytes(), 20);
PBEKeySpec pbeKeySpec = new PBEKeySpec(this.spec.toCharArray());
SecretKeyFactory keyFac =
SecretKeyFactory.getInstance(this.algorithm);
this.secretKey = keyFac.generateSecret(pbeKeySpec);
}
if (this.providerClass == null)
cipher = Cipher.getInstance(this.transformation);
else
cipher = Cipher.getInstance(this.transformation, this.providerClass);
cipher.init(cryptMode, this.secretKey, this.pbeParamSpec);
} else if (this.algorithm.equals("RSA")) {
if ((this.publicKey == null) || (this.privateKey == null)) {
KeyFactory fac = KeyFactory.getInstance("RSA", this.providerClass);
this.publicKey = fac.generatePublic(new RSAPublicKeySpec(
new BigInteger(this.modulus), new BigInteger(this.key)));
this.privateKey = fac.generatePrivate(new RSAPrivateKeySpec(
new BigInteger(this.modulus), new BigInteger(this.spec)));
}
if (this.providerClass == null)
cipher = Cipher.getInstance(this.transformation);
else
cipher = Cipher.getInstance(this.transformation, this.providerClass);
if (encrypt)
cipher.init(cryptMode, this.publicKey);
else
cipher.init(cryptMode, this.privateKey);
} else {
if (this.secretkeySpec == null) {
int padLen = this.algorithm.equals("SKIPJACK") ? 10 : 16;
byte[] byteArray = this.spec.getBytes();
byteArray = pad(byteArray, padLen);
this.secretkeySpec = new SecretKeySpec(byteArray, this.algorithm);
}
if (this.providerClass == null)
cipher = Cipher.getInstance(this.transformation);
else
cipher = Cipher.getInstance(this.transformation, this.providerClass);
cipher.init(cryptMode, this.secretkeySpec);
}
return cipher;
}
private boolean validateParams(String algTest, String modeTest, String paddingTest, String keyTest, String specTest, String modTest)
{
if ((algTest != null) && (!algTest.equals("")))
this.algorithm = algTest;
if ((modeTest != null) && (!modeTest.equals("")))
this.mode = modeTest;
if ((paddingTest != null) && (!paddingTest.equals("")))
this.padding = paddingTest;
if ((keyTest != null) && (!keyTest.equals("")))
this.key = keyTest;
if ((specTest != null) && (!specTest.equals("")))
this.spec = specTest;
if ((modTest != null) && (!modTest.equals("")))
this.modulus = modTest;
if (this.algorithm == null)
return false;
if ((this.algorithm.equals("AES")) || (this.algorithm.equals("Serpent")) ||
(this.algorithm.equals("MARS")) || (this.algorithm.equals("RC6")) ||
(this.algorithm.equals("Rijndael")) || (this.algorithm.equals("Square")) ||
(this.algorithm.equals("Twofish")))
this.padLen = 16;
else if (this.algorithm.equals("RSA"))
this.padLen = 0;
if ((!this.algorithm.equals("DES")) && (!this.algorithm.equals("DESede")) &&
(!this.algorithm.equals("AES"))) {
if ((modeTest == null) || (modeTest.equals("")))
this.mode = "";
if ((paddingTest == null) || (paddingTest.equals("")))
this.padding = "";
}
if (this.nonSunProviders)
return true;
if ((!this.algorithm.equals("DESede")) && (!this.algorithm.equals("DES")) &&
(!this.algorithm.equals("AES")) &&
(!this.algorithm.equals("PBEWithMD5AndDES")))
return false;
if ((this.algorithm.equals("AES")) && ((this.mode == null) || (!this.mode.equals("ECB"))))
return false;
if (this.algorithm.equals("PBEWithMD5AndDES")) {
if ((this.mode == null) || (!this.mode.equals("CBC")))
return false;
if ((this.padding == null) || (!this.padding.equals("PKCS5Padding")))
return false;
if (this.key.getBytes().length != 8)
return false;
}
if ((this.mode != null) && (!this.mode.equals("")) && (!this.mode.equals("CBC")) &&
(!this.mode.equals("CFB")) && (!this.mode.equals("ECB")) &&
(!this.mode.equals("OFB")) && (!this.mode.equals("PCBC")))
return false;
if ((this.padding != null) && (!this.padding.equals("")) &&
(!this.padding.equals("NoPadding")) &&
(!this.padding.equals("PKCS5Padding")))
return false;
if ((this.key != null) && (!this.key.equals("")) && (!this.algorithm.equals("RSA")) &&
(this.key.length() % 24 != 0))
return false;
if ((this.spec != null) && (!this.spec.equals("")) && (!this.algorithm.equals("RSA")) &&
(this.spec.length() % 8 != 0))
return false;
return (this.mode == null) || (!this.mode.equals("OFB")) || (this.padding == null) ||
(this.padding.equals("NoPadding")) || (
(this.algorithm != null) &&
(this.algorithm.equals("DES")));
}
public synchronized String encData(String in) {
byte[] temp = in.getBytes();
temp = pad(temp);
byte[] encryptVal = (byte[])null;
try {
encryptVal = this.cipherEncrypt.doFinal(temp);
} catch (Exception e) {
e.printStackTrace();
return null;
}
return EncodeUtil.Bytes2HexString(encryptVal);
}
public synchronized String decData(String in)
{
byte[] temp = EncodeUtil.HexString2Bytes(in);
temp = pad(temp);
byte[] decryptVal = (byte[])null;
try
{
decryptVal = this.cipherEncrypt.doFinal(temp);
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
}
String value = new String(decryptVal);
return value.trim();
}
protected byte[] pad(byte[] in) {
return pad(in, this.padLen);
}
protected byte[] pad(byte[] in, int padLen) {
if (padLen == 0)
return in;
int inlen = in.length;
int outlen = inlen;
int rem = inlen % padLen;
if (rem > 0)
outlen = inlen + (padLen - rem);
byte[] out = new byte[outlen];
for (int xx = 0; xx < inlen; xx++) {
out[xx] = in[xx];
}
return out;
}
}
\ No newline at end of file
package tohi.app.rlrelaymanage;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.util.PropertyPlaceholderHelper;
public class PropertiesConfigurerUtil extends PropertyPlaceholderConfigurer
{
private static Map<String, String> properties = new HashMap();
protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)
throws BeansException
{
PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${",
"}", ":", false);
for (Map.Entry entry : props.entrySet()) {
String stringKey = String.valueOf(entry.getKey()).trim();
String stringValue = String.valueOf(entry.getValue()).trim();
stringValue = helper.replacePlaceholders(stringValue, props);
properties.put(stringKey, stringValue);
}
super.processProperties(beanFactoryToProcess, props);
}
public static Map<String, String> getProperties()
{
return properties;
}
public static String getProperty(String proName)
{
return (String)properties.get(proName);
}
}
\ No newline at end of file
package tohi.app.rlrelaymanage;
public class PropertiesUtil
{
public static String CRYPTOX_MODE = "CBC";
public static String CRYPTOX_PADDING = "PKCS5Padding";
public static String CRYPTOX_KEY = "Sa#qk5usfmMI-@2dbZP9`jL3";
public static String CRYPTOX_SPEC = "beLd7$lB";
public static String CRYPTOX_ALGORITHM = "DESede";
public static String CRYPTOX_MODULUS = "";
public static String CRYPTOX_PROVIDER = null;
private String algorithm;
private String mode;
private String padding;
private String key;
private String spec;
private String modulus;
private String provider;
public PropertiesUtil()
{
try
{
this.algorithm = PropertiesConfigurerUtil.getProperty("mxe.security.cryptox.algorithm");
this.mode = PropertiesConfigurerUtil.getProperty("mxe.security.cryptox.mode");
this.padding = PropertiesConfigurerUtil.getProperty("mxe.security.cryptox.padding");
this.key = PropertiesConfigurerUtil.getProperty("mxe.security.cryptox.key");
this.spec = PropertiesConfigurerUtil.getProperty("mxe.security.cryptox.spec");
this.modulus = "";
this.provider = null;
} catch (Exception e) {
e.printStackTrace();
}
}
public void setAlgorithm(String algorithm) {
this.algorithm = algorithm;
}
public void setMode(String mode) {
this.mode = mode;
}
public void setPadding(String padding) {
this.padding = padding;
}
public void setKey(String key) {
this.key = key;
}
public void setSpec(String spec) {
this.spec = spec;
}
public void setModulus(String modulus) {
this.modulus = modulus;
}
public void setProvider(String provider) {
this.provider = provider;
}
public String getAlgorithm() {
return this.algorithm;
}
public String getMode() {
return this.mode;
}
public String getPadding() {
return this.padding;
}
public String getKey() {
return this.key;
}
public String getSpec() {
return this.spec;
}
public String getModulus() {
return this.modulus;
}
public String getProvider() {
return this.provider;
}
}
\ No newline at end of file
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