diff --git a/pom.xml b/pom.xml index b318719..9508467 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,11 @@ + + org.bouncycastle + bcprov-jdk16 + 1.46 + junit junit @@ -175,12 +180,12 @@ true - - mysql - mysql-connector-java - 5.1.38 - - + + mysql + mysql-connector-java + 5.1.38 + + diff --git a/src/main/java/osc/git/eh3/pack/FileUtil.java b/src/main/java/osc/git/eh3/pack/FileUtil.java new file mode 100644 index 0000000..8d3297e --- /dev/null +++ b/src/main/java/osc/git/eh3/pack/FileUtil.java @@ -0,0 +1,202 @@ +package osc.git.eh3.pack; + +import java.awt.Component; +import java.awt.Point; +import java.awt.Rectangle; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; + +public class FileUtil { + private static int sumError = 0; + private static int sumExistError = 0; + private static int sumNotFoundError = 0; + private static int sumSuccess = 0; + private static int sumNum = 1; + + private static String getDate(Date date) { + SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return sd.format(date).toString(); + } + + private static BufferedReader getBufferedReader(String path) throws FileNotFoundException { + return new BufferedReader(new InputStreamReader(new FileInputStream(path))); + } + + public static void setInfo(String info, JFrame root) { + sumError += 1; + info.equals(""); + + Component[] components = root.getRootPane().getContentPane().getComponents(); + for (int i = 0; i < components.length; i++) { + if (components[i].getClass().toString().equals("class javax.swing.JScrollPane")) { + JTextArea textarea = (JTextArea) ((JScrollPane) components[i]).getViewport().getView(); + if (info.equals("")) { + sumError = 0; + sumExistError = 0; + sumNotFoundError = 0; + sumSuccess = 0; + sumNum = 1; + textarea.setText(""); + } else if ((textarea.getText().equals("")) || (textarea.getText() == null)) { + textarea.setText(sumNum + ". " + info); + } else { + textarea.setText(textarea.getText() + "\n" + sumNum + ". " + info); + } + } + } + } + + private static boolean copy(String from, String dirPath, JFrame root) { + boolean isCommon = true; + File fromFile = new File(from); + if (!fromFile.exists()) { + sumExistError += 1; + setInfo(from + "-------未找到!", root); + + System.out.println(from + "---------------未找到!"); + return false; + } + makeDirs(dirPath); + try { + File toFile = new File(dirPath + File.separatorChar + fromFile.getName()); + if (toFile.exists()) { + sumNotFoundError += 1; + int k = checkFileVersion(fromFile, toFile); + if (k == -1) { + setInfo(fromFile.getAbsolutePath() + "--输出失败(已存在!)", root); + System.out.println( + "文件版本在目标版本之前,处理为不覆盖!若要处理请人工处理!\n原文件:" + fromFile.getAbsolutePath() + "\n目标文件:" + toFile.getAbsolutePath()); + JOptionPane jp = new JOptionPane(); + jp.setBounds(new Rectangle(new Point(400, 400))); + + int isYes = JOptionPane.showConfirmDialog(root, "发现相同的文件,文件版本在目标版本之前!是否要进行覆盖?\n当前文件:" + + + fromFile.getAbsolutePath() + ",修改日期:" + getDate(new Date(fromFile.lastModified())) + "\n目标文件:" + + toFile.getAbsolutePath() + ",修改日期:" + getDate(new Date(toFile.lastModified()))); + if (isYes == 0) { + isCommon = false; + System.out.println("您选择了是!"); + } else { + return false; + } + } + if (k == 0) { + setInfo(fromFile.getAbsolutePath() + "--输出失败(已存在)", root); + System.out + .println("相同文件重复,处理为不覆盖!若要处理请人工处理!\n原文件:" + fromFile.getAbsolutePath() + "\n目标文件:" + toFile.getAbsolutePath()); + return true; + } + if (k == 1) { + isCommon = false; + } + } else if (!toFile.exists()) { + toFile.createNewFile(); + isCommon = false; + } + if (!isCommon) { + InputStream is = new FileInputStream(fromFile); + OutputStream out = new FileOutputStream(toFile); + byte[] b = new byte[1024]; + int len = -1; + while ((len = is.read(b)) != -1) { + out.write(b, 0, len); + } + out.flush(); + out.close(); + is.close(); + toFile.setLastModified(fromFile.lastModified()); + sumSuccess += 1; + return true; + } + } catch (Exception e) { + System.out.println("Copy Error!"); + } + return false; + } + + private static void makeDirs(String path) { + File f = new File(path); + if (!f.exists()) { + f.mkdirs(); + } + } + + private static int checkFileVersion(File file1, File file2) { + long file1LastTime = file1.lastModified(); + long file2LastTime = file2.lastModified(); + if (file1LastTime > file2LastTime) { + return 1; + } + if (file1LastTime < file2LastTime) { + return -1; + } + return 0; + } + + public static boolean becomePackage(String fileList, String cutStr, String dir, JFrame root) throws Exception { + dir = dir + "\\"; + + String filePath = null; + String addStr = null; + String fromFile = null; + String toFile = null; + boolean flag = false; + try { + BufferedReader br = getBufferedReader(fileList); + addStr = br.readLine(); + addStr = addStr.trim(); + setInfo("", root); + while ((filePath = br.readLine()) != null) { + sumNum += 1; + if (!"".equals(filePath.trim())) { + filePath = filePath.replaceAll("/", "\\\\"); + + System.out.println(filePath.replaceAll("\\\\", "/")); + if (filePath.startsWith(cutStr)) { + fromFile = filePath.trim(); + toFile = dir + addStr + File.separatorChar + getCenter(cutStr, fromFile); + flag = copy(fromFile, toFile, root); + } else { + fromFile = cutStr + File.separatorChar + filePath.trim(); + toFile = dir + addStr + File.separatorChar + filePath.substring(0, filePath.trim().lastIndexOf("\\")); + + flag = copy(fromFile, toFile, root); + } + } + } + br.close(); + setInfo("----成功:" + sumSuccess + "\n" + "----失败:" + sumError + "\n" + "--------未找到:" + sumNotFoundError + "\n" + "--------已存在:" + + sumExistError, root); + return flag; + } catch (FileNotFoundException e) { + System.out.println("列表文件没有找到!"); + throw new Exception("列表文件没有找到!"); + } catch (IOException e) { + System.out.println("列表文件读取出错!"); + throw new Exception("列表文件读取出错!"); + } + } + + private static String getCenter(String flag, String message) { + int k1 = message.trim().indexOf(flag); + int k2 = message.trim().lastIndexOf("\\"); + if ((k1 != -1) && (k2 != -1)) { + return message.substring(flag.length() + 1, k2 + 1); + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/osc/git/eh3/pack/PackView.java b/src/main/java/osc/git/eh3/pack/PackView.java new file mode 100644 index 0000000..845f987 --- /dev/null +++ b/src/main/java/osc/git/eh3/pack/PackView.java @@ -0,0 +1,270 @@ +package osc.git.eh3.pack; + +import java.awt.Color; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextPane; +import javax.swing.filechooser.FileFilter; +import javax.swing.filechooser.FileSystemView; + +@SuppressWarnings("serial") +public class PackView extends JFrame { + private JButton jb = new JButton(); + private JButton jb1 = new JButton(); + private JButton jb2 = new JButton(); + private String inputPath = "D:\\wins-dsp"; + private String outputPath = "D:"; + private JLabel jl0 = new JLabel(); + private JButton cancel = new JButton("退出"); + private JTextPane jText1 = new JTextPane(); + private JTextPane jText2 = new JTextPane(); + public JTextArea jArea = new JTextArea(); + public JScrollPane p = new JScrollPane(this.jArea); + + private PackView() { + setTitle("打包工具(By:Henry)"); + setBounds(400, 400, 500, 300); + setLayout(null); + setResizable(false); + this.jb.setText("打包清单"); + this.jb1.setText("打包根目录"); + this.jb2.setText("输出目录"); + + this.jText1.setText(this.inputPath); + this.jText2.setText(this.outputPath); + + this.jb.addMouseListener(new MouseListener() { + public void mouseReleased(MouseEvent e) { + if (PackView.this.packs()) { + PackView.this.jl0.setText("成功打包!"); + PackView.this.jb.setText("...继续"); + } else { + PackView.this.jl0.setText("打包失败!"); + } + } + + public void mousePressed(MouseEvent e) { + } + + public void mouseExited(MouseEvent e) { + } + + public void mouseEntered(MouseEvent e) { + } + + public void mouseClicked(MouseEvent e) { + } + }); + this.jb1.addMouseListener(new MouseListener() { + public void mouseReleased(MouseEvent e) { + PackView.this.choosePath(1); + PackView.this.jText1.setText(PackView.this.inputPath); + } + + public void mousePressed(MouseEvent e) { + } + + public void mouseExited(MouseEvent e) { + } + + public void mouseEntered(MouseEvent e) { + } + + public void mouseClicked(MouseEvent e) { + } + }); + this.jb2.addMouseListener(new MouseListener() { + public void mouseReleased(MouseEvent e) { + PackView.this.choosePath(2); + PackView.this.jText2.setText(PackView.this.outputPath); + } + + public void mousePressed(MouseEvent e) { + } + + public void mouseExited(MouseEvent e) { + } + + public void mouseEntered(MouseEvent e) { + } + + public void mouseClicked(MouseEvent e) { + } + }); + this.cancel.addMouseListener(new MouseListener() { + public void mouseReleased(MouseEvent e) { + PackView.this.close(); + } + + public void mousePressed(MouseEvent e) { + } + + public void mouseExited(MouseEvent e) { + } + + public void mouseEntered(MouseEvent e) { + } + + public void mouseClicked(MouseEvent e) { + } + }); + this.jb1.setBounds(10, 5, 100, 30); + this.jText1.setBounds(120, 5, 250, 30); + + this.jb2.setBounds(10, 40, 100, 30); + this.jText2.setBounds(120, 40, 250, 30); + + this.jb.setBounds(10, 100, 100, 30); + this.cancel.setBounds(120, 100, 100, 30); + this.jl0.setBounds(230, 100, 100, 30); + this.jArea.setLineWrap(true); + this.jArea.setForeground(Color.red); + this.jArea.setEditable(false); + + this.p.setBounds(10, 130, 480, 130); + + this.p.setVerticalScrollBarPolicy(22); + this.p.setHorizontalScrollBarPolicy(32); + + add(this.jb1); + add(this.jText1); + add(this.jb2); + add(this.jText2); + add(this.jb); + add(this.cancel); + add(this.jl0); + + add(this.p); + setVisible(true); + setDefaultCloseOperation(3); + } + + private List chooseFile(int chooseMode) { + try { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setMultiSelectionEnabled(true); + fileChooser.setDialogTitle("文件打包"); + fileChooser.setDragEnabled(true); + fileChooser.setAutoscrolls(true); + + fileChooser.setFileFilter(new FileFilter() { + public boolean accept(File f) { + if (f.isDirectory()) { + return true; + } + if ((f.getName().endsWith(".TXT")) || (f.getName().endsWith(".txt"))) { + return true; + } + return false; + } + + public String getDescription() { + return ".txt"; + } + }); + fileChooser.setCurrentDirectory(FileSystemView.getFileSystemView().getHomeDirectory()); + + fileChooser.setOpaque(true); + fileChooser.setDoubleBuffered(true); + int returnVal = -1; + switch (chooseMode) { + case 1: + returnVal = fileChooser.showOpenDialog(this); + break; + case 2: + returnVal = fileChooser.showSaveDialog(this); + } + File[] fileName; + if (returnVal == 0) { + fileName = fileChooser.getSelectedFiles(); + } else { + fileName = (File[]) null; + } + List list = new ArrayList(); + System.out.println("打包文件路径列表:"); + String filePath = null; + for (int i = 0; i < fileName.length; i++) { + filePath = fileName[i].getAbsolutePath(); + if (filePath.toUpperCase().endsWith("TXT")) { + list.add(filePath); + System.out.println("序号 " + i + " " + filePath); + } else { + System.out.println("序号 " + i + " " + filePath + " >>该文件不能作为打包文件! "); + } + } + return list; + } catch (Exception e) { + } + return null; + } + + private boolean choosePath(int id) { + try { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setMultiSelectionEnabled(true); + switch (id) { + case 1: + fileChooser.setDialogTitle("打包文件根目录"); + fileChooser.setCurrentDirectory(new File(this.inputPath)); + break; + case 2: + fileChooser.setDialogTitle("输出文件目录"); + fileChooser.setCurrentDirectory(new File(this.outputPath)); + } + fileChooser.setDragEnabled(true); + fileChooser.setAutoscrolls(true); + fileChooser.setAcceptAllFileFilterUsed(true); + fileChooser.setOpaque(true); + fileChooser.setDoubleBuffered(true); + fileChooser.setFileSelectionMode(1); + + fileChooser.showOpenDialog(this); + switch (id) { + case 1: + this.inputPath = fileChooser.getSelectedFile().toString(); + break; + case 2: + this.outputPath = fileChooser.getSelectedFile().toString(); + } + return true; + } catch (Exception e) { + } + return false; + } + + private void close() { + dispose(); + } + + private boolean packs() { + boolean flag = true; + List fileName = chooseFile(1); + if ((fileName == null) || (fileName.size() <= 0)) { + System.out.println("打包原始文件没有找到"); + flag = false; + } else { + for (int i = 0; i < fileName.size(); i++) { + try { + flag = FileUtil.becomePackage((String) fileName.get(i), this.inputPath, this.outputPath, this); + } catch (Exception e) { + return false; + } + } + } + return flag; + } + + public static void main(String[] args) { + new PackView(); + } +} diff --git a/src/main/java/osc/git/eh3/redis/redis.properties b/src/main/java/osc/git/eh3/redis/redis.properties index 9a7fa3f..4e38a2a 100644 --- a/src/main/java/osc/git/eh3/redis/redis.properties +++ b/src/main/java/osc/git/eh3/redis/redis.properties @@ -3,7 +3,7 @@ redis.pool.maxIdle=200 redis.pool.maxWait=1000 redis.pool.testOnBorrow=true redis.pool.testOnReturn=true -#redis.ip=192.168.3.166 -redis.ip=111.235.158.31 +redis.ip=192.168.3.166 +#redis.ip=111.235.158.31 redis.port=7379 redis.password= \ No newline at end of file diff --git a/src/main/java/osc/git/eh3/test/OperateKPIBudgetRedisData.java b/src/main/java/osc/git/eh3/test/OperateKPIBudgetRedisData.java new file mode 100644 index 0000000..17375cf --- /dev/null +++ b/src/main/java/osc/git/eh3/test/OperateKPIBudgetRedisData.java @@ -0,0 +1,77 @@ +package osc.git.eh3.test; + +import java.io.IOException; +import java.math.BigDecimal; + +import osc.git.eh3.redis.JedisUtil; + +public class OperateKPIBudgetRedisData { + + + public static void main(String[] args) throws IOException { + showSom("022ea1a5-3f21-40dd-9c24-c0edfa82bfda"); +// delete("c46b8885-4c1d-48f9-befb-3ba3a0f33d4a"); + } + + public static void showSom(String groupid){ + String[] keys = JedisUtil.getKeys("dsp_budget_*_"+groupid); + BigDecimal totals = new BigDecimal(0); + for (String key : keys) { + System.out.println(key+"-----------:"+JedisUtil.getStr(key)); + totals = totals.add(new BigDecimal(JedisUtil.getStr(key))); + } + System.out.println("budget_balance_"+groupid+"----------:"+JedisUtil.getStr("budget_balance_"+groupid)); + totals = totals.add(new BigDecimal(JedisUtil.getStr("budget_balance_"+groupid))); + System.out.println("-------------------------------------------------------------:"+totals.toPlainString()); + System.out.println(); + + totals = new BigDecimal(0); + keys = JedisUtil.getKeys("dsp_counter_*_"+groupid); + for (String key : keys) { + System.out.println(key+"-----------:"+JedisUtil.getStr(key)); + String[] split = JedisUtil.getStr(key).split(","); + if(split.length>1){ + totals = totals.add(new BigDecimal(split[1])); + }else{ + totals = totals.add(new BigDecimal(split[0])); + } + } + System.out.println("counter_balance_"+groupid+"---------:"+JedisUtil.getStr("counter_balance_"+groupid)); + String[] split = JedisUtil.getStr("counter_balance_"+groupid).split(","); + if(split.length>1){ + totals = totals.add(new BigDecimal(split[1])); + }else{ + totals = totals.add(new BigDecimal(split[0])); + } + System.out.println("-------------------------------------------------------------:"+totals.toPlainString()); + } + + + public static void delete(String groupid){ + + + String[] keys ={"d012aa41-35b8-4ef9-a3ee-9bc918d0da82", + "f26701ea-3bfc-4b4f-ae88-f39bff59c77c", + "a4e14ee1-1ae3-4e04-8850-c1345c5af200", + "d3ca7a1a-7a8d-4e43-be28-46f450a84d99", + "f9fdd963-558c-4d5a-b18f-c7d8386fac2d", + "a4dbe6b6-bd69-4bab-aa84-d5459860ad7b", + "6d3508d8-c978-4446-ba4c-895196af5021", + "033d5820-2ca8-4304-87ab-aaad6a0d0652", + "b4572eae-3f4f-46e2-95be-78ec3cb47b75", + "8c6f32fc-450d-4912-a7e3-7bbc7e4341a9", + "7275405b-b12d-4f8b-95a4-7274cbf3f942", + "6f1d947b-bc03-4560-b3ff-1200725f352c", + "52a9558d-bada-4e2b-8e71-d83ee40e804f", + "92b8bd98-6698-48b7-b402-5ccf49e9c674", + "b605daa7-6a85-40dc-8c5e-d9022e8fc3d2", + "853aad03-a2f5-4665-aaac-26aadd42be84", + "5f3668bf-ebb9-4db7-ac29-62216fd86f2d"}; + + for (String key : keys) { + JedisUtil.delete("dsp_mapid_"+key); + } + + + } +} \ No newline at end of file diff --git a/src/main/java/osc/git/eh3/test/TestCode.java b/src/main/java/osc/git/eh3/test/TestCode.java index 0a5f2c1..c5e5f34 100644 --- a/src/main/java/osc/git/eh3/test/TestCode.java +++ b/src/main/java/osc/git/eh3/test/TestCode.java @@ -8,6 +8,9 @@ import java.util.Date; import java.util.HashSet; import java.util.Set; +import osc.git.eh3.utils.AESTool; +import osc.git.eh3.utils.Base64; + public class TestCode { public static void main(String[] args) throws Exception { @@ -169,12 +172,12 @@ public class TestCode { // System.out.println(Integer.valueOf("11", 2)); -// System.out.println(AESEncrypter.encrypt("lixiangrong")); -// System.out.println(AESEncrypter.decrypt(AESEncrypter.encrypt("lixiangrong"))); +// System.out.println(AESTool.encrypt("lixiangrong")); +// System.out.println(AESTool.decrypt(AESEncrypter.encrypt("lixiangrong"))); -// System.out.println(AESEncrypter.encrypt("fa4d7d90618dcba5fa1d969cffc04def","002020202")); -// System.out.println(AESEncrypter.decrypt(AESEncrypter.encrypt("lixiangrong","0"),"0")); -// System.out.println(Base64.encodeToString(AESEncrypter.encrypt("fa4d7d90618dcba5fa1d969cffc04def","002020202").getBytes(), false)); + System.out.println(AESTool.encrypt("liixangrong","adjdjfjfjfjdkdkd")); + System.out.println(AESTool.decrypt("bfb0c038342ffead45511879853279bf","adjdjfjfjfjdkdkd")); +// System.out.println(Base64.encodeToString(AESTool.encrypt("fa4d7d90618dcba5fa1d969cffc04def","002020202").getBytes(), false)); // byte[] bytes = "lixiangrong".getBytes(); // for (int i = 0; i < bytes.length; i++) { @@ -232,15 +235,15 @@ public class TestCode { // double budgets = 10000; // System.out.println((budgets/100)); - String str = null; - BigDecimal budget = new BigDecimal(str); - budget = budget.subtract(new BigDecimal(10)); - if (budget.compareTo(new BigDecimal(0)) <= 0) { - System.out.println("1"); - } else { - System.out.println("2"); - } - System.out.println(budget.doubleValue()); +// String str = null; +// BigDecimal budget = new BigDecimal(str); +// budget = budget.subtract(new BigDecimal(10)); +// if (budget.compareTo(new BigDecimal(0)) <= 0) { +// System.out.println("1"); +// } else { +// System.out.println("2"); +// } +// System.out.println(budget.doubleValue()); } diff --git a/src/main/java/osc/git/eh3/test/TestJdbc143.java b/src/main/java/osc/git/eh3/test/TestJdbc143.java index 35bfea0..9e33e20 100644 --- a/src/main/java/osc/git/eh3/test/TestJdbc143.java +++ b/src/main/java/osc/git/eh3/test/TestJdbc143.java @@ -10,7 +10,7 @@ import java.util.UUID; public class TestJdbc143 { private static Connection getConn() { String driver = "com.mysql.jdbc.Driver"; - String url = "jdbc:mysql://115.182.33.143:3306/wins-dsp-new?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&connectTimeout=60000&socketTimeout=60000"; + String url = "jdbc:mysql://111.235.158.31:3306/wins-dsp-new?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&connectTimeout=60000&socketTimeout=60000"; String username = "root"; String password = "pxene"; Connection conn = null; @@ -33,8 +33,9 @@ public class TestJdbc143 { private static void insertData(){ Connection conn = getConn(); System.out.println(new Date()); - for (int i = 0; i > -1; i++) { - String cid = UUID.randomUUID().toString(); + for (int i = 0; i < 1; i++) { +// String cid = UUID.randomUUID().toString(); + String cid = "0123456789"; String sql = "INSERT INTO `dsp_t_statis_by_day` (`time`, `creativeid`, `category`, `imprs`, `clks`, `cost`, `downloads`, `regists`, `flag`, `createtime`) VALUES ('2014-12-06 00:00:00', '"+cid+"', '2', '961', '9', '201860.7000', '0', '0', '0', '2015-09-14 15:07:42');"; PreparedStatement pstmt; try { diff --git a/src/main/java/osc/git/eh3/test/TestRedisData.java b/src/main/java/osc/git/eh3/test/TestRedisData.java deleted file mode 100644 index f09e1a2..0000000 --- a/src/main/java/osc/git/eh3/test/TestRedisData.java +++ /dev/null @@ -1,32 +0,0 @@ -package osc.git.eh3.test; - -import java.io.IOException; -import java.math.BigDecimal; - -import osc.git.eh3.redis.JedisUtil; - -public class TestRedisData { - - - public static void main(String[] args) throws IOException { - showSom("b8093670-ceb0-4c1d-9413-8bb23a1217f2"); - } - - public static void showSom(String groupid){ - String[] keys = JedisUtil.getKeys("dsp_budget_*_"+groupid); - BigDecimal totals = new BigDecimal(0); - for (String key : keys) { - System.out.println(key+"-----------:"+JedisUtil.getStr(key)); - totals = totals.add(new BigDecimal(JedisUtil.getStr(key))); - } - System.out.println("budget_balance_"+groupid+"-----------:"+JedisUtil.getStr("budget_balance_"+groupid)); - totals = totals.add(new BigDecimal(JedisUtil.getStr("budget_balance_"+groupid))); - System.out.println(totals.toPlainString()); - - keys = JedisUtil.getKeys("dsp_counter_*_"+groupid); - for (String key : keys) { - System.out.println(key+"-----------:"+JedisUtil.getStr(key)); - } - System.out.println("counter_balance_"+groupid+"-----------:"+JedisUtil.getStr("counter_balance_"+groupid)); - } -} \ No newline at end of file diff --git a/src/main/java/osc/git/eh3/test/keygen.java b/src/main/java/osc/git/eh3/test/keygen.java new file mode 100644 index 0000000..22c3c45 --- /dev/null +++ b/src/main/java/osc/git/eh3/test/keygen.java @@ -0,0 +1,127 @@ +package osc.git.eh3.test; + +import java.math.BigInteger; +import java.util.Date; +import java.util.Random; +import java.util.zip.CRC32; + +/** + * IntelliJ IDEA 14.0.1 注册机 + * + * @author lixiangrong + * + */ +public class keygen { + /** + * @param s + * @param i + * @param bytes + * @return + */ + public static short getCRC(String s, int i, byte bytes[]) { + CRC32 crc32 = new CRC32(); + if (s != null) { + for (int j = 0; j < s.length(); j++) { + char c = s.charAt(j); + crc32.update(c); + } + } + crc32.update(i); + crc32.update(i >> 8); + crc32.update(i >> 16); + crc32.update(i >> 24); + for (int k = 0; k < bytes.length - 2; k++) { + byte byte0 = bytes[k]; + crc32.update(byte0); + } + return (short) (int) crc32.getValue(); + } + + /** + * @param biginteger + * @return String + */ + public static String encodeGroups(BigInteger biginteger) { + BigInteger beginner1 = BigInteger.valueOf(0x39aa400L); + StringBuilder sb = new StringBuilder(); + for (int i = 0; biginteger.compareTo(BigInteger.ZERO) != 0; i++) { + int j = biginteger.mod(beginner1).intValue(); + String s1 = encodeGroup(j); + if (i > 0) { + sb.append("-"); + } + sb.append(s1); + biginteger = biginteger.divide(beginner1); + } + return sb.toString(); + } + + /** + * @param i + * @return + */ + public static String encodeGroup(int i) { + StringBuilder sb = new StringBuilder(); + for (int j = 0; j < 5; j++) { + int k = i % 36; + char c; + if (k < 10) { + c = (char) (48 + k); + } else { + c = (char) ((65 + k) - 10); + } + sb.append(c); + i /= 36; + } + return sb.toString(); + } + + /** + * @param name + * @param days + * @param id + * @param prtype + * @return + */ + public static String MakeKey(String name, int days, int id) { + id %= 100000; + byte bkey[] = new byte[12]; + bkey[0] = (byte) 1; // Product type: IntelliJ IDEA is 1 + bkey[1] = 14; // version + Date d = new Date(); + long ld = (d.getTime() >> 16); + bkey[2] = (byte) (ld & 255); + bkey[3] = (byte) ((ld >> 8) & 255); + bkey[4] = (byte) ((ld >> 16) & 255); + bkey[5] = (byte) ((ld >> 24) & 255); + days &= 0xffff; + bkey[6] = (byte) (days & 255); + bkey[7] = (byte) ((days >> 8) & 255); + bkey[8] = 105; + bkey[9] = -59; + bkey[10] = 0; + bkey[11] = 0; + int w = getCRC(name, id % 100000, bkey); + bkey[10] = (byte) (w & 255); + bkey[11] = (byte) ((w >> 8) & 255); + BigInteger pow = new BigInteger("89126272330128007543578052027888001981", 10); + BigInteger mod = new BigInteger("86f71688cdd2612ca117d1f54bdae029", 16); + BigInteger k0 = new BigInteger(bkey); + BigInteger k1 = k0.modPow(pow, mod); + String s0 = Integer.toString(id); + String sz = "0"; + while (s0.length() != 5) { + s0 = sz.concat(s0); + } + s0 = s0.concat("-"); + String s1 = encodeGroups(k1); + s0 = s0.concat(s1); + return s0; + } + + public static void main(String[] args) { + Random r = new Random(); + String userid = "elvin"; + System.out.println(userid+":"+MakeKey(userid, 0, r.nextInt(100000))); + } +} \ No newline at end of file diff --git a/src/main/java/osc/git/eh3/testopen/SignatureUtil.java b/src/main/java/osc/git/eh3/testopen/SignatureUtil.java new file mode 100644 index 0000000..a9e2bf0 --- /dev/null +++ b/src/main/java/osc/git/eh3/testopen/SignatureUtil.java @@ -0,0 +1,146 @@ +package osc.git.eh3.testopen; + + + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.StringUtils; + +/** + * 签名工具类 + * + */ +public class SignatureUtil { + + + private static final char[] hexArray = "0123456789ABCDEF".toCharArray(); + + private static String encryptionAlgorithm = "SHA-1"; + + public static String bytesToHexString(byte[] bytes) { + char[] hexChars = new char[bytes.length * 2]; + for (int j = 0; j < bytes.length; j++) { + int v = bytes[j] & 0xFF; + hexChars[j * 2] = hexArray[v >>> 4]; + hexChars[j * 2 + 1] = hexArray[v & 0x0F]; + } + return new String(hexChars); + } + + public static byte[] hexStringToBytes(String s) { + int len = s.length(); + byte[] data = new byte[len / 2]; + for (int i = 0; i < len; i += 2) { + data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16)); + } + return data; + } + + /** + * 使用指定算法生成消息摘要,默认是md5 + * + * @param strSrc + * , a string will be encrypted;
+ * @param encName + * , the algorithm name will be used, dafault to "MD5";
+ * @return + */ + public static String digest(String strSrc, String encName) { + MessageDigest md = null; + String strDes = null; + byte[] bt = strSrc.getBytes(); + try { + if (encName == null || encName.equals("")) { + encName = "MD5"; + } + md = MessageDigest.getInstance(encName); + md.update(bt); + strDes = bytesToHexString(md.digest()); // to HexString + } catch (NoSuchAlgorithmException e) { + return null; + } + return strDes; + } + + /** + * 根据appid、token、lol以及时间戳来生成签名 + * + * @param appid + * @param token + * @param lol + * @param millis + * @return + */ + public static String generateSignature(String appid, String token, String lol, long millis) { + String timestamp = String.valueOf(millis); + String signature = null; + if (StringUtils.isNotBlank(token) && StringUtils.isNotBlank(timestamp) && StringUtils.isNotBlank(appid)) { + List srcList = new ArrayList(); + srcList.add(timestamp); + srcList.add(appid); + srcList.add(token); + srcList.add(lol); + // 按照字典序逆序拼接参数 + Collections.sort(srcList); + Collections.reverse(srcList); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < srcList.size(); i++) { + sb.append(srcList.get(i)); + } + signature = digest(sb.toString(), encryptionAlgorithm); + srcList.clear(); + srcList = null; + } + return signature; + } + + /** + * 验证签名:
+ * 1.根据appid获取该渠道的token;
+ * 2.根据appid、token、lol以及时间戳计算一次签名;
+ * 3.比较传过来的签名以及计算出的签名是否一致; + * + * @param signature + * @param appid + * @param lol + * @param millis + * @return + */ + public static boolean isValid(String signature, String appid,String token, String lol, long millis) { + String calculatedSignature = generateSignature(appid, token, lol, millis); + if (StringUtils.equals(calculatedSignature, signature)) { + return true; + } else { + return false; + } + } + + + public static void main(String[] args) { + String xmlString = "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"; + System.out.println(xmlString.getBytes().length); + + //消息 + String digest = SignatureUtil.digest(xmlString, "MD5"); + System.out.println("----" + digest); + System.out.println(digest.getBytes().length); + + + String appid = "canairport001"; + String token = "111ddff"; + long millis = System.currentTimeMillis(); + + //生成签名 + String signature = SignatureUtil.generateSignature(appid, token, digest, millis); + + System.out.println(signature); + + //验证签名 + boolean isValid = SignatureUtil.isValid(signature, appid,token, digest, millis); + System.out.println(isValid); + } +} diff --git a/src/main/java/osc/git/eh3/testopen/TestOpenPuton.java b/src/main/java/osc/git/eh3/testopen/TestOpenPuton.java new file mode 100644 index 0000000..f78e937 --- /dev/null +++ b/src/main/java/osc/git/eh3/testopen/TestOpenPuton.java @@ -0,0 +1,232 @@ +package osc.git.eh3.testopen; + +import java.util.HashMap; +import java.util.Map; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import osc.git.eh3.utils.AESTool; +import osc.git.eh3.utils.Base64; +import osc.git.eh3.utils.HttpClientUtil; + +public class TestOpenPuton { + public static String URL = "http://127.0.0.1:3/dsp-open/opendsp.do"; + private static String key = "adjdjfjfjfjdkdkd";// + private static String appid = "t123456";// 用户 + private static String token = "cst123456";// 令牌 + + public static void main(String[] args) throws Exception { + + String sendPostParam = HttpClientUtil.sendPostParam(URL, getPostParam("getKpiByCampaignIds"));// 获得数据并且发送请求 + String data = getData(sendPostParam); + System.out.println(JSONObject.fromObject(data)); + } + + // 解密 + public static String getData(String encryptString) throws Exception { + byte[] decode = Base64.decode(encryptString.getBytes()); + String aString = new String(decode, "utf-8"); + String decrypt = AESTool.decrypt(aString, key); + return decrypt; + } + + public static Map getPostParam(String content) throws Exception { + Map postParam = new HashMap(); + content = getContent(content); + + // 业务数据 + long millis = System.currentTimeMillis();// 时间戳j + content = AESTool.encrypt(content, key);// 使用aes加密 + String lol = SignatureUtil.digest(content, "MD5");// 摘要 + String signature = SignatureUtil.generateSignature(appid, token, lol, millis);// 签名 + + // 准备提交数据 + postParam.put("appid", appid); + postParam.put("content", content); + postParam.put("lol", lol); + postParam.put("signature", signature); + postParam.put("millis", millis + ""); + + return postParam; + } + + // 在这里写请求数据 + public static String getContent(String contentName) { + JSONObject content = new JSONObject(); + JSONObject param = new JSONObject(); + content.put("servicename", "putonServiceCall"); + + switch (contentName) { + case "putOnByCreative": + param.put("campaignid", "26861f62-5cd7-4073-9186-676f8f5d7b24"); + param.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda"); + param.put("adxid", "1fed4171-9925-4834-aa7b-9b4d3a58841b"); + + JSONArray mapIds = new JSONArray(); + mapIds.add("28f13909-dbbe-42e4-b9fd-edd97a31d6ce"); + mapIds.add("8b7b1b4a-eb3a-4be0-809b-b497c58a14f6"); + mapIds.add("b7f39e0c-3025-4fa3-8e83-ef1f492fe358"); + param.put("mapids", mapIds); + + content.put("funcname", "putOnByCreative"); + content.put("methodparam", param); + break; + case "pauseByCreative": + param.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda"); + param.put("adxid", "1fed4171-9925-4834-aa7b-9b4d3a58841b"); + + mapIds = new JSONArray(); + mapIds.add("28f13909-dbbe-42e4-b9fd-edd97a31d6ce"); + mapIds.add("8b7b1b4a-eb3a-4be0-809b-b497c58a14f6"); + mapIds.add("b7f39e0c-3025-4fa3-8e83-ef1f492fe358"); + param.put("mapids", mapIds); + + content.put("funcname", "pauseByCreative"); + content.put("methodparam", param); + break; + case "putOnByAdx": + param.put("campaignid", "26861f62-5cd7-4073-9186-676f8f5d7b24"); + + JSONArray groupAdxs = new JSONArray(); + JSONObject groupAdx = new JSONObject(); + groupAdx.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda"); + groupAdx.put("adxid", "1fed4171-9925-4834-aa7b-9b4d3a58841b"); + groupAdxs.add(groupAdx); + groupAdx = new JSONObject(); + groupAdx.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda"); + groupAdx.put("adxid", "6246ae47-d24b-4afa-88ba-57417ccab6aa"); + groupAdxs.add(groupAdx); + groupAdx = new JSONObject(); + groupAdx.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda"); + groupAdx.put("adxid", "ce579246-e707-4cb9-b982-88cad7944b92"); + groupAdxs.add(groupAdx); + + param.put("groupadxs", groupAdxs); + + content.put("funcname", "putOnByAdx"); + content.put("methodparam", param); + break; + case "pauseByAdx": + groupAdxs = new JSONArray(); + groupAdx = new JSONObject(); + groupAdx.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda"); + groupAdx.put("adxid", "1fed4171-9925-4834-aa7b-9b4d3a58841b"); + groupAdxs.add(groupAdx); + groupAdx = new JSONObject(); + groupAdx.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda"); + groupAdx.put("adxid", "6246ae47-d24b-4afa-88ba-57417ccab6aa"); + groupAdxs.add(groupAdx); + groupAdx = new JSONObject(); + groupAdx.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda"); + groupAdx.put("adxid", "ce579246-e707-4cb9-b982-88cad7944b92"); + groupAdxs.add(groupAdx); + + param.put("groupadxs", groupAdxs); + + content.put("funcname", "pauseByAdx"); + content.put("methodparam", param); + break; + case "putOnByGroup": + param.put("campaignid", "26861f62-5cd7-4073-9186-676f8f5d7b24"); + + JSONArray groupids = new JSONArray(); + groupids.add("022ea1a5-3f21-40dd-9c24-c0edfa82bfda"); + param.put("groupids", groupids); + + content.put("funcname", "putOnByGroup"); + content.put("methodparam", param); + break; + case "pauseByGroup": + groupids = new JSONArray(); + groupids.add("022ea1a5-3f21-40dd-9c24-c0edfa82bfda"); + param.put("groupids", groupids); + + content.put("funcname", "pauseByGroup"); + content.put("methodparam", param); + break; + case "putOnByCampaign": + JSONArray campaignids = new JSONArray(); + campaignids.add("26861f62-5cd7-4073-9186-676f8f5d7b24"); + param.put("campaignids", campaignids); + + content.put("funcname", "putOnByCampaign"); + content.put("methodparam", param); + break; + case "pauseByCampaign": + campaignids = new JSONArray(); + campaignids.add("26861f62-5cd7-4073-9186-676f8f5d7b24"); + param.put("campaignids", campaignids); + + content.put("funcname", "pauseByCampaign"); + content.put("methodparam", param); + break; + case "setAdxProp": + JSONArray propdatas = new JSONArray(); + JSONObject propdata = new JSONObject(); + JSONObject adxprop = new JSONObject(); + JSONArray adxprops = new JSONArray(); + + adxprop.put("adxid", "1fed4171-9925-4834-aa7b-9b4d3a58841b"); + adxprop.put("prop", 40); + adxprops.add(adxprop); + + adxprop = new JSONObject(); + adxprop.put("adxid", "6246ae47-d24b-4afa-88ba-57417ccab6aa"); + adxprop.put("prop", 30); + adxprops.add(adxprop); + + adxprop = new JSONObject(); + adxprop.put("adxid", "ce579246-e707-4cb9-b982-88cad7944b92"); + adxprop.put("prop", 30); + adxprops.add(adxprop); + + propdata.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda"); + propdata.put("adxprops", adxprops); + + propdatas.add(propdata); + + param.put("propdatas", propdatas); + content.put("funcname", "setAdxProp"); + content.put("methodparam", param); + break; + case "setCreateivePrice": + JSONArray createiveprices = new JSONArray(); + + JSONObject createiveprice = new JSONObject(); + createiveprice.put("mapid", "28f13909-dbbe-42e4-b9fd-edd97a31d6ce"); + createiveprice.put("price", 10); + createiveprices.add(createiveprice); + + createiveprice = new JSONObject(); + createiveprice.put("mapid", "8b7b1b4a-eb3a-4be0-809b-b497c58a14f6"); + createiveprice.put("price", 6); + createiveprices.add(createiveprice); + + createiveprice = new JSONObject(); + createiveprice.put("mapid", "b7f39e0c-3025-4fa3-8e83-ef1f492fe358"); + createiveprice.put("price", 8); + createiveprices.add(createiveprice); + + param.put("groupid", "022ea1a5-3f21-40dd-9c24-c0edfa82bfda"); + param.put("adxid", "1fed4171-9925-4834-aa7b-9b4d3a58841b"); + param.put("createiveprices", createiveprices); + + content.put("funcname", "setCreateivePrice"); + content.put("methodparam", param); + break; + case "getKpiByCampaignIds": + campaignids = new JSONArray(); + campaignids.add("26861f62-5cd7-4073-9186-676f8f5d7b24"); + + param.put("campaignids", campaignids); + + content.put("funcname", "getKpiByCampaignIds"); + content.put("methodparam", param); + break; + default: + break; + } + System.out.println(content.toString()); + return content.toString(); + } +} diff --git a/src/main/java/osc/git/eh3/utils/AESEncrypter.java b/src/main/java/osc/git/eh3/utils/AESEncrypter.java deleted file mode 100644 index dff1165..0000000 --- a/src/main/java/osc/git/eh3/utils/AESEncrypter.java +++ /dev/null @@ -1,135 +0,0 @@ -package osc.git.eh3.utils; - -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.KeyGenerator; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.SecretKey; -import javax.crypto.spec.IvParameterSpec; - -public class AESEncrypter { - - private static byte[] iv = new byte[] { 21, 22, 50, 44, -16, 124, -40, -114, -11, -40, 37, 23, -33, 23, -33, 75 }; - private static String defalut_key = "defalut_keydefalut_key"; - - /** - * 加密 - * - * @param content - * 要加密的内容 - * @return 加密后的32位字符串 - */ - public static String encrypt(String content) { - return encrypt(content, defalut_key); - } - - /** - * 解密 - * - * @param content - * AES密文 - * @return 解密后的内容 - */ - public static String decrypt(String content) { - return decrypt(content, defalut_key); - } - - /** - * 加密 - * - * @param content - * 要加密的内容 - * @param key - * 秘钥 - * @return 加密后的32位字符串 - */ - public static String encrypt(String content, String key) { - String str = ""; - try { - KeyGenerator kgen = KeyGenerator.getInstance("AES"); - kgen.init(128, new SecureRandom(key.getBytes())); - AlgorithmParameterSpec paramSpec = new IvParameterSpec(iv); - SecretKey skey = kgen.generateKey(); - Cipher ecipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - ecipher.init(Cipher.ENCRYPT_MODE, skey, paramSpec); - str = asHex(ecipher.doFinal(content.getBytes())); - } catch (BadPaddingException e) { - e.printStackTrace(); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (NoSuchPaddingException e) { - e.printStackTrace(); - } catch (InvalidKeyException e) { - e.printStackTrace(); - } catch (InvalidAlgorithmParameterException e) { - e.printStackTrace(); - } catch (IllegalBlockSizeException e) { - e.printStackTrace(); - } - return str; - } - - /** - * 解密 - * - * @param content - * AES密文 - * @param key - * 秘钥 - * @return 解密后的内容 - */ - public static String decrypt(String content, String key) { - try { - KeyGenerator kgen = KeyGenerator.getInstance("AES"); - kgen.init(128, new SecureRandom(key.getBytes())); - AlgorithmParameterSpec paramSpec = new IvParameterSpec(iv); - SecretKey skey = kgen.generateKey(); - Cipher dcipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - dcipher.init(Cipher.DECRYPT_MODE, skey, paramSpec); - return new String(dcipher.doFinal(asBin(content))); - } catch (BadPaddingException e) { - e.printStackTrace(); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (NoSuchPaddingException e) { - e.printStackTrace(); - } catch (InvalidKeyException e) { - e.printStackTrace(); - } catch (InvalidAlgorithmParameterException e) { - e.printStackTrace(); - } catch (IllegalBlockSizeException e) { - e.printStackTrace(); - } - return ""; - } - - private static String asHex(byte buf[]) { - StringBuffer strbuf = new StringBuffer(buf.length * 2); - int i; - for (i = 0; i < buf.length; i++) { - if (((int) buf[i] & 0xff) < 0x10) - strbuf.append("0"); - strbuf.append(Long.toString((int) buf[i] & 0xff, 16)); - } - return strbuf.toString(); - } - - private static byte[] asBin(String src) { - if (src.length() < 1) - return null; - byte[] encrypted = new byte[src.length() / 2]; - for (int i = 0; i < src.length() / 2; i++) { - int high = Integer.parseInt(src.substring(i * 2, i * 2 + 1), 16); - int low = Integer.parseInt(src.substring(i * 2 + 1, i * 2 + 2), 16); - - encrypted[i] = (byte) (high * 16 + low); - } - return encrypted; - } -} diff --git a/src/main/java/osc/git/eh3/utils/AESTool.java b/src/main/java/osc/git/eh3/utils/AESTool.java new file mode 100644 index 0000000..73be808 --- /dev/null +++ b/src/main/java/osc/git/eh3/utils/AESTool.java @@ -0,0 +1,150 @@ +package osc.git.eh3.utils; + +import org.bouncycastle.crypto.CipherParameters; +import org.bouncycastle.crypto.engines.AESFastEngine; +import org.bouncycastle.crypto.modes.CBCBlockCipher; +import org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher; +import org.bouncycastle.crypto.params.KeyParameter; +import org.bouncycastle.crypto.params.ParametersWithIV; +import org.bouncycastle.util.encoders.Hex; +/** + * AES encryption and decryption tool. + * + * @author ben + * @creation 2014年3月20日 + */ +public class AESTool { + private static byte[] initVector = { 0x32, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, + 0x38, 0x27, 0x36, 0x35, 0x33, 0x23, 0x32, 0x31 }; + + /** + * Encrypt the content with a given key using aes algorithm. + * + * @param content + * @param key + * must contain exactly 32 characters + * @return + * @throws Exception + */ + public static String encrypt(String content, String key) throws Exception { + if (key == null) { + throw new IllegalArgumentException("Key cannot be null!"); + } + String encrypted = null; + byte[] keyBytes = key.getBytes(); + if (keyBytes.length != 32 && keyBytes.length != 24 + && keyBytes.length != 16) { + throw new IllegalArgumentException( + "Key length must be 128/192/256 bits!"); + } + byte[] encryptedBytes = null; + encryptedBytes = encrypt(content.getBytes(), keyBytes, initVector); + encrypted = new String(Hex.encode(encryptedBytes)); + return encrypted; + } + + /** + * Decrypt the content with a given key using aes algorithm. + * + * @param content + * @param key + * must contain exactly 32 characters + * @return + * @throws Exception + */ + public static String decrypt(String content, String key) throws Exception { + if (key == null) { + throw new IllegalArgumentException("Key cannot be null!"); + } + String decrypted = null; + byte[] encryptedContent = Hex.decode(content); + byte[] keyBytes = key.getBytes(); + byte[] decryptedBytes = null; + if (keyBytes.length != 32 && keyBytes.length != 24 + && keyBytes.length != 16) { + throw new IllegalArgumentException( + "Key length must be 128/192/256 bits!"); + } + decryptedBytes = decrypt(encryptedContent, keyBytes, initVector); + decrypted = new String(decryptedBytes); + return decrypted; + } + + /** + * Encrypt data. + * + * @param plain + * @param key + * @param iv + * @return + * @throws Exception + */ + public static byte[] encrypt(byte[] plain, byte[] key, byte[] iv) throws Exception { + PaddedBufferedBlockCipher aes = new PaddedBufferedBlockCipher( + new CBCBlockCipher(new AESFastEngine())); + CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(key), + iv); + aes.init(true, ivAndKey); + return cipherData(aes, plain); + } + + /** + * Decrypt data. + * + * @param cipher + * @param key + * @param iv + * @return + * @throws Exception + */ + public static byte[] decrypt(byte[] cipher, byte[] key, byte[] iv) + throws Exception { + PaddedBufferedBlockCipher aes = new PaddedBufferedBlockCipher( + new CBCBlockCipher(new AESFastEngine())); + CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(key), + iv); + aes.init(false, ivAndKey); + return cipherData(aes, cipher); + } + + /** + * Encrypt or decrypt data. + * + * @param cipher + * @param data + * @return + * @throws Exception + */ + private static byte[] cipherData(PaddedBufferedBlockCipher cipher, byte[] data) + throws Exception { + int minSize = cipher.getOutputSize(data.length); + byte[] outBuf = new byte[minSize]; + int length1 = cipher.processBytes(data, 0, data.length, outBuf, 0); + int length2 = cipher.doFinal(outBuf, length1); + int actualLength = length1 + length2; + byte[] result = new byte[actualLength]; + System.arraycopy(outBuf, 0, result, 0, result.length); + return result; + } + + public static void main(String[] args) throws Exception { + String appid = "canairport001"; + String key = "1111111111111111"; + String xml = "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"; + String str ="fbac6c10aa8e0f946e02e0b57b35c7483b57b485c41147c31511ad1c212e3388ed223a2ddadd8d98c2306841b58927d8d8da4013d4057a20d00d87fb6c8ad3a66495638b6ddb42e405acdd4e28d0de2928f5f03b3b049070d4d1302f9cd9886c3b0052e1e61edb0f4de74c0f592a22d10bceb06944688c5a0521adb37b74648a2647357229058094deae4950053f6d67db76c4d013c024a1128b471f8d5a0f4765a447fd92eb6c84f5db6c5b2aa0721ce027d311cdb95e285f6e6f1deb6027e9a666ab5600fe3d094f7008a08b415c876d8fa48f5cd0e1b66e2a81fb8763c242620f4109607e17a9ef8e61fedf630f3900b34b39efd19674d1a9968b8ed5ecb7f344becbf2d9928ab6e52cca89dd261538335a3e14b11c216dff10ac1567d5a52a26c600265557d20b8bfff97007526371b381652dc12dd92034f8d62d4a760497dc3c7168d03932e33e455661157b36a13c6ac3cffb32a2a21816333e410dea8a147346de7a83b26d823056be8e9ec18406bb7e5e95f164e0e69c6ed398d3163133d6aa912d239897720db3392766ee5780da46b8ecb626aeb22ce4ab2cd1e397ca8f9063796301403d1b9a26cdaae1a90789d1d036c74da0566a4a9428dcb4af17d743cbda2de768d90001f485145254da6a60fb4ada8419ba906bd38c991649f8422d98fc9ec8d55503753e274e8a16ec9a6f06f04bd4ea99c9e4c9b5389bb077c8a63959fbc2574456e614bb3b64d4469c8d8d773fd774f366c4f50dbc5f985afc2511f74001dbb1947d88134faf58fb4f9cb43047e4aa5e821147d6aa1b868cc46fbae459e5a784269739b157ea59e3c7bff6b28b6f0f9895c1ddc23467d221a55ac9ca3cb6b773a94b7dcc86e73bf3e467609f4f700a5458e09aaa0502cbd60e48ec9b832274e262bb1112299ae455f00e7ee6fb1c80cdcc7dd6fe3b34648194d7fbea874d75c3ab27f9f7d086c45c57ae6dafc19164372f7a5d73bfdde04c8b99979be281618e12f5c272757c4029ace9f6404aa48653a12f95e42dcdcdca201c5efed5d428c4c366dea3af9eb095f81b6daa4521b2171585666342e9d64f6e80555da4bda8444969fc9fe02c0b7ec6aad78f0286dcb39f0b2c1a358993c7a9920213ec814496a8cd345a25ddbd41ca6e31fe9f6abca80caac322a613ad28004dfafad578c283b7ebf4066fc16f269e4a407087c1ba90a0d7c6ad53a9787b75b69eb87cd610b4cecfaa1da06194dd03503a4025a861e283fa72f70bbcc6eeb1c7018a13e4570c9e42cf6e844fbf1de486277440bf7bb2ebf956fa6f35507681645fd4bf0fbd055d7c2345b7eb495952948bd5ea12e965c190ef6dec77f838520ebe691d95f3d2ba2cc996b67e961423a3a8873ca617276090ef06152bab734986e74674a51d44deb8979cefc535f43c24482918463d8c5f64becb3f05ff01ee79664ef2569931ffb861205781ffd2ab558c3d40cfd7a93821b218ff92926f92ff1ab666d8464b97b76f724e399231cd50f95826d1c9c37ec6b919c5c994635d416979f89e263cac32253c2f823b435c5456fcae93be60e0ac11bff83613503a148c67f4faa4d69a541e907979b15b2b3286180e125299f593a7e25ef3f41d9b0abf0f36e576ea2ca352dcbf911b423686da8ffc8c7c19e9fc68eba8740a3278907bad0e8abf3b853f849bd6bc94b88ddef0f773ee7af3d057d4991a1e947ccd3cb1376e69479177ee66be454845375fc60fdd244f25797480b0fcec66ca98c98f0c6b8438d04a5488b371ea5e09b06b304a50019c7c937ccaae38530de324b765bd76a86837c6c0d69728e4c5c2b2aca45fa2046d8d93c676f37b02013c0b3adae166ce251d4588f8714af8568d9ab35d3bcde421e9477bea3eed0389332f8b45684af4ebbb441e8a672b06c78974748de20faa2ae4a18e80120c4d33a08dda7f7ed386a76152e67ed5846e089fad1e39d5050d58b8a2fe2b6a4b25a5d7fa4984916b1953292fc7c6afa6d1d5579e1c9f567d153f52abc4b9e33ed1c02c531c2b5895761a0f070988659e1eafe2103997955ef1780199f0862c503230be370aa49e45c81d70fa5eca0dcda5bf017878f6b95476f3512e3fb43b780659b977af63aff58a3378f510d63c17057709c20f5e0300679ab70fe224b2de34bda56f5c21d0d45a4460bd286440e17cec82796da2e0d8af245a35db1e29020bc7e9030891c7af357de4c32400244ba1c837a2a1a9780d8297b9705b0d64a4073b8998e0c60bce73327eb8f25534ad31ca0b2ad2fd3c650328db045fb0ec28e992935eab465391c4b9682e2ea49a152232c332a0134d7104d7b5a497a927de813fd7002596ce441f35038c4af03f5743de311f2e7737c318f964363270e28d308cf523eb26d27c593437b4442f4af2f4a59413459c01c723e7bb3e0ff6e99e2b49e961075a0424318bce841b3d734cbb01ff9a2c85465280ff5b1b9d1bb7621f32632c76ba5556b5e667111f58ef125ca0b526d483414b8621501d9122717d30d40d46bdf9a67458ad2c9d196904154302190a336d422a461594b1060dfd30810c79037741bea437e4b27eb2befb07922bfe2c6f714e75f4f7a0db9e59c3c94fe02fcc2b315d1f518621b1d2a2711b7141f720697468ed8bbb5f54552ef4d59c0421bc3b07f0a8daa2c8de0e8239a92bbdb6d6bac60a9da08ee3e495382af4bfe673f6a74ba25b86ef54b0205acbcd31d29cc5109b3a49e8648a0db21746b0479c3dc25b5765ee5ccfb3ad484bf1b21d9408410f4863f01704ae9caa83ba1a19743641c69fcb0bc8c7012202c0e86917b9758fbf1d2475da7b8c714dcc87362b1a6b0efc831af6abe6bc64ee5b908c90530c86295d548bc4e60d626ef706b3cb2fb996f14dbba2208befbd68ea9418eabbdc1d87f0dc463b48a5b2e0bcc11be8fe697321c74aef6c4afd662e16e861f9c6f5a90e5289e7af998cedbb73121ecbdf0ea3ef32ad45452481afeabb166aa0c064686450616441ea6c66f5a9cbd9ab18ebcebd219acfeecef9fd369b1742db9b0a2c9db6f2c55b59d650a387d4ec6e106d69915d733e7a32b7ca9d9850b44547af581630dfcf4711f78a967daf9b9ca22e8c4be5adbbb1da4cacab3061f928207e6de93f6a675c272163868101dd80c83cdec0d8166190ec08bf4c38c5c05eec84fc6c8abb02dd672aa901f87430a4b329f280f61b431cf4357c010b4ad3e308b36bb4dd92e8abd27eed8688ced05327ac42f27e6bd448645b0ad5a9d0afe597e87504fe78648df10671d89617b422bc5492faa73876c4e8a8861c3d4e69a13de32a214c1a89fecae026225e62004ae3dd937e27fd557ce68a84c1575b0910cddf28a92932414cd9fb1dd29ea2bce3444a6d0a98152b1991f028236784c5bc937ebafd7decda605c4e372933ab6975a0db312d791f231fb6aba5564468933e16cfcab5433fdb4a9baa2e0805be97ce09b452b29f7d1aa03c2c79a8dd8796e356b18c598cbb0f943c62ebb9c39ecf9f99c013301621d55079f7a6cabd8bb2937c535d6aa802a16d6451ce1aed115550781ebaff01738800739c2877e63e8c499128d8e15d5b4b3291f48e8507cfcdc7ec76e095be149f27fb1dacaaa2ca09b4161bdd1217cba428884b885356befdd8371ca9df05eb394b2be93f24135b23603f42106865202175e34bdade14c14725426189eee00bc3f070ced7b07bca5c263f4f3c1ba69cf45092c236afe9bab54e2b09d9dcde437233665ff4af14b871c0ead96d34a315832f4d3d1decc48e89d47168c86d68565645cad3b3ed6ca4a95b19d1acb678ed2ea8cdda36100dd6e57a76ee53bdc65bde1fca8a0b21ef66d0f36f0a4dc3b9c9350178fc8614442cc63aee58f5fe23c83fdbf4393f65a34494439577034d5eee6b76d2ebabcd0d4a846cb9a6c884d7789872a1c653edb82fa814f6fdf7436ad835d04771f579f6261bfff6f3ff23e3054f63f54582c43f49be2142b6aa99962f87b342d4c771874e924b92c175167016de0a67d3807ec298b44e9c9fff071b0fefc1fd449b38b999e1b711c6dc8a1a85eba594b03550ce89db6d2918ae2fa5e5ef87bb2432201aac1b2548b8556cfec7061d7f37b38ceecbc87dfbd819a725c7908f89b5b1dabdc65a460d418d0eb7895c99994d71c85c41ea9db57088586093501a41baa9fd40df3278c2df3f1c1f788e5a821054cc577df114777934c5fccc18b5d9299e32596478e1f8b5742fcab870ace51cf3601767388fc998a45d0006f9c010e1ffbb1bbf192866fe6da787d9de9e16b202835ee3067b8a5710a6f9f1e5e374924697189eede8f05d5a41d526473d084bdb0a13d012ab5fe258f1d2eef68a51fd813588c8fd5b6608c6c541077e6ad137c6c1eaa93c93d3b326a44f4995f4e1cad48a8d386369ee16f3ad7c1d49609a504fb2ba49efca355cc8c53a0a448972c6419c1d696fdaf237264bd06069c2f613e45f867af01ad781adde5ca2d566019f08fd2fe9ada26c35f3095c1384709062e240bafd9d5711a2478bbb39af17366d5082dd300b92ac6581820e0cb183d2b4eaca538831ea3778681b519ec4ec96c1f20d34eff13ecb71d8a1a7184904f866bb2dc814c80c455de5f2e5017b1e38b28c9d26f49f175e158a7de318561e5fa97f6ba9eb29ffc521b94466ab4b4c00b6275b19965974867f1380787b345f23652a2a06b1cb0c4b36547d60700d915cdaff7a5dae4ccc5902c8dce37d9be2e8eed228d5bd64212a516bb35c39e9f69e52e22f2b9e6913c53d35f11eca8b84557539e631154b6a71ec4eab16babc158af1caaa742523754884ef69c62a3e53a3db0f551d4767db571fe0a8ad6ede1ae3396b40cdc19ab01117d44ef5da09963183db0151024e235aa97f644b99435b61f7c60d4c50d4f9fc48e3bac8bd57028744e377b829c44cf77451808589d3d6b19a09511d1bceee9d0cd094d2bb181b5148b23c456dde5e54e97daa5cdcd8c33973d51b7f2c08a5a6f26b58cc7bdc21108059f04497149a28cca5740e3eeb72306ce4344c86e2fc50843655972ce54a3c6a2c1fed2ac23d36666e9a8369b51d206636615c6a539cae30e7d0fcbf6275bbdfd9d509bb7914f2728a8c0ce039161b08bd7010a539cbafad0a97d0847e24a3e05cc2daf50c0acf4409376859bc201b9397a7d5ed07f4059dd1607a564bc0ec54ece5b5c1680a846616e0c058b192cd8780092107df2d47b84c161b79845d1bc6ca1043ad6977a1dca3264a54b8e4db17047de9bfa2cf77717ffe1549230c2afa1684dc2a3bc7590b098e7a896c57e0caa172cb1174e51bc8d77d831051fdfc01a7026d8904599fe87659c6781ca120e011bebd6e111bacb09743c37c0bb20545df91c6ca2ecee2112a4eae506a35754f7d0d302222c2a70c665f3ec001aab8c375cbc11f0b5f095e75e3ad5d2d18eb3827a44de165e92ff980cc2a1043b1049cffd185a49131b7d6e58c90eed17b4a4a82000e7bb5d79269fa6097b37a854d9a097f2e3c83238ff4efd0e46d46accf0ade825b8b60702a068f1302e6e4115abf25254998830cffd6a6119412dce6c6f7c6f9f28a01999c4afbe2cd4fda127cd883303ad954af1275de70fa7beacebcbb4b2c6fb98db13996ce62f1c391d222241555ab9856d2bc8cd5813b7ff8da47a4bfa4d935d22399713fa76cd827f0844a8912a230146236ca61578b692f11c5def686fd96364f8a69a98d8116a92303a961a1e025a7e39a7d2a210168359c751771333b3a539a24c45724a33f64460dd32503de82e709aec0b9d98d5e730e1126179349f9820e09cbac110a9864678311c7a5f043e1f54bb2202d59b6cdb7f9622d9bd9b5778a48b3f1d42207e762d2afdd107a20ba985d6fd6f9955bfb9df3884c1c305d4ee2fa9fa90aab2c23019b631350561456ef70659af1ca1853f91619993f8a00429485bb7ce0a77c816a6e770ea07aeccecf5a8785020311749212cd00223b62512280205294429276cc70926a8564b09fc962fbaf993aeafc61d386b0693041088f2ada92940e4f8e51794875859ef60007d700ecbe9008b39ccf670a563c844d88d1468b9ce1258a76d4ba80ae2ba12dc2bddee2c0bce309f025d7735230da73769837ab031cd6949ff5396a59fd9d76c5afdb708d31d4c29a19c4111f963502d8b1db0db6debe8bb635cd924c1e2c269398f110d77a5bcabdfac88873a1c33cd1747429c3798bfd1548d2e38bd189a9d33e4b65280733e011d9437ea28953379c7433d8d383412cfcfbe838b8d10ef2697c84c6695dfba005b0b4d36f8a3f627566551b02c27e2549c253110ff7cdfcd643e2379f61073e75b1d948e8ccb831014f5c525af48ad6643b25640497efe02fafc996a5db4d02ea8cc1baf565c976f049f77f88fad8864b196792fe58174eab7ece45f00a6e7ab13fe58b9f023a58623def2a24a5ccebd6f6205da136d53ae9263bfd558f64ff0f002c94f252a4bcab6bf514f5d87e63fe69aaa6609894d77a1b2dd6c8ba30fd360f0fbb6fdc8d86ad91582b726675d92ba54d5fc422d3f4cd85a53bf78ca9d8790d2fd0f1e9bfabbd9bb8a6e484564344d3d4f49caa2b69cd3593f2465cbd475a16c8d37a3066fad9453af1687e0090457eae90b3ece7faadb8b9b681ec5b65587532f2164b1b5befc5b46224f1a670c6f7f2d2e2bdba6141305bb2b7a607f9d8f2ef72d622cc766c093560e51e87cdb7a937c8904e1ae093e7fda741038d0537386ae8426bf16045a38f1e2eb905b05f3adad3fc82bf54839bd7b9630179582c4c51d2a8fa58191a6755844588a5d004d1c1b6255a8b91f7a03c3d528b621f67b332486cb2b89f09dababff6dbc7eaf079058cb7fd507bd49b76fc77ab3372d7589e3eb25f4730ae52428c0d9c12ac399e2836d59c84b757df3aafb1f50e4021120bf64c13eb304e89a9eef31665faefc6ae952c5b808465cb5847b9731c4cd789a86bddcdca5d6120013a335ee57a8c848a8b94d6520f35a61a211ce37f26d954ab6a90f5ce78e1f9fc59f059d5494140b03159ab1d213bc6a7d6df9326e38ac9ed6481afafb49a8e77be93cdf1944b8a6e27d9a094a5bea3227284dcb82758db0b7be7cff7a1e609f9d2d7e99920c855593ce73b05c9a1753793699c351f01c5d502c19d0287546c774736950922280986844a8c9c7b80a1e34093ce16da0c87667c1384a622063f3804e09c62f18cbc9487e0963dfd856fbd30097bfb695db1ad04f53ee765869c7925adb42a8066940e0f1bd0dc70e09f5539eb3a9aa885f8e73dd505a8ec1599f66025bc1cbf8359d16d96595bdf93b003da12faa6d0bad0ed0e4e86e2168cd212357348ede4e29e7be72d4b9c05d789f17b4ff383cb68671da6c323603ccf16b7b68c22aa9ac49c60f7062e40a81ce12e92a1b805bcbb225a99654ee54308e3c7de3f95a0f583ddc6772f20258d56e0631371be878e0f7895f677d1b730581aaadedd71658ecac4648932a8098c5093c84adf28a25db83255350ca821e5f52d083abbf9c2badc3aa80c6498a6c1a1083fc788cccf123f802e08ad87d4eb9bcceb4006c093823e87d950734af8b96fbf62045a6c557844e8cc48a31b7a27f1a87982538ddd5499d002e35e2c8298957c588d757ab5a9228726e7ded98466d439a55b6e51c614eefc16878c19c9d3b6c6b8069c19ad7c1798118cc49f33c2e20986f57e5dfe626ba08f8c2692bc3a6f745d3306804120c7f2c31a5970d9242f2ef0df07b97df3fd21188140909aafc6abe8eaaaa20fb85ebf60a12e4b97d77723fc756c94601e47c0594e866bb89c766caf2d26fdc0e4bd583040ea64f76025929aab4e6e6fc52c8aea37d29d88babbed8874a1f77f8fa4b80f67bc9bc8117f06e7c4a9415039d40f97eb4a1aaa4660fde0fe898b15f5488eba4f703484f2853f91ba314170b3ef4eb609dcbd7706be4d69a23b44a9fcc66155388f9ad463401a6984d337e7cd3a3ce1dd67ab91b205630c07b2c8967e291ec07b3137d1ca493daeec28de3a188e930c645eb22bcb91a2bb6ef6546ba257b88e92cd7d507acce6fcc2e5eb42755a3edb930c26271e4416e17a619be680863700860c8e93f47c035a90ac134b645744df0e04f8724876822979568109e6ff2692d56cfff74cbf7ba43296196b4cae1f2ce3652cf6d86e9e2c29266d0b1d2241eff62d4b5eb684c521bc5a81bc5869764958d3c17e7b36d73dc610d190d12835baff8b1774550c7660f153701ad7ac39140ca923cbb33aaac15d4c56699c7fcbfff96a01f2c1951857d0245c2d202c758d29e7452fdbf0f4ce29ba1610b94f6fc781b66d13bdaa08dda551a07972e84fe64296a069887ad13315900bc034b1c3d2748ac8166bc87b421a22eb2b213ae05e8f4449fab2699a149d64b7e88c5123615baf6f5479a700e4ec9e7f0605ef2927b252f13a5872082c09ef3534f7faed1f05910f60ffb23b4aafab763557680279dbbdb39da01952e766daca892fe6134b78aaa2b85ad50b3a6b26323a696f88ec478545e68b01886cf7a5fdd6254bd78c579d421c73274da92626e0cbcf857cf5d8f2bbd171b7ec000efa955f02821f6d6d9a32c4750472038a377051782abeabb84bf680a2d3b53fc0e356640a0735a25cb1894350fe7e9b6b399f2dbf352a1c51dd45e4f85053f5b534973262829e9f324082693c960ab0f9d73ff23db68efb09396e8cac04fa90e0e3d1591f9233c882922bafa0e310f2cf717b33b9d954d9fa972a06b9c04cf5515faed843066cbb3316f725cce7468c9d475a2cccb26eb6867787817fefd878c3710e5e65211168f69f2a293fdbb72d59b33fdebc4fe2130073cbb1505eba12a52e466414ab6dfc886fb7eb3fd70603f077a9cc2e1b7ace14eadf011e6373d22eb2748f71f1f7aa83935c4c82fcb85b317d077d251a9c1eec08837109417c9e6609f5fe80b752e8adba3635e4a5b2fdebd8dac1c07d081c0b73c98397f3f961af4968d0702dc7aba230f2da6863fa4e662e5cedc8148a9d69e7ad07da558d6ee905356219a9367fb970596017329014653311b3dd08789736c4c8482ea3c783ba70b7b3aac3675b5ec70d61878073ebceb530b3f377431184dc79035e6c030ca86f8af1a754df4f8ce6f085ebcfabb035f1f78f3b917901c1a3148fa4c0160512994b29c06bdccd6322a22a45f7e5fe5a4d8f5c68de0fee7973194708b9dbc95bc5a4c826ecab8dcfd61ed391e6fae0348564fd6404b6e732834db2589ed9cb2cfbe3e97c2241e684e8051e998c3afe3a7e60a373c87dcc905f4bd1160a7266067aa058367643cc66dc37213d94c7efb264ab98aae9eee92efc4812261d4383481b293143bec7edf57f22ff7ab0b63975c27212eca0cc41babf8da97bfd78a83c2d2298a398a3742cfe85d3fbe225c2c24e34145d47c8488a6917de1385c8e2529a91b7d2b93b702dca61b946dca955fbd0fc2d05167e93f79e8e19134559881bdb8eff0f9570ef5232cef7bd20992d2038da12fb483f1d54912737e7d51b83da88bc2655a710aacd2cd78fa46e6c997b0b5984f103b72de334646ec751a011d7b264308028252f9dcf728cc3c06b9d9ca8e3bc1a1ff54a3064f1b344446c7575d1276a8bc9db9ffbca4a2ea8e5b1e61f67af346dce56c9b37ea706a6ff32a19b9b4067e5e655168b7a73976613630e877e5dc03d25e3be92ad1b0cd813c1df124d39641d0858eb99b6a756fd1f207ace0648433edc47261b5b222dbb218a13f1456e875888dd2b61284d3d5561ca36eb65c609f52e17b126f85986216962f1625829d18d94d389639e107e39aaba878f07400d73dc63177c4d9627dd26ddcc801161274ef21e965453d09207e700513e79ebae00c384ccc0ca81bbd78880d22f491f9d4dc1c0877145427fa1e04a7bdfa8402b9030837e8fd2666bffb99a205fb2e365a1d27cab81dc396b7b116f159e3ef7cf6cfe92f7b223c0c1217d867de5e9a34bbaf4b8c7d6b1dc737dc75276f83e608a18aac5088b9b2f437741f0d50629dd2120407d92d1f4d263c5454b152e8806c53875e956529c8d13a50eb99a16de7b2e80dbf2dbcdb065d42010354bf57f03d7df22ce95c279cac35e6ca7b18a8296a4841ba07b734ee8463d4e78e6acfd48457d24e1527f6105199cf1eac36454842315befa348d24966fb6b2942b9b6fa28e026c0d66cc806294429d3163b9ee26128f4c4e7e49e5b233114a7eb8e6c3a6d45d3780d9111e8ac0f30708036eae99e8fd69f915b4d9d48225fe4336080394c5f726dcf9f2eace37b55b5d43412e1826eb6e295ec8da5062199de904ecd2fdf8a4d15924b2160bfadc5b303722965691cf99d5cccbd8c29f010a9838a64c09d5bce90bc08f486812e638001223a448921a689afa6d81b7fbfdd922d3c285e9182abcfbe305c037e21102a8731aa05d8c1cd4db39155f5d1335d02b15422e0ef328776006129fc0483e79a310e3efb2500060a361e204033d48be6249b66739142a82e03ee06f5b16c829e647bc29bfc9b661225820d2cb849319b6d0448f7609ec723e611e8d1f03da1448538fa2ab9344992d4bca82ad71325d3575996f8fc7d91c191028fe1f6f246ad41b63abc65fa1e52d6417ee71c0e5da26ac61c82a57e7e4cc26fd3deb1491eaa248a49479977b353142c39ee018f1262137d37d1f38edfc9a2e635d5153699d976e5aa986db9a65204e5346482275ec21dfb482e836c6cfe8d494e64dd13561479c7ed46f27eae0d80366c836cc11f0cbf8f197db5bb07245263249ed530d4642d1e241f231b795ffbb7b18d28e4962f77163a10cbef7db92a19a0fa866e81ea53a3d36f21242d05c5f1c0bb4279d3521f902806665a04357990cf1d72460ae0ca2e273467ed5f8333717d321b3ddd92f0b2d31f5744b5d49810d8c4ba6c47a51d7d24e30e631b8e20002b040a1de5075023ae897daafb4285146f33688e4792a79fcb36824c1a98091c7692b1e023c548c40afd8d0586fed448f2e7da560c6902c85935c5449ed2e101610d34ffdc6076fc74f87ca3a76d1b667ec38c9cdb33c486f8579e4fb861f1d3bfdcd7c4ff114572a4f18fba187ed4b030a513f9ed252ba1b6a9d4bb1c5bd70e9e6dbdf516ccad5c69d4b9cc28b8059ffbe0ac48adf1340b4a414fb897f51a3d9c57299da011f6a57aa58995c6de5814c70e6caf7a3249bc1ac29b4b9ca99c6656fa35d7846a34ea40796f8c1f05c5d20f05d57e1deabeb5a84537694213b934476293fa694922f684f66617e9c97628fe9efc0c7295907744b67140fccc1690405fd3d6b185566652e1e18c685088cfa016cb194c2c86ec2e39d7825c977f68b46096c238734226e30fb014f774660c5f1c0116faccdd19aa4f3906d734450a5f31f0ae22ffe49534bd20a09eabacd7a49f0e738c333555dc0877cbb778b840a038d281a597bb6ff79d033843c0c8df0de3c0454862ee428303a80eab6571ab61a66a19bec2d8a8ff5d573f468ea26cacb3c96745c4678c795d742b98533bc61d8c930a100cb9a757d62c554f8fa7bde7d019fddab57bf2d6ac7cbbb5b85d5471e39314c3faa59e5df2400658394df152a8f779ebcd0dc489e5eb85fb4fb41806a4e40c14b226236f0e419880ccdf739b5fad7958c35beb243aa33713eab7a8ce29f3b2130cd7460a6ddaa62cc4abdd8df7c04465396482f9d84c8bc0dffba4eca9f7b10f043194566cad0408033ad53b704752964bc354877cc7c494f2714103a2d6fe12ab20a5ac6042168cbef3d0448c12fad8366d09b03830bbd359d01139b8e515660217d82692f5be30999cf60e2e7e3c78f00fed47de7994a6b45c9843c7da8ed08998f392e48b72270ba7375b61babab937410848b3afa70f9e7c5bd68a0902e12a4ae9617f933ec03270e7560cfd333a4fc525d17122913e7d24985a9becd1cfa864477eb5ac2e061616b52f89b4e8e893449ff951ee102ff45e266d5c0a1225b5c0e57ac95e557e6a67f331ef68012323b0fb73a6779f715b69d41dff6fde128fe71676eea5999c97da5e6e0c0ed4cbb3d3fe70e3e8ea2d03f59e64fa9d45c81bd11b99ff33e62503935e50f6c04477f45e00c014454ef64dd49bb92fc20084766988adbc9b35142dfab262f456f0d9e3dfac8b6d4106ee5b1513f9cc215343cefa7854ff68db1da31db4d2f80caf1e52e4e14338137dfe9667852a3eca6f42dfe381796fad39d932adfa6b847199eb56dd04cae2697a7ba7754f35c37317f81d62f3eb7f5a764874efaf1c9a700d5261eb8c109921b453398f459ae6482be8cf6d9705a8263d4c67767e88997d078c15a246bf59b4d53d407e16950366d8f126ec5cdaedf514789364364b4485ed7a325d7c8fb964eaa9b140e797e773c608e7994c066b889832590c6ff7469bd154c3535ca326009aa23f1c9d19f947b978b2b08e3059db117d7d20da5394b549e0931d29af53070f8b40f0cc5cad338e4026687e73e87f452f1e51db39bf3334e1ea69496c9688609fb22c0e51619c80bd8c5cd573f636243b25941ecfa17063e8ca1a21fec58aeff87fc1bc3a92ee72d9501f300172e683d6e04b38b7e89de1ff5e801d0d881c314a75a014754a9d2354551e4b24b6b2d6b486ed49026b9df0e82cb1aefb84866fa849911c61c599365ddaf73c8679ea4d9d22285fd72634f5dc700978d7fdb61befe301012dca2dd103d6752807cc204a6101d110b6a5ecd5aefa8af2b1fed1ecf15b18e686d202daef48825213e302269ba386a17049b5c4fab54de595a5e2328f27088d9f56c6bc129ffbac88aa5638e5449f361abd1d2d91f2f65ad1ad385b6d5cf3e3d9fddbe1cc5dcba2583601a81ac376bf07a5a10be0c27c0424cc38c04c2f253dd9fd01a205ff68aa49c0725e129eb3d9ba390b25afe3cac92a38c050a205549a0aee293850081ca71d3f4b86c72a282072a7e454c66a1304be0123e6cbbdc3d855bd433379d194ececebf86163d37f31ee15e5edee526cb7cd1cf96c863a20b2f90b4b58e02210998026c88e8e1acfea900518a8138034c6fe0d39a54ddedb04a3c66748bbf6785cb74b3e8d3518f8079d005cf3ae15cdac1abaf93d5827589d089cd7daccd2da464ed3f87d4b0cf32cbf298aa6b09c660068b6b3b588bc7f0f33f918bfdd33c75353b623c26476c4e9ea9b5400bca8a17a6b5ccfae433f63095e2c0792d601487c47c035999067135d61b0f1946db4b851aa2f7d586c19e838c2cd38e10f575d0b49a215482ec6ce25fddfbb00f616296846007d5271520fa7f1ac003efd7b1a0bd7eb7a7bfa7ccef8b402369d22165e07c9476fdf2aea66c34e8c92a6ccbda6719ec368893bfcca150c6829513eaabdbe7bf2f37245e3b160e7ce7ecfd654d3360a77931d50c63daea7579b4a0c92fa1a6a9c971f27e5e6e2e19a077227f6bf69aa6bd7556dcdcc088646468b4ab2db6437a66e045b15393a50b73f9a76b9816142fa10f324f488cd6215b7967a49f097abf6955e22732cfd3ec4473e73557f56de4db376b9af48ca9f83135ee7220eba45c377b01ad135811b8ed810c0a3fcaf10469a265ef4f3f737270b9a80f617f2458bf38523575c9022668c3760df9d88e5c05367b6ba0079ef9cece2f61b8d0eb23cd40670975e74b4c5a3607f2c4410fe0bd59b6b01e3c7f2ef03437672093b43bdbc8fc82be83544af3c7d53150ab1b3ebccc9219e8e72decde672e233e80030dd2c69e9abaa0b0db9baed49218c7a6940ec6fc4a887c22c3a5141362a7b6f615c15d60fc558c997603085895617e6ce71a57d34a30485907d27703eae64991262fbcbfc8cf78219b6fca49f1671edb0215c1b75b1e266137bd6a142ade281a0895099d58803e0a450cb8e2a171613f63e3c417cd166e2cc0de70e152af55743dc12b5f1c69a740ef28f7ec06562495fd3cce4b2ededb368492f6e2509417f4f0cb09dd4f57e0c33e7816387ad6b47922361f6d86210fe516a048738db895c0a2957031883704df1346ac31b626e0f0221f602a98f126f8962513e54bb2a5494c98b220f30f564980fac36dbd33ce7b5090201b106d169e86ec8f0fc189f85ecd5beb5b2a3282dec14e52aa4e2f0a08c651ad6bfcfee47eef72d139c72184d7715c49b3dbbbaba3a7f55546da5bdf45704d132d9cf3524906c9943d66a0c0289863821fe4dcf1fb001f44ca95b005039d2467d49ccce0ff947c3ad9497edbc36aa227ad9e1389f5b9b2df87dcb1bb6029d6141559218323ef7f99f86ee9e937654cfa20e829ac33ebb44fdaae313b4fdb85f2e4e0780a52f6cb9b4b709d5b70eddd93d45109e11e579bd4b2d8ca82bc3b4b3e1909088d9d15d598dde6d44b107f8711e16bc04beeefaa3aeeb815af7f594461e0946337cdcf0b14feb35ef42aef3455b057ec56fc04aaa30ed1cb6d53ba35e3eaf0df4046eeffa3fab285ea31598e7309ddddcc587ed4ebcf37b2e317b0e1785a53f616d767152ef313146704c80990e3ce9f91bded474695cc227c8174f5f5a1dc8129ee37759756d54a3f09e9e642e56bfbc800effa2643b99f265c9d0ec39c0e4b54a9c34ad71686a082e371bdfa3fb286f91113b22d99d7c4acef7c7da5b8d1e0f9c4c553ec798132b98894f33eba0cd30b40374e686a521e8a566148e5425f72f7750fa108aa12741a1b04fdcfb1df6b027f45c4f1cd8d1b695509b907280e49e96b8afdc71cdc576a51a9944429c10a9026cc52e45e0ad4"; +// //使用aes加密 +// String encrypted = AESTool.encrypt(xml, key); +// System.out.println("encrypted: \n" + encrypted); +// System.out.println("encrypted length: \n" + encrypted.length()); +// +// //解密 +// String decrypted = AESTool.decrypt(encrypted, key); +// System.out.println("decrypted: \n" + decrypted); +// System.out.println("decrypted length: \n" + decrypted.length()); +// +// +// boolean isSuccessful = StringUtils.equals(decrypted, xml); +// System.out.println(isSuccessful); + System.out.println(AESTool.decrypt(str, "adjdjfjfjfjdkdkd")); + } +} \ No newline at end of file diff --git a/src/main/java/osc/git/eh3/utils/HttpClientUtil.java b/src/main/java/osc/git/eh3/utils/HttpClientUtil.java index 6079607..632aa7f 100644 --- a/src/main/java/osc/git/eh3/utils/HttpClientUtil.java +++ b/src/main/java/osc/git/eh3/utils/HttpClientUtil.java @@ -42,7 +42,7 @@ import org.apache.http.protocol.HttpContext; @SuppressWarnings("deprecation") public class HttpClientUtil { private static Log log = LogFactory.getLog(HttpClientUtil.class); - private static final int timeOut = 30000;// timeOut(Millisecond) + private static final int timeOut = 300000;// timeOut(Millisecond) private static final int BUFFERSIZE = 2048; private static Registry getRegistry() { diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml index 292e105..3b1e1de 100644 --- a/src/main/resources/generatorConfig.xml +++ b/src/main/resources/generatorConfig.xml @@ -24,6 +24,6 @@ -
+
\ No newline at end of file