-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpSigAlgorithm.java
More file actions
81 lines (71 loc) · 1.81 KB
/
Copy pathHttpSigAlgorithm.java
File metadata and controls
81 lines (71 loc) · 1.81 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package io.bspk.httpsig;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
/**
* Signature algorithms.
* @author jricher
*
*/
public class HttpSigAlgorithm {
public static final HttpSigAlgorithm RSAPSS = new HttpSigAlgorithm("rsa-pss-sha512");
public static final HttpSigAlgorithm RSA15 = new HttpSigAlgorithm("rsa-v1_5-sha256");
public static final HttpSigAlgorithm HMAC = new HttpSigAlgorithm("hmac-sha256");
public static final HttpSigAlgorithm ECDSA = new HttpSigAlgorithm("ecdsa-p256-sha256");
public static final HttpSigAlgorithm ED25519 = new HttpSigAlgorithm("ed25519");
public static final HttpSigAlgorithm JOSE = new HttpSigAlgorithm(null);
@JsonValue
private final String explicitAlg;
/**
* @param object
*/
private HttpSigAlgorithm(String explicitAlg) {
this.explicitAlg = explicitAlg;
}
/**
* @return the explicitAlg
*/
public String getExplicitAlg() {
return explicitAlg;
}
/**
* @return
*/
@JsonCreator
public static HttpSigAlgorithm of(String alg) {
if (alg == null) {
return null;
} else if (alg.equalsIgnoreCase("jose")) {
return JOSE;
} else {
return new HttpSigAlgorithm(alg);
}
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
HttpSigAlgorithm other = (HttpSigAlgorithm) obj;
if (getExplicitAlg() == null) {
if (other.getExplicitAlg() != null) {
return false;
}
} else if (!getExplicitAlg().equals(other.getExplicitAlg())) {
return false;
}
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getExplicitAlg() == null) ? 0 : getExplicitAlg().hashCode());
return result;
}
}