Class AuthenticationUtil
- java.lang.Object
-
- org.camunda.bpm.webapp.impl.security.auth.AuthenticationUtil
-
public class AuthenticationUtil extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAPP_WELCOMEstatic java.lang.String[]APPSprotected static java.lang.StringCAM_AUTH_SESSION_KEYprotected static WebappLoggerLOGGER
-
Constructor Summary
Constructors Constructor Description AuthenticationUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static UserAuthenticationcreateAuthentication(java.lang.String engineName, java.lang.String username)static UserAuthenticationcreateAuthentication(java.lang.String engineName, java.lang.String username, java.util.List<java.lang.String> groupIds, java.util.List<java.lang.String> tenantIds)static UserAuthenticationcreateAuthentication(ProcessEngine processEngine, java.lang.String username)static UserAuthenticationcreateAuthentication(ProcessEngine processEngine, java.lang.String username, java.util.List<java.lang.String> groupIds, java.util.List<java.lang.String> tenantIds)Creates and returns aUserAuthenticationwith the following information:userIdprocessEngineNamegroupIdstenantIdsauthorizedAppsstatic AuthenticationsgetAuthsFromSession(javax.servlet.http.HttpSession session)Allows obtaining anAuthenticationsobject from theHttpSession.static java.util.List<java.lang.String>getGroupsOfUser(ProcessEngine engine, java.lang.String userId)protected static java.lang.ObjectgetSessionMutex(javax.servlet.http.HttpSession session)Returns the session mutex to synchronize on.static java.util.List<java.lang.String>getTenantsOfUser(ProcessEngine engine, java.lang.String userId)protected static booleanisAuthorizedForApp(AuthorizationService authorizationService, java.lang.String username, java.util.List<java.lang.String> groupIds, java.lang.String application)static voidrevalidateSession(javax.servlet.http.HttpServletRequest request, UserAuthentication authentication)Invalidates the oldHttpSessionof the current request and creates a new one.static voidupdateCache(Authentications authentications, javax.servlet.http.HttpSession session, long cacheTimeToLive)Update/remove authentications when cache validation time (= x + TTL) is due.static voidupdateSession(javax.servlet.http.HttpSession session, Authentications authentications)Store authentications in current session.
-
-
-
Field Detail
-
LOGGER
protected static final WebappLogger LOGGER
-
CAM_AUTH_SESSION_KEY
protected static final java.lang.String CAM_AUTH_SESSION_KEY
- See Also:
- Constant Field Values
-
APPS
public static final java.lang.String[] APPS
-
APP_WELCOME
public static final java.lang.String APP_WELCOME
- See Also:
- Constant Field Values
-
-
Method Detail
-
createAuthentication
public static UserAuthentication createAuthentication(java.lang.String engineName, java.lang.String username)
-
createAuthentication
public static UserAuthentication createAuthentication(ProcessEngine processEngine, java.lang.String username)
-
createAuthentication
public static UserAuthentication createAuthentication(java.lang.String engineName, java.lang.String username, java.util.List<java.lang.String> groupIds, java.util.List<java.lang.String> tenantIds)
-
createAuthentication
public static UserAuthentication createAuthentication(ProcessEngine processEngine, java.lang.String username, java.util.List<java.lang.String> groupIds, java.util.List<java.lang.String> tenantIds)
Creates and returns a
UserAuthenticationwith the following information:userIdprocessEngineNamegroupIdstenantIdsauthorizedApps
-
getTenantsOfUser
public static java.util.List<java.lang.String> getTenantsOfUser(ProcessEngine engine, java.lang.String userId)
-
getGroupsOfUser
public static java.util.List<java.lang.String> getGroupsOfUser(ProcessEngine engine, java.lang.String userId)
-
isAuthorizedForApp
protected static boolean isAuthorizedForApp(AuthorizationService authorizationService, java.lang.String username, java.util.List<java.lang.String> groupIds, java.lang.String application)
-
getAuthsFromSession
public static Authentications getAuthsFromSession(javax.servlet.http.HttpSession session)
Allows obtaining anAuthenticationsobject from theHttpSession. If no such object exists in the session, a new instance is created and returned.- Parameters:
session- theHttpSessioninstance from which to retrieve theAuthentications.
-
revalidateSession
public static void revalidateSession(javax.servlet.http.HttpServletRequest request, UserAuthentication authentication)Invalidates the oldHttpSessionof the current request and creates a new one. Additionally, transfers the existing authentications to the new session and adds a new one.- Parameters:
request- theHttpServletRequestinstance from which the session is obtained and a newHttpSessioncreated.authentication- the newAuthenticationinstance that is created through user login. It is added to the existing authentications.
-
updateSession
public static void updateSession(javax.servlet.http.HttpSession session, Authentications authentications)Store authentications in current session.
-
updateCache
public static void updateCache(Authentications authentications, javax.servlet.http.HttpSession session, long cacheTimeToLive)
Update/remove authentications when cache validation time (= x + TTL) is due.
The following information is updated:
groupIdstenantIdsauthorizedAppsAn authorization is only removed if the user doesn't exist anymore (user was deleted).
-
getSessionMutex
protected static java.lang.Object getSessionMutex(javax.servlet.http.HttpSession session)
Returns the session mutex to synchronize on.
Avoids updating the auth cache by multiple HTTP requests in parallel.
-
-