Skip to content

Commit f8f58a7

Browse files
committed
vue sample update
1 parent 0b183f8 commit f8f58a7

9 files changed

+612
-85
lines changed

core/pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@
241241
<dependency>
242242
<groupId>com.thoughtworks.qdox</groupId>
243243
<artifactId>qdox</artifactId>
244-
<version>2.0.0</version>
244+
<version>2.1.0</version>
245245
<optional>true</optional>
246246
</dependency>
247247
<dependency>
@@ -275,6 +275,12 @@
275275
<version>3.0.9</version>
276276
<optional>true</optional>
277277
</dependency>
278+
<dependency>
279+
<groupId>org.javassist</groupId>
280+
<artifactId>javassist</artifactId>
281+
<version>3.25.0-GA</version>
282+
<optional>true</optional>
283+
</dependency>
278284
</dependencies>
279285

280286

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
package com.robin.core.base.util;
2+
3+
import com.google.common.collect.Lists;
4+
import com.robin.core.base.shell.CommandLineExecutor;
5+
import com.robin.core.hardware.MachineIdUtils;
6+
import lombok.extern.slf4j.Slf4j;
7+
import org.apache.commons.io.FileUtils;
8+
import org.apache.commons.io.filefilter.DirectoryFileFilter;
9+
import org.apache.commons.io.filefilter.FileFilterUtils;
10+
import org.dom4j.Document;
11+
import org.dom4j.DocumentException;
12+
import org.dom4j.Element;
13+
import org.dom4j.io.SAXReader;
14+
import org.springframework.util.CollectionUtils;
15+
import org.springframework.util.ObjectUtils;
16+
import org.springframework.util.StringUtils;
17+
18+
import java.io.File;
19+
import java.util.*;
20+
21+
@Slf4j
22+
public class MavenUtils {
23+
public static String getMavenRepository(){
24+
File m2Path=new File(FileUtils.getUserDirectoryPath()+"/.m2/settings.xml");
25+
String localRepository=null;
26+
try {
27+
if (m2Path.exists()) {
28+
SAXReader reader = new SAXReader();
29+
Document document = reader.read(m2Path);
30+
if(!ObjectUtils.isEmpty(document)){
31+
Element element=document.getRootElement().element("localRepository");
32+
if(element!=null){
33+
localRepository=element.getText();
34+
}
35+
}
36+
}else{
37+
String mavenHome=System.getenv("MAVEN_HOME");
38+
if(!ObjectUtils.isEmpty(mavenHome)){
39+
File configPath=new File(mavenHome+"/conf/settings.xml");
40+
if(configPath.exists()){
41+
SAXReader reader = new SAXReader();
42+
Document document = reader.read(configPath);
43+
if(!ObjectUtils.isEmpty(document)){
44+
Element element=document.getRootElement().element("localRepository");
45+
if(element!=null){
46+
localRepository=element.getText();
47+
}
48+
}
49+
}
50+
51+
}else{
52+
log.error("can not get maven config from m2 path or MAVEN_HOME!");
53+
}
54+
}
55+
}catch (DocumentException ex){
56+
log.error("{}",ex.getMessage());
57+
}
58+
return localRepository;
59+
}
60+
public static List<String> getDepenendcyList(String mavenRepoPath,String mavenFilePath){
61+
List<String> dependencyList=new ArrayList<>();
62+
try {
63+
String content = null;
64+
if(MachineIdUtils.isWindows()) {
65+
content=CommandLineExecutor.getInstance().executeCmd(Lists.newArrayList("cmd.exe", "/c", "CD " + mavenFilePath + " & mvn dependency:tree -D outputType=dot"));
66+
}else if(MachineIdUtils.isLinux() || MachineIdUtils.isMacosName()){
67+
content=CommandLineExecutor.getInstance().executeCmd(Lists.newArrayList("sh", "-c", "CD " + mavenFilePath + " & mvn dependency:tree -D outputType=dot"));
68+
}
69+
process(mavenRepoPath, dependencyList, content);
70+
}catch (Exception ex){
71+
log.error("{}",ex.getMessage());
72+
}
73+
return dependencyList;
74+
}
75+
76+
private static void process(String mavenRepoPath, List<String> dependencyList, String content) {
77+
try(Scanner scanner = new Scanner(content)) {
78+
while (scanner.hasNext()) {
79+
String line = scanner.nextLine();
80+
if (!ObjectUtils.isEmpty(line) && (line.contains("+") || line.contains("-"))) {
81+
String[] arr = null;
82+
if(line.contains("+-")){
83+
arr=StringUtils.split(line, "+-");
84+
}else if(line.contains("\\-")){
85+
arr=StringUtils.split(line, "\\-");
86+
}
87+
if (arr!=null && arr.length == 2) {
88+
String trimStr = arr[1].trim().replace("\"", "");
89+
String[] dependencyPart = trimStr.trim().split(":");
90+
if ("compile".equalsIgnoreCase(dependencyPart[4])) {
91+
dependencyList.add(mavenRepoPath + File.separator + dependencyPart[0].replace(".", File.separator) + File.separator + dependencyPart[1] + File.separator + dependencyPart[3] + File.separator + dependencyPart[1] + "-" + dependencyPart[3] + ".jar");
92+
} else {
93+
log.info("{} scope {}", trimStr, dependencyPart[4]);
94+
}
95+
}
96+
}
97+
}
98+
}catch (Exception ex){
99+
log.error("{}",ex.getMessage());
100+
}
101+
}
102+
103+
public static void main(String[] args){
104+
String mavenPath=getMavenRepository();
105+
System.out.println(getDepenendcyList(mavenPath,"E:/dev/workspaceframe/JavaFramework/core"));
106+
107+
/*Collection<File> files=FileUtils.listFiles(new File("e:/tmp/testoutput/META-INF/maven"), FileFilterUtils.suffixFileFilter("xml"), DirectoryFileFilter.INSTANCE);
108+
if (!CollectionUtils.isEmpty(files)) {
109+
for(File file:files) {
110+
System.out.println(getDepenendcyList(mavenPath, file.getParent()));
111+
}
112+
}*/
113+
114+
}
115+
}

core/src/main/java/com/robin/core/base/util/PropertiesLoader.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99
package com.robin.core.base.util;
1010

11-
import org.apache.commons.compress.utils.IOUtils;
1211
import org.slf4j.Logger;
1312
import org.slf4j.LoggerFactory;
1413
import org.springframework.core.io.DefaultResourceLoader;

core/src/main/java/com/robin/core/encrypt/CipherUtil.java

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.bouncycastle.util.io.pem.PemObject;
1414
import org.bouncycastle.util.io.pem.PemReader;
1515
import org.bouncycastle.util.io.pem.PemWriter;
16+
import org.springframework.util.Assert;
1617
import org.springframework.util.ObjectUtils;
1718

1819
import javax.crypto.*;
@@ -23,8 +24,10 @@
2324
import java.security.interfaces.RSAPrivateKey;
2425
import java.security.interfaces.RSAPublicKey;
2526
import java.security.spec.*;
27+
import java.util.ArrayList;
2628
import java.util.Base64;
2729
import java.util.List;
30+
import java.util.Random;
2831

2932
import static com.google.common.base.Preconditions.checkArgument;
3033

@@ -33,6 +36,7 @@
3336
public class CipherUtil {
3437
private static final String DEFAULTALGORITHM = "AES";
3538
private static final String DEFAULT_CIPHER_ALGORITHM = "AES/ECB/PKCS7Padding";
39+
private static final String[] CONFUSEDSTRS = {"i", "I", "l", "O", "0", "1"};
3640

3741
public static final String SIGNATURE_ALGORITHM = "SHA256WithRSA";
3842
public static final char[] avaiablechar = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '-', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '/'};
@@ -194,6 +198,17 @@ public byte[] getDigest(InputStream stream) {
194198
}
195199
return null;
196200
}
201+
public static byte[] getMd5(byte[] bytes) {
202+
byte[] b = null;
203+
try {
204+
MessageDigest md = MessageDigest.getInstance("MD5");
205+
md.update(bytes);
206+
b = md.digest();
207+
} catch (NoSuchAlgorithmException e) {
208+
e.printStackTrace();
209+
}
210+
return b;
211+
}
197212

198213
public static byte[] getKeyByClassPath(String keyFile) {
199214
return getKeyByInputStream(CipherUtil.class.getClassLoader().getResourceAsStream(keyFile));
@@ -383,11 +398,79 @@ public static List<String> generateRandomKey() throws NoSuchAlgorithmException {
383398

384399
}
385400
}
401+
public static String bytesToHexString1(byte[] src) {
402+
StringBuilder stringBuilder = new StringBuilder("");
403+
if (src == null || src.length <= 0) {
404+
return null;
405+
}
406+
for (int i = 0; i < src.length; i++) {
407+
int v = src[i] & 0xFF;
408+
String hv = Integer.toHexString(v);
409+
if (hv.length() < 2) {
410+
stringBuilder.append(0);
411+
}
412+
stringBuilder.append(hv);
413+
}
414+
return stringBuilder.toString().toUpperCase();
415+
}
416+
417+
public static byte[] LongToBytes(long values) {
418+
byte[] buffer = new byte[8];
419+
for (int i = 0; i < 8; i++) {
420+
int offset = 64 - (i + 1) * 8;
421+
buffer[i] = (byte) ((values >> offset) & 0xff);
422+
}
423+
return buffer;
424+
}
425+
public static byte[] hexStringToBytes(String hex) {
426+
byte[] bytes = new byte[hex.length() / 2];
427+
for (int i = 0; i < bytes.length; i++) {
428+
bytes[i] = (byte) Integer.parseInt(hex.substring(i * 2, i * 2 + 2), 16);
429+
}
430+
return bytes;
431+
}
432+
public static String bytesToHexString(byte[] bytes) {
433+
StringBuilder builder = new StringBuilder();
434+
for (byte b : bytes) {
435+
builder.append(String.format("%02X", b));
436+
}
437+
return builder.toString();
438+
}
386439

440+
public static byte[] getEncryptKey(byte[] bytes){
441+
if(bytes.length==16 || bytes.length==32){
442+
return bytes;
443+
}else{
444+
return getMd5(bytes);
445+
}
446+
}
447+
public static String generateRandomKey(int range, int num, Random random) {
448+
StringBuilder builder = new StringBuilder();
449+
for (int i = 0; i < num; i++) {
450+
int randint = random.nextInt(range);
451+
builder.append(CipherUtil.avaiablechar[randint]);
452+
}
453+
return builder.toString();
454+
}
455+
public static List<String> getConfusedName(int length, Random random) {
456+
StringBuilder builder = new StringBuilder();
457+
StringBuilder builder1 = new StringBuilder();
458+
for (int i = 0; i < length; i++) {
459+
int pos = random.nextInt(CONFUSEDSTRS.length);
460+
builder1.append(pos);
461+
builder.append(CONFUSEDSTRS[pos]);
462+
}
463+
List<String> retList = new ArrayList<>();
464+
retList.add(builder.toString());
465+
retList.add(builder1.toString());
466+
return retList;
467+
}
387468

388469
public static void main(String[] args) {
389470
try {
390-
471+
byte[] bytes=hexStringToBytes("9AF16B867075453592358C8BDB17CBF1");
472+
System.out.println(bytes);
473+
System.out.println(bytesToHexString(bytes));
391474

392475
/*byte[] bytes = CipherUtil.initSecretKey();
393476
String ret = Base64.getEncoder().encodeToString(bytes);

0 commit comments

Comments
 (0)