From 274f7c2df050023d360c03133510658be928234b Mon Sep 17 00:00:00 2001 From: MaxKey Date: Sat, 20 Feb 2021 22:55:12 +0800 Subject: [PATCH] test remove --- .../maxkey/persistence/derby/DerbyTest.java | 65 ------- .../src/test/java/org/maxkey/Copyright.java | 166 ----------------- .../src/test/java/org/maxkey/CopyrightC.java | 10 -- .../org/maxkey/cache/CacheFactoryTest.java | 54 ------ .../java/org/maxkey/cache/RandomCache.java | 73 -------- .../src/test/java/org/maxkey/copyright.txt | 16 -- .../org/maxkey/crypto/Base64UtilsTest.java | 49 ----- .../org/maxkey/crypto/DigestUtilsTest.java | 59 ------ .../test/java/org/maxkey/crypto/KeyGen.java | 63 ------- .../java/org/maxkey/crypto/Md5SumTest.java | 42 ----- .../org/maxkey/crypto/PasswordGenTest.java | 40 ----- .../java/org/maxkey/crypto/RSAUtilsTest.java | 53 ------ .../maxkey/crypto/ReciprocalUtilsTest.java | 70 -------- .../java/org/maxkey/crypto/RsaMessage.java | 168 ------------------ .../crypto/SCryptPasswordEncoderTest.java | 38 ---- .../maxkey/crypto/cert/X509CertUtilsTest.java | 104 ----------- .../maxkey/crypto/cert/X509V3CertGenTest.java | 59 ------ .../password/PasswordPolicyValidatorTest.java | 48 ----- .../password/PasswordReciprocalTest.java | 38 ---- .../password/SM3PasswordEncoderTest.java | 31 ---- .../crypto/signature/DsaSignerTest.java | 52 ------ .../crypto/signature/RsaSignerTest.java | 53 ------ .../org/maxkey/json/util/JsonUtilsTest.java | 41 ----- .../test/java/org/maxkey/mail/MailTest.java | 47 ----- .../org/maxkey/otp/algorithm/RQcodeTest.java | 112 ------------ .../maxkey/rest/AuthorizationHeaderTest.java | 32 ---- .../java/org/maxkey/util/DateUtilsTest.java | 79 -------- .../org/maxkey/util/EthernetAddressTest.java | 29 --- .../java/org/maxkey/util/IdSequenceTest.java | 33 ---- .../java/org/maxkey/util/MacAddressTest.java | 29 --- .../maxkey/util/ObjectTransformerTest.java | 46 ----- .../java/org/maxkey/util/PathUtilsTest.java | 30 ---- .../java/org/maxkey/util/SqlPrettyTest.java | 35 ---- .../org/maxkey/util/StringGeneratorTest.java | 40 ----- .../org/maxkey/util/UUIDGeneratorTest.java | 59 ------ .../java/org/maxkey/util/XMLHelperTest.java | 48 ----- .../java/org/maxkey/word/CharacterCase.java | 33 ---- .../src/test/java/org/maxkey/word/SubStr.java | 31 ---- .../templates/views/layout/footer.ftl | 2 +- 39 files changed, 1 insertion(+), 2076 deletions(-) delete mode 100644 maxkey-common/src/test/java/org/maxkey/persistence/derby/DerbyTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/Copyright.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/CopyrightC.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/cache/CacheFactoryTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/cache/RandomCache.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/copyright.txt delete mode 100644 maxkey-core/src/test/java/org/maxkey/crypto/Base64UtilsTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/crypto/DigestUtilsTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/crypto/KeyGen.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/crypto/Md5SumTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/crypto/PasswordGenTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/crypto/RSAUtilsTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/crypto/ReciprocalUtilsTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/crypto/RsaMessage.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/crypto/SCryptPasswordEncoderTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/crypto/cert/X509CertUtilsTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/crypto/cert/X509V3CertGenTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/crypto/password/PasswordPolicyValidatorTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/crypto/password/PasswordReciprocalTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/crypto/password/SM3PasswordEncoderTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/crypto/signature/DsaSignerTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/crypto/signature/RsaSignerTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/json/util/JsonUtilsTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/mail/MailTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/otp/algorithm/RQcodeTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/rest/AuthorizationHeaderTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/util/DateUtilsTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/util/EthernetAddressTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/util/IdSequenceTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/util/MacAddressTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/util/ObjectTransformerTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/util/PathUtilsTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/util/SqlPrettyTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/util/StringGeneratorTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/util/UUIDGeneratorTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/util/XMLHelperTest.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/word/CharacterCase.java delete mode 100644 maxkey-core/src/test/java/org/maxkey/word/SubStr.java diff --git a/maxkey-common/src/test/java/org/maxkey/persistence/derby/DerbyTest.java b/maxkey-common/src/test/java/org/maxkey/persistence/derby/DerbyTest.java deleted file mode 100644 index fb136224..00000000 --- a/maxkey-common/src/test/java/org/maxkey/persistence/derby/DerbyTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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")); - } - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/Copyright.java b/maxkey-core/src/test/java/org/maxkey/Copyright.java deleted file mode 100644 index 4d09056c..00000000 --- a/maxkey-core/src/test/java/org/maxkey/Copyright.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * 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; - } - -} \ No newline at end of file diff --git a/maxkey-core/src/test/java/org/maxkey/CopyrightC.java b/maxkey-core/src/test/java/org/maxkey/CopyrightC.java deleted file mode 100644 index a36740d7..00000000 --- a/maxkey-core/src/test/java/org/maxkey/CopyrightC.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.maxkey; - -public class CopyrightC { - - public static void main(String[] args) { - // TODO Auto-generated method stub - System.out.println(Character.toString(0xA9)); - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/cache/CacheFactoryTest.java b/maxkey-core/src/test/java/org/maxkey/cache/CacheFactoryTest.java deleted file mode 100644 index ba6c3d91..00000000 --- a/maxkey-core/src/test/java/org/maxkey/cache/CacheFactoryTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 cacheList=new ArrayList(); - cacheList.add(randomCache); - CacheFactory cacheFactory=new CacheFactory(); - cacheFactory.setCache(cacheList); - cacheFactory.start(); - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/cache/RandomCache.java b/maxkey-core/src/test/java/org/maxkey/cache/RandomCache.java deleted file mode 100644 index 5077d11e..00000000 --- a/maxkey-core/src/test/java/org/maxkey/cache/RandomCache.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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; - } - - - -} diff --git a/maxkey-core/src/test/java/org/maxkey/copyright.txt b/maxkey-core/src/test/java/org/maxkey/copyright.txt deleted file mode 100644 index 9759194f..00000000 --- a/maxkey-core/src/test/java/org/maxkey/copyright.txt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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. - */ - \ No newline at end of file diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/Base64UtilsTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/Base64UtilsTest.java deleted file mode 100644 index 95e7daee..00000000 --- a/maxkey-core/src/test/java/org/maxkey/crypto/Base64UtilsTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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=")); - - - - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/DigestUtilsTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/DigestUtilsTest.java deleted file mode 100644 index ffa59cfd..00000000 --- a/maxkey-core/src/test/java/org/maxkey/crypto/DigestUtilsTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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()); - } -} diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/KeyGen.java b/maxkey-core/src/test/java/org/maxkey/crypto/KeyGen.java deleted file mode 100644 index e2a8e57f..00000000 --- a/maxkey-core/src/test/java/org/maxkey/crypto/KeyGen.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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); - // ȡ����Կ�� - KeyPair kp = keygen.generateKeyPair(); - // ȡ�ù�Կ - PublicKey publicKey = kp.getPublic(); - System.out.println(publicKey); - saveFile(publicKey, "pk.dat"); - // ȡ��˽Կ - 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(); - } -} -//���ù�Կ���ܣ�˽Կ���ܣ� - - - diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/Md5SumTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/Md5SumTest.java deleted file mode 100644 index b3a555a1..00000000 --- a/maxkey-core/src/test/java/org/maxkey/crypto/Md5SumTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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)); - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/PasswordGenTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/PasswordGenTest.java deleted file mode 100644 index 4809a32b..00000000 --- a/maxkey-core/src/test/java/org/maxkey/crypto/PasswordGenTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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)); - } - - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/RSAUtilsTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/RSAUtilsTest.java deleted file mode 100644 index cd44025c..00000000 --- a/maxkey-core/src/test/java/org/maxkey/crypto/RSAUtilsTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 { - - // ˽Կ���ܡ�����Կ���� - // ˽Կǩ����Կ��֤ǩ�� - Map 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("���ܺ�\r\n" + new String(encodedData)); - System.out.println("���ܺ�B64��\r\n" + HexUtils.bytes2HexString(encodedData)); - byte[] decodedData = RSAUtils.decryptByPublicKey(encodedData, publicKey); - String target = new String(decodedData); - System.out.println("target:" + target); - - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/ReciprocalUtilsTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/ReciprocalUtilsTest.java deleted file mode 100644 index b1077afa..00000000 --- a/maxkey-core/src/test/java/org/maxkey/crypto/ReciprocalUtilsTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 ); - - } -} diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/RsaMessage.java b/maxkey-core/src/test/java/org/maxkey/crypto/RsaMessage.java deleted file mode 100644 index 058db6fe..00000000 --- a/maxkey-core/src/test/java/org/maxkey/crypto/RsaMessage.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * 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�ӽ���,RSAǩ��ǩ����֤�� - * - * @author Administrator - * - */ - public class RsaMessage { - - - - - public static void main(String[] args) throws Exception { - String str = "hello,�����ĵ����"; - System.out.println("ԭ�ģ�" + 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("˽Կ���ܺ�"); - String encStr = toHexString(encbyte); - System.out.println(encStr); - - byte[] signBytes = rsa.sign(str, privateKey); - System.out.println("ǩ��ֵ��"); - String signStr = toHexString(signBytes); - System.out.println(signStr); - - byte[] decByte = rsa.decrypt(encStr, publickKey); - System.out.println("��Կ���ܺ�"); - 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"); - } - } - - /** - * ����,key�����ǹ�Կ��Ҳ������˽Կ - * - * @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()); - } - - /** - * ���ܣ�key�����ǹ�Կ��Ҳ������˽Կ������ǹ�Կ���ܾ���˽Կ���ܣ���֮��Ȼ - * - * @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)); - } - - /** - * ��˽Կǩ�� - * - * @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(); - } - - /** - * �ù�Կ��֤ǩ�����ȷ�� - * - * @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)); - } - - /** - * ���ļ���ȡ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' }; - } diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/SCryptPasswordEncoderTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/SCryptPasswordEncoderTest.java deleted file mode 100644 index 42f2bdd7..00000000 --- a/maxkey-core/src/test/java/org/maxkey/crypto/SCryptPasswordEncoderTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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)); - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509CertUtilsTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509CertUtilsTest.java deleted file mode 100644 index 5c639524..00000000 --- a/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509CertUtilsTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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(); - * - * } - * - * } - */ diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509V3CertGenTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509V3CertGenTest.java deleted file mode 100644 index 3e050726..00000000 --- a/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509V3CertGenTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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()); - - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/password/PasswordPolicyValidatorTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/password/PasswordPolicyValidatorTest.java deleted file mode 100644 index 4aca438a..00000000 --- a/maxkey-core/src/test/java/org/maxkey/crypto/password/PasswordPolicyValidatorTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.maxkey.domain.PasswordPolicy; -import org.maxkey.domain.UserInfo; -import org.maxkey.persistence.db.PasswordPolicyValidator; - -public class PasswordPolicyValidatorTest { - - public static void main(String[] args) { - // TODO Auto-generated method stub - PasswordPolicy passwordPolicy =new PasswordPolicy(); - passwordPolicy.setDigits(3); - passwordPolicy.setMaxLength(16); - passwordPolicy.setMinLength(6); - passwordPolicy.setLowerCase(2); - passwordPolicy.setUpperCase(2); - passwordPolicy.setSpecialChar(1); - passwordPolicy.setUsername(1); - passwordPolicy.setDictionary(0); - PasswordPolicyValidator passwordPolicyValidator =new PasswordPolicyValidator(); - - passwordPolicyValidator.setPasswordPolicy(passwordPolicy); - - UserInfo u=new UserInfo(); - u.setUsername("admin"); - u.setPassword("admin无"); - passwordPolicyValidator.validator(u); - - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/password/PasswordReciprocalTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/password/PasswordReciprocalTest.java deleted file mode 100644 index ce456de3..00000000 --- a/maxkey-core/src/test/java/org/maxkey/crypto/password/PasswordReciprocalTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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")); - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/password/SM3PasswordEncoderTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/password/SM3PasswordEncoderTest.java deleted file mode 100644 index 631f2720..00000000 --- a/maxkey-core/src/test/java/org/maxkey/crypto/password/SM3PasswordEncoderTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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)); - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/signature/DsaSignerTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/signature/DsaSignerTest.java deleted file mode 100644 index b38ce198..00000000 --- a/maxkey-core/src/test/java/org/maxkey/crypto/signature/DsaSignerTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 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��" + sign); - // verify - boolean status = dsaSigner.verifyB64(signStr, publicKey, sign); - System.out.println("status��" + status); - - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/signature/RsaSignerTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/signature/RsaSignerTest.java deleted file mode 100644 index 0be0a619..00000000 --- a/maxkey-core/src/test/java/org/maxkey/crypto/signature/RsaSignerTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 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); - - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/json/util/JsonUtilsTest.java b/maxkey-core/src/test/java/org/maxkey/json/util/JsonUtilsTest.java deleted file mode 100644 index f41c349a..00000000 --- a/maxkey-core/src/test/java/org/maxkey/json/util/JsonUtilsTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.json.util; - -import org.maxkey.domain.Groups; -import org.maxkey.pretty.impl.JsonPretty; -import org.maxkey.util.JsonUtils; - -public class JsonUtilsTest { - - /** - * @param args - */ - public static void main(String[] args) { - // TODO Auto-generated method stub - Groups g=new Groups("test"); - g.setName("jjjj"); - - JsonPretty jp=new JsonPretty(); - String json=jp.format(g); - System.out.println(json); - Groups newg=JsonUtils.gson2Object(json, Groups.class); - System.out.println(newg.getName()); - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/mail/MailTest.java b/maxkey-core/src/test/java/org/maxkey/mail/MailTest.java deleted file mode 100644 index 26d351e6..00000000 --- a/maxkey-core/src/test/java/org/maxkey/mail/MailTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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(); - } -} diff --git a/maxkey-core/src/test/java/org/maxkey/otp/algorithm/RQcodeTest.java b/maxkey-core/src/test/java/org/maxkey/otp/algorithm/RQcodeTest.java deleted file mode 100644 index e2d42d94..00000000 --- a/maxkey-core/src/test/java/org/maxkey/otp/algorithm/RQcodeTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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(); - } - } - - -} diff --git a/maxkey-core/src/test/java/org/maxkey/rest/AuthorizationHeaderTest.java b/maxkey-core/src/test/java/org/maxkey/rest/AuthorizationHeaderTest.java deleted file mode 100644 index ba686b57..00000000 --- a/maxkey-core/src/test/java/org/maxkey/rest/AuthorizationHeaderTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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]); - } -} diff --git a/maxkey-core/src/test/java/org/maxkey/util/DateUtilsTest.java b/maxkey-core/src/test/java/org/maxkey/util/DateUtilsTest.java deleted file mode 100644 index ad4ee22f..00000000 --- a/maxkey-core/src/test/java/org/maxkey/util/DateUtilsTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 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}"; //��ʾa��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")); - - } -} diff --git a/maxkey-core/src/test/java/org/maxkey/util/EthernetAddressTest.java b/maxkey-core/src/test/java/org/maxkey/util/EthernetAddressTest.java deleted file mode 100644 index 7db3af45..00000000 --- a/maxkey-core/src/test/java/org/maxkey/util/EthernetAddressTest.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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()); - - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/util/IdSequenceTest.java b/maxkey-core/src/test/java/org/maxkey/util/IdSequenceTest.java deleted file mode 100644 index 6124136d..00000000 --- a/maxkey-core/src/test/java/org/maxkey/util/IdSequenceTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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); - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/util/MacAddressTest.java b/maxkey-core/src/test/java/org/maxkey/util/MacAddressTest.java deleted file mode 100644 index cba766dc..00000000 --- a/maxkey-core/src/test/java/org/maxkey/util/MacAddressTest.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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()); - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/util/ObjectTransformerTest.java b/maxkey-core/src/test/java/org/maxkey/util/ObjectTransformerTest.java deleted file mode 100644 index e9292030..00000000 --- a/maxkey-core/src/test/java/org/maxkey/util/ObjectTransformerTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.domain.UserInfo; -import org.maxkey.util.ObjectTransformer; - -public class ObjectTransformerTest { - - /** - * @param args - */ - public static void main(String[] args) { - // TODO Auto-generated method stub - UserInfo u=new UserInfo(); - - u.setUsername("shimingxy"); - u.setPassword("test"); - u.setDepartment("我的部门"); - String hexString =ObjectTransformer.serialize(u); - - System.out.println("hexString "+hexString); - System.out.println(hexString.length()); - UserInfo 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()); - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/util/PathUtilsTest.java b/maxkey-core/src/test/java/org/maxkey/util/PathUtilsTest.java deleted file mode 100644 index 0192a832..00000000 --- a/maxkey-core/src/test/java/org/maxkey/util/PathUtilsTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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()); - } -} diff --git a/maxkey-core/src/test/java/org/maxkey/util/SqlPrettyTest.java b/maxkey-core/src/test/java/org/maxkey/util/SqlPrettyTest.java deleted file mode 100644 index c666a18f..00000000 --- a/maxkey-core/src/test/java/org/maxkey/util/SqlPrettyTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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)); - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/util/StringGeneratorTest.java b/maxkey-core/src/test/java/org/maxkey/util/StringGeneratorTest.java deleted file mode 100644 index 7b654c9b..00000000 --- a/maxkey-core/src/test/java/org/maxkey/util/StringGeneratorTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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")); - - - } -} diff --git a/maxkey-core/src/test/java/org/maxkey/util/UUIDGeneratorTest.java b/maxkey-core/src/test/java/org/maxkey/util/UUIDGeneratorTest.java deleted file mode 100644 index 366fa4ae..00000000 --- a/maxkey-core/src/test/java/org/maxkey/util/UUIDGeneratorTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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())); - - - } -} diff --git a/maxkey-core/src/test/java/org/maxkey/util/XMLHelperTest.java b/maxkey-core/src/test/java/org/maxkey/util/XMLHelperTest.java deleted file mode 100644 index eee2076d..00000000 --- a/maxkey-core/src/test/java/org/maxkey/util/XMLHelperTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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="maxkey"; - System.out.println(XMLHelper.prettyPrintXML(sqlString)); - System.out.println(XMLHelper.transformer(sqlString)); - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/word/CharacterCase.java b/maxkey-core/src/test/java/org/maxkey/word/CharacterCase.java deleted file mode 100644 index 89629da5..00000000 --- a/maxkey-core/src/test/java/org/maxkey/word/CharacterCase.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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()); - } - -} diff --git a/maxkey-core/src/test/java/org/maxkey/word/SubStr.java b/maxkey-core/src/test/java/org/maxkey/word/SubStr.java deleted file mode 100644 index 9b542722..00000000 --- a/maxkey-core/src/test/java/org/maxkey/word/SubStr.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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('.')); - } - -} diff --git a/maxkey-web-maxkey/src/main/resources/templates/views/layout/footer.ftl b/maxkey-web-maxkey/src/main/resources/templates/views/layout/footer.ftl index 6eedcbc4..bffb41b5 100644 --- a/maxkey-web-maxkey/src/main/resources/templates/views/layout/footer.ftl +++ b/maxkey-web-maxkey/src/main/resources/templates/views/layout/footer.ftl @@ -19,6 +19,6 @@ <#-- encryption certificate for login --> <#-- footer end --> \ No newline at end of file