secrets updated
This commit is contained in:
parent
cec6726b90
commit
53274e1c67
|
@ -9,10 +9,10 @@ import org.gcube.common.keycloak.model.AccessToken;
|
|||
import org.gcube.common.security.Owner;
|
||||
|
||||
public class AccessTokenSecret extends Secret {
|
||||
|
||||
|
||||
private static final String AUTH_HEADER = "Authorization";
|
||||
private static final String USER_HEADER = "d4s-user";
|
||||
|
||||
|
||||
private String encodedAccessToken;
|
||||
|
||||
private Owner owner;
|
||||
|
@ -24,7 +24,7 @@ public class AccessTokenSecret extends Secret {
|
|||
|
||||
public AccessTokenSecret(String encodedAccessToken) {
|
||||
this.encodedAccessToken = encodedAccessToken;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,12 +48,12 @@ public class AccessTokenSecret extends Secret {
|
|||
return authorizationHeaders;
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected String getEncodedAccessToken() {
|
||||
return encodedAccessToken;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isExpired() {
|
||||
init();
|
||||
|
@ -63,11 +63,11 @@ public class AccessTokenSecret extends Secret {
|
|||
private synchronized void init() {
|
||||
if (!initialised)
|
||||
try {
|
||||
|
||||
|
||||
String realAccessTokenEncoded = encodedAccessToken.split("\\.")[1];
|
||||
|
||||
|
||||
String decodedAccessPart = new String(Base64.getDecoder().decode(realAccessTokenEncoded.getBytes()));
|
||||
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
GCubeJWTObject obj = objectMapper.readValue(decodedAccessPart, GCubeJWTObject.class);
|
||||
owner = new Owner(obj.getUsername(), obj.getRoles(), obj.getEmail(), obj.getFirstName(), obj.getLastName(), obj.isExternalService());
|
||||
|
@ -75,14 +75,14 @@ public class AccessTokenSecret extends Secret {
|
|||
owner.setContactOrganisation(obj.getContactOrganisation());
|
||||
owner.setClientName(obj.getClientName());
|
||||
context = obj.getContext();
|
||||
|
||||
|
||||
this.accessToken = objectMapper.readValue(decodedAccessPart, AccessToken.class);
|
||||
|
||||
|
||||
initialised = true;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -61,5 +61,4 @@ public class CredentialSecret extends Secret {
|
|||
public boolean isExpired() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class JWTSecret extends Secret {
|
|||
|
||||
private String jwtToken;
|
||||
|
||||
|
||||
|
||||
private String context;
|
||||
private AccessTokenSecret accessTokenSecret;
|
||||
|
||||
|
@ -79,4 +79,5 @@ public class JWTSecret extends Secret {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue