separate common
This commit is contained in:
166
maxkey-common/src/test/java/org/maxkey/Copyright.java
Normal file
166
maxkey-common/src/test/java/org/maxkey/Copyright.java
Normal file
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top ]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.maxkey;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
||||
/**
|
||||
* 给java文件批量添加License信息.
|
||||
* @author MaxKey Copyright Adder
|
||||
*
|
||||
*/
|
||||
public class Copyright {
|
||||
// 存放java文件的文件夹,必须是文件夹
|
||||
private static String srcFolder = "C:\\IDES\\shimi\\eclipse-workspace\\MaxKey";
|
||||
//已添加标识
|
||||
private static String copyRightText = "http://www.apache.org/licenses/LICENSE-2.0";
|
||||
//扫描目录
|
||||
private String folder;
|
||||
//版权信息
|
||||
private String copyRight;
|
||||
//待添加所以文件统计
|
||||
private long fileCount = 0;
|
||||
//添加的问题就统计
|
||||
private long copyRightFileCount = 0;
|
||||
private static String lineSeperator = System.getProperty("line.separator");
|
||||
private static String encode = "UTF-8";
|
||||
|
||||
/**
|
||||
* Copyright.
|
||||
* @param folder java文件夹.
|
||||
* @param copyRight 版权内容.
|
||||
*/
|
||||
public Copyright(String folder, String copyRight) {
|
||||
this.folder = folder;
|
||||
this.copyRight = copyRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* main .
|
||||
* @param args String
|
||||
* @throws IOException IOException
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
// 从文件读取版权内容
|
||||
// 在D盘创建一个copyright.txt文件,把版权内容放进去即可
|
||||
String copyright = readCopyrightFromFile(
|
||||
Copyright.class.getResource("copyright.txt").getFile());
|
||||
new Copyright(srcFolder, copyright).process();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* process.
|
||||
* @throws IOException not
|
||||
*/
|
||||
public void process() throws IOException {
|
||||
this.addCopyright(new File(folder));
|
||||
System.out.println("fileCount " + fileCount);
|
||||
System.out.println("copyRightFileCount " + copyRightFileCount);
|
||||
}
|
||||
|
||||
private void addCopyright(File folder) throws IOException {
|
||||
File[] files = folder.listFiles();
|
||||
|
||||
if (files == null || files.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (File f : files) {
|
||||
if (f.isFile()) {
|
||||
doAddCopyright(f);
|
||||
} else {
|
||||
addCopyright(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void doAddCopyright(File file) throws IOException {
|
||||
String fileName = file.getName();
|
||||
boolean isJavaFile = fileName.toLowerCase().endsWith(".java");
|
||||
this.fileCount++;
|
||||
if (isJavaFile && !isAddCopyrightFile(file.getAbsolutePath())) {
|
||||
copyRightFileCount++;
|
||||
System.out.println(file.getAbsolutePath());
|
||||
try {
|
||||
this.doWrite(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void doWrite(File file) throws IOException {
|
||||
StringBuilder javaFileContent = new StringBuilder();
|
||||
String line = null;
|
||||
// 先添加copyright到文件头
|
||||
javaFileContent.append(copyRight).append(lineSeperator);
|
||||
// 追加剩余内容
|
||||
BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(new FileInputStream(file), encode));
|
||||
while ((line = br.readLine()) != null) {
|
||||
javaFileContent.append(line).append(lineSeperator);
|
||||
}
|
||||
|
||||
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), encode);
|
||||
writer.write(javaFileContent.toString());
|
||||
writer.close();
|
||||
br.close();
|
||||
}
|
||||
|
||||
private static String readCopyrightFromFile(String copyFilePath) throws IOException {
|
||||
StringBuilder copyright = new StringBuilder();
|
||||
|
||||
String line = null;
|
||||
|
||||
BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(new FileInputStream(copyFilePath), encode));
|
||||
|
||||
while ((line = br.readLine()) != null) {
|
||||
copyright.append(line).append(lineSeperator);
|
||||
}
|
||||
br.close();
|
||||
|
||||
return copyright.toString();
|
||||
}
|
||||
|
||||
private static boolean isAddCopyrightFile(String filePath) throws IOException {
|
||||
boolean isAddCopyright = false;
|
||||
String line = null;
|
||||
|
||||
BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(new FileInputStream(filePath), encode));
|
||||
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (line.indexOf(copyRightText) > -1) {
|
||||
isAddCopyright = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
br.close();
|
||||
|
||||
return isAddCopyright;
|
||||
}
|
||||
|
||||
}
|
||||
54
maxkey-common/src/test/java/org/maxkey/cache/CacheFactoryTest.java
vendored
Normal file
54
maxkey-common/src/test/java/org/maxkey/cache/CacheFactoryTest.java
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.maxkey.cache;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.maxkey.cache.AbstractCache;
|
||||
import org.maxkey.cache.CacheFactory;
|
||||
|
||||
/**
|
||||
* @author amarsoft
|
||||
*
|
||||
*/
|
||||
public class CacheFactoryTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CacheFactoryTest() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
RandomCache randomCache=new RandomCache();
|
||||
ArrayList<AbstractCache> cacheList=new ArrayList<AbstractCache>();
|
||||
cacheList.add(randomCache);
|
||||
CacheFactory cacheFactory=new CacheFactory();
|
||||
cacheFactory.setCache(cacheList);
|
||||
cacheFactory.start();
|
||||
}
|
||||
|
||||
}
|
||||
73
maxkey-common/src/test/java/org/maxkey/cache/RandomCache.java
vendored
Normal file
73
maxkey-common/src/test/java/org/maxkey/cache/RandomCache.java
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.maxkey.cache;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.maxkey.cache.AbstractCache;
|
||||
|
||||
/**
|
||||
* @author amarsoft
|
||||
*
|
||||
*/
|
||||
public class RandomCache extends AbstractCache {
|
||||
java.util.Random random=new Random();
|
||||
|
||||
int i;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public RandomCache() {
|
||||
// TODO Auto-generated constructor stub
|
||||
this.setInterval(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public RandomCache(String name) {
|
||||
super(name);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.cache.AbstractCache#business()
|
||||
*/
|
||||
@Override
|
||||
public void business() {
|
||||
// TODO Auto-generated method stub
|
||||
i=random.nextInt(100);
|
||||
System.out.println(i);
|
||||
}
|
||||
|
||||
public int getI() {
|
||||
return i;
|
||||
}
|
||||
|
||||
public void setI(int i) {
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
16
maxkey-common/src/test/java/org/maxkey/copyright.txt
Normal file
16
maxkey-common/src/test/java/org/maxkey/copyright.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.crypto;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.maxkey.crypto.Base64Utils;
|
||||
|
||||
public class Base64UtilsTest {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
@Test
|
||||
public void test() {
|
||||
// TODO Auto-generated method stub
|
||||
String encode=Base64Utils.encoder("base64ToFile".getBytes());
|
||||
System.out.println(encode);
|
||||
String decode=Base64Utils.decode(encode);
|
||||
System.out.println(decode);
|
||||
|
||||
|
||||
|
||||
String urlEncode=Base64Utils.base64UrlEncode("{\"typ\":\"JWT\",\"alg\":\"HS256\"}".getBytes());
|
||||
System.out.println(urlEncode);
|
||||
String urlDecode=new String(Base64Utils.base64UrlDecode(urlEncode));
|
||||
System.out.println(urlDecode);
|
||||
|
||||
System.out.println(Base64Utils.decode("AAMkADU2OWY1MGQ3LWEyNWQtNDFmOC04MWFiLTI5YTE2NGM5YTZmNABGAAAAAABPKgpqnlfYQ7BVC/BfH2XIBwCS0xhUjzMYSLVky9bw7LddAAAAjov5AACS0xhUjzMYSLVky9bw7LddAAADzoyxAAA="));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.crypto;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.maxkey.crypto.DigestUtils;
|
||||
|
||||
public class DigestUtilsTest {
|
||||
/*
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
System.out.println(DigestUtils.shaB64("mytest"));
|
||||
|
||||
System.out.println(DigestUtils.sha1B64("e707c852-29a4-bf56-f8b9-014716850d89"));
|
||||
|
||||
System.out.println(DigestUtils.sha256B64("mytest"));
|
||||
|
||||
System.out.println(DigestUtils.sha384B64("mytest"));
|
||||
|
||||
System.out.println(DigestUtils.sha512B64("mytest"));
|
||||
|
||||
System.out.println(DigestUtils.md5B64("e707c852-29a4-bf56-f8b9-014716850d89"));
|
||||
}
|
||||
*/
|
||||
@Test
|
||||
public void testHex() {
|
||||
|
||||
System.out.println(DigestUtils.shaHex("mytest"));
|
||||
|
||||
System.out.println(DigestUtils.sha1Hex("mytest"));
|
||||
|
||||
System.out.println(DigestUtils.sha256Hex("mytest"));
|
||||
|
||||
System.out.println(DigestUtils.sha384Hex("mytest"));
|
||||
|
||||
System.out.println(DigestUtils.sha512Hex("mytest"));
|
||||
|
||||
System.out.println(DigestUtils.md5Hex("seamingxy99"));
|
||||
System.out.println((new Date()).getTime());
|
||||
}
|
||||
}
|
||||
63
maxkey-common/src/test/java/org/maxkey/crypto/KeyGen.java
Normal file
63
maxkey-common/src/test/java/org/maxkey/crypto/KeyGen.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.crypto;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.security.KeyPair;
|
||||
import java.security.KeyPairGenerator;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
|
||||
public class KeyGen {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String keyInfo="ASDFSDFNUGD__TYTY";
|
||||
KeyGen kg = new KeyGen();
|
||||
kg.genKeys(keyInfo);
|
||||
}
|
||||
|
||||
|
||||
public void genKeys(String keyInfo) throws Exception {
|
||||
KeyPairGenerator keygen = KeyPairGenerator.getInstance("RSA");
|
||||
SecureRandom random = new SecureRandom();
|
||||
random.setSeed(keyInfo.getBytes());
|
||||
|
||||
keygen.initialize(512, random);
|
||||
// ȡ<><C8A1><EFBFBD><EFBFBD>Կ<EFBFBD><D4BF>
|
||||
KeyPair kp = keygen.generateKeyPair();
|
||||
// ȡ<>ù<EFBFBD>Կ
|
||||
PublicKey publicKey = kp.getPublic();
|
||||
System.out.println(publicKey);
|
||||
saveFile(publicKey, "pk.dat");
|
||||
// ȡ<><C8A1>˽Կ
|
||||
PrivateKey privateKey = kp.getPrivate();
|
||||
saveFile(privateKey, "sk.dat");
|
||||
}
|
||||
|
||||
private void saveFile(Object obj, String fileName) throws Exception {
|
||||
ObjectOutputStream output=new ObjectOutputStream(
|
||||
new FileOutputStream(fileName));
|
||||
output.writeObject(obj);
|
||||
output.close();
|
||||
}
|
||||
}
|
||||
//<2F><><EFBFBD>ù<EFBFBD>Կ<EFBFBD><D4BF><EFBFBD>ܣ<EFBFBD>˽Կ<CBBD><D4BF><EFBFBD>ܣ<EFBFBD>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.crypto;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import org.maxkey.crypto.Md5Sum;
|
||||
|
||||
public class Md5SumTest {
|
||||
|
||||
public Md5SumTest() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException {
|
||||
// TODO Auto-generated method stub
|
||||
//String md5value=Md5Sum.produce(new File("E:/transwarp-4.3.4-Final-el6/transwarp-4.3.4-Final-26854-zh.el6.x86_64.tar.gz"));
|
||||
File f=new File("E:/Soft/Xmanager4_setup.1410342608.exe");
|
||||
String md5value=Md5Sum.produce(f);
|
||||
|
||||
System.out.println(""+md5value);
|
||||
|
||||
System.out.println(Md5Sum.check(f,md5value));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.crypto;
|
||||
|
||||
import org.maxkey.crypto.password.PasswordGen;
|
||||
|
||||
public class PasswordGenTest {
|
||||
|
||||
public PasswordGenTest() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
PasswordGen gen=new PasswordGen();
|
||||
System.out.println(gen.gen(2,2,2,1));
|
||||
for(int i=1;i<100;i++){
|
||||
//System.out.println(gen.gen());
|
||||
//System.out.println(gen.gen(6));
|
||||
//System.out.println(gen.gen(2,2,2,0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.crypto;
|
||||
|
||||
import java.security.Key;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.maxkey.crypto.Base64Utils;
|
||||
import org.maxkey.crypto.HexUtils;
|
||||
import org.maxkey.crypto.RSAUtils;
|
||||
|
||||
public class RSAUtilsTest {
|
||||
|
||||
//@Test
|
||||
public void test() throws Exception {
|
||||
|
||||
// ˽Կ<CBBD><D4BF><EFBFBD>ܡ<EFBFBD><DCA1><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD><D4BF><EFBFBD><EFBFBD>
|
||||
// ˽Կǩ<D4BF><C7A9><EFBFBD><EFBFBD>Կ<EFBFBD><D4BF>֤ǩ<D6A4><C7A9>
|
||||
Map<String, Object> key = RSAUtils.genKeyPair();
|
||||
String privateKey = RSAUtils.getPublicKey2Hex(key);
|
||||
String publicKey = RSAUtils.getPrivateKey2Hex(key);
|
||||
System.out.println("privateKey:" + privateKey);
|
||||
System.out.println("publicKey:" + publicKey);
|
||||
String signString = "my name is shiming";
|
||||
Key keyp = (Key) key.get(RSAUtils.PUBLIC_KEY);
|
||||
System.out.println("privateKey:" + Base64Utils.base64UrlEncode(keyp.getEncoded()));
|
||||
|
||||
byte[] encodedData = RSAUtils.encryptByPrivateKey(signString.getBytes(), privateKey);
|
||||
System.out.println("<EFBFBD><EFBFBD><EFBFBD>ܺ<EFBFBD>\r\n" + new String(encodedData));
|
||||
System.out.println("<EFBFBD><EFBFBD><EFBFBD>ܺ<EFBFBD>B64<EFBFBD><EFBFBD>\r\n" + HexUtils.bytes2HexString(encodedData));
|
||||
byte[] decodedData = RSAUtils.decryptByPublicKey(encodedData, publicKey);
|
||||
String target = new String(decodedData);
|
||||
System.out.println("target:" + target);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.crypto;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.maxkey.crypto.ReciprocalUtils;
|
||||
|
||||
public class ReciprocalUtilsTest {
|
||||
@Test
|
||||
public void test() throws UnsupportedEncodingException {
|
||||
/*
|
||||
//System.out.println(ReciprocalUtils.generateKey(ReciprocalUtils.Algorithm.AES));
|
||||
|
||||
System.out.println( ReciprocalUtils.aesDecoder("7f8cbcd348ea99914f077250b9d14421e32eb7335be127f4838db9ea24f59ea0be2e17e0ce63da63ff29c50150b3343703ed778f2505ea50486236d2c682fa7f49d1efd7dc37fd62b5c518c2a7285d6063dd1d5d1a5c8cd53a622fff407c6537540f0bba5957180835d928082f3901d5aedf4e6ae873f5ab17dc46b7b385a1e306abab90696aed1fbfb147308d6114f5", "846KZSzYq56M6d5o"));
|
||||
|
||||
//System.out.println(ReciprocalUtils.blowfishEncode("sadf","1111"));
|
||||
|
||||
// System.out.println(ReciprocalUtils.blowfishDecoder("3547433be1e3a817","1111"));
|
||||
System.out.println( ReciprocalUtils.encode("0eFm6iHvTgNs"));
|
||||
|
||||
System.out.println( ReciprocalUtils.decoder("76efad66eb7d10140dc2d9ef41c51df0"));
|
||||
|
||||
System.out.println( ReciprocalUtils.generatorDefaultKey(ReciprocalUtils.Algorithm.DESede));
|
||||
|
||||
|
||||
|
||||
|
||||
String urlencodeString="中国";
|
||||
String urlencode = java.net.URLEncoder.encode(urlencodeString, "utf-8");
|
||||
System.out.println(urlencode);
|
||||
String urldecodeString="http://exchange.connsec.com/owa/?ae=Item&a=Open&t=IPM.Note&id=RgAAAABPKgpqnlfYQ7BVC%2fBfH2XIBwCS0xhUjzMYSLVky9bw7LddAAAAjov5AACS0xhUjzMYSLVky9bw7LddAAADzoy%2fAAAA&pspid=_1428036768398_867461813";
|
||||
String urldcode = java.net.URLDecoder.decode(urldecodeString, "utf-8");
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println(urldcode);*/
|
||||
System.out.println( ReciprocalUtils.decoder("76efad66eb7d10140dc2d9ef41c51df0"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
String encoderString="root";
|
||||
System.out.println( ReciprocalUtils.encode(encoderString));
|
||||
|
||||
encoderString="ead67db5c4f55eace090ab0044682451";
|
||||
encoderString=ReciprocalUtils.decoder(encoderString);
|
||||
System.out.println(encoderString );
|
||||
|
||||
}
|
||||
}
|
||||
168
maxkey-common/src/test/java/org/maxkey/crypto/RsaMessage.java
Normal file
168
maxkey-common/src/test/java/org/maxkey/crypto/RsaMessage.java
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.crypto;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.security.Key;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
import java.security.Signature;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
|
||||
|
||||
/**
|
||||
* RSA<53>ӽ<EFBFBD><D3BD><EFBFBD>,RSAǩ<41><C7A9>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>֤<EFBFBD><D6A4>
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
public class RsaMessage {
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String str = "hello,<2C><><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD>";
|
||||
System.out.println("ԭ<EFBFBD>ģ<EFBFBD>" + str);
|
||||
|
||||
RsaMessage rsa = new RsaMessage();
|
||||
RSAPrivateKey privateKey = (RSAPrivateKey) rsa.readFromFile("sk.dat");
|
||||
RSAPublicKey publickKey = (RSAPublicKey) rsa.readFromFile("pk.dat");
|
||||
|
||||
byte[] encbyte = rsa.encrypt(str, privateKey);
|
||||
System.out.println("˽Կ<EFBFBD><EFBFBD><EFBFBD>ܺ<EFBFBD>");
|
||||
String encStr = toHexString(encbyte);
|
||||
System.out.println(encStr);
|
||||
|
||||
byte[] signBytes = rsa.sign(str, privateKey);
|
||||
System.out.println("ǩ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>");
|
||||
String signStr = toHexString(signBytes);
|
||||
System.out.println(signStr);
|
||||
|
||||
byte[] decByte = rsa.decrypt(encStr, publickKey);
|
||||
System.out.println("<EFBFBD><EFBFBD>Կ<EFBFBD><EFBFBD><EFBFBD>ܺ<EFBFBD>");
|
||||
String decStr = new String(decByte);
|
||||
System.out.println(decStr);
|
||||
|
||||
if (rsa.verifySign(str, signStr, publickKey)) {
|
||||
System.out.println("rsa sign check success");
|
||||
} else {
|
||||
System.out.println("rsa sign check failure");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD>,key<65><79><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD>Կ<EFBFBD><D4BF>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˽Կ
|
||||
*
|
||||
* @param message
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public byte[] encrypt(String message, Key key) throws Exception {
|
||||
Cipher cipher = Cipher.getInstance("RSA");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key);
|
||||
return cipher.doFinal(message.getBytes());
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD>ܣ<EFBFBD>key<65><79><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD>Կ<EFBFBD><D4BF>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˽Կ<CBBD><D4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD>Կ<EFBFBD><D4BF><EFBFBD>ܾ<EFBFBD><DCBE><EFBFBD>˽Կ<CBBD><D4BF><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>֮<EFBFBD><D6AE>Ȼ
|
||||
*
|
||||
* @param message
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public byte[] decrypt(String message, Key key) throws Exception {
|
||||
Cipher cipher = Cipher.getInstance("RSA");
|
||||
cipher.init(Cipher.DECRYPT_MODE, key);
|
||||
return cipher.doFinal(toBytes(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><>˽Կǩ<D4BF><C7A9>
|
||||
*
|
||||
* @param message
|
||||
* @param key
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public byte[] sign(String message, PrivateKey key) throws Exception {
|
||||
Signature signetcheck = Signature.getInstance("MD5withRSA");
|
||||
signetcheck.initSign(key);
|
||||
signetcheck.update(message.getBytes("ISO-8859-1"));
|
||||
return signetcheck.sign();
|
||||
}
|
||||
|
||||
/**
|
||||
* <20>ù<EFBFBD>Կ<EFBFBD><D4BF>֤ǩ<D6A4><C7A9><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>
|
||||
*
|
||||
* @param message
|
||||
* @param signStr
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public boolean verifySign(String message, String signStr, PublicKey key)
|
||||
throws Exception {
|
||||
if (message == null || signStr == null || key == null) {
|
||||
return false;
|
||||
}
|
||||
Signature signetcheck = Signature.getInstance("MD5withRSA");
|
||||
signetcheck.initVerify(key);
|
||||
signetcheck.update(message.getBytes("ISO-8859-1"));
|
||||
return signetcheck.verify(toBytes(signStr));
|
||||
}
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ȡobject
|
||||
*
|
||||
* @param fileName
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private Object readFromFile(String fileName) throws Exception {
|
||||
ObjectInputStream input = new ObjectInputStream(new FileInputStream(
|
||||
fileName));
|
||||
Object obj = input.readObject();
|
||||
input.close();
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static String toHexString(byte[] b) {
|
||||
StringBuilder sb = new StringBuilder(b.length * 2);
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
sb.append(HEXCHAR[(b[i] & 0xf0) >>> 4]);
|
||||
sb.append(HEXCHAR[b[i] & 0x0f]);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static final byte[] toBytes(String s) {
|
||||
byte[] bytes;
|
||||
bytes = new byte[s.length() / 2];
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
bytes[i] = (byte) Integer.parseInt(s.substring(2 * i, 2 * i + 2),
|
||||
16);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
private static char[] HEXCHAR = { '0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.crypto;
|
||||
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
public class SCryptPasswordEncoderTest {
|
||||
|
||||
public SCryptPasswordEncoderTest() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
BCryptPasswordEncoder pe=new BCryptPasswordEncoder();
|
||||
//String c="$e0801$7Holo9EgzBeg5xf/WLZu3/5IQwOyEPDLJPgMXkF9jnekBrbQUMt4CF9O2trkz3zBCnCLpUMR437q/AjQ5TTToA==$oYB8KRSxAsxkKkt5r79W6r6P0wTUcKwGye1ivXRN0Ts="
|
||||
//;
|
||||
System.out.println(pe.encode("admin"));
|
||||
// System.out.println(pe.encode("shimingxy")+"_password");
|
||||
//System.out.println(pe.matches("shimingxy"+"_password", c));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* package org.maxkey.crypto.cert;
|
||||
*
|
||||
* import java.io.FileInputStream; import java.io.FileOutputStream; import
|
||||
* java.io.IOException; import java.security.InvalidKeyException; import
|
||||
* java.security.KeyStore; import java.security.KeyStoreException; import
|
||||
* java.security.NoSuchAlgorithmException; import
|
||||
* java.security.NoSuchProviderException; import java.security.PrivateKey;
|
||||
* import java.security.SignatureException; import
|
||||
* java.security.UnrecoverableKeyException; import
|
||||
* java.security.cert.CertificateException; import java.util.Date;
|
||||
*
|
||||
* import org.junit.Test;
|
||||
*
|
||||
* import sun.security.x509.AlgorithmId; import
|
||||
* sun.security.x509.CertificateAlgorithmId; import
|
||||
* sun.security.x509.CertificateIssuerName; import
|
||||
* sun.security.x509.CertificateSerialNumber; import
|
||||
* sun.security.x509.CertificateSubjectName; import
|
||||
* sun.security.x509.CertificateValidity; import sun.security.x509.X500Name;
|
||||
* import sun.security.x509.X509CertImpl; import sun.security.x509.X509CertInfo;
|
||||
*
|
||||
* public class X509CertUtilsTest {
|
||||
*
|
||||
* //@Test public void test() throws KeyStoreException,
|
||||
* NoSuchAlgorithmException, CertificateException, IOException,
|
||||
* UnrecoverableKeyException, InvalidKeyException, NoSuchProviderException,
|
||||
* SignatureException { ////
|
||||
*
|
||||
* String keystoreFile = "c:\\keyStoreFile.jks"; String caAlias = "caAlias";
|
||||
* String certToSignAlias = "cert"; String newAlias = "newAlias";
|
||||
*
|
||||
* char[] password = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' };
|
||||
* char[] caPassword = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' };
|
||||
* char[] certPassword = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g','h' };
|
||||
*
|
||||
* FileInputStream input = new FileInputStream(keystoreFile); KeyStore keyStore
|
||||
* = KeyStore.getInstance("JKS"); keyStore.load(input, password); input.close();
|
||||
*
|
||||
* PrivateKey caPrivateKey = (PrivateKey) keyStore.getKey(caAlias,caPassword);
|
||||
* java.security.cert.Certificate caCert = keyStore.getCertificate(caAlias);
|
||||
*
|
||||
* byte[] encoded = caCert.getEncoded(); X509CertImpl caCertImpl = new
|
||||
* X509CertImpl(encoded);
|
||||
*
|
||||
* X509CertInfo caCertInfo = (X509CertInfo) caCertImpl.get(X509CertImpl.NAME +
|
||||
* "." + X509CertImpl.INFO);
|
||||
*
|
||||
* X500Name issuer = (X500Name) caCertInfo.get(X509CertInfo.SUBJECT + "."+
|
||||
* CertificateIssuerName.DN_NAME);
|
||||
*
|
||||
* java.security.cert.Certificate cert =
|
||||
* keyStore.getCertificate(certToSignAlias); PrivateKey privateKey =
|
||||
* (PrivateKey) keyStore.getKey(certToSignAlias,certPassword); encoded =
|
||||
* cert.getEncoded(); X509CertImpl certImpl = new X509CertImpl(encoded);
|
||||
* X509CertInfo certInfo = (X509CertInfo) certImpl.get(X509CertImpl.NAME+ "." +
|
||||
* X509CertImpl.INFO);
|
||||
*
|
||||
* Date firstDate = new Date(); Date lastDate = new Date(firstDate.getTime() +
|
||||
* 365 * 24 * 60 * 60* 1000L); CertificateValidity interval = new
|
||||
* CertificateValidity(firstDate,lastDate);
|
||||
*
|
||||
* certInfo.set(X509CertInfo.VALIDITY, interval);
|
||||
*
|
||||
* certInfo.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber((int)
|
||||
* (firstDate.getTime() / 1000)));
|
||||
*
|
||||
* certInfo.set(X509CertInfo.ISSUER + "." +
|
||||
* CertificateSubjectName.DN_NAME,issuer);
|
||||
*
|
||||
* AlgorithmId algorithm = new
|
||||
* AlgorithmId(AlgorithmId.md5WithRSAEncryption_oid);
|
||||
* certInfo.set(CertificateAlgorithmId.NAME + "."+
|
||||
* CertificateAlgorithmId.ALGORITHM, algorithm); X509CertImpl newCert = new
|
||||
* X509CertImpl(certInfo);
|
||||
*
|
||||
* newCert.sign(caPrivateKey, "MD5WithRSA");
|
||||
*
|
||||
* keyStore.setKeyEntry(newAlias, privateKey, certPassword,new
|
||||
* java.security.cert.Certificate[] { newCert });
|
||||
*
|
||||
* FileOutputStream output = new FileOutputStream(keystoreFile);
|
||||
* keyStore.store(output, password); output.close();
|
||||
*
|
||||
* }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.crypto.cert;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.security.KeyPair;
|
||||
import java.security.Security;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Date;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Test;
|
||||
import org.maxkey.crypto.cert.X509V3CertGen;
|
||||
|
||||
public class X509V3CertGenTest {
|
||||
|
||||
//@Test
|
||||
public void generateV3() throws Exception {
|
||||
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
|
||||
KeyPair keyPair =X509V3CertGen.genRSAKeyPair();
|
||||
String issuer="CN=maxkey.top,O=maxkey,L=SH,ST=SH,C=CN";
|
||||
Date startDate=DateTime.now().toDate();
|
||||
Date endDate=DateTime.now().plusMonths(10).toDate();
|
||||
System.out.println("Private : "+ keyPair.getPrivate().toString());
|
||||
|
||||
System.out.println("Public : "+ keyPair.getPublic().toString());
|
||||
X509Certificate cert = X509V3CertGen.genV3Certificate(issuer,issuer,startDate,endDate,keyPair);
|
||||
String certFileString = "D:\\MaxKey\\Workspaces\\maxkey\\Cert345.cer";
|
||||
File certFile =new File(certFileString);
|
||||
if(certFile.exists()) {
|
||||
certFile.deleteOnExit();
|
||||
}
|
||||
|
||||
FileOutputStream out = new FileOutputStream(certFileString);
|
||||
out.write(cert.getEncoded());
|
||||
out.close();
|
||||
|
||||
cert.checkValidity(new Date());
|
||||
cert.verify(cert.getPublicKey());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.crypto.password;
|
||||
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
public class PasswordReciprocalTest {
|
||||
|
||||
public PasswordReciprocalTest() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
BCryptPasswordEncoder spe= new BCryptPasswordEncoder();
|
||||
String pass=PasswordReciprocal.getInstance().rawPassword("admin", "admin");
|
||||
String epass=spe.encode(pass);
|
||||
System.out.println("PasswordEncoder "+epass);
|
||||
|
||||
System.out.println(PasswordReciprocal.getInstance().decoder("f1ee1e9b912f05333a06925c99daf9c0"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.crypto.password;
|
||||
|
||||
public class SM3PasswordEncoderTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
SM3PasswordEncoder sm3 = new SM3PasswordEncoder();
|
||||
System.out.println(sm3.encode("maxkeypassword"));
|
||||
|
||||
String c="f4679d46e96d95d67db4c8c91fcf8aaaa4e1d437ffee278d2ea97f41f7f48c12";
|
||||
System.out.println(sm3.matches("maxkeypassword",c));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.crypto.signature;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.maxkey.crypto.KeyPairUtil;
|
||||
import org.maxkey.crypto.signature.DsaSigner;
|
||||
|
||||
public final class DsaSignerTest {
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
|
||||
DsaSigner dsaSigner = new DsaSigner();
|
||||
// genKeyPair
|
||||
Map<String, Object> keyMap = KeyPairUtil.genKeyPairMap(DsaSigner.KEY_ALGORITHM);
|
||||
|
||||
String publicKey = KeyPairUtil.getPublicKey(keyMap);
|
||||
String privateKey = KeyPairUtil.getPrivateKey(keyMap);
|
||||
System.out.println("privateKey:" + privateKey);
|
||||
System.out.println("privateKey:" + privateKey.length());
|
||||
System.out.println("publicKey:" + publicKey);
|
||||
System.out.println("publicKey:" + publicKey.length());
|
||||
|
||||
String signStr = "my data need to sign use DSA Digital signature";
|
||||
System.out.println("signStr:" + signStr);
|
||||
|
||||
String sign = dsaSigner.signB64(signStr, privateKey);
|
||||
System.out.println("sign<EFBFBD><EFBFBD>" + sign);
|
||||
// verify
|
||||
boolean status = dsaSigner.verifyB64(signStr, publicKey, sign);
|
||||
System.out.println("status<EFBFBD><EFBFBD>" + status);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.maxkey.crypto.signature;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.maxkey.crypto.KeyPairUtil;
|
||||
import org.maxkey.crypto.signature.RsaSigner;
|
||||
|
||||
|
||||
public final class RsaSignerTest {
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
|
||||
RsaSigner rsaSigner = new RsaSigner();
|
||||
Map<String, Object> key = KeyPairUtil.genKeyPairMap(RsaSigner.KEY_ALGORTHM);
|
||||
String privateKey = KeyPairUtil.getPrivateKey(key);
|
||||
String publicKey = KeyPairUtil.getPublicKey(key);
|
||||
System.out.println("privateKey:" + privateKey);
|
||||
System.out.println("privateKey:" + privateKey.length());
|
||||
System.out.println("publicKey:" + publicKey);
|
||||
System.out.println("publicKey:" + publicKey.length());
|
||||
String sdata = "MIIBSwIBADCCASwGByqGSM44BAEwggEfAoGBAP1/U4EddRIpUt9KnC7s5Of2EbdSPO9EAMMeP4C2USZpRV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7gB00b/JmYLdrmVClpJ+f6AR7ECLCT7up1/63xhv4O1fnxqimFQ8E+4P208UewwI1VBNaFpEy9nXzrith1yrv8iIDGZ3RSAHHAhUAl2BQjxUjC8yykrmCouuEC/BYHPUCgYEA9+GghdabPd7LvKtcNrhXuXmUr7v6OuqC+VdMCz0HgmdRWVeOutRZT+ZxBxCBgLRJFnEj6EwoFhO3zwkyjMim4TwWeotUfI0o4KOuHiuzpnWRbqN/C/ohNWLx+2J6ASQ7zKTxvqhRkImog9/hWuWfBpKLZl6Ae1UlZAFMO/7PSSoEFgIUWEKjQXEsmz9cfPNxwhAlXl90U8c=";
|
||||
String signedStringuuid = rsaSigner.signB64(sdata, privateKey);
|
||||
System.out.println("signedStringuuid:" + signedStringuuid);
|
||||
System.out.println("signedStringuuid:" + signedStringuuid.length());
|
||||
boolean isSigneduuid = rsaSigner.verifyB64(sdata, publicKey,
|
||||
signedStringuuid);
|
||||
System.out.println("isSigneduuid:" + isSigneduuid);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
47
maxkey-common/src/test/java/org/maxkey/mail/MailTest.java
Normal file
47
maxkey-common/src/test/java/org/maxkey/mail/MailTest.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.mail;
|
||||
|
||||
import org.apache.commons.mail.DefaultAuthenticator;
|
||||
import org.apache.commons.mail.Email;
|
||||
import org.apache.commons.mail.SimpleEmail;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MailTest {
|
||||
|
||||
//@Test
|
||||
public void test() throws Exception {
|
||||
String username="test@connsec.com";
|
||||
String password="3&8Ujbnm5hkjhFD";
|
||||
String smtpHost="smtp.exmail.qq.com";
|
||||
int port=465;
|
||||
boolean ssl=true;
|
||||
String senderMail="test@connsec.com";
|
||||
|
||||
Email email = new SimpleEmail();
|
||||
email.setHostName(smtpHost);
|
||||
email.setSmtpPort(port);
|
||||
email.setAuthenticator(new DefaultAuthenticator(username, password));
|
||||
email.setSSLOnConnect(ssl);
|
||||
email.setFrom(senderMail);
|
||||
email.setSubject("One Time PassWord");
|
||||
email.setMsg("You Token is "+111+" , it validity in "+5 +" minutes");
|
||||
email.addTo("shimingxy@qq.com");
|
||||
email.send();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.otp.algorithm;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.maxkey.util.QRCode;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.MultiFormatWriter;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
|
||||
public class RQcodeTest {
|
||||
|
||||
/*
|
||||
* BEGIN:VCARD
|
||||
VERSION:3.0
|
||||
N:Gump;Forrest;;Mr.
|
||||
FN:Forrest Gump
|
||||
ORG:Bubba Gump Shrimp Co.
|
||||
TITLE:Shrimp Man
|
||||
PHOTO;VALUE=URL;TYPE=GIF:http://www.example.com/dir_photos/my_photo.gif
|
||||
TEL;TYPE=WORK,VOICE:(111) 555-12121
|
||||
TEL;TYPE=HOME,VOICE:(404) 555-1212
|
||||
ADR;TYPE=WORK:;;100 Waters Edge;Baytown;LA;30314;United States of America
|
||||
LABEL;TYPE=WORK:100 Waters Edge\nBaytown, LA 30314\nUnited States of America
|
||||
ADR;TYPE=HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America
|
||||
LABEL;TYPE=HOME:42 Plantation St.\nBaytown, LA 30314\nUnited States of America
|
||||
EMAIL;TYPE=PREF,INTERNET:forrestgump@example.com
|
||||
REV:2008-04-24T19:52:43Z
|
||||
END:VCARD
|
||||
|
||||
|
||||
|
||||
BEGIN:VCARD
|
||||
VERSION:4.0
|
||||
N:Gump;Forrest;;;
|
||||
FN:Forrest Gump
|
||||
ORG:Bubba Gump Shrimp Co.
|
||||
TITLE:Shrimp Man
|
||||
PHOTO;MEDIATYPE=image/gif:http://www.example.com/dir_photos/my_photo.gif
|
||||
TEL;TYPE=work,voice;VALUE=uri:tel:+1-111-555-1212
|
||||
TEL;TYPE=home,voice;VALUE=uri:tel:+1-404-555-1212
|
||||
ADR;TYPE=work;LABEL="100 Waters Edge\nBaytown, LA 30314\nUnited States of America"
|
||||
:;;100 Waters Edge;Baytown;LA;30314;United States of America
|
||||
ADR;TYPE=home;LABEL="42 Plantation St.\nBaytown, LA 30314\nUnited States of America"
|
||||
:;;42 Plantation St.;Baytown;LA;30314;United States of America
|
||||
EMAIL:forrestgump@example.com
|
||||
REV:20080424T195243Z
|
||||
END:VCARD
|
||||
*/
|
||||
// 编码
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
|
||||
String str = "BEGIN:VCARD\n" +
|
||||
"VERSION:3.0\n" +
|
||||
"N:石明海\n" +
|
||||
"EMAIL:shimh@qq.com\n" +
|
||||
"TEL:15618726256\n" +
|
||||
"TEL;CELL:12345678912" +
|
||||
"ADR:上海\n" +
|
||||
"ORG:" +
|
||||
"Connsec\n" +
|
||||
"TITLE:技术总监\n" +
|
||||
//"URL:http://blog.csdn.net/lidew521\n" +
|
||||
//"NOTE:呼呼测试下吧。。。\n" +
|
||||
"END:VCARD";
|
||||
|
||||
String str1 = "BEGIN:VCARD\n" +
|
||||
"VERSION:3.0\n" +
|
||||
"N:Gump;Forrest;;Mr.\n" +
|
||||
"ORG:Bubba Gump Shrimp Co.\n" +
|
||||
"TITLE:Shrimp Man\n" +
|
||||
"TEL;TYPE=WORK,VOICE:(111) 555-12121\n" +
|
||||
"ADR;TYPE=WORK:;;100 Waters Edge;Baytown;LA;30314;United States of America\n" +
|
||||
"EMAIL;TYPE=PREF,INTERNET:forrestgump@example.com\n" +
|
||||
"URL:http://www.johndoe.com\n" +
|
||||
"GENDER:F\n"+
|
||||
"REV:2008-04-24T19:52:43Z\n" +
|
||||
"END:VCARD\n" ;
|
||||
|
||||
//String str = "CN:男;COP:公司;ZW:职务";// 二维码内容
|
||||
String path = "D:\\hwy.png";
|
||||
BitMatrix byteMatrix;
|
||||
byteMatrix = new MultiFormatWriter().encode(new String(str1.getBytes("UTF-8"),"iso-8859-1"),
|
||||
BarcodeFormat.QR_CODE, 300, 300);
|
||||
File file = new File(path);
|
||||
|
||||
QRCode.writeToPath(byteMatrix, "png", file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
18
maxkey-common/src/test/java/org/maxkey/package-info.java
Normal file
18
maxkey-common/src/test/java/org/maxkey/package-info.java
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey;
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.persistence.derby;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
|
||||
public class DerbyTest {
|
||||
/**
|
||||
* 1.
|
||||
* first SET JAVA_HOME,DERBY_HOME,PATH
|
||||
* set PATH=%DERBY_HOME%\bin;%PATH%
|
||||
* 2.
|
||||
* startNetworkServer Start Derby Database
|
||||
* 3.
|
||||
* create db seconddb1 , user is tquist
|
||||
* CONNECT 'jdbc:derby://localhost:1527/seconddb1;create=true;user=tquist';
|
||||
* 4.
|
||||
* Configuring NATIVE authentication
|
||||
* call SYSCS_UTIL.SYSCS_CREATE_USER( 'tquist', 'tquist' );
|
||||
* 5.
|
||||
* then restart derby database
|
||||
*/
|
||||
/**
|
||||
* @param args
|
||||
* @throws SQLException
|
||||
*/
|
||||
public static void main(String[] args) throws SQLException {
|
||||
// TODO Auto-generated method stub
|
||||
String nsURL="jdbc:derby://localhost:1527/seconddb1";
|
||||
java.util.Properties props = new java.util.Properties();
|
||||
props.setProperty("user","tquist");
|
||||
props.setProperty("password","tquist");
|
||||
|
||||
Connection conn = DriverManager.getConnection(nsURL, props);
|
||||
|
||||
/*interact with Derby*/
|
||||
Statement s = conn.createStatement();
|
||||
|
||||
ResultSet rs = s.executeQuery("SELECT * FROM SECONDTABLE");
|
||||
|
||||
while(rs.next()){
|
||||
System.out.println("key : "+rs.getInt("ID")+" ,name : "+rs.getString("NAME"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.rest;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.maxkey.util.AuthorizationHeaderUtils;
|
||||
|
||||
public class AuthorizationHeaderTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String basic =AuthorizationHeaderUtils.createBasic("Aladdin", "open sesame");
|
||||
System.out.println(basic);
|
||||
String []rb=AuthorizationHeaderUtils.resolveBasic(basic);
|
||||
System.out.println(rb[0]+":"+rb[1]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.util;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.maxkey.util.DateUtils;
|
||||
|
||||
public class DateUtilsTest {
|
||||
|
||||
/**
|
||||
* Main method for test.
|
||||
*
|
||||
* @param args
|
||||
* @throws EncryptException
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
String stringValue = "20110610090519";
|
||||
System.out.println(stringValue);
|
||||
// System.out.println("Parse \"" + stringValue
|
||||
// + "\" using format pattern \"" + DateUtils.FORMAT_DATE_DEFAULT
|
||||
// + "\" with method \"DateUtils.parse()\", result: "
|
||||
// + DateUtils.parse(stringValue));
|
||||
// stringValue = "20080506";
|
||||
// System.out.println("Parse \"" + stringValue
|
||||
// + "\" using method \"DateUtils.tryParse()\", result: "
|
||||
// + DateUtils.tryParse(stringValue));
|
||||
// String s = DateUtils.getExchangeFormat(stringValue,FORMAT_DATE_YYYYMMDDHHMMSS,DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS);
|
||||
// System.out.print("--->>>"+s);
|
||||
|
||||
// String str = "2011-08-09";
|
||||
// System.out.println(UserPasswordUtil.decrypt("PVuyeIHtXnXv5oSPwPUug66w=="));
|
||||
// System.out.println(DateUtils.getFormtPattern1ToPattern2(str, DateUtils.FORMAT_DATE_YYYY_MM_DD, DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS));
|
||||
// str = "aaa\r\nbbb";
|
||||
// List<String> list = StringUtil.strToList(str, "\r\n");
|
||||
// System.out.println(list.size());
|
||||
// System.out.println(StringUtil.listToStr(null, ","));
|
||||
|
||||
// String value = "a,b,,c,,";
|
||||
// System.out.println(value.split("\\,").length);
|
||||
// System.out.println(StringUtil.removeSplit(value, ","));
|
||||
|
||||
// Class clazz = TmEmployeeUserInfo.class;
|
||||
// Field field = clazz.getDeclaredField("spellName");
|
||||
// System.out.println(field.getName());
|
||||
|
||||
// System.out.println(UserPasswordUtil.encrypt("oscwebadmin@163.com"));
|
||||
//System.out.println(JCEnDecrypt.randomDecrypt("2AF5022B2E78478A9761FD3381BB"));
|
||||
// System.out.println(JCEnDecrypt.randomEncrypt("aaa")); 41l2Iw4V
|
||||
// String regEx="[1]{1}[3,5,8,6]{1}[0-9]{9}"; //<2F><>ʾa<CABE><61>f
|
||||
// System.out.println(Pattern.compile(regEx).matcher("18258842633").find());
|
||||
// Date lockoutDate = DateUtils.addDate(new Date(), 0, 30, 0); //解锁时间
|
||||
// System.out.println(DateUtils.format(lockoutDate, DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS));
|
||||
Date date = new Date();
|
||||
System.out.println(DateUtils.format(DateUtils.addDate(date, 0, 0, 1, 0, 0, 0),DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS));
|
||||
|
||||
System.out.println(DateUtils.format(DateUtils.addMinutes(new Date(), Integer.parseInt("2")*1000),DateUtils.FORMAT_DATE_ISO_TIMESTAMP));
|
||||
System.out.println(DateUtils.toUtc(date));
|
||||
|
||||
System.out.println(DateUtils.toUtcLocal("2015-11-04T16:00:22.875Z"));
|
||||
System.out.println(DateUtils.toUtcLocal("2015-11-04T23:58:14.286+08:00"));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.util;
|
||||
|
||||
import org.maxkey.util.EthernetAddress;
|
||||
|
||||
public class EthernetAddressTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(EthernetAddress.fromInterface());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.util;
|
||||
|
||||
public class IdSequenceTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
long s =System.currentTimeMillis();
|
||||
int k;
|
||||
for(int i=1;i<=10010;i++){
|
||||
k=(i)%10000;
|
||||
System.out.println(k);
|
||||
}
|
||||
System.out.println(System.currentTimeMillis()-s);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.util;
|
||||
|
||||
import org.maxkey.util.MacAddress;
|
||||
|
||||
public class MacAddressTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
System.out.println(MacAddress.getAllHostMacAddress());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import org.maxkey.util.ObjectTransformer;
|
||||
|
||||
public class ObjectTransformerTest {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
HashMap<String, Object> ut=new HashMap<String, Object>();
|
||||
|
||||
ut.put("username","shimingxy");
|
||||
ut.put("password","test");
|
||||
ut.put("department","我的部门");
|
||||
|
||||
String hexString =ObjectTransformer.serialize(ut);
|
||||
|
||||
System.out.println("hexString "+hexString);
|
||||
System.out.println(hexString.length());
|
||||
|
||||
HashMap<String, Object> u2=ObjectTransformer.deserialize(hexString);
|
||||
|
||||
System.out.println("deserialize "+u2.toString());
|
||||
|
||||
System.out.println("{’id’:’be90f66d-95df-4daf-93c1-ece002542702’,’tid’:null,’tname’:null,’description’:null,’status’:0,’sortOrder’:0,’createdBy’:’admin’,’createdDate’:’2014-11-07 21:27:38’,’modifiedBy’:null,’modifiedDate’:null,’startDate’:null,’endDate’:null,’username’:’yyyyy’,’password’:’Pt3dCf6Zad9h3g7q/DI0e7jQ5evO2Jn+tk2TjtdJ0eY=’,’decipherable’:’yaOLYlcdjfF5hFOskBOOxQ==’,’sharedSecret’:null,’sharedCounter’:null,’userType’:’EMPLOYEE’,’windowsAccount’:null,’displayName’:’test’,’nickName’:null,’nameZHSpell’:’test’,’nameZHShortSpell’:’test’,’givenName’:null,’middleName’:null,’familyName’:null,’honorificPrefix’:null,’honorificSuffix’:null,’formattedName’:null,’married’:0,’gender’:1,’birthDate’:null,’idType’:0,’idCardNo’:null,’webSite’:null,’startWorkDate’:null,’authnType’:0,’email’:null,’emailVerified’:0,’mobile’:null,’mobileVerified’:0,’passwordQuestion’:null,’passwordAnswer’:null,’appLoginAuthnType’:0,’appLoginPassword’:null,’protectedApps’:null,’passwordLastSetTime’:’2014-11-07 21:27:38’,’badPasswordCount’:0,’unLockTime’:null,’isLocked’:0,’lastLoginTime’:null,’lastLogoffTime’:null,’passwordSetType’:0,’locale’:’zh_CN’,’timeZone’:’Asia/Shanghai’,’preferredLanguage’:’zh_CN’,’workCountry’:’CHN’,’workRegion’:null,’workLocality’:null,’workStreetAddress’:null,’workAddressFormatted’:null,’workEmail’:null,’workPhoneNumber’:null,’workPostalCode’:null,’workFax’:null,’homeCountry’:’CHN’,’homeRegion’:null,’homeLocality’:null,’homeStreetAddress’:null,’homeAddressFormatted’:null,’homeEmail’:null,’homePhoneNumber’:null,’homePostalCode’:null,’homeFax’:null,’employeeNumber’:null,’costCenter’:null,’organization’:null,’division’:null,’departmentId’:null,’department’:null,’jobTitle’:null,’jobLevel’:null,’managerId’:null,’manager’:null,’assistantId’:null,’assistant’:null,’entryDate’:null,’quitDate’:null,’ims’:’QQ:\r\nWeiXin:\r\nSinaWeibo:\r\nGtalk:\r\nYiXin:\r\nIMessage:\r\nSkype:\r\nYahoo:\r\nMSN:\r\nAim:\r\nICQ :\r\nXmpp :’,’extraAttribute’:null,’extraAttributeName’:null,’extraAttributeValue’:null,’online’:0,’ldapDn’:null}".length());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.util;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.maxkey.util.PathUtils;
|
||||
|
||||
public class PathUtilsTest {
|
||||
@Test
|
||||
public void test() {
|
||||
//System.out.println(PathUtils.getInstance().getAppPath());
|
||||
//System.out.println(PathUtils.getInstance().getWebInf());
|
||||
//System.out.println(PathUtils.getInstance().getClassPath());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.util;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.maxkey.pretty.PrettyFactory;
|
||||
|
||||
public class SqlPrettyTest {
|
||||
|
||||
public SqlPrettyTest() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSqlFormat() {
|
||||
String sqlString="select * from userinfo where t='111' order by t,s,t";
|
||||
System.out.println(PrettyFactory.getSqlPretty().format(sqlString));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.util;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.maxkey.util.StringGenerator;
|
||||
|
||||
public class StringGeneratorTest {
|
||||
@Test
|
||||
public void test() {
|
||||
StringGenerator stringGenerator=new StringGenerator();
|
||||
System.out.println(stringGenerator.uuidGenerate());
|
||||
System.out.println(stringGenerator.uuidGenerate().length());
|
||||
System.out.println(stringGenerator.uniqueGenerate());
|
||||
System.out.println(stringGenerator.uniqueGenerate().length());
|
||||
|
||||
System.out.println(StringGenerator.uuidMatches(stringGenerator.uuidGenerate()));
|
||||
System.out.println(StringGenerator.uuidMatches(UUID.randomUUID().toString()));
|
||||
System.out.println(StringGenerator.uuidMatches("408192be-cab9-4b5b-8d41-4cd827cc4091"));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.util;
|
||||
|
||||
import java.util.Date;
|
||||
//import java.util.UUID;
|
||||
|
||||
import org.maxkey.uuid.UUID;
|
||||
import org.junit.Test;
|
||||
import org.maxkey.util.UUIDGenerator;
|
||||
|
||||
public class UUIDGeneratorTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
Date sd=new Date();
|
||||
|
||||
//for(int i=0;i<100000;i++){
|
||||
UUIDGenerator generated=new UUIDGenerator();
|
||||
generated.toString();
|
||||
//System.out.println(generated.toString());
|
||||
|
||||
//}
|
||||
Date ed=new Date();
|
||||
System.out.println("usertime "+(ed.getTime()-sd.getTime()));
|
||||
|
||||
// UUIDGenerator.version(generated);
|
||||
|
||||
|
||||
System.out.println("JDK UUID");
|
||||
Date ssd=new Date();
|
||||
// for(int i=0;i<100000;i++){
|
||||
//UUID.randomUUID().toString();
|
||||
UUID.generate().toString();
|
||||
// System.out.println(UUID.randomUUID().toString());
|
||||
//}
|
||||
Date sed=new Date();
|
||||
System.out.println("usertime "+(sed.getTime()-ssd.getTime()));
|
||||
|
||||
UUIDGenerator.version(new UUIDGenerator(UUID.generate().toString()));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.util;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.maxkey.pretty.PrettyFactory;
|
||||
import org.maxkey.pretty.impl.XMLHelper;
|
||||
import org.w3c.dom.DOMConfiguration;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.ls.DOMImplementationLS;
|
||||
import org.w3c.dom.ls.LSOutput;
|
||||
import org.w3c.dom.ls.LSSerializer;
|
||||
import org.w3c.dom.ls.LSSerializerFilter;
|
||||
|
||||
import net.shibboleth.utilities.java.support.collection.LazyMap;
|
||||
|
||||
public class XMLHelperTest {
|
||||
|
||||
@Test
|
||||
public void testSqlFormat() {
|
||||
String sqlString="<?xml version=\"1.0\" encoding=\"UTF-8\"?><xml><data><name>maxkey</name><age v=\"20\"/></data></xml>";
|
||||
System.out.println(XMLHelper.prettyPrintXML(sqlString));
|
||||
System.out.println(XMLHelper.transformer(sqlString));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.word;
|
||||
|
||||
public class CharacterCase {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
String word="partner ";
|
||||
|
||||
System.out.println(word.toUpperCase());
|
||||
System.out.println(word.toLowerCase());
|
||||
}
|
||||
|
||||
}
|
||||
31
maxkey-common/src/test/java/org/maxkey/word/SubStr.java
Normal file
31
maxkey-common/src/test/java/org/maxkey/word/SubStr.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.word;
|
||||
|
||||
public class SubStr {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
String browser="Chrome/44.0.2369.0";
|
||||
System.out.println(browser.indexOf('.'));
|
||||
}
|
||||
|
||||
}
|
||||
37
maxkey-common/src/test/resources/log4j2.xml
Normal file
37
maxkey-common/src/test/resources/log4j2.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--DOCTYPE log4j:configuration SYSTEM "log4j.dtd" -->
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
|
||||
status="INFO" monitorInterval="300"
|
||||
>
|
||||
<appenders>
|
||||
|
||||
<Console name="consolePrint" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss,SSS} %-5level [%t] %logger{36}:%L - %msg%n" />
|
||||
</Console>
|
||||
|
||||
<!-- 输出到文件,按天或者超过128MB分割 每天进行归档yyyy-MM-dd -->
|
||||
<RollingFile name="RollingFile" fileName="logs/maxkey.log" filePattern="logs/$${date:yyyyMMdd}/maxkey-%d{yyyy-MM-dd}-%i.log.gz">
|
||||
<!-- 需要记录的级别 -->
|
||||
<!-- <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY" /> -->
|
||||
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss,SSS} %-5level [%t] %logger{36}:%L - %msg%n" />
|
||||
<Policies>
|
||||
<OnStartupTriggeringPolicy />
|
||||
<TimeBasedTriggeringPolicy />
|
||||
<SizeBasedTriggeringPolicy size="128 MB" />
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="100"/>
|
||||
</RollingFile>
|
||||
</appenders>
|
||||
|
||||
<loggers>
|
||||
<Logger name="org.springframework" level="INFO"></Logger>
|
||||
<Logger name="org.apache.logging" level="INFO"></Logger>
|
||||
<Logger name="org.maxkey" level="DEBUG"></Logger>
|
||||
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="consolePrint" />
|
||||
<appender-ref ref="RollingFile" />
|
||||
</root>
|
||||
</loggers>
|
||||
</log4j:configuration>
|
||||
Reference in New Issue
Block a user