forked from auth0/java-jwt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlgorithm.java
More file actions
33 lines (25 loc) · 790 Bytes
/
Algorithm.java
File metadata and controls
33 lines (25 loc) · 790 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
29
30
31
32
33
package com.auth0.jwt;
import org.apache.commons.lang3.Validate;
/**
* Supported Library Algorithms
*
* https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#KeyPairGenerator
*/
public enum Algorithm {
HS256("HmacSHA256"), HS384("HmacSHA384"), HS512("HmacSHA512"), RS256("SHA256withRSA"), RS384("SHA384withRSA"), RS512("SHA512withRSA");
private Algorithm(final String value) {
this.value = value;
}
private String value;
public String getValue() {
return value;
}
public static Algorithm findByName(final String name) throws JWTAlgorithmException {
Validate.notNull(name);
try {
return Algorithm.valueOf(name);
} catch (IllegalArgumentException e) {
throw new JWTAlgorithmException("Unsupported algorithm: " + name);
}
}
}