Executes the call to the REST Service and processes the response.
80 clientRequest.header(
"Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
83 if (
getRequest().getAuthorizationMethod() == null
84 ||
getRequest().getAuthorizationMethod() == AuthorizationMethod.AUTHORIZATION_REQUEST_HEADER_FIELD) {
85 if (StringUtils.isNotBlank(
getRequest().getAccessToken())) {
88 }
else if (
getRequest().getAuthorizationMethod() == AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER) {
89 if (StringUtils.isNotBlank(
getRequest().getAccessToken())) {
92 }
else if (
getRequest().getAuthorizationMethod() == AuthorizationMethod.URL_QUERY_PARAMETER) {
93 if (StringUtils.isNotBlank(
getRequest().getAccessToken())) {
100 if (
getRequest().getAuthorizationMethod() == null
101 ||
getRequest().getAuthorizationMethod() == AuthorizationMethod.AUTHORIZATION_REQUEST_HEADER_FIELD
102 ||
getRequest().getAuthorizationMethod() == AuthorizationMethod.URL_QUERY_PARAMETER) {
104 }
else if (
getRequest().getAuthorizationMethod() == AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER) {
115 if (StringUtils.isNotBlank(entity)) {
116 List<Object> contentType =
clientResponse.getHeaders().get(
"Content-Type");
117 if (contentType != null && contentType.contains(
"application/jwt")) {
118 String[] jwtParts = entity.split(
"\\.");
119 if (jwtParts.length == 5) {
120 byte[] sharedSymmetricKey =
sharedKey != null ?
sharedKey.getBytes(Util.UTF8_STRING_ENCODING) : null;
121 Jwe jwe = Jwe.parse(entity,
privateKey, sharedSymmetricKey);
124 Jwt jwt = Jwt.parse(entity);
126 OxAuthCryptoProvider cryptoProvider =
new OxAuthCryptoProvider();
127 boolean signatureVerified = cryptoProvider.verifySignature(
128 jwt.getSigningInput(),
129 jwt.getEncodedSignature(),
130 jwt.getHeader().getKeyId(),
131 JwtUtil.getJSONWebKeys(
jwksUri),
133 jwt.getHeader().getAlgorithm());
135 if (signatureVerified) {
141 JSONObject jsonObj =
new JSONObject(entity);
143 if (jsonObj.has(
"error")) {
144 getResponse().setErrorType(UserInfoErrorResponseType.fromString(jsonObj.getString(
"error")));
145 jsonObj.remove(
"error");
147 if (jsonObj.has(
"error_description")) {
148 getResponse().setErrorDescription(jsonObj.getString(
"error_description"));
149 jsonObj.remove(
"error_description");
151 if (jsonObj.has(
"error_uri")) {
152 getResponse().setErrorUri(jsonObj.getString(
"error_uri"));
153 jsonObj.remove(
"error_uri");
156 for (Iterator<String> iterator = jsonObj.keys(); iterator.hasNext(); ) {
157 String key = iterator.next();
158 List<String> values =
new ArrayList<String>();
160 JSONArray jsonArray = jsonObj.optJSONArray(key);
161 if (jsonArray != null) {
162 for (
int i = 0; i < jsonArray.length(); i++) {
163 String value = jsonArray.optString(i);
169 String value = jsonObj.optString(key);
177 }
catch (JSONException e) {
182 }
catch (Exception e) {
String getHttpMethod()
Definition: UserInfoClient.java:50
void closeConnection()
Definition: BaseClient.java:239
String sharedKey
Definition: UserInfoClient.java:36
ClientResponse< String > clientResponse
Definition: BaseClient.java:43
V getResponse()
Definition: BaseClient.java:72
ClientRequest clientRequest
Definition: BaseClient.java:42
T getRequest()
Definition: BaseClient.java:64
void setResponse(V response)
Definition: BaseClient.java:76
void initClientRequest()
Definition: BaseClient.java:225
String jwksUri
Definition: UserInfoClient.java:38
PrivateKey privateKey
Definition: UserInfoClient.java:37