public class JaloSession extends AbstractJaloSession
| Modifier and Type | Class and Description |
|---|---|
static interface |
JaloSession.LoginProperties
Contains login property names.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CART
The session attribute key for 'cart'.
|
static java.lang.String |
CART_TYPE |
static SessionContext |
CTX_NO_PREFTCH_LANGUAGES |
static java.lang.String |
HYBRIS_ASSERT_INTERNALS |
static java.lang.String |
IS_HMC_SESSION |
static java.lang.String |
PREFETCH_LANGUAGES |
static java.lang.String |
REMOVE_CART_ON_CLOSE |
static java.lang.String |
SESSION_TIMEOUT |
| Constructor and Description |
|---|
JaloSession() |
| Modifier and Type | Method and Description |
|---|---|
void |
activate()
Set the given JaloSession as the active session for the current thread.
|
protected void |
addLocalSessionContext(SessionContext localCtx) |
void |
appendSavedCart(Cart appendCart)
Appends the entries from the saved cart to the session cart.
|
static boolean |
assureSessionNotStale(JaloSession session) |
protected void |
checkSessionValidity()
returns false if session is already closed()
|
protected void |
cleanup() |
void |
close()
Closes this session.
|
int |
compareTo(java.lang.Object object)
Implements item comparison by PK.
|
protected Cart |
createCart()
Used by getCart() to create a new cart.
|
SessionContext |
createLocalSessionContext()
creates a new session context which hides this session's current context within the current thread until it is
disabled via
removeLocalSessionContext(). |
SessionContext |
createLocalSessionContext(SessionContext original) |
JaloPropertyContainer |
createPropertyContainer()
Create a new property container that can be used for mass property updates.
|
SearchContext |
createSearchContext()
Returns a SearchContext object which is used for Search operations.
|
SessionContext |
createSessionContext()
Returns a SessionContext which is filled with the current session settings but is NOT bound to the session.
|
protected SessionContext |
createSessionContext(SessionContext original)
Creates a new
SessionContext instance setting given context as original. |
protected java.lang.String |
createSessionID()
creates a session ID for a newly created session.
|
static void |
deactivate()
remove the active session from the current thread.
|
protected Cart |
doCreateCart(ComposedType cartType,
User user,
Currency curr,
java.util.Date date,
boolean isNet) |
boolean |
equals(java.lang.Object object) |
protected User |
findSessionUser(ComposedType userType,
java.lang.String login) |
protected ComposedType |
findSessionUserType(java.lang.String sessionTypeString) |
java.lang.String |
generateLoginTokenCookieValue()
Generates a value entry for a CookieBasedLoginToken instance, which will be used by some web apps (like
printcockpit, hmc, ...) for an 'auto' login process
|
java.lang.String |
generateLoginTokenCookieValue(java.lang.String iso)
Generates a value entry for a CookieBasedLoginToken instance, which will be used by some web apps (like
printcockpit, hmc, ...) for an 'auto' login process
|
AccessManager |
getAccessManager()
returns the AccessManager.
|
protected Cart |
getAttachedCart() |
java.lang.Object |
getAttribute(java.lang.String name)
Returns the value of the attribute with the specified name from the attribute map of the current session context.
|
java.util.Enumeration |
getAttributeNames()
Returns an
Enumeration of String objects containing the names of all the objects bound
to this session. |
java.util.Map |
getAttributes()
Returns the attribute map of the session context.
|
C2LManager |
getC2LManager()
returns the C2LManager.
|
Cart |
getCart()
Returns the cart which is currently associated with this session.
|
protected ComposedType |
getCartType()
Provides composed type for newly created cart.
|
long |
getCreationTime() |
static JaloSession |
getCurrentSession()
Returns the active session for the current thread and tenant
If none is available, a new anonymous session will be created.
|
static JaloSession |
getCurrentSession(Tenant tenant) |
protected int |
getDefaultSessionTimeout()
returns the default session timeout in seconds which will be assigned to a new session if it is created The
default implementation returns the value of the "default.session.timeout" configuration parameter or '86400' if
not set (that is 1 day).
|
EnumerationManager |
getEnumerationManager()
return the enumeration manager
|
ExtensionManager |
getExtensionManager()
returns the ExtensionManger.
|
FlexibleSearch |
getFlexibleSearch()
returns the FlexibleSearch.
|
HttpSession |
getHttpSession()
Deprecated.
since 5.5.1 session management was changed and this method always returns null
|
java.lang.String |
getHttpSessionId() |
protected Currency |
getInitialSessionCurrency(User user) |
protected Language |
getInitialSessionLanguage(User user) |
<T extends Item> |
getItem(PK pk)
returns the item with the given PK.
|
<T extends Item> |
getItem(java.lang.String pk)
Deprecated.
since ages - please use
getItem(PK) with PK.parse(String) |
java.util.Collection<? extends Item> |
getItems(java.util.Collection<PK> pks)
Returns a collection of items for a given collection of PKs.
|
java.util.Collection<? extends Item> |
getItems(SessionContext ctx,
java.util.Collection<PK> pks)
Returns a collection of items for a given collection of PKs.
|
java.util.Collection<? extends Item> |
getItems(SessionContext ctx,
java.util.Collection<PK> pks,
boolean ignoreMissingItems)
Returns a collection of items for a given collection of PKs.
|
java.util.Collection<? extends Item> |
getItems(SessionContext ctx,
java.util.Collection<PK> pks,
boolean ignoreMissingItems,
boolean returnMissingAsNull)
Returns a collection of items for a given collection of PKs.
|
long |
getLastAccessed() |
LinkManager |
getLinkManager()
returns the LinkManager.
|
protected SessionContext |
getLocalSessionContext() |
java.util.Map |
getLoginProperties()
returns the properties that was used to create this session.
|
protected LoginToken |
getLoginToken(java.util.Map props) |
MediaManager |
getMediaManager()
returns the MediaManager.
|
MetaInformationManager |
getMetaInformationManager()
returns the MetaInformationManager.
|
NumberSeriesManager |
getNumberSeriesManager()
returns the NumberSeriesManager.
|
OrderManager |
getOrderManager()
returns the OrderManager.
|
PriceFactory |
getPriceFactory() |
ProductManager |
getProductManager()
returns the ProductManager.
|
SessionContext |
getSessionContext()
Returns the SessionContext currently bound to this session.
|
java.lang.String |
getSessionID()
Returns the session ID.
|
<T extends Tenant> |
getTenant() |
int |
getTimeout()
Deprecated.
since 5.5.1 session management was changed and this method always return -1
|
TypeManager |
getTypeManager()
returns the TypeManager.
|
User |
getUser()
Returns the user which is currently associated with this session.
|
UserManager |
getUserManager()
returns the UserManager.
|
boolean |
hasCart() |
static boolean |
hasCurrentSession()
Helper method for testing if the current thread has an active session.
|
static boolean |
hasCurrentSession(Tenant tenant) |
int |
hashCode()
Returns the hashcode of this JaloSession
The hashcode of an item is defined as the hashcode of its primary key object.
|
protected void |
init()
Overwrite this class for special initialization logic.
|
protected void |
initSessionContext(java.util.Map props) |
protected User |
initUser(java.util.Map props,
boolean isDefaultAnonymousSession) |
static JaloSession |
internalGetCurrentSession()
Returns the active session for the current thread.
|
protected boolean |
isAnonymousAndAnonymousLoginIsDisabled(java.lang.String login)
Tells whether this is the anonymous account and anonymous login is disallowed ( using the
login.anonymous.always.disabled configuration parameter ). |
boolean |
isClosed()
returns true if this session is closed.
|
protected boolean |
isDefaultAnonymous(java.util.Map props) |
boolean |
isExpired()
Deprecated.
since 5.5.1 session management was changed and this method always return false
|
protected boolean |
isNotAnonymousOrAnonymousLoginIsAllowed(java.lang.String login)
Tells whether this is not anonymous account or anonymous login is allowed by setting
login.anonymous.always.disabled configuration parameter to false. |
protected boolean |
isRemoveCartOnSessionClose() |
static <T extends Item> |
lookupItem(PK pk)
Same as
getItem(PK) but without actually requiring a session instance. |
static <T extends Item> |
lookupItem(Tenant tenant,
PK pk)
Same as
lookupItem(PK) with the ability to pass the (required) tenant manually. |
static java.util.Collection<? extends Item> |
lookupItems(SessionContext ctx,
java.util.Collection<PK> pks)
Same as
getItems(SessionContext, Collection) but without requiring a jalo session instance. |
static java.util.Collection<? extends Item> |
lookupItems(SessionContext ctx,
java.util.Collection<PK> pks,
boolean ignoreMissingItems)
Same as
getItems(SessionContext, Collection, boolean) but without requiring a jalo session instance. |
static java.util.Collection<? extends Item> |
lookupItems(SessionContext ctx,
java.util.Collection<PK> pks,
boolean ignoreMissingItems,
boolean returnMissingAsNull)
Same as
getItems(SessionContext, Collection, boolean, boolean) but without requiring a jalo session
instance. |
static java.util.Collection<? extends Item> |
lookupItems(Tenant tenant,
SessionContext ctx,
java.util.Collection<PK> pks,
boolean ignoreMissingItems,
boolean returnMissingAsNull) |
protected void |
notifyExtensionsBeforeSessionClose() |
protected User |
performLogin(LoginToken token,
java.util.Map loginProperties)
performs login for a given login token and additionally params.
|
protected User |
performLogin(java.lang.String login,
java.lang.String password,
java.util.Map loginProperties)
performs login for a given login, password and additionally params.
|
protected void |
removeAllLocalSessionContexts() |
java.lang.Object |
removeAttribute(java.lang.String name)
Removes the specified attribute from the attribute map of the current session context.
|
void |
removeCart()
Removes a cart from the current session and database, if the
Item.remove() fails it is always clearing the
internal reference. |
void |
removeLocalSessionContext()
removes the (thread)local session context associated with this session so that the previous session context is
visible again.
|
void |
restoreSavedCart(Cart savedCart)
Restores all entries from a saved cart to the session cart, thereby removes currently existing entries.
|
SearchResult |
search(GenericQuery query) |
SearchResult |
search(GenericQuery genericQuery,
Principal principal,
SearchContext searchCtx)
Initiates a search with the given
GenericQuery and SearchContext. |
SearchResult |
search(GenericQuery query,
SearchContext ctx)
Initiates a search with the given
GenericQuery and SearchContext. |
protected void |
setAttachedCart(Cart cart) |
java.lang.Object |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets a new value for the attribute with the specified name in the attribute map of the current session context.
|
void |
setAttributes(java.util.Map attributes)
Replaces multiple session attributes at once.
|
void |
setCart(Cart cart) |
void |
setHttpSessionId(java.lang.String httpSessionId)
Stores a http session id inside this session.
|
protected void |
setLastAccessed(long accessed) |
protected void |
setLoginProperties(java.util.Map loginProperties) |
void |
setPriceFactory(PriceFactory factory) |
void |
setTimeout(int seconds)
Deprecated.
since 5.5.1 session management was changed and this method has no effect
|
void |
setTimeoutInMillis(long timeOutInMillis)
Deprecated.
since 5.5.1 session management was changed and this method has no effect
|
void |
setUser(User user)
Changes the session user without any login processing.
|
void |
storeLoginTokenCookie(HttpServletResponse response)
Generates and stores a CookieBasedLoginToken instance, for the current session user ('auto' login process)
|
java.lang.String |
toString()
returns a String representation which contains the SessionID and the UserID which is currently assigned to this
Session.
|
void |
touch()
mark this session as used.
|
void |
transfer(java.util.Map props)
changes the session user including the full login process.
|
void |
transfer(java.util.Map props,
boolean activateUserLanguageAndCurrency)
changes the session user including the full login process.
|
void |
transfer(java.lang.String user,
java.lang.String pwd)
changes the session user including the full login process.
|
public static final java.lang.String IS_HMC_SESSION
public static final java.lang.String REMOVE_CART_ON_CLOSE
public static final java.lang.String SESSION_TIMEOUT
public static final java.lang.String PREFETCH_LANGUAGES
public static final java.lang.String CART_TYPE
public static final java.lang.String HYBRIS_ASSERT_INTERNALS
public static final java.lang.String CART
getAttribute(String) for generically access the session
cart.public static final SessionContext CTX_NO_PREFTCH_LANGUAGES
public <T extends Tenant> T getTenant()
public static boolean assureSessionNotStale(JaloSession session)
tenantRestartMarker with the Tenant
which is referenced by this JaloSession.protected void init()
protected SessionContext createSessionContext(SessionContext original)
SessionContext instance setting given context as original. Overwrite this method to change
implementation to use for SessionContext.protected boolean isDefaultAnonymous(java.util.Map props)
protected void initSessionContext(java.util.Map props)
throws JaloSecurityException
JaloSecurityExceptionprotected User initUser(java.util.Map props, boolean isDefaultAnonymousSession) throws JaloSecurityException
JaloSecurityExceptionprotected java.lang.String createSessionID()
public java.lang.String generateLoginTokenCookieValue()
throws EJBPasswordEncoderNotFoundException
EJBPasswordEncoderNotFoundExceptionpublic java.lang.String generateLoginTokenCookieValue(java.lang.String iso)
throws EJBPasswordEncoderNotFoundException
iso - languageEJBPasswordEncoderNotFoundExceptionpublic void storeLoginTokenCookie(HttpServletResponse response)
throws EJBPasswordEncoderNotFoundException
protected User performLogin(LoginToken token, java.util.Map loginProperties) throws JaloSecurityException
token - login tokenloginProperties - logging properties ( see JaloSession.LoginProperties )JaloSecurityExceptionprotected User performLogin(java.lang.String login, java.lang.String password, java.util.Map loginProperties) throws JaloSecurityException
login - user's loginpassword - user's passwordloginProperties - logging properties ( see JaloSession.LoginProperties )JaloSecurityExceptionprotected boolean isAnonymousAndAnonymousLoginIsDisabled(java.lang.String login)
login.anonymous.always.disabled configuration parameter ).protected boolean isNotAnonymousOrAnonymousLoginIsAllowed(java.lang.String login)
login.anonymous.always.disabled configuration parameter to false.protected ComposedType findSessionUserType(java.lang.String sessionTypeString) throws JaloInvalidParameterException
JaloInvalidParameterExceptionprotected User findSessionUser(ComposedType userType, java.lang.String login) throws JaloSecurityException, JaloInvalidParameterException
public void activate()
public static void deactivate()
protected void setLastAccessed(long accessed)
public long getCreationTime()
public long getLastAccessed()
public static JaloSession getCurrentSession()
java.lang.IllegalStateException - in case no tenant is activepublic static JaloSession getCurrentSession(Tenant tenant)
protected void checkSessionValidity()
public void touch()
@Deprecated public int getTimeout()
@Deprecated public void setTimeout(int seconds)
seconds - the timeout in seconds@Deprecated public void setTimeoutInMillis(long timeOutInMillis)
setTimeout(int) but expects the timeout in milliseconds
here! If 0 or less is specified, the session will never expire.timeOutInMillis - the time out of the session in milli seconds@Deprecated public boolean isExpired()
protected int getDefaultSessionTimeout()
public static JaloSession internalGetCurrentSession()
public static boolean hasCurrentSession()
true if the current thread has an active session (that is not already closed()), false
otherwisepublic static boolean hasCurrentSession(Tenant tenant)
public User getUser()
public void setUser(User user)
user - the new userpublic void transfer(java.util.Map props)
throws JaloSecurityException,
JaloInvalidParameterException
transfer(Map props, boolean activateUserLanguageAndCurrency) with
last parameter = true.props - logging properties ( see JaloSession.LoginProperties )JaloSecurityException - in case login process failedJaloInvalidParameterException - in case some provided parameter had an unexpected valuepublic void transfer(java.lang.String user,
java.lang.String pwd)
throws JaloSecurityException
transfer(Map props, boolean activateUserLanguageAndCurrency) with
last parameter = true.user - the new userpwd - the password of the userJaloSecurityException - in case login process failedpublic void transfer(java.util.Map props,
boolean activateUserLanguageAndCurrency)
throws JaloSecurityException,
JaloInvalidParameterException
GeneratedUser.getSessionLanguage() and
GeneratedUser.getSessionCurrency() ). Set the Boolean activateUserLanguageAndCurrency to true if you
want the new user to use his / her default language and currency. If set to false, the new user will
have the language and currency used by the former user.props - logging properties ( see JaloSession.LoginProperties )activateUserLanguageAndCurrency - if true the session language and session currency are set to the values set at the new userJaloSecurityException - in case login process failedJaloInvalidParameterException - in case some provided parameter had an unexpected valueprotected LoginToken getLoginToken(java.util.Map props)
public Cart getCart()
protected Cart getAttachedCart()
protected void setAttachedCart(Cart cart)
protected Cart createCart()
Cartprotected ComposedType getCartType()
null.protected Cart doCreateCart(ComposedType cartType, User user, Currency curr, java.util.Date date, boolean isNet)
public boolean hasCart()
public void removeCart()
Item.remove() fails it is always clearing the
internal reference.public void setCart(Cart cart)
public void restoreSavedCart(Cart savedCart)
savedCart - public void appendSavedCart(Cart appendCart)
appendCart - public java.util.Map getLoginProperties()
JaloConnection.createSession() you have to specify a map with user
informations.
This method returns this 'login-information' map.protected void setLoginProperties(java.util.Map loginProperties)
public void setAttributes(java.util.Map attributes)
attributes - the attributes to storepublic java.util.Map getAttributes()
public java.lang.Object getAttribute(java.lang.String name)
name - of the attributepublic java.lang.Object setAttribute(java.lang.String name,
java.lang.Object value)
name - of the attributevalue - the new valuepublic java.util.Enumeration getAttributeNames()
Enumeration of String objects containing the names of all the objects bound
to this session.Enumeration of String objects containing the names of all the objects bound
to this session.public java.lang.Object removeAttribute(java.lang.String name)
name - of the attribute, which should be removedpublic AccessManager getAccessManager()
public UserManager getUserManager()
public ProductManager getProductManager()
public NumberSeriesManager getNumberSeriesManager()
public FlexibleSearch getFlexibleSearch()
public C2LManager getC2LManager()
public MetaInformationManager getMetaInformationManager()
public MediaManager getMediaManager()
public OrderManager getOrderManager()
public LinkManager getLinkManager()
public ExtensionManager getExtensionManager()
public TypeManager getTypeManager()
public EnumerationManager getEnumerationManager()
public SessionContext getSessionContext()
SessionContext ctx = jaloSession.getSessionContext(); ctx.setLanguage(xy);.
protected SessionContext getLocalSessionContext()
protected void addLocalSessionContext(SessionContext localCtx)
public SessionContext createSessionContext()
public SessionContext createLocalSessionContext()
removeLocalSessionContext(). since createLocalSessionContext may be called multiple time the
now visible context might be a local context too.
please note that any changes made on this sessions context will not pass through to the original context
and therefore will be lost after disabling the local context.
the saves way to use local session context requires finally blocks:
try
{
SessionContext myLocalCtx = JaloSession.getCurrentSession().createLocalSessionContext();
myLocalCtx.setAttribute("specialForThisThreadOnly", myValue);
// do whatever in this context should be done
}
finally
{
JaloSession.getCurrentSession().removeLocalSessionContext();
}
public SessionContext createLocalSessionContext(SessionContext original)
public void removeLocalSessionContext()
createLocalSessionContext() may be called multiple time the now visible context
might be a local context too.protected void removeAllLocalSessionContexts()
public SearchContext createSearchContext()
public static <T extends Item> T lookupItem(PK pk) throws JaloItemNotFoundException
getItem(PK) but without actually requiring a session instance.JaloItemNotFoundExceptionpublic static <T extends Item> T lookupItem(Tenant tenant, PK pk) throws JaloItemNotFoundException
lookupItem(PK) with the ability to pass the (required) tenant manually.JaloItemNotFoundExceptionpublic static java.util.Collection<? extends Item> lookupItems(SessionContext ctx, java.util.Collection<PK> pks) throws JaloItemNotFoundException
getItems(SessionContext, Collection) but without requiring a jalo session instance.JaloItemNotFoundExceptionpublic static java.util.Collection<? extends Item> lookupItems(SessionContext ctx, java.util.Collection<PK> pks, boolean ignoreMissingItems) throws JaloItemNotFoundException
getItems(SessionContext, Collection, boolean) but without requiring a jalo session instance.JaloItemNotFoundExceptionpublic static java.util.Collection<? extends Item> lookupItems(SessionContext ctx, java.util.Collection<PK> pks, boolean ignoreMissingItems, boolean returnMissingAsNull) throws JaloItemNotFoundException
getItems(SessionContext, Collection, boolean, boolean) but without requiring a jalo session
instance.JaloItemNotFoundExceptionpublic static java.util.Collection<? extends Item> lookupItems(Tenant tenant, SessionContext ctx, java.util.Collection<PK> pks, boolean ignoreMissingItems, boolean returnMissingAsNull) throws JaloItemNotFoundException
JaloItemNotFoundExceptionpublic <T extends Item> T getItem(PK pk) throws JaloItemNotFoundException
pk - the primary key object of the itemJaloItemNotFoundException - if the item could not be found in the system@Deprecated public <T extends Item> T getItem(java.lang.String pk) throws JaloItemNotFoundException, java.lang.IllegalArgumentException
getItem(PK) with PK.parse(String)pk - the item primary key as string representation ( see PK.toString() )JaloItemNotFoundException - in case no item can be foundjava.lang.IllegalArgumentException - in case the string is no valid PK representationpublic java.util.Collection<? extends Item> getItems(java.util.Collection<PK> pks) throws JaloItemNotFoundException
pks - the primary key collectionJaloItemNotFoundException - if one item could not be found in the systempublic java.util.Collection<? extends Item> getItems(SessionContext ctx, java.util.Collection<PK> pks) throws JaloItemNotFoundException
ctx - the session context to define advanced settings like data prefetchingpks - the primary key collectionJaloItemNotFoundException - if one item could not be found in the systempublic java.util.Collection<? extends Item> getItems(SessionContext ctx, java.util.Collection<PK> pks, boolean ignoreMissingItems) throws JaloItemNotFoundException
ctx - the session context to define advanced settings like data pre-fetchingpks - the primary key collectionignoreMissingItems - if true invalid item PKs are simply ignored and omitted from the result collectionJaloItemNotFoundException - if one item could not be found in the system unless ignoreMissingItems is truepublic java.util.Collection<? extends Item> getItems(SessionContext ctx, java.util.Collection<PK> pks, boolean ignoreMissingItems, boolean returnMissingAsNull) throws JaloItemNotFoundException
ctx - the session context to define advanced settings like data pre-fetchingpks - the primary key collectionignoreMissingItems - if true invalid item PKs are simply ignored and omitted from the result collectionreturnMissingAsNull - if true when ignoring missing items all non-existent PKs will be returned as NULL within the result
collection - otherwise the missing PK is filtered completelyJaloItemNotFoundException - if one item could not be found in the system unless ignoreMissingItems is truepublic java.lang.String getSessionID()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean isClosed()
public void close()
protected void cleanup()
protected boolean isRemoveCartOnSessionClose()
public JaloPropertyContainer createPropertyContainer()
ExtensibleItem.setAllProperties(JaloPropertyContainer)@Deprecated public HttpSession getHttpSession()
public void setHttpSessionId(java.lang.String httpSessionId)
public java.lang.String getHttpSessionId()
public SearchResult search(GenericQuery query, SearchContext ctx)
GenericQuery and SearchContext.query - A GenericQuery instance that specifies your search query.ctx - Besides standard evaluation of SearchContext, following custom properties are considered
valid: GenericSearchConstants.DONT_NEED_TOTAL -> default is true.public SearchResult search(GenericQuery query)
public void setPriceFactory(PriceFactory factory)
public PriceFactory getPriceFactory()
public SearchResult search(GenericQuery genericQuery, Principal principal, SearchContext searchCtx)
GenericQuery and SearchContext.genericQuery - A GenericQuery instance that specifies your search query.principal - A Principal instance for restriction evaluation.searchCtx - Besides standard evaluation of SearchContext, following custom properties are considered
valid: GenericSearchConstants.DONT_NEED_TOTAL -> default is true.protected void notifyExtensionsBeforeSessionClose()
public final boolean equals(java.lang.Object object)
equals in class java.lang.Objectpublic int compareTo(java.lang.Object object)
object - which will be compared to this item.public final int hashCode()
hashCode in class java.lang.ObjectCopyright © 2018 SAP SE. All Rights Reserved.