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

com.alogic.xscript.crypto.EncryptExtend Maven / Gradle / Ivy

There is a newer version: 1.6.17
Show newest version
package com.alogic.xscript.crypto;

import org.apache.commons.lang3.StringUtils;

import com.alogic.xscript.AbstractLogiclet;
import com.alogic.xscript.ExecuteWatcher;
import com.alogic.xscript.Logiclet;
import com.alogic.xscript.LogicletContext;
import com.alogic.xscript.doc.XsObject;
import com.anysoft.util.Properties;
import com.anysoft.util.PropertiesConstants;
import com.anysoft.util.code.Coder;
import com.anysoft.util.code.CoderFactory;

/**
 * 扩展的Encrypt
 * @author yyduan
 * @version 1.6.12.7 [20181108 duanyy] 
* - 改造coder框架
*/ public class EncryptExtend extends AbstractLogiclet { protected String in = "in"; protected String id; protected String coder = "DES3"; protected String key; protected boolean hex = false; protected boolean urlSafe = true; public EncryptExtend(String tag, Logiclet p) { super(tag, p); } @Override public void configure(Properties p) { super.configure(p); in = PropertiesConstants.getRaw(p,"in", ""); id = PropertiesConstants.getRaw(p,"id", "$" + this.getXmlTag()); key = PropertiesConstants.getRaw(p,"key", ""); hex = PropertiesConstants.getBoolean(p,"hex", hex); urlSafe = PropertiesConstants.getBoolean(p,"urlSafe", urlSafe); coder = PropertiesConstants.getRaw(p,"coder", coder); } @Override protected void onExecute(XsObject root,XsObject current, LogicletContext ctx, ExecuteWatcher watcher) { String inData = ctx.transform(in); String keyData = ctx.transform(key); if (StringUtils.isNotEmpty(inData)){ Coder c = CoderFactory.newCoder(PropertiesConstants.transform(ctx,coder,"DES3")); String outData = c.encode(inData, keyData,hex,urlSafe); String outId = ctx.transform(id); if (StringUtils.isNotEmpty(outData) && StringUtils.isNotEmpty(outId)){ ctx.SetValue(outId, outData); } } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy