-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathAuthenticationResultMetadata.java
More file actions
114 lines (89 loc) · 3.95 KB
/
AuthenticationResultMetadata.java
File metadata and controls
114 lines (89 loc) · 3.95 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.microsoft.aad.msal4j;
import java.io.Serializable;
import java.util.Objects;
/**
* Contains metadata and additional context for the contents of an AuthenticationResult
*/
public class AuthenticationResultMetadata implements Serializable {
/**
* The source of the tokens in the {@link AuthenticationResult}, see {@link TokenSource} for possible values
*/
private TokenSource tokenSource;
/**
* When the token should be proactively refreshed. May be null or 0 if proactive refresh is not used
*/
private Long refreshOn;
/**
* Specifies the reason for refreshing the access token, see {@link CacheRefreshReason} for possible values. Will be {@link CacheRefreshReason#NOT_APPLICABLE} if the token was returned from the cache or if the API used to fetch the token does not attempt to read the cache.
*/
private CacheRefreshReason cacheRefreshReason = CacheRefreshReason.NOT_APPLICABLE;
AuthenticationResultMetadata(TokenSource tokenSource, Long refreshOn, CacheRefreshReason cacheRefreshReason) {
this.tokenSource = tokenSource;
this.refreshOn = refreshOn;
this.cacheRefreshReason = cacheRefreshReason == null ? CacheRefreshReason.NOT_APPLICABLE : cacheRefreshReason;
}
public static AuthenticationResultMetadataBuilder builder() {
return new AuthenticationResultMetadataBuilder();
}
public TokenSource tokenSource() {
return this.tokenSource;
}
public Long refreshOn() {
return this.refreshOn;
}
public CacheRefreshReason cacheRefreshReason() {
return this.cacheRefreshReason;
}
void tokenSource(TokenSource tokenSource) {
this.tokenSource = tokenSource;
}
void refreshOn(Long refreshOn) {
this.refreshOn = refreshOn;
}
void cacheRefreshReason(CacheRefreshReason cacheRefreshReason) {
this.cacheRefreshReason = cacheRefreshReason;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof AuthenticationResultMetadata)) return false;
AuthenticationResultMetadata other = (AuthenticationResultMetadata) o;
return Objects.equals(tokenSource, other.tokenSource)
&& Objects.equals(refreshOn, other.refreshOn)
&& Objects.equals(cacheRefreshReason, other.cacheRefreshReason);
}
@Override
public int hashCode() {
int result = tokenSource == null ? 0 : tokenSource.hashCode();
result = 31 * result + (refreshOn == null ? 0 : refreshOn.hashCode());
result = 31 * result + (cacheRefreshReason == null ? 0 : cacheRefreshReason.hashCode());
return result;
}
public static class AuthenticationResultMetadataBuilder {
private TokenSource tokenSource;
private Long refreshOn;
private CacheRefreshReason cacheRefreshReason;
AuthenticationResultMetadataBuilder() {
}
public AuthenticationResultMetadataBuilder tokenSource(TokenSource tokenSource) {
this.tokenSource = tokenSource;
return this;
}
public AuthenticationResultMetadataBuilder refreshOn(Long refreshOn) {
this.refreshOn = refreshOn;
return this;
}
public AuthenticationResultMetadataBuilder cacheRefreshReason(CacheRefreshReason cacheRefreshReason) {
this.cacheRefreshReason = cacheRefreshReason;
return this;
}
public AuthenticationResultMetadata build() {
return new AuthenticationResultMetadata(this.tokenSource, this.refreshOn, cacheRefreshReason);
}
public String toString() {
return "AuthenticationResultMetadata.AuthenticationResultMetadataBuilder(tokenSource=" + this.tokenSource + ", refreshOn=" + this.refreshOn + ", cacheRefreshReason$value=" + this.cacheRefreshReason + ")";
}
}
}