Improving library
This commit is contained in:
parent
98669b25a3
commit
41b83c7c69
|
@ -22,11 +22,6 @@ public class ClienIDSecret extends Secret {
|
|||
this.clientID = clientID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set() throws Exception {
|
||||
TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(clientID, token, ScopeProvider.instance.get(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContext() throws Exception {
|
||||
return null;
|
||||
|
@ -70,7 +65,14 @@ public class ClienIDSecret extends Secret {
|
|||
|
||||
@Override
|
||||
public void setToken() throws Exception {
|
||||
// TODO
|
||||
TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(clientID, token, ScopeProvider.instance.get(), null);
|
||||
logger.trace("{}", tr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetToken() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,4 +86,5 @@ public class ClienIDSecret extends Secret {
|
|||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,4 +65,14 @@ public class SecretHolder {
|
|||
return ScopeProvider.instance.get();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
for(Secret secret : secrets) {
|
||||
try {
|
||||
secret.reset();
|
||||
}catch (Exception e) {
|
||||
// trying the next one
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ public class SecretManager {
|
|||
|
||||
public static final InheritableThreadLocal<SecretManager> instance = new InheritableThreadLocal<SecretManager>() {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected SecretManager initialValue() {
|
||||
return new SecretManager();
|
||||
|
@ -108,4 +110,11 @@ public class SecretManager {
|
|||
return currentSecretHolder.getContext();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
initialSecretHolder.reset();
|
||||
if(initialSecretHolder!=currentSecretHolder) {
|
||||
currentSecretHolder.reset();
|
||||
}
|
||||
instance.remove();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,10 +39,16 @@ public class GCubeSecret extends Secret {
|
|||
return authorizationEntry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToken() throws Exception {
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetToken() throws Exception {
|
||||
SecurityTokenProvider.instance.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientInfo getClientInfo() throws Exception {
|
||||
return getAuthorizationEntry().getClientInfo();
|
||||
|
|
|
@ -32,6 +32,11 @@ public class JWTSecret extends Secret {
|
|||
AccessTokenProvider.instance.set(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetToken() throws Exception {
|
||||
AccessTokenProvider.instance.reset();
|
||||
}
|
||||
|
||||
protected JWToken getJWToken() throws Exception {
|
||||
if(jwt==null) {
|
||||
String realUmaTokenEncoded = token.split("\\.")[1];
|
||||
|
|
|
@ -52,6 +52,8 @@ public abstract class Secret implements Comparable<Secret> {
|
|||
|
||||
public abstract void setToken() throws Exception;
|
||||
|
||||
public abstract void resetToken() throws Exception;
|
||||
|
||||
public abstract ClientInfo getClientInfo() throws Exception;
|
||||
|
||||
public abstract Caller getCaller() throws Exception;
|
||||
|
@ -104,6 +106,12 @@ public abstract class Secret implements Comparable<Secret> {
|
|||
return token.compareTo(obj.token);
|
||||
}
|
||||
|
||||
public void reset() throws Exception {
|
||||
resetToken();
|
||||
AuthorizationProvider.instance.reset();
|
||||
ScopeProvider.instance.reset();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue