|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.fhg.igd.atlas.core.CookieManager
Provides all methods needed for the Location Service Protocol (LSP) which deal with cookie generation and storage.
Field Summary | |
protected AgentContext |
agentContext_
The reference to the agent context (needed to read, update and delete the current and temporary cookie of the agent). |
static int |
COOKIE_LENGTH
The length of a cookie in bytes. |
static byte[] |
NULL_COOKIE
The unique null cookie, which is used to distinguish between Init, Update and Delete register requests within the Location Service Protocol. |
static String |
PATH_TO_CURRENT_COOKIE
The path and filename within the agent resource to store the current cookie. |
static String |
PATH_TO_TMP_COOKIE
The path and filename within the agent resource to store the temporary cookie, which is needed for the backup protocol. |
static String |
SR_ALG
The algorithm used to calculate secure randoms for cookie generation. |
Constructor Summary | |
CookieManager(AgentContext agentContext)
Creates an new instance of this class. |
Method Summary | |
boolean |
existsCurrentCookie()
Checks if a current cookie is existent. |
boolean |
existsTmpCookie()
Checks if a temporary cookie is existent. |
static byte[] |
generateCookie()
Generates a new cookie of length COOKIE_LENGTH . |
protected byte[] |
readCookieFromResource(Resource agentResource,
String path)
Reads a cookie from the given path
within the agent resource. |
byte[] |
readCurrentCookie()
Reads the current cookie from the agent resource. |
byte[] |
readTmpCookie()
Reads the temporary cookie from the agent resource. |
void |
removeCurrentCookie()
Removes the current cookie of the agent within the agent resource and the agent context. |
void |
removeTmpCookie()
Removes the temporary cookie of the agent within the agent resource and the agent context. |
protected void |
writeCookieToResource(Resource agentResource,
byte[] cookie,
String path)
Writes the given cookie to the given
path within the agent resource. |
void |
writeCurrentCookie(byte[] cookie)
Writes the given cookie as current cookie
to the agent resource and to the agent context. |
void |
writeTmpCookie(byte[] cookie)
Writes the given cookie as temporary cookie
to the agent resource and to the agent context. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String SR_ALG
public static String PATH_TO_CURRENT_COOKIE
public static String PATH_TO_TMP_COOKIE
public static final byte[] NULL_COOKIE
public static final int COOKIE_LENGTH
protected AgentContext agentContext_
Constructor Detail |
public CookieManager(AgentContext agentContext)
agentContext is used to obtain the
current or temporary cookie directly or from
the resource of the agent.
If the agent resource is existent it obtains priority
concerning the state of the cookies. Only in the case
when the agent resource is not valid any more, those
cookies are used, which are stored directly within the
agents context. This happens, if the agent has migrated
and the agent context is still available (when the
agent state changes from migrated to invalid)
- Parameters:
agentContext
- The context of an agent.
Method Detail |
public static byte[] generateCookie() throws NoSuchAlgorithmException
COOKIE_LENGTH
.
NoSuchAlgorithmException
- if the generation of secure randoms
is not supported.public void removeCurrentCookie() throws IOException
IOException
- if an error occures
during access to the agents resource.public void removeTmpCookie() throws IOException
IOException
- if an error occures
during access to the agents resource.public boolean existsCurrentCookie()
true
if the current cookie is
existent; false
otherwise.public boolean existsTmpCookie()
true
if the temporary cookie is
existent; false
otherwise.public byte[] readCurrentCookie() throws IOException
NULL_COOKIE
otherwise
IOException
- if an error occures
during access to the agents resource.public byte[] readTmpCookie() throws IOException
NULL_COOKIE
otherwise.
IOException
- if an error occures
during access to the agents resource.protected byte[] readCookieFromResource(Resource agentResource, String path) throws IOException
path
within the agent resource.
path
- The path within the agent resource.
NULL_COOKIE
otherwise.
IOException
- if an error occures
during access to the agents resource.public void writeCurrentCookie(byte[] cookie) throws IOException
cookie
as current cookie
to the agent resource and to the agent context.
IOException
- if an error occures
during access to the agents resource.public void writeTmpCookie(byte[] cookie) throws IOException
cookie
as temporary cookie
to the agent resource and to the agent context.
IOException
- if an error occures
during access to the agents resource.protected void writeCookieToResource(Resource agentResource, byte[] cookie, String path) throws IOException
cookie
to the given
path
within the agent resource.
path
- The path within the agent resource.
IOException
- if an error occures
during access to the agents resource.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |