/
UserInfoResponse.java
129 lines (111 loc) · 3.54 KB
/
UserInfoResponse.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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
* oxAuth is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
*
* Copyright (c) 2014, Gluu
*/
package org.xdi.oxauth.client;
import org.xdi.oxauth.model.userinfo.UserInfoErrorResponseType;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Represents an user info response received from the authorization server.
*
* @author Javier Rojas Blum Date: 11.30.2011
*/
public class UserInfoResponse extends BaseResponse {
private Map<String, List<String>> claims;
private UserInfoErrorResponseType errorType;
private String errorDescription;
private String errorUri;
/**
* Constructs a User Info response.
*
* @param status The response status code.
*/
public UserInfoResponse(int status) {
super(status);
claims = new HashMap<String, List<String>>();
}
public Map<String, List<String>> getClaims() {
return claims;
}
public void setClaims(Map<String, List<String>> claims) {
this.claims = claims;
}
/**
* Returns the error code when the request fails, otherwise will return <code>null</code>.
*
* @return The error code when the request fails.
*/
public UserInfoErrorResponseType getErrorType() {
return errorType;
}
/**
* Sets the error code when the request fails, otherwise will return
* <code>null</code>.
*
* @param errorType The error code when the request fails.
*/
public void setErrorType(UserInfoErrorResponseType errorType) {
this.errorType = errorType;
}
/**
* Returns a human-readable UTF-8 encoded text providing additional
* information, used to assist the client developer in understanding the
* error that occurred.
*
* @return The error description.
*/
public String getErrorDescription() {
return errorDescription;
}
/**
* Sets a human-readable UTF-8 encoded text providing additional
* information, used to assist the client developer in understanding the
* error that occurred.
*
* @param errorDescription The error description.
*/
public void setErrorDescription(String errorDescription) {
this.errorDescription = errorDescription;
}
/**
* Returns a URI identifying a human-readable web page with information
* about the error, used to provide the client developer with additional
* information about the error.
*
* @return A URI with information about the error.
*/
public String getErrorUri() {
return errorUri;
}
/**
* Sets a URI identifying a human-readable web page with information about
* the error, used to provide the client developer with additional
* information about the error.
*
* @param errorUri A URI with information about the error.
*/
public void setErrorUri(String errorUri) {
this.errorUri = errorUri;
}
public List<String> getClaim(String claimName) {
if (claims.containsKey(claimName)) {
return claims.get(claimName);
}
return null;
}
@Override
public String toString() {
return "UserInfoResponse{" +
"status=" + status +
"entity=" + entity +
"headers=" + headers +
"claims=" + claims +
", errorType=" + errorType +
", errorDescription='" + errorDescription + '\'' +
", errorUri='" + errorUri + '\'' +
'}';
}
}