Added some methods to clear caches
This commit is contained in:
parent
6c6f896b77
commit
530637d2de
|
@ -1,4 +1,4 @@
|
|||
package com.nubisware.oidc.lr62;
|
||||
package org.gcube.portal.oidc.lr62;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
@ -6,15 +6,16 @@ import java.util.TreeMap;
|
|||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.liferay.portal.model.User;
|
||||
import com.nubisware.oidc.rest.JWTToken;
|
||||
import org.gcube.oidc.rest.JWTToken;
|
||||
|
||||
public class IntraVMOIDCTokenProxy extends OIDCTokenProxy {
|
||||
import com.liferay.portal.model.User;
|
||||
|
||||
public class IntraVMOIDCTokenCacheProxy extends OIDCTokenCacheProxy {
|
||||
|
||||
private Map<String, String> oidcTokens;
|
||||
private Map<String, String> rptTokens;
|
||||
|
||||
protected IntraVMOIDCTokenProxy() {
|
||||
protected IntraVMOIDCTokenCacheProxy() {
|
||||
oidcTokens = Collections.synchronizedMap(new TreeMap<>());
|
||||
rptTokens = Collections.synchronizedMap(new TreeMap<>());
|
||||
}
|
||||
|
@ -49,4 +50,20 @@ public class IntraVMOIDCTokenProxy extends OIDCTokenProxy {
|
|||
rptTokens.remove(generateKey(user, session));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearOIDCTokens() {
|
||||
oidcTokens.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearUMATokens() {
|
||||
rptTokens.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAllTokens() {
|
||||
clearOIDCTokens();
|
||||
clearUMATokens();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
package com.nubisware.oidc.lr62;
|
||||
package org.gcube.portal.oidc.lr62;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.oidc.rest.JWTToken;
|
||||
|
||||
import com.liferay.portal.model.User;
|
||||
import com.nubisware.oidc.rest.JWTToken;
|
||||
|
||||
public abstract class OIDCTokenProxy {
|
||||
public abstract class OIDCTokenCacheProxy {
|
||||
|
||||
protected static OIDCTokenProxy instance;
|
||||
protected static OIDCTokenCacheProxy instance;
|
||||
|
||||
public OIDCTokenProxy() {
|
||||
public OIDCTokenCacheProxy() {
|
||||
instance = this;
|
||||
}
|
||||
public static synchronized OIDCTokenProxy getInstance() {
|
||||
return instance != null ? instance : new IntraVMOIDCTokenProxy();
|
||||
public static synchronized OIDCTokenCacheProxy getInstance() {
|
||||
return instance != null ? instance : new IntraVMOIDCTokenCacheProxy();
|
||||
}
|
||||
|
||||
public abstract void setOIDCToken(User user, HttpSession session, JWTToken token);
|
||||
|
@ -28,6 +29,12 @@ public abstract class OIDCTokenProxy {
|
|||
|
||||
public abstract void removeUMAToken(User user, HttpSession session);
|
||||
|
||||
public abstract void clearOIDCTokens();
|
||||
|
||||
public abstract void clearUMATokens();
|
||||
|
||||
public abstract void clearAllTokens();
|
||||
|
||||
protected String generateKey(User user, HttpSession session) {
|
||||
return user.getScreenName() + "@" + session.getId();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue