/
Version.java
62 lines (50 loc) · 1.38 KB
/
Version.java
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
package com.bazaarvoice.auth.hmac.common;
/**
* Represents a version of the authentication contract between the client and server.
*/
public enum Version {
/**
* Version 1
* <p> - Has mixed implementations for including content data in signature (deprecated)
*/
@Deprecated
V1("1", true),
/**
* Version 2
* <p> - will not include content data in signature
*/
V2("2", false),
/**
* Version 3
* <p> - will include content data in signature
*/
V3("3", true),
;
private String value;
private boolean dataInSignature;
Version(String value, boolean dataInSignature) {
this.value = value;
this.dataInSignature = dataInSignature;
}
public static Version fromValue(String value) {
if (value == null || value.isEmpty()) {
throw new IllegalArgumentException("Version value cannot be null");
}
for (Version version : Version.values()) {
if (value.equalsIgnoreCase(version.value)) {
return version;
}
}
throw new IllegalArgumentException(value + " does not have a valid mapping in Version");
}
public String getValue() {
return value;
}
public boolean isDataInSignature() {
return dataInSignature;
}
@Override
public String toString() {
return value;
}
}