Changed UmaTokenProvider with AccessTokenProvider

This commit is contained in:
lucio.lelii 2021-05-24 16:30:58 +02:00
parent be74dac112
commit 32452f3c6a
3 changed files with 10 additions and 19 deletions

View File

@ -2,6 +2,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for Common Smartgears
## [v1.3.0] - 2020-11-18
- Changed UmaTokenProvider with AccessTokenProvider
## [v1.2.0] - 2020-11-18
- interceptor for UmaToken added

12
pom.xml
View File

@ -11,7 +11,7 @@
<groupId>org.gcube.core</groupId>
<artifactId>common-gcube-calls</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>
<properties>
<distroDirectory>distro</distroDirectory>
@ -29,15 +29,7 @@
<artifactId>common-authorization</artifactId>
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope</artifactId>

View File

@ -1,13 +1,11 @@
package org.gcube.common.calls.interceptors;
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.authorization.library.provider.UmaJWTProvider;
import org.gcube.common.calls.Call;
import org.gcube.common.calls.Interceptor;
import org.gcube.common.calls.Request;
import org.gcube.common.calls.Response;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -21,14 +19,11 @@ public class AuthorizationInterceptor implements Interceptor {
@Override
public void handleRequest(Request request, Call call) {
String token = SecurityTokenProvider.instance.get();
String umaToken = UmaJWTProvider.instance.get();
String accessToken = AccessTokenProvider.instance.get();
if (umaToken!=null) {
if (accessToken!=null) {
try {
JSONParser parser = new JSONParser();
JSONObject jsonObject = (JSONObject) parser.parse(umaToken);
String accesToken = (String) jsonObject.get("access_token");
request.addHeader(uma_token_header, "Bearer "+accesToken);
request.addHeader(uma_token_header, "Bearer "+accessToken);
logger.trace("uma token set");
}catch (Exception e) {
logger.error("error parsing uma token",e);