Package org.gcube.portal.oidc.lr62
Class OIDCWithDynamicScopeTokenUtil
- java.lang.Object
-
- org.gcube.portal.oidc.lr62.OIDCWithDynamicScopeTokenUtil
-
public class OIDCWithDynamicScopeTokenUtil extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringD4S_DYNAMIC_SCOPE_NAMEstatic StringD4S_DYNAMIC_SCOPE_NAME_TOKEN_CLAIMstatic StringDEFAULT_DYNAMIC_SCOPE_SEPARATORstatic StringROOT_DYNAMIC_SCOPE_FOR_ENABLING
-
Constructor Summary
Constructors Constructor Description OIDCWithDynamicScopeTokenUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckContextTokenAndProvideInThreadLocal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, com.liferay.portal.model.User user, javax.servlet.http.HttpSession session, String scope)protected static voidforceLogout(javax.servlet.http.HttpServletResponse response)static org.gcube.oidc.rest.JWTTokengetContextToken(javax.servlet.http.HttpServletRequest request, com.liferay.portal.model.User user, String scope)static org.gcube.oidc.rest.JWTTokengetContextToken(javax.servlet.http.HttpServletRequest request, Long userId, String scope)Used to request a temporary OIDC context token from the OIDC server in a specific context for an user.static org.gcube.oidc.rest.JWTTokengetContextToken(javax.servlet.http.HttpServletRequest request, String screenName, String scope)Used to request a temporary OIDC context token from the OIDC server in a specific context for an user.protected static booleanisContextInAud(org.gcube.oidc.rest.JWTToken token, String context)protected static booleanisRestrictedTo(org.gcube.oidc.rest.JWTToken token, String context)protected static booleanisRestrictionChanged(org.gcube.oidc.rest.JWTToken token, String context)static voidprovideClientContextTokenInThreadLocal(String clientId, String clientSecret, URL tokenURL, String infraContext)static voidprovideClientContextTokenInThreadLocal(URL tokenURL, String clientAccessToken, String clientId, String clientSecret, String infraContext)static voidprovideConfiguredPortalClientContextTokenInThreadLocal(String infraContext)static voidprovideTokenInThreadlocal(org.gcube.oidc.rest.JWTToken contextToken)
-
-
-
Field Detail
-
D4S_DYNAMIC_SCOPE_NAME
public static final String D4S_DYNAMIC_SCOPE_NAME
- See Also:
- Constant Field Values
-
D4S_DYNAMIC_SCOPE_NAME_TOKEN_CLAIM
public static final String D4S_DYNAMIC_SCOPE_NAME_TOKEN_CLAIM
- See Also:
- Constant Field Values
-
DEFAULT_DYNAMIC_SCOPE_SEPARATOR
public static final String DEFAULT_DYNAMIC_SCOPE_SEPARATOR
- See Also:
- Constant Field Values
-
ROOT_DYNAMIC_SCOPE_FOR_ENABLING
public static final String ROOT_DYNAMIC_SCOPE_FOR_ENABLING
- See Also:
- Constant Field Values
-
-
Method Detail
-
provideConfiguredPortalClientContextTokenInThreadLocal
public static void provideConfiguredPortalClientContextTokenInThreadLocal(String infraContext)
-
provideClientContextTokenInThreadLocal
public static void provideClientContextTokenInThreadLocal(String clientId, String clientSecret, URL tokenURL, String infraContext)
-
provideClientContextTokenInThreadLocal
public static void provideClientContextTokenInThreadLocal(URL tokenURL, String clientAccessToken, String clientId, String clientSecret, String infraContext)
-
getContextToken
public static org.gcube.oidc.rest.JWTToken getContextToken(javax.servlet.http.HttpServletRequest request, Long userId, String scope) throws ContextTokenException, InvalidTokenException, MissingTokenException, MissingRefreshTokenException, RefreshException, NotInContextException, RefreshTokenExpiredExceptionUsed to request a temporary OIDC context token from the OIDC server in a specific context for an user. The OIDC access token in theJWTCacheProxyfor the user in the currentsessionwill be used.- Parameters:
request- the current HTTP requestuserId- the user's user idscope- the scope to issue the token for (e.g. "/gcube")- Returns:
- the temporary token in the requested context for the user
- Throws:
ContextTokenException- if a generic error related to the OIDC context token issue occursInvalidTokenException- if the OIDC access token is become invalid for the userMissingTokenException- if the OIDC token is missing for the user in the cache proxyMissingRefreshTokenException- if the refresh token is not present in current OIDC tokenRefreshException- if an error occurs refreshing the OIDC token that is expiredNotInContextException- if the user is not authorized to access the requested contextRefreshTokenExpiredException- if the refresh token has been expired (Keycloak session is expired)
-
getContextToken
public static org.gcube.oidc.rest.JWTToken getContextToken(javax.servlet.http.HttpServletRequest request, String screenName, String scope) throws InvalidTokenException, MissingTokenException, MissingRefreshTokenException, RefreshException, NotInContextException, ContextTokenException, RefreshTokenExpiredExceptionUsed to request a temporary OIDC context token from the OIDC server in a specific context for an user. The OIDC access token in theJWTCacheProxyfor the user in the currentsessionwill be used.- Parameters:
request- the current HTTP requestscreenName- the user's screen namescope- the scope to issue the token for (e.g. "/gcube")- Returns:
- the temporary token in the requested context for the user
- Throws:
ContextTokenException- if a generic error related to the OIDC context token issue occursMissingTokenException- if the OIDC token is missing for the user in the cache proxyMissingRefreshTokenException- if the refresh token is not present in current OIDC tokenInvalidTokenException- if the OIDC access token is become invalid for the userRefreshException- if an error occurs refreshing the OIDC token that is expiredNotInContextException- if the user is not authorized to access the requested contextRefreshTokenExpiredException- if the refresh token has been expired (Keycloak session is expired)
-
getContextToken
public static org.gcube.oidc.rest.JWTToken getContextToken(javax.servlet.http.HttpServletRequest request, com.liferay.portal.model.User user, String scope) throws InvalidTokenException, MissingTokenException, MissingRefreshTokenException, RefreshException, NotInContextException, ContextTokenException, RefreshTokenExpiredException
-
isContextInAud
protected static boolean isContextInAud(org.gcube.oidc.rest.JWTToken token, String context)
-
isRestrictedTo
protected static boolean isRestrictedTo(org.gcube.oidc.rest.JWTToken token, String context)
-
isRestrictionChanged
protected static boolean isRestrictionChanged(org.gcube.oidc.rest.JWTToken token, String context)
-
checkContextTokenAndProvideInThreadLocal
public static void checkContextTokenAndProvideInThreadLocal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, com.liferay.portal.model.User user, javax.servlet.http.HttpSession session, String scope)
-
provideTokenInThreadlocal
public static void provideTokenInThreadlocal(org.gcube.oidc.rest.JWTToken contextToken)
-
forceLogout
protected static void forceLogout(javax.servlet.http.HttpServletResponse response)
-
-