forked from GJWT/javaOIDCMsg
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringUtil.java
More file actions
28 lines (24 loc) · 973 Bytes
/
StringUtil.java
File metadata and controls
28 lines (24 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package oiccli;
import org.apache.commons.text.CharacterPredicates;
import org.apache.commons.text.RandomStringGenerator;
public class StringUtil {
public static String generateRandomString(int length) {
return new RandomStringGenerator.Builder()
.withinRange('0', 'z')
.filteredBy(CharacterPredicates.LETTERS, CharacterPredicates.DIGITS)
.build().generate(length);
}
public static String alg2keytype(String algorithm) {
if (algorithm == null || algorithm.toLowerCase().equals("none")) {
return "none";
} else if (algorithm.startsWith("RS") || algorithm.startsWith("PS")) {
return "RSA";
} else if (algorithm.startsWith("HS") || algorithm.startsWith("A")) {
return "oct";
} else if (algorithm.startsWith("ES") || algorithm.startsWith("ECDH-ES")) {
return "EC";
} else {
return null;
}
}
}