public abstract class OwCookieStoreCodec extends Object implements OwParameterMapCodec
An OwParameterMap
codec that relays on a stored cookie scheme.
When encoding an OwParameterMap
a cookie value is generated, stored in the encoded map
and the generated cookie is associated with the parameters to be encoded.
When decoding an OwParameterMap
the value of the URL parameter is fetched and
the parameter map associated with it is returned as the decoded value.
The stored cookies expire after a certain amount of time and they are removed along with the
parameter map they are associated with. When expired cookies are subject to decoding an OwUserOperationException
is thrown to signal expiration.
Storing the cookies is delegated to subclasses.
Alfresco Workdesk
Copyright (c) Alfresco Software, Inc.
All rights reserved.
For licensing information read the license.txt file or
go to: http://wiki.alfresco.com
Modifier and Type | Class and Description |
---|---|
protected static class |
OwCookieStoreCodec.OwTimedCookie
Inner cookie name class used to
encapsulate a cookie name and its expiration time.
|
protected static class |
OwCookieStoreCodec.OwTimedCookieValue
Inner cookie name class used to
encapsulate an
OwCookieStoreCodec.OwTimedCookie and its
associated parameter map. |
Modifier and Type | Field and Description |
---|---|
static String |
CONFIGURATION_BOOTSTRAP_ELEMENT_NAME
Configuration root element which contains the definition of values
|
static String |
CONFIGURATION_DAYS_ATTRIBUTE
Configuration attribute for count of days
|
static String |
CONFIGURATION_HOURS_ATTRIBUTE
Configuration attribute for count of hours
|
static String |
CONFIGURATION_MINUTES_ATTRIBUTE
Configuration attribute for count of minutes
|
static String |
CONFIGURATION_NAME_ATTRIBUTE
Configuration attribute of name for
CONFIGURATION_URL_PARAMETER_ELEMENT |
static String |
CONFIGURATION_SECONDS_ATTRIBUTE
Configuration attribute for count of seconds
|
static String |
CONFIGURATION_URL_LIFE_TIME_ELEMENT
Configuration element for definition of life time
|
static String |
CONFIGURATION_URL_PARAMETER_ELEMENT
Configuration element for definition of the URL parameter
|
static long |
DEFAULT_CONFIG_URL_LIFE_TIME
default value for expiration time 5 years
value in milliseconds, calculated 5 (years) * 365 (days) * 24 (hours) * 60 (minutes) * 60 (seconds) * 1000 (milliseconds)
|
static String |
DEFAULT_URL_PARAMETER_NAME
Default value for URL parameter name
|
Constructor and Description |
---|
OwCookieStoreCodec()
|
OwCookieStoreCodec(long namesUrlLifeTime_p)
Constructor
|
OwCookieStoreCodec(OwAlphabetCoder alphabetCder_p,
String urlParamenterName_p,
long namesUrlLifeTime_p)
Constructor
|
OwCookieStoreCodec(String urlParamenterName_p,
long namesUrlLifeTime_p)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
addCookieValue(OwCookieStoreCodec.OwTimedCookieValue timedCookieValue_p)
Adds the given
OwCookieStoreCodec.OwTimedCookieValue to the cookie store |
boolean |
canDecode(OwParameterMap parameterMap_p)
Verifies that this codec can decode the given
OwParameterMap without system-errors. |
protected void |
collectExpiredNames() |
protected String |
createCookie(long uniqueNameIndex_p) |
protected abstract List |
createTimedCookieCollectList()
Hook method that returns a list of
OwCookieStoreCodec.OwTimedCookie s to be collected. |
OwParameterMap |
decode(OwParameterMap parameterMap_p,
boolean preserveEncoding_p)
Decodes the given
OwParameterMap |
OwParameterMap |
encode(OwParameterMap parameterMap_p)
Encodes the given
OwParameterMap |
protected abstract OwCookieStoreCodec.OwTimedCookieValue |
getCookieValue(String cookieName_p) |
static long |
loadUrlLifeTimeConfig(OwXMLUtil codecConfiguration_p)
Loads XML URLLifeTime configuration :
URLLifeTime - tag
Configures the amount of time an encoded URL parameter map is valid. After that the parameter map is considered expired and links that relay on are considered out of date / expired and will not produce the desired response. Attributes : days = days until the parameter map expires considering the URL parameter map encoding time hours = hours until the parameter map expires considering the URL parameter map encoding time minutes = minutes until the parameter map expires considering the URL parameter map encoding time seconds = seconds until the parameter map expires considering the URL parameter map encoding time |
static String |
loadUrlParameterConfig(OwXMLUtil codecConfiguration_p)
Loads URL parameter XML configuration :
URLParameter - tag
The parameter map codec encodes a parameter map into another parameter map containing one cookie defining parameter. |
protected abstract void |
remove(OwCookieStoreCodec.OwTimedCookie timedCookie_p)
Removes the given
OwCookieStoreCodec.OwTimedCookie from cookie storage. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getNextUnqiueNameIndex
public static final String CONFIGURATION_BOOTSTRAP_ELEMENT_NAME
public static final String CONFIGURATION_DAYS_ATTRIBUTE
public static final String CONFIGURATION_HOURS_ATTRIBUTE
public static final String CONFIGURATION_MINUTES_ATTRIBUTE
public static final String CONFIGURATION_NAME_ATTRIBUTE
CONFIGURATION_URL_PARAMETER_ELEMENT
public static final String CONFIGURATION_SECONDS_ATTRIBUTE
public static final String CONFIGURATION_URL_LIFE_TIME_ELEMENT
public static final String CONFIGURATION_URL_PARAMETER_ELEMENT
public static final long DEFAULT_CONFIG_URL_LIFE_TIME
public static final String DEFAULT_URL_PARAMETER_NAME
public OwCookieStoreCodec()
public OwCookieStoreCodec(long namesUrlLifeTime_p)
namesUrlLifeTime_p
- the time in which a URL will expire (in milliseconds)public OwCookieStoreCodec(String urlParamenterName_p, long namesUrlLifeTime_p)
urlParamenterName_p
- name of the encoded URL parameternamesUrlLifeTime_p
- the time in which a cookie will expire (in milliseconds)public OwCookieStoreCodec(OwAlphabetCoder alphabetCder_p, String urlParamenterName_p, long namesUrlLifeTime_p)
alphabetCder_p
- the alphabet coder used to generate cookie string values based on unique long valuesurlParamenterName_p
- name of the encoded URL parameternamesUrlLifeTime_p
- the time in which a cookie will expire (in milliseconds)protected abstract void addCookieValue(OwCookieStoreCodec.OwTimedCookieValue timedCookieValue_p) throws OwException
OwCookieStoreCodec.OwTimedCookieValue
to the cookie storetimedCookieValue_p
- OwException
public boolean canDecode(OwParameterMap parameterMap_p) throws OwException
OwParameterMapCodec
OwParameterMap
without system-errors.canDecode
in interface OwParameterMapCodec
true
if the given OwParameterMap
can be decoded or false
otherwiseOwException
protected void collectExpiredNames() throws OwException
OwException
protected abstract List createTimedCookieCollectList() throws OwException
OwCookieStoreCodec.OwTimedCookie
s to be collected.List
of OwCookieStoreCodec.OwTimedCookie
OwException
- if the collect List
creation failscollectExpiredNames()
public OwParameterMap decode(OwParameterMap parameterMap_p, boolean preserveEncoding_p) throws OwException
OwParameterMapCodec
OwParameterMap
decode
in interface OwParameterMapCodec
preserveEncoding_p
- if true
the decoded OwParameterMap
will also contain the encoded parametersOwParameterMap
OwException
- if the decoding process failsOwUserOperationException
- if the decoding process fails but recovery is possible (non-system-errors)protected String createCookie(long uniqueNameIndex_p) throws OwInvalidOperationException, OwException
uniqueNameIndex_p
- OwInvalidOperationException
OwException
public OwParameterMap encode(OwParameterMap parameterMap_p) throws OwException
OwParameterMapCodec
OwParameterMap
encode
in interface OwParameterMapCodec
OwParameterMap
OwException
- if the encoding process failsprotected abstract OwCookieStoreCodec.OwTimedCookieValue getCookieValue(String cookieName_p) throws OwException
cookieName_p
- OwCookieStoreCodec.OwTimedCookieValue
for the given cookieOwException
protected abstract void remove(OwCookieStoreCodec.OwTimedCookie timedCookie_p) throws OwException
OwCookieStoreCodec.OwTimedCookie
from cookie storage.timedCookie_p
- OwException
public static long loadUrlLifeTimeConfig(OwXMLUtil codecConfiguration_p) throws Exception
codecConfiguration_p
- Exception
public static String loadUrlParameterConfig(OwXMLUtil codecConfiguration_p) throws Exception
codecConfiguration_p
- Exception
Copyright © 2014 Alfresco Business Solutions. All Rights Reserved.