java.lang.Object
org.tentackle.session.DefaultSessionInfo
- All Implemented Interfaces:
Serializable,Cloneable,Immutable,SessionInfo
The default implementation for a session info.
The password is encrypted if a Cryptor is configured.
- Author:
- harald
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a session info from the default properties file.
The property file's name is"backend".DefaultSessionInfo(String propertiesName) Creates a session info from a property file holding the connection parameters.DefaultSessionInfo(String username, char[] password, String propertiesName) Creates a session info from an optional username, optional password and a property file holding the connection parameters.DefaultSessionInfo(org.tentackle.common.EncryptedProperties properties) Creates a session from a properties object. -
Method Summary
Modifier and TypeMethodDescriptionvoidApplies the properties to this session info.
Sets user, password and application-name from properties, if given.protected voidAsserts that this session info is mutable.voidcheckServerVersion(String serverVersion) Checks the version of the server.voidClears the cloned flag.
Useful if the session-info should no longer be treated as cloned.voidClears the password.
Will remove it from memory by overwriting each element in the character array.clone()Clones a session info.
The password is copied, if not null.
The properties are cloned as well.
Cloned session infos are mutable by default and have no sessionName.booleanSession infos are equal if their login credentials are equal.longReturns the application id.Gets the name of the application.Gets the client version.Gets the host info.Gets the session's locale.
Returns the JVM's default locale if not set explicitly viaSessionInfo.setLocale(java.util.Locale).Gets the operating system info.char[]Gets the password.org.tentackle.common.EncryptedPropertiesGets the connection properties.
The properties are not set so far, the method will load the properties file by adding the extension".properties"toSessionInfo.getPropertiesName()(if it does not contain an extension already).
If there is no such file, the properties will be read as a resource according to the classpath.
If all fails aPersistenceExceptionis thrown.Gets the name of the property file.Gets the optional session name.longgetSince()Gets the epochal time since when logged in.Gets the timezone.intGets the class id of the current user.longGets the user id.Gets the username.Gets the info string describing the JVM.inthashCode()booleanisCloned()Checks whether this session info is cloned.booleanbooleanbooleanDetermines whether token-locks are removed when session is closed.
By default, locks are not removed for cloned sessions.protected org.tentackle.common.EncryptedPropertiesloadProperties(String propertiesName) Loads the properties.voidsetApplicationId(long applicationId) Sets the application id.
Should be unique among the same application name.voidsetApplicationName(String application) Sets the name of the application.voidsetClientVersion(String clientVersion) Sets the client's version.voidvoidsetHostInfo(String hostInfo) Sets the host info.voidsetImmutable(boolean immutable) voidsetImmutableLoggingLevel(Logger.Level immutableLoggingLevel) voidSets the session's locale.voidsetLockLingerEnabled(boolean enabled) Sets whether token-locks are removed when session is closed.voidSets the operating system info.voidsetPassword(char[] password) Sets the password.voidsetProperties(org.tentackle.common.EncryptedProperties properties) Sets the connection properties.voidsetPropertiesName(String propertiesName) Sets the name of the property file.
(without the extension.properties)voidsetSessionName(String sessionName) Sets an optional session name.
May be used to describe the purpose of the session.voidsetSince(long since) Sets the epochal time since when logged in.voidsetTimeZone(TimeZone timeZone) Sets the timezone.voidsetUserClassId(int userClassId) Sets the class id of the current user.voidsetUserId(long userId) Sets the user id.voidsetUserName(String userName) Sets the username.voidSets the info string describing the JVM.toString()
-
Constructor Details
-
DefaultSessionInfo
Creates a session info from an optional username, optional password and a property file holding the connection parameters.- Parameters:
username- is the name of the userpassword- is the password, null if nonepropertiesName- name of the session's properties file, null if"backend"
-
DefaultSessionInfo
Creates a session info from a property file holding the connection parameters.- Parameters:
propertiesName- name of the session's properties file, null if"backend"
-
DefaultSessionInfo
public DefaultSessionInfo()Creates a session info from the default properties file.
The property file's name is"backend". -
DefaultSessionInfo
public DefaultSessionInfo(org.tentackle.common.EncryptedProperties properties) Creates a session from a properties object.- Parameters:
properties- the properties
-
-
Method Details
-
equals
Session infos are equal if their login credentials are equal. -
hashCode
public int hashCode() -
isImmutable
public boolean isImmutable()- Specified by:
isImmutablein interfaceImmutable
-
setImmutable
public void setImmutable(boolean immutable) - Specified by:
setImmutablein interfaceImmutable
-
setFinallyImmutable
public void setFinallyImmutable()- Specified by:
setFinallyImmutablein interfaceImmutable
-
isFinallyImmutable
public boolean isFinallyImmutable()- Specified by:
isFinallyImmutablein interfaceImmutable
-
setImmutableLoggingLevel
- Specified by:
setImmutableLoggingLevelin interfaceImmutable
-
getImmutableLoggingLevel
- Specified by:
getImmutableLoggingLevelin interfaceImmutable
-
assertMutable
protected void assertMutable()Asserts that this session info is mutable. -
setSince
public void setSince(long since) Description copied from interface:SessionInfoSets the epochal time since when logged in.- Specified by:
setSincein interfaceSessionInfo- Parameters:
since- logged in since, 0 if not logged in
-
getSince
public long getSince()Description copied from interface:SessionInfoGets the epochal time since when logged in.- Specified by:
getSincein interfaceSessionInfo- Returns:
- logged in since, 0 if not logged in
-
setUserName
Description copied from interface:SessionInfoSets the username.- Specified by:
setUserNamein interfaceSessionInfo- Parameters:
userName- the name of the user
-
getUserName
Description copied from interface:SessionInfoGets the username.- Specified by:
getUserNamein interfaceSessionInfo- Returns:
- the username
-
setPassword
public void setPassword(char[] password) Description copied from interface:SessionInfoSets the password.- Specified by:
setPasswordin interfaceSessionInfo- Parameters:
password- the password
-
getPassword
public char[] getPassword()Description copied from interface:SessionInfoGets the password.- Specified by:
getPasswordin interfaceSessionInfo- Returns:
- the password
-
clearPassword
public void clearPassword()Description copied from interface:SessionInfoClears the password.
Will remove it from memory by overwriting each element in the character array.- Specified by:
clearPasswordin interfaceSessionInfo
-
getClientVersion
Description copied from interface:SessionInfoGets the client version.- Specified by:
getClientVersionin interfaceSessionInfo- Returns:
- the client version
-
setClientVersion
Description copied from interface:SessionInfoSets the client's version.- Specified by:
setClientVersionin interfaceSessionInfo- Parameters:
clientVersion- the client version
-
getLocale
Description copied from interface:SessionInfoGets the session's locale.
Returns the JVM's default locale if not set explicitly viaSessionInfo.setLocale(java.util.Locale).- Specified by:
getLocalein interfaceSessionInfo- Returns:
- the locale, never null
-
setLocale
Description copied from interface:SessionInfoSets the session's locale.- Specified by:
setLocalein interfaceSessionInfo- Parameters:
locale- the locale, null to use JVM's locale
-
getVmInfo
Description copied from interface:SessionInfoGets the info string describing the JVM.- Specified by:
getVmInfoin interfaceSessionInfo- Returns:
- the jvm info
-
setVmInfo
Description copied from interface:SessionInfoSets the info string describing the JVM.- Specified by:
setVmInfoin interfaceSessionInfo- Parameters:
vmInfo- the jvm info
-
getTimeZone
Description copied from interface:SessionInfoGets the timezone.- Specified by:
getTimeZonein interfaceSessionInfo- Returns:
- the timezone
-
setTimeZone
Description copied from interface:SessionInfoSets the timezone.- Specified by:
setTimeZonein interfaceSessionInfo- Parameters:
timeZone- the timezone
-
getOsInfo
Description copied from interface:SessionInfoGets the operating system info.- Specified by:
getOsInfoin interfaceSessionInfo- Returns:
- the OS info
-
setOsInfo
Description copied from interface:SessionInfoSets the operating system info.- Specified by:
setOsInfoin interfaceSessionInfo- Parameters:
osInfo- the OS info
-
getHostInfo
Description copied from interface:SessionInfoGets the host info.- Specified by:
getHostInfoin interfaceSessionInfo- Returns:
- the hostname or similar info
-
setHostInfo
Description copied from interface:SessionInfoSets the host info.- Specified by:
setHostInfoin interfaceSessionInfo- Parameters:
hostInfo- the info
-
toString
-
clone
Clones a session info.
The password is copied, if not null.
The properties are cloned as well.
Cloned session infos are mutable by default and have no sessionName.- Specified by:
clonein interfaceSessionInfo- Overrides:
clonein classObject- Returns:
- the cloned session info
-
isCloned
public boolean isCloned()Description copied from interface:SessionInfoChecks whether this session info is cloned.- Specified by:
isClonedin interfaceSessionInfo- Returns:
- true if cloned
-
clearCloned
public void clearCloned()Description copied from interface:SessionInfoClears the cloned flag.
Useful if the session-info should no longer be treated as cloned.- Specified by:
clearClonedin interfaceSessionInfo
-
getPropertiesName
Description copied from interface:SessionInfoGets the name of the property file.- Specified by:
getPropertiesNamein interfaceSessionInfo- Returns:
- the filename
-
setPropertiesName
Description copied from interface:SessionInfoSets the name of the property file.
(without the extension.properties)- Specified by:
setPropertiesNamein interfaceSessionInfo- Parameters:
propertiesName- the filename
-
getProperties
public org.tentackle.common.EncryptedProperties getProperties()Description copied from interface:SessionInfoGets the connection properties.
The properties are not set so far, the method will load the properties file by adding the extension".properties"toSessionInfo.getPropertiesName()(if it does not contain an extension already).
If there is no such file, the properties will be read as a resource according to the classpath.
If all fails aPersistenceExceptionis thrown.- Specified by:
getPropertiesin interfaceSessionInfo- Returns:
- the connection properties, never null
-
setProperties
public void setProperties(org.tentackle.common.EncryptedProperties properties) Description copied from interface:SessionInfoSets the connection properties.- Specified by:
setPropertiesin interfaceSessionInfo- Parameters:
properties- the connection properties.
-
applyProperties
public void applyProperties()Description copied from interface:SessionInfoApplies the properties to this session info.
Sets user, password and application-name from properties, if given.- Specified by:
applyPropertiesin interfaceSessionInfo
-
getApplicationName
Description copied from interface:SessionInfoGets the name of the application.- Specified by:
getApplicationNamein interfaceSessionInfo- Returns:
- the name, null if none
-
setApplicationName
Description copied from interface:SessionInfoSets the name of the application.- Specified by:
setApplicationNamein interfaceSessionInfo- Parameters:
application- the name
-
setApplicationId
public void setApplicationId(long applicationId) Description copied from interface:SessionInfoSets the application id.
Should be unique among the same application name.- Specified by:
setApplicationIdin interfaceSessionInfo- Parameters:
applicationId- the optional application id
-
getApplicationId
public long getApplicationId()Description copied from interface:SessionInfoReturns the application id.- Specified by:
getApplicationIdin interfaceSessionInfo- Returns:
- the id, 0 if none
-
setSessionName
Description copied from interface:SessionInfoSets an optional session name.
May be used to describe the purpose of the session.- Specified by:
setSessionNamein interfaceSessionInfo- Parameters:
sessionName- the session name, null if none
-
getSessionName
Description copied from interface:SessionInfoGets the optional session name.- Specified by:
getSessionNamein interfaceSessionInfo- Returns:
- the name, null if none
-
checkServerVersion
Description copied from interface:SessionInfoChecks the version of the server.The default implementation does nothing.
- Specified by:
checkServerVersionin interfaceSessionInfo- Parameters:
serverVersion- the server's version
-
getUserId
public long getUserId()Description copied from interface:SessionInfoGets the user id.- Specified by:
getUserIdin interfaceSessionInfo- Returns:
- the object ID of the current user
-
setUserId
public void setUserId(long userId) Description copied from interface:SessionInfoSets the user id.- Specified by:
setUserIdin interfaceSessionInfo- Parameters:
userId- the object ID of the user
-
getUserClassId
public int getUserClassId()Description copied from interface:SessionInfoGets the class id of the current user.- Specified by:
getUserClassIdin interfaceSessionInfo- Returns:
- the class id
-
setUserClassId
public void setUserClassId(int userClassId) Description copied from interface:SessionInfoSets the class id of the current user.- Specified by:
setUserClassIdin interfaceSessionInfo- Parameters:
userClassId- the class id
-
isLockLingerEnabled
public boolean isLockLingerEnabled()Description copied from interface:SessionInfoDetermines whether token-locks are removed when session is closed.
By default, locks are not removed for cloned sessions.- Specified by:
isLockLingerEnabledin interfaceSessionInfo- Returns:
- true if leave locks untouched, false to remove locks
-
setLockLingerEnabled
public void setLockLingerEnabled(boolean enabled) Description copied from interface:SessionInfoSets whether token-locks are removed when session is closed.- Specified by:
setLockLingerEnabledin interfaceSessionInfo- Parameters:
enabled- true if leave locks untouched, false to remove locks
-
loadProperties
Loads the properties.- Parameters:
propertiesName- the resource or filename- Returns:
- the properties
-