Improving code

This commit is contained in:
Luca Frosini 2021-12-01 16:22:36 +01:00
parent 4af598dfa8
commit ff7b79bb05
4 changed files with 9 additions and 17 deletions

View File

@ -27,7 +27,7 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId> <artifactId>gcube-bom</artifactId>
<version>2.1.0-SNAPSHOT</version> <version>2.0.1</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>

View File

@ -61,11 +61,6 @@ public class GCubeSecret extends Secret {
return getAuthorizationEntry().getContext(); return getAuthorizationEntry().getContext();
} }
@Override
public String getUsername() throws Exception {
return getClientInfo().getId();
}
@Override @Override
public Map<String, String> getHTTPAuthorizationHeaders() { public Map<String, String> getHTTPAuthorizationHeaders() {
Map<String, String> authorizationHeaders = new HashMap<>(); Map<String, String> authorizationHeaders = new HashMap<>();

View File

@ -80,14 +80,4 @@ public class JWTSecret extends Secret {
return authorizationHeaders; return authorizationHeaders;
} }
@Override
public String getUsername() throws Exception {
// TODO Auto-generated method stub
return null;
}
} }

View File

@ -3,6 +3,7 @@ package org.gcube.common.authorization.utils.secret;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import org.gcube.common.authorization.library.ClientType;
import org.gcube.common.authorization.library.exception.AuthorizationException; import org.gcube.common.authorization.library.exception.AuthorizationException;
import org.gcube.common.authorization.library.provider.AuthorizationProvider; import org.gcube.common.authorization.library.provider.AuthorizationProvider;
import org.gcube.common.authorization.library.provider.ClientInfo; import org.gcube.common.authorization.library.provider.ClientInfo;
@ -57,7 +58,13 @@ public abstract class Secret implements Comparable<Secret> {
public abstract String getContext() throws Exception; public abstract String getContext() throws Exception;
public abstract String getUsername() throws Exception; public String getUsername() throws Exception {
return getClientInfo().getId();
}
public boolean isApplication() throws Exception {
return getClientInfo().getType() == ClientType.EXTERNALSERVICE;
}
public abstract Map<String,String> getHTTPAuthorizationHeaders(); public abstract Map<String,String> getHTTPAuthorizationHeaders();