Removed code not needed if the library is integrated in Smartgears
This commit is contained in:
parent
6731b8f6a6
commit
a66c1da525
|
@ -2,7 +2,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
# Changelog for Authorization utils
|
||||
|
||||
## [v1.0.1-SNAPSHOT]
|
||||
## [v2.0.0-SNAPSHOT]
|
||||
|
||||
- Fixed getRoles for JWTSecret [#22754]
|
||||
-
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
|||
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>authorization-utils</artifactId>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
package org.gcube.common.authorization.utils.manager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import org.gcube.common.authorization.utils.provider.GCubeSecretProvider;
|
||||
import org.gcube.common.authorization.utils.provider.JWTSecretProvider;
|
||||
import org.gcube.common.authorization.utils.provider.SecretProvider;
|
||||
import org.gcube.common.authorization.utils.secret.Secret;
|
||||
import org.gcube.common.authorization.utils.user.User;
|
||||
|
||||
|
@ -23,43 +18,19 @@ public class SecretManager {
|
|||
}
|
||||
|
||||
};
|
||||
|
||||
private List<SecretProvider> secretProviders;
|
||||
|
||||
|
||||
private SecretHolder initialSecretHolder;
|
||||
private SecretHolder currentSecretHolder;
|
||||
|
||||
private SecretManager(){
|
||||
initialSecretHolder = new SecretHolder();
|
||||
currentSecretHolder = initialSecretHolder;
|
||||
initSecretProviders();
|
||||
}
|
||||
|
||||
protected void initSecretProviders() {
|
||||
secretProviders = new ArrayList<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<SecretProvider>[] classes = new Class[]{
|
||||
JWTSecretProvider.class, GCubeSecretProvider.class
|
||||
};
|
||||
|
||||
for(Class<SecretProvider> clz : classes) {
|
||||
try {
|
||||
SecretProvider authorizationSecretProvider = clz.newInstance();
|
||||
addSecretProvider(authorizationSecretProvider);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
public synchronized void addSecret(Secret secret) throws Exception {
|
||||
if(currentSecretHolder!=initialSecretHolder) {
|
||||
throw new Exception("You can't add a Secret in a session. You must terminate the session first.");
|
||||
}
|
||||
}
|
||||
|
||||
public List<SecretProvider> getSecretProviders(){
|
||||
return secretProviders;
|
||||
}
|
||||
|
||||
public void addSecretProvider(SecretProvider secretProvider) {
|
||||
secretProviders.add(secretProvider);
|
||||
Secret secret = secretProvider.getSecret();
|
||||
initialSecretHolder.addSecret(secret);
|
||||
}
|
||||
|
||||
|
@ -67,23 +38,29 @@ public class SecretManager {
|
|||
if(currentSecretHolder!=initialSecretHolder) {
|
||||
throw new Exception("You are already in a session. You must terminate the session first.");
|
||||
}
|
||||
initialSecretHolder.reset();
|
||||
currentSecretHolder = new SecretHolder(secret);
|
||||
currentSecretHolder.set();
|
||||
}
|
||||
|
||||
public synchronized void startSession(SortedSet<Secret> secrets) throws Exception {
|
||||
if(currentSecretHolder!=initialSecretHolder) {
|
||||
throw new Exception("You are already in a session. You must terminate the session first.");
|
||||
}
|
||||
initialSecretHolder.reset();
|
||||
currentSecretHolder = new SecretHolder(secrets);
|
||||
currentSecretHolder.set();
|
||||
}
|
||||
|
||||
public synchronized void endSession() throws Exception {
|
||||
if(currentSecretHolder!=initialSecretHolder) {
|
||||
currentSecretHolder.reset();
|
||||
initialSecretHolder.set();
|
||||
currentSecretHolder = initialSecretHolder;
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
public synchronized void reset() {
|
||||
initialSecretHolder.reset();
|
||||
if(initialSecretHolder!=currentSecretHolder) {
|
||||
currentSecretHolder.reset();
|
||||
|
@ -91,11 +68,11 @@ public class SecretManager {
|
|||
instance.remove();
|
||||
}
|
||||
|
||||
public String getContext() {
|
||||
public synchronized String getContext() {
|
||||
return currentSecretHolder.getContext();
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
public synchronized User getUser() {
|
||||
return currentSecretHolder.getUser();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue