Package com.microstrategy.web.app.beans
Class WebAppSessionManagerImpl
- java.lang.Object
-
- com.microstrategy.utils.serialization.AbstractPersistable
-
- com.microstrategy.web.beans.WebSessionManagerImpl
-
- com.microstrategy.web.app.beans.WebAppSessionManagerImpl
-
- All Implemented Interfaces:
EnumWebPersistableState,Persistable,WebAppSessionManager,RequestPersistable,WebSessionManager
- Direct Known Subclasses:
ServerAdminSessionManager
public class WebAppSessionManagerImpl extends WebSessionManagerImpl implements WebAppSessionManager
- Since:
- MicroStrategy Web 8.0.1
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringMSTR_AUTH-
Fields inherited from class com.microstrategy.web.beans.WebSessionManagerImpl
_sessionList, WebSessionManagerState, WebUserSessionManagerState
-
Fields inherited from class com.microstrategy.utils.serialization.AbstractPersistable
scriptEndTagEncoder
-
Fields inherited from interface com.microstrategy.utils.serialization.EnumWebPersistableState
BARE_MINIMAL_STATE_INFO, MAXIMAL_STATE_INFO, MINIMAL_STATE_INFO, TYPICAL_STATE_INFO
-
-
Constructor Summary
Constructors Constructor Description WebAppSessionManagerImpl(AppContext ownerAppContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intbuildLastMessageKey(java.lang.String... serverName)Create a GUID that is a combination of server/project info in order to maintain a keyed list of last message across server/project at client-side.voidchangeLocale()Changes the locale on all sessions in a cluster with the active one to the setting which is set on the session's preferences.voidchangePassword(java.lang.String oldP, java.lang.String newP)Changes the active session's password from the old password given to the new password.voidchangeSessionFlags()Changes the session flags for the session.protected voidcloseSession(WebIServerSession session)WebIServerSessioncreateLoginFirstSession()Creates a Login First sessionintgetAvailableAuthModes(WebIServerSession session)Returns the available authentication modes that may be used with this session.intgetAvailableWebLoginModes(WebIServerSession session)Returns the available web login modes that may be used with this session.protected intgetInitialAuthMode(WebIServerSession session)intgetLastMessageKey()Get cached message key that matches the last message idjava.lang.StringgetLastMsgIDFromCookie(int msgKey)Get the last message ID from cookie for provided message key {@see buildLastMessageKey()}WebIServerSessiongetLoginFirstSession()Returns the existing Login First session (already created or restored).static java.lang.StringgetNewRedirectToken()java.util.ArrayListgetProjectsList()Returns an ArrayList ofProjectInformationobjects, which contain information about the projects we are connected to.java.util.ArrayListgetProjectsList(boolean refresh)Returns an ArrayList ofProjectInformationobjects, which contain information about the projects we are connected to.WebIServerSessiongetSession(java.lang.String server, int port, java.lang.String project)Returns theWebIServerSessionfor the given server/project.java.lang.StringgetUserName()Attempts to retrieve a printable user name for either the active session, or, if loginFirst is true, the credentials set on the Session Manager will be used to obtain the user name.booleanhasCredentials()Returns whether this instance of the session manager contains credentials internally.protected voidinit()WebIServerSessioninitActiveSessionFromRequest()This method will examine the request, and attempt to either set the active session properly, or create a brand new session that will become the active session, if the request asks for a session on a server without a session and project already created on it.WebIServerSessioninitActiveSessionFromRequest(ServletWebComponent servletWebComponent)This method will examine the request, and attempt to either set the active session properly, or create a brand new session that will become the active session, if the request asks for a session on a server without a session and project already created on it.WebIServerSessioninitActiveSessionFromRequest(ServletWebComponent servletWebComponent, boolean doNotInvalidateSession)This method will examine the request, and attempt to either set the active session properly, or create a brand new session that will become the active session, if the request asks for a session on a server without a session and project already created on it.booleanisAdminUser()Returns whether the active session's user is an administrative user or not.booleanisLoginFirstEnabled()protected booleanisSeamlessLoginEnabled()booleanisSSOLoging()booleanneedNewPswd()Returns whether the user needs to update password or not.voidremoveActiveSession()Removes the active session from the list, closing it if the external security manager setup on the application context says to do so.voidremoveAllSessions()Removes all sessions from the list, closing them if the external security manager setup on the application context says to do so.protected booleanrestoreSessionListState(WebIServerSessionList list, java.lang.String state)booleanrestoreState(SAXSupport saxSupport, java.lang.String a, java.lang.String b, java.lang.String c, org.xml.sax.Attributes attrs)Restores a component from an embedded XML during a SAX parsing.booleanrestoreState(RequestKeys keys, java.lang.String key, java.lang.String state)voidsaveState(java.lang.StringBuffer buf, int howMuchState)Saves and stores a component's state into aStringBuffer.voidsetCredentials(java.lang.String uid, java.lang.String p, int authMode)Sets the credentials for the active session.voidupdateActiveSession(WebIServerSession wiss)Sets passed session as the existing active sessionprotected voidvalidatePrivileges(WebIServerSession session)voidvalidateSession()This method attempts to validate the active session.voidvalidateSession(boolean refresh)This method attempts to validate the active session.voidvalidateSession(WebIServerSession session)This method attempts to validate the given session.-
Methods inherited from class com.microstrategy.web.beans.WebSessionManagerImpl
getActiveSession, getKey, getSessionList, initActiveSessionFromRequestKeys, restoreState, restoreStateFromRequest, restoreStateFromRequest, setActiveSession
-
Methods inherited from class com.microstrategy.utils.serialization.AbstractPersistable
doFlatState, doFlatState, getStateHandler, isXMLStateZipped, restoreXMLState, saveState, saveState, saveState, saveXMLState, saveXMLState
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.microstrategy.utils.serialization.Persistable
restoreState, saveState, saveState, saveState
-
Methods inherited from interface com.microstrategy.web.beans.RequestPersistable
restoreStateFromRequest, restoreStateFromRequest
-
Methods inherited from interface com.microstrategy.web.app.WebAppSessionManager
getKey
-
Methods inherited from interface com.microstrategy.web.beans.WebSessionManager
getActiveSession, getSessionList, initActiveSessionFromRequestKeys, setActiveSession
-
-
-
-
Field Detail
-
MSTR_AUTH
protected static final java.lang.String MSTR_AUTH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
WebAppSessionManagerImpl
public WebAppSessionManagerImpl(AppContext ownerAppContext)
-
-
Method Detail
-
init
protected void init()
- Overrides:
initin classWebSessionManagerImpl
-
changeLocale
public void changeLocale()
Description copied from interface:WebAppSessionManagerChanges the locale on all sessions in a cluster with the active one to the setting which is set on the session's preferences. This method will look at those preferences, and if they do not match the locale on the session, change the session locale, if we have enough information to recreate the session.- Specified by:
changeLocalein interfaceWebAppSessionManager
-
changeSessionFlags
public void changeSessionFlags()
Description copied from interface:WebAppSessionManagerChanges the session flags for the session. This method will check the user session's prefrerences for the session and all sessions in the same cluster of servers, and if the current session flags are not the same as the session flags in the preferences, the session flags will be changed, if there exists enough information to recreate the session.- Specified by:
changeSessionFlagsin interfaceWebAppSessionManager
-
changePassword
public void changePassword(java.lang.String oldP, java.lang.String newP) throws WebAppExceptionDescription copied from interface:WebAppSessionManagerChanges the active session's password from the old password given to the new password.- Specified by:
changePasswordin interfaceWebAppSessionManager- Parameters:
oldP- The old password. Needed to confirm the correct user's identity.newP- The new password.- Throws:
WebAppException- Thrown if an error occurs when attempting to change password.
-
isAdminUser
public boolean isAdminUser()
Description copied from interface:WebAppSessionManagerReturns whether the active session's user is an administrative user or not. This is checked via checking privileges.- Specified by:
isAdminUserin interfaceWebAppSessionManager- Returns:
- True if the active session's user has administrative privileges, false otherwise.
-
getProjectsList
public java.util.ArrayList getProjectsList() throws WebAppExceptionDescription copied from interface:WebAppSessionManagerReturns an ArrayList ofProjectInformationobjects, which contain information about the projects we are connected to. This method is the same as getProjectList(false).- Specified by:
getProjectsListin interfaceWebAppSessionManager- Returns:
- An ArrayList of
ProjectInformationobjects. - Throws:
WebAppException- Thrown if an error occurs.- See Also:
WebAppSessionManager.getProjectsList(boolean)
-
needNewPswd
public boolean needNewPswd()
Description copied from interface:WebAppSessionManagerReturns whether the user needs to update password or not.- Specified by:
needNewPswdin interfaceWebAppSessionManager- Returns:
- true if new password is needed.
-
createLoginFirstSession
public WebIServerSession createLoginFirstSession() throws WebAppException
Description copied from interface:WebAppSessionManagerCreates a Login First session- Specified by:
createLoginFirstSessionin interfaceWebAppSessionManager- Returns:
- Login First session
- Throws:
WebAppException
-
getLoginFirstSession
public WebIServerSession getLoginFirstSession() throws WebAppException
Description copied from interface:WebAppSessionManagerReturns the existing Login First session (already created or restored). If there is no login first session yet, it will create one and return it.- Specified by:
getLoginFirstSessionin interfaceWebAppSessionManager- Returns:
- Login First session
- Throws:
WebAppException
-
getProjectsList
public java.util.ArrayList getProjectsList(boolean refresh) throws WebAppExceptionDescription copied from interface:WebAppSessionManagerReturns an ArrayList ofProjectInformationobjects, which contain information about the projects we are connected to.- Specified by:
getProjectsListin interfaceWebAppSessionManager- Parameters:
refresh- A boolean variable indicates whether we should refresh the project list. If this parameter is false, and there is cached result of this call, we will return the last result, or throw the same exception as last time. If this parameter is true, we will ingore the cache and refresh the project list.- Returns:
- An ArrayList of
ProjectInformationobjects. - Throws:
WebAppException- Thrown if an error occurs.- Since:
- MicroStrategy Web 8.0.3
-
removeAllSessions
public void removeAllSessions()
Description copied from interface:WebAppSessionManagerRemoves all sessions from the list, closing them if the external security manager setup on the application context says to do so.- Specified by:
removeAllSessionsin interfaceWebAppSessionManager
-
removeActiveSession
public void removeActiveSession()
Description copied from interface:WebAppSessionManagerRemoves the active session from the list, closing it if the external security manager setup on the application context says to do so.- Specified by:
removeActiveSessionin interfaceWebAppSessionManager
-
validateSession
public void validateSession() throws WebAppExceptionDescription copied from interface:WebAppSessionManagerThis method attempts to validate the active session. If the session cannot be validated, then it can also attempt to recover for a specific set of error conditions. If the session cannot be validated or recovered, this method will throw an exception. If an exception is not thrown, then the session is valid. If there is result of previous validateSession call, it will not re-do the validation, install just returns the same validation result. If you need do the validation regardless the previous result, useWebAppSessionManager.validateSession(boolean)passing true as parameter.- Specified by:
validateSessionin interfaceWebAppSessionManager- Throws:
WebAppException- Thrown if the active session is confirmed to be invalid.
-
validateSession
public void validateSession(WebIServerSession session) throws WebAppException
Description copied from interface:WebAppSessionManagerThis method attempts to validate the given session. If the session cannot be validated, then it can also attempt to recover for a specific set of error conditions. If the session cannot be validated or recovered, this method will throw an exception. If an exception is not thrown, then the session is valid.- Specified by:
validateSessionin interfaceWebAppSessionManager- Parameters:
session- The session to validate.- Throws:
WebAppException- Thrown if the active session is confirmed to be invalid.
-
validateSession
public void validateSession(boolean refresh) throws WebAppExceptionDescription copied from interface:WebAppSessionManagerThis method attempts to validate the active session. If the session cannot be validated, then it can also attempt to recover for a specific set of error conditions. If the session cannot be validated or recovered, this method will throw an exception. If an exception is not thrown, then the session is valid.- Specified by:
validateSessionin interfaceWebAppSessionManager- Parameters:
refresh- The boolean vairable indicates whether we should use previous validation result. If this is false and there is result of previous validateSession call, it will not re-do the validation, install just returns the same validation result. Eitherwise, it will do the validation process.- Throws:
WebAppException- Thrown if the active session is confirmed to be invalid.- Since:
- MicroStrategy Web 8.0.3
-
getLastMsgIDFromCookie
public java.lang.String getLastMsgIDFromCookie(int msgKey)
Get the last message ID from cookie for provided message key {@see buildLastMessageKey()}- Specified by:
getLastMsgIDFromCookiein interfaceWebAppSessionManager- Returns:
- {String}
-
isSSOLoging
public boolean isSSOLoging()
- Specified by:
isSSOLogingin interfaceWebAppSessionManager
-
validatePrivileges
protected void validatePrivileges(WebIServerSession session) throws WebAppException
- Throws:
WebAppException
-
initActiveSessionFromRequest
public WebIServerSession initActiveSessionFromRequest() throws WebAppException
Description copied from interface:WebAppSessionManagerThis method will examine the request, and attempt to either set the active session properly, or create a brand new session that will become the active session, if the request asks for a session on a server without a session and project already created on it.- Specified by:
initActiveSessionFromRequestin interfaceWebAppSessionManager- Returns:
- The WebIServerSession that is active after the call. This session is the one that is requested to be used by the variables passed as part of the request.
- Throws:
WebAppException- Thrown if an error occurs.
-
initActiveSessionFromRequest
public WebIServerSession initActiveSessionFromRequest(ServletWebComponent servletWebComponent) throws WebAppException
Description copied from interface:WebAppSessionManagerThis method will examine the request, and attempt to either set the active session properly, or create a brand new session that will become the active session, if the request asks for a session on a server without a session and project already created on it. Note that this method will, if a key or server/project/port is not found in the request, check with the ServletWebComponent to see what the current server/project/port is. This will return null if no server is specified, or the server is not connected (or cannot be auto-connected).- Specified by:
initActiveSessionFromRequestin interfaceWebAppSessionManager- Parameters:
servletWebComponent- AServletWebComponentobject representing the servlet, which can be queried for the server, project, and port for the current request.- Returns:
- The WebIServerSession that is active after the call. This session is the one that is requested to be used by the variables passed as part of the request.
- Throws:
WebAppException- Thrown if an error occurs.
-
initActiveSessionFromRequest
public WebIServerSession initActiveSessionFromRequest(ServletWebComponent servletWebComponent, boolean doNotInvalidateSession) throws WebAppException
Description copied from interface:WebAppSessionManagerThis method will examine the request, and attempt to either set the active session properly, or create a brand new session that will become the active session, if the request asks for a session on a server without a session and project already created on it. Note that this method will, if a key or server/project/port is not found in the request, check with the ServletWebComponent to see what the current server/project/port is. This will return null if no server is specified, or the server is not connected (or cannot be auto-connected).- Specified by:
initActiveSessionFromRequestin interfaceWebAppSessionManager- Parameters:
servletWebComponent- AServletWebComponentobject representing the servlet, which can be queried for the server, project, and port for the current request.doNotInvalidateSession- a flag to indacate whether to invalidate Session. Can be passed by AppTaskRequestContext- Returns:
- The WebIServerSession that is active after the call. This session is the one that is requested to be used by the variables passed as part of the request.
- Throws:
WebAppException- Thrown if an error occurs.
-
getSession
public WebIServerSession getSession(java.lang.String server, int port, java.lang.String project)
Description copied from interface:WebAppSessionManagerReturns theWebIServerSessionfor the given server/project. Will return null if the server is not connected (or cannot be auto-connected). It will also be made the current session.- Specified by:
getSessionin interfaceWebAppSessionManager- Overrides:
getSessionin classWebSessionManagerImpl- Returns:
- The current active session.
-
setCredentials
public void setCredentials(java.lang.String uid, java.lang.String p, int authMode) throws WebAppExceptionDescription copied from interface:WebAppSessionManagerSets the credentials for the active session. If the login first functionality is enabled, then these credentials will be kept around until overridden and used for every session.- Specified by:
setCredentialsin interfaceWebAppSessionManager- Parameters:
uid- The user ID of the loginp- The password of the loginauthMode- The authentication mode of the credentials, fromEnumDSSXMLAuthModes.- Throws:
WebAppException- Thrown if an error occurs.
-
isLoginFirstEnabled
public boolean isLoginFirstEnabled()
- Specified by:
isLoginFirstEnabledin interfaceWebAppSessionManager
-
isSeamlessLoginEnabled
protected boolean isSeamlessLoginEnabled()
-
getInitialAuthMode
protected int getInitialAuthMode(WebIServerSession session)
-
saveState
public void saveState(java.lang.StringBuffer buf, int howMuchState) throws java.lang.UnsupportedOperationExceptionDescription copied from interface:PersistableSaves and stores a component's state into aStringBuffer. The returned state should be HTML friendly.There are generally two formats of the saved state: flat state and XML representation. The minimum state is saved in flat state format, while the typical and maximum states are saved in XML string representation.
- Specified by:
saveStatein interfacePersistable- Overrides:
saveStatein classAbstractPersistable- Parameters:
buf- a StringBuffer to store the saved state.howMuchState- how much state information to save (EnumWebPersistableState).- Throws:
java.lang.UnsupportedOperationException- thrown if the component does not support this method, or does not support certainhowMuchStatelevel.
-
restoreState
public boolean restoreState(SAXSupport saxSupport, java.lang.String a, java.lang.String b, java.lang.String c, org.xml.sax.Attributes attrs)
Description copied from interface:PersistableRestores a component from an embedded XML during a SAX parsing.- Specified by:
restoreStatein interfacePersistable- Overrides:
restoreStatein classAbstractPersistable- Parameters:
saxSupport- a SAX parser processing the XML representation of a statea- The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performedb- The local name (without prefix), or the empty string if Namespace processing is not being performedc- The qualified name (with prefix), or the empty string if qualified names are not availableattrs- The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object- Returns:
trueto indicate a successful restoration. Otherwise,falsewill be returned.
-
restoreState
public boolean restoreState(RequestKeys keys, java.lang.String key, java.lang.String state)
- Overrides:
restoreStatein classWebSessionManagerImpl
-
restoreSessionListState
protected boolean restoreSessionListState(WebIServerSessionList list, java.lang.String state)
- Overrides:
restoreSessionListStatein classWebSessionManagerImpl
-
hasCredentials
public boolean hasCredentials()
Description copied from interface:WebAppSessionManagerReturns whether this instance of the session manager contains credentials internally. This will be true if setCredentials has been called since the creation or deserialization of this SessionManager object, or if loginFirst is true and the credentials have ever been set.- Specified by:
hasCredentialsin interfaceWebAppSessionManager- Returns:
- True if the session manager has credentials associated with it, false otherwise.
-
getUserName
public java.lang.String getUserName()
Description copied from interface:WebAppSessionManagerAttempts to retrieve a printable user name for either the active session, or, if loginFirst is true, the credentials set on the Session Manager will be used to obtain the user name.- Specified by:
getUserNamein interfaceWebAppSessionManager- Returns:
- The user name for the user of the session manager.
-
getAvailableAuthModes
public int getAvailableAuthModes(WebIServerSession session) throws WebAppException
Description copied from interface:WebAppSessionManagerReturns the available authentication modes that may be used with this session. A project name or ID (along with the residing server) should be specified prior to making this call if the intented login is to a project since authentication modes may be project specific.- Specified by:
getAvailableAuthModesin interfaceWebAppSessionManager- Returns:
- the available authentication modes that may be used with this session.
- Throws:
WebAppException- thrown if there was a problem getting the authentication modes.
-
getAvailableWebLoginModes
public int getAvailableWebLoginModes(WebIServerSession session) throws WebAppException
Description copied from interface:WebAppSessionManagerReturns the available web login modes that may be used with this session. A project name or ID (along with the residing server) should be specified prior to making this call if the intented login is to a project since web login modes may be project specific.- Specified by:
getAvailableWebLoginModesin interfaceWebAppSessionManager- Returns:
- the available web login modes that may be used with this session.
- Throws:
WebAppException- thrown if there was a problem getting the web lgoin modes.
-
closeSession
protected void closeSession(WebIServerSession session)
-
getNewRedirectToken
public static java.lang.String getNewRedirectToken()
-
updateActiveSession
public void updateActiveSession(WebIServerSession wiss) throws WebObjectsException
Description copied from interface:WebAppSessionManagerSets passed session as the existing active session- Specified by:
updateActiveSessionin interfaceWebAppSessionManager- Parameters:
wiss- the new IServer session- Throws:
WebObjectsException
-
buildLastMessageKey
public int buildLastMessageKey(java.lang.String... serverName)
Create a GUID that is a combination of server/project info in order to maintain a keyed list of last message across server/project at client-side. If server name is not provided, it will read from active session.- Specified by:
buildLastMessageKeyin interfaceWebAppSessionManager- Returns:
-
getLastMessageKey
public int getLastMessageKey()
Description copied from interface:WebAppSessionManagerGet cached message key that matches the last message id- Specified by:
getLastMessageKeyin interfaceWebAppSessionManager- Returns:
-
-