Skip to content

Commit

Permalink
optimise
Browse files Browse the repository at this point in the history
  • Loading branch information
javahongxi committed Jan 18, 2019
1 parent f952e0e commit 75ae2ff
Show file tree
Hide file tree
Showing 43 changed files with 233 additions and 234 deletions.
67 changes: 2 additions & 65 deletions whatsmars-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,6 @@
<description>Utils公共模块</description>

<dependencies>
<!-- 图片压缩工具 -->
<dependency>
<groupId>org.imgscalr</groupId>
<artifactId>imgscalr-lib</artifactId>
<version>4.2</version>
</dependency>

<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
Expand All @@ -44,18 +25,6 @@
<artifactId>httpmime</artifactId>
</dependency>

<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>${json-lib.version}</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>net.sf.ezmorph</groupId>
<artifactId>ezmorph</artifactId>
<version>1.0.6</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
Expand All @@ -68,41 +37,9 @@
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>

<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
</dependency>

<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.6</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-asian</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>com.itextpdf.tool</groupId>
<artifactId>xmlworker</artifactId>
<version>5.5.6</version>
</dependency>

<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

</dependencies>


Expand Down
1 change: 1 addition & 0 deletions whatsmars-earth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<module>whatsmars-earth-web</module>
<module>whatsmars-earth-support-web</module>
<module>whatsmars-earth-manager</module>
<module>whatsmars-earth-common</module>
</modules>

<properties>
Expand Down
107 changes: 107 additions & 0 deletions whatsmars-earth/whatsmars-earth-common/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>whatsmars-earth</artifactId>
<groupId>org.hongxi</groupId>
<version>Rocket.S1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>whatsmars-earth-common</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>Earth Utils 公共模块</description>

<dependencies>
<!-- 图片压缩工具 -->
<dependency>
<groupId>org.imgscalr</groupId>
<artifactId>imgscalr-lib</artifactId>
<version>4.2</version>
</dependency>

<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
</dependency>

<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
</dependency>

<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>${json-lib.version}</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>net.sf.ezmorph</groupId>
<artifactId>ezmorph</artifactId>
<version>1.0.6</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
</dependency>

<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.6</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-asian</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>com.itextpdf.tool</groupId>
<artifactId>xmlworker</artifactId>
<version>5.5.6</version>
</dependency>

<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

</dependencies>


</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hongxi.whatsmars.common;
package org.hongxi.whatsmars.earth.common;

/**
* Created by liuguanqing on 15/4/16.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hongxi.whatsmars.common;
package org.hongxi.whatsmars.earth.common;

/**
* Created by liuguanqing on 15/4/20.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package org.hongxi.whatsmars.common.mongo;
package org.hongxi.whatsmars.earth.common.mongo;

import org.hongxi.whatsmars.common.mongo.object.MongoDBConfig;
import org.hongxi.whatsmars.common.ImageSizeEnum;
import org.hongxi.whatsmars.common.mongo.object.MongoDBCredential;
import org.hongxi.whatsmars.common.mongo.object.MongoDBDriver;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
Expand All @@ -13,6 +9,10 @@
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.RandomStringUtils;
import org.hongxi.whatsmars.earth.common.ImageSizeEnum;
import org.hongxi.whatsmars.earth.common.mongo.object.MongoDBConfig;
import org.hongxi.whatsmars.earth.common.mongo.object.MongoDBCredential;
import org.hongxi.whatsmars.earth.common.mongo.object.MongoDBDriver;
import org.imgscalr.Scalr;

import javax.imageio.ImageIO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.hongxi.whatsmars.common.mongo;
package org.hongxi.whatsmars.earth.common.mongo;

import org.hongxi.whatsmars.common.mongo.object.MongoDBConfig;
import org.hongxi.whatsmars.common.mongo.object.MongoDBCredential;
import org.hongxi.whatsmars.common.mongo.object.MongoDBDriver;
import com.mongodb.client.ListCollectionsIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import org.hongxi.whatsmars.earth.common.mongo.object.MongoDBConfig;
import org.hongxi.whatsmars.earth.common.mongo.object.MongoDBCredential;
import org.hongxi.whatsmars.earth.common.mongo.object.MongoDBDriver;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hongxi.whatsmars.common.mongo.object;
package org.hongxi.whatsmars.earth.common.mongo.object;

import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hongxi.whatsmars.common.mongo.object;
package org.hongxi.whatsmars.earth.common.mongo.object;

/**
* Author: qing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hongxi.whatsmars.common.mongo.object;
package org.hongxi.whatsmars.earth.common.mongo.object;

import com.mongodb.DB;
import com.mongodb.Mongo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hongxi.whatsmars.common.mongo.object;
package org.hongxi.whatsmars.earth.common.mongo.object;

import org.bson.types.ObjectId;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hongxi.whatsmars.common.mongo.serializer;
package org.hongxi.whatsmars.earth.common.mongo.serializer;

import org.apache.commons.lang.time.DateUtils;
import org.codehaus.jackson.JsonParser;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hongxi.whatsmars.common.mongo.serializer;
package org.hongxi.whatsmars.earth.common.mongo.serializer;

import org.apache.commons.lang.time.DateFormatUtils;
import org.codehaus.jackson.JsonGenerator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hongxi.whatsmars.common.pojo;
package org.hongxi.whatsmars.earth.common.pojo;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hongxi.whatsmars.common.pojo;
package org.hongxi.whatsmars.earth.common.pojo;

public class ResultCode {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hongxi.whatsmars.common.util;
package org.hongxi.whatsmars.earth.common.util;

import javax.mail.PasswordAuthentication;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package org.hongxi.whatsmars.earth.common.util;

import org.apache.commons.codec.binary.Base64;

import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import java.security.SecureRandom;


public class DESUtils {
private static final String DES = "DES";
private static final String PADDING = "DES/ECB/PKCS5Padding";
private static final String DEFAULT_ENCODING = "utf-8";

public final static String encrypt(String code, String key) {
try {
return Base64.encodeBase64String(encrypt(code.getBytes(DEFAULT_ENCODING), key
.getBytes(DEFAULT_ENCODING)));
} catch (Exception e) {
//
}
return null;

}

public static byte[] encrypt(byte[] src, byte[] key) throws Exception {
SecureRandom sr = new SecureRandom();
DESKeySpec dks = new DESKeySpec(key);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(DES);
SecretKey securekey = keyFactory.generateSecret(dks);
Cipher cipher = Cipher.getInstance(PADDING);
cipher.init(Cipher.ENCRYPT_MODE, securekey, sr);
return cipher.doFinal(src);

}

public final static String decrypt(String data, String key) {
try {
//base64,default-charset is UTF-8
return new String(decrypt(Base64.decodeBase64(data),
key.getBytes(DEFAULT_ENCODING)), DEFAULT_ENCODING);

} catch (Exception e) {
//
}
return null;
}

public static byte[] decrypt(byte[] src, byte[] key) throws Exception {
SecureRandom sr = new SecureRandom();
DESKeySpec dks = new DESKeySpec(key);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(DES);
SecretKey securekey = keyFactory.generateSecret(dks);
Cipher cipher = Cipher.getInstance(PADDING);
cipher.init(Cipher.DECRYPT_MODE, securekey, sr);
return cipher.doFinal(src);
}


}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hongxi.whatsmars.common.util;
package org.hongxi.whatsmars.earth.common.util;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hongxi.whatsmars.common.util;
package org.hongxi.whatsmars.earth.common.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.hongxi.whatsmars.common.util;
package org.hongxi.whatsmars.earth.common.util;

import org.hongxi.whatsmars.common.pojo.Result;
import org.codehaus.jackson.map.ObjectMapper;
import org.hongxi.whatsmars.earth.common.pojo.Result;

/**
* qing
Expand Down
Loading

0 comments on commit 75ae2ff

Please sign in to comment.