is application added to Owner
This commit is contained in:
parent
f17613b4b4
commit
85637986d6
8
pom.xml
8
pom.xml
|
@ -8,8 +8,10 @@
|
||||||
<name>gcube secrets</name>
|
<name>gcube secrets</name>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/gcube-secrets</connection>
|
<connection>
|
||||||
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/gcube-secrets</developerConnection>
|
scm:git:https://code-repo.d4science.org/gCubeSystem/gcube-secrets</connection>
|
||||||
|
<developerConnection>
|
||||||
|
scm:git:https://code-repo.d4science.org/gCubeSystem/gcube-secrets</developerConnection>
|
||||||
<url>https://code-repo.d4science.org/gCubeSystem/gcube-secrets</url>
|
<url>https://code-repo.d4science.org/gCubeSystem/gcube-secrets</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
|
@ -29,7 +31,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.distribution</groupId>
|
<groupId>org.gcube.distribution</groupId>
|
||||||
<artifactId>gcube-bom</artifactId>
|
<artifactId>gcube-bom</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.0.1-SNAPSHOT</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
|
@ -51,6 +51,7 @@ public class GCubeJWTObject {
|
||||||
|
|
||||||
@JsonProperty("email")
|
@JsonProperty("email")
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
public List<String> getRoles(){
|
public List<String> getRoles(){
|
||||||
return contextAccess.get(this.context) == null ? MINIMAL_ROLES : contextAccess.get(this.context).roles;
|
return contextAccess.get(this.context) == null ? MINIMAL_ROLES : contextAccess.get(this.context).roles;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +71,10 @@ public class GCubeJWTObject {
|
||||||
return contactOrganisation != null && contactOrganisation.equals(INTERNAL_CLIENT_ORGANISATION_NAME);
|
return contactOrganisation != null && contactOrganisation.equals(INTERNAL_CLIENT_ORGANISATION_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isApplication() {
|
||||||
|
return clientId != null;
|
||||||
|
}
|
||||||
|
|
||||||
public String getFirstName() {
|
public String getFirstName() {
|
||||||
return firstName;
|
return firstName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,16 +23,17 @@ public class GCubeSecret extends Secret {
|
||||||
|
|
||||||
public GCubeSecret(String gcubeToken) {
|
public GCubeSecret(String gcubeToken) {
|
||||||
if( gcubeToken == null || gcubeToken.isEmpty())
|
if( gcubeToken == null || gcubeToken.isEmpty())
|
||||||
throw new RuntimeException("Invalid token: is null or empty");
|
throw new IllegalArgumentException("Invalid token: is null or empty");
|
||||||
if(!Pattern.matches(GCUBE_TOKEN_REGEX, gcubeToken))
|
if(!Pattern.matches(GCUBE_TOKEN_REGEX, gcubeToken))
|
||||||
throw new RuntimeException("Invalid token: the gCube token must comply with the regex " + GCUBE_TOKEN_REGEX);
|
throw new IllegalArgumentException("Invalid token: the gCube token must comply with the regex " + GCUBE_TOKEN_REGEX);
|
||||||
this.gcubeToken = gcubeToken;
|
this.gcubeToken = gcubeToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() throws Exception{
|
private void init() throws Exception{
|
||||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(gcubeToken);
|
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(gcubeToken);
|
||||||
this.owner = new Owner(authorizationEntry.getClientInfo().getId(),
|
this.owner = new Owner(authorizationEntry.getClientInfo().getId(),
|
||||||
authorizationEntry.getClientInfo().getRoles(), authorizationEntry.getClientInfo().getType()!=ClientType.USER);
|
authorizationEntry.getClientInfo().getRoles(), authorizationEntry.getClientInfo().getType()==ClientType.EXTERNALSERVICE,
|
||||||
|
authorizationEntry.getClientInfo().getType()==ClientType.SERVICE);
|
||||||
this.context = authorizationEntry.getContext();
|
this.context = authorizationEntry.getContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,14 +68,16 @@ public class UmaTokenSecret extends Secret {
|
||||||
String decodedAccessPart = new String(Base64.getDecoder().decode(realAccessTokenEncoded.getBytes()));
|
String decodedAccessPart = new String(Base64.getDecoder().decode(realAccessTokenEncoded.getBytes()));
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
this.accessToken = objectMapper.readValue(decodedAccessPart, AccessToken.class);
|
||||||
GCubeJWTObject obj = objectMapper.readValue(decodedAccessPart, GCubeJWTObject.class);
|
GCubeJWTObject obj = objectMapper.readValue(decodedAccessPart, GCubeJWTObject.class);
|
||||||
owner = new Owner(obj.getUsername(), obj.getRoles(), obj.getEmail(), obj.getFirstName(), obj.getLastName(), obj.isExternalService());
|
owner = new Owner(obj.getUsername(), obj.getRoles(), obj.getEmail(), obj.getFirstName(), obj.getLastName(), obj.isExternalService(), obj.isApplication());
|
||||||
owner.setClientName(obj.getClientName());
|
owner.setClientName(obj.getClientName());
|
||||||
owner.setContactOrganisation(obj.getContactOrganisation());
|
owner.setContactOrganisation(obj.getContactOrganisation());
|
||||||
owner.setClientName(obj.getClientName());
|
owner.setClientName(obj.getClientName());
|
||||||
context = obj.getContext();
|
context = obj.getContext();
|
||||||
|
|
||||||
this.accessToken = objectMapper.readValue(decodedAccessPart, AccessToken.class);
|
|
||||||
|
|
||||||
initialised = true;
|
initialised = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Reference in New Issue