com.force.sdk.oauth.context.store
Class SecurityContextCookieStore

java.lang.Object
  extended by com.force.sdk.oauth.context.store.SecurityContextCookieStore
All Implemented Interfaces:
SecurityContextStorageService

public class SecurityContextCookieStore
extends Object
implements SecurityContextStorageService

Handles the storage of a SecurityContext via browser cookies.

Author:
John Simone

Field Summary
static String SECURITY_CONTEXT_COOKIE_NAME
          Constant that stores the name of the security context cookie.
 
Constructor Summary
SecurityContextCookieStore()
           
 
Method Summary
static byte[] b64decode(String s)
          decode a base 64 encoded string back to the original byte array.
static String b64encode(byte[] b)
          base 64 encode the passed in byte array.
 void clearSecurityContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Clears the security context cookies from the browser.
 SecretKeySpec getSecureKey()
          Retrieves the secret key if one is used in this security context store.
 SecurityContext retreiveSecurityContext(javax.servlet.http.HttpServletRequest request)
          retrieves the security context from a browser cookie.
 void setKeyFileName(String fileName)
          Sets the key file name and reads the key from the file.
 void storeSecurityContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, SecurityContext securityContext)
          Saves the security context to a browser cookie.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SECURITY_CONTEXT_COOKIE_NAME

public static final String SECURITY_CONTEXT_COOKIE_NAME
Constant that stores the name of the security context cookie.

See Also:
Constant Field Values
Constructor Detail

SecurityContextCookieStore

public SecurityContextCookieStore()
Method Detail

storeSecurityContext

public void storeSecurityContext(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response,
                                 SecurityContext securityContext)
                          throws ContextStoreException
Saves the security context to a browser cookie. Store the security context. The means of storage will vary by implementation.

Specified by:
storeSecurityContext in interface SecurityContextStorageService
Parameters:
request - HttpServletRequest
response - HttpServletResponse
securityContext - SecurityContext
Throws:
ContextStoreException - ContextStoreException

retreiveSecurityContext

public SecurityContext retreiveSecurityContext(javax.servlet.http.HttpServletRequest request)
                                        throws ContextStoreException
retrieves the security context from a browser cookie. Retrieve the security context. The means of storage will vary by implementation.

Specified by:
retreiveSecurityContext in interface SecurityContextStorageService
Parameters:
request - HttpServletRequest
Returns:
the stored SecurityContext
Throws:
ContextStoreException - ContextStoreException

getSecureKey

public SecretKeySpec getSecureKey()
                           throws ForceEncryptionException
Description copied from interface: SecurityContextStorageService
Retrieves the secret key if one is used in this security context store.

Specified by:
getSecureKey in interface SecurityContextStorageService
Returns:
SecretKeySpec
Throws:
ForceEncryptionException - ForceEncryptionException

setKeyFileName

public void setKeyFileName(String fileName)
                    throws ForceEncryptionException
Sets the key file name and reads the key from the file.

Parameters:
fileName - String
Throws:
ForceEncryptionException - ForceEncryptionException

b64encode

public static String b64encode(byte[] b)
base 64 encode the passed in byte array.

Parameters:
b - - byte array
Returns:
b64 String representation

b64decode

public static byte[] b64decode(String s)
decode a base 64 encoded string back to the original byte array.

Parameters:
s - - the encoded string
Returns:
the byte array

clearSecurityContext

public void clearSecurityContext(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response)
Clears the security context cookies from the browser. Clears the security context from storage. This won't be relevant for all storage types.

Specified by:
clearSecurityContext in interface SecurityContextStorageService
Parameters:
request - HttpServletRequest
response - HttpServletResponse


Copyright © 2011. All Rights Reserved.