[java-opensaml COMMIT] in /trunk/opensaml-storage-impl/src: main/java/org/opensaml/storage/impl/ServletRequestScopedS...
noreply at shibboleth.net
noreply at shibboleth.net
Mon Nov 17 14:47:46 EST 2014
Author: scantor
Date: Mon Nov 17 14:47:45 2014
New Revision: 4148
URL: http://svn.shibboleth.net/view/java-opensaml?rev=4148&view=rev
Log:
Allow multiple instances of cookie storage service to run.
Modified:
trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/ServletRequestScopedStorageService.java
trunk/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/ServletRequestScopedStorageServiceTest.java
Modified: trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/ServletRequestScopedStorageService.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/ServletRequestScopedStorageService.java?rev=4148&r1=4147&r2=4148&view=diff
==============================================================================
--- trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/ServletRequestScopedStorageService.java (original)
+++ trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/ServletRequestScopedStorageService.java Mon Nov 17 14:47:45 2014
@@ -160,6 +160,15 @@
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
cookieManager = Constraint.isNotNull(manager, "CookieManager cannot be null");
+ }
+
+ /**
+ * Get the cookie name to use for storage tracking.
+ *
+ * @return cookie name to use
+ */
+ @Nonnull @NotEmpty public String getCookieName() {
+ return cookieName;
}
/**
@@ -449,13 +458,13 @@
@Override
@Nonnull @NonnullElements @Live protected Map<String, Map<String, MutableStorageRecord>> getContextMap() {
- final Object contextMap = httpServletRequest.getAttribute(CONTEXT_MAP_ATTRIBUTE);
+ final Object contextMap = httpServletRequest.getAttribute(CONTEXT_MAP_ATTRIBUTE + '.' + cookieName);
if (contextMap != null) {
return (Map<String, Map<String, MutableStorageRecord>>) contextMap;
}
final Map<String, Map<String, MutableStorageRecord>> newMap = Maps.newHashMap();
- httpServletRequest.setAttribute(CONTEXT_MAP_ATTRIBUTE, newMap);
+ httpServletRequest.setAttribute(CONTEXT_MAP_ATTRIBUTE + '.' + cookieName, newMap);
// The first time through, do a load from the cookie.
// Any subsequent calls to get the context map will return the previously set map.
@@ -482,9 +491,9 @@
*/
private void setDirty(final boolean flag) {
if (flag) {
- httpServletRequest.setAttribute(DIRTY_BIT_ATTRIBUTE, Boolean.TRUE);
+ httpServletRequest.setAttribute(DIRTY_BIT_ATTRIBUTE + '.' + cookieName, Boolean.TRUE);
} else {
- httpServletRequest.removeAttribute(DIRTY_BIT_ATTRIBUTE);
+ httpServletRequest.removeAttribute(DIRTY_BIT_ATTRIBUTE + '.' + cookieName);
}
}
@@ -494,7 +503,7 @@
* @return status of dirty bit
*/
private boolean isDirty() {
- final Object dirty = httpServletRequest.getAttribute(DIRTY_BIT_ATTRIBUTE);
+ final Object dirty = httpServletRequest.getAttribute(DIRTY_BIT_ATTRIBUTE + '.' + cookieName);
if (dirty != null && dirty instanceof Boolean) {
return (Boolean) dirty;
} else {
Modified: trunk/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/ServletRequestScopedStorageServiceTest.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/ServletRequestScopedStorageServiceTest.java?rev=4148&r1=4147&r2=4148&view=diff
==============================================================================
--- trunk/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/ServletRequestScopedStorageServiceTest.java (original)
+++ trunk/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/ServletRequestScopedStorageServiceTest.java Mon Nov 17 14:47:45 2014
@@ -142,7 +142,7 @@
ss.save();
Assert.assertNotNull(mockResponse.getCookie("test"));
- mockRequest.setAttribute(ServletRequestScopedStorageService.CONTEXT_MAP_ATTRIBUTE, null);
+ mockRequest.setAttribute(ServletRequestScopedStorageService.CONTEXT_MAP_ATTRIBUTE + "." + ss.getCookieName(), null);
for (int i = 1; i <= 10; i++) {
Assert.assertNull(ss.read(context, Integer.toString(i)));
More information about the commits
mailing list