[java-identity-provider] 02/02: IDP-634 Default consent storage lifetime is "forever"
Rod Widdowson
rdw at steadingsoftware.com
Wed Feb 10 16:03:36 UTC 2021
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=414e29134e0edec6690cdc075fbeab7a42066e89
commit 414e29134e0edec6690cdc075fbeab7a42066e89
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Feb 10 15:28:33 2021 +0000
IDP-634 Default consent storage lifetime is "forever"
https://issues.shibboleth.net/jira/browse/IDP-634
---
.../shibboleth/idp/conf/profile-intercept-system.xml | 4 ++--
idp-conf/src/main/resources/conf/idp.properties | 3 ++-
.../idp/consent/flow/impl/ConsentFlowDescriptor.java | 17 +++++++----------
.../flow/storage/impl/CreateGlobalConsentResult.java | 9 ++++++++-
.../idp/consent/flow/storage/impl/CreateResult.java | 10 ++++++++--
5 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/profile-intercept-system.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/profile-intercept-system.xml
index 2a3fa7094..5d6d39b8c 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/profile-intercept-system.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/profile-intercept-system.xml
@@ -54,7 +54,7 @@
p:globalConsentAllowed="%{idp.consent.allowGlobal:true}"
p:perAttributeConsentEnabled="%{idp.consent.allowPerAttribute:false}"
p:compareValues="%{idp.consent.compareValues:false}"
- p:lifetime="%{idp.consent.storageRecordLifetime:P1Y}"
+ p:lifetime="#{ environment.containsProperty('idp.consent.storageRecordLifetime') ? '%{idp.consent.storageRecordLifetime:0}' : null}"
p:maximumNumberOfStoredRecords="%{idp.consent.maxStoredRecords:10}"
p:expandedNumberOfStoredRecords="%{idp.consent.expandedMaxStoredRecords:0}"
p:expandedStorageThreshold="%{idp.consent.expandedStorageThreshold:1048576}"
@@ -88,7 +88,7 @@
class="net.shibboleth.idp.consent.flow.impl.ConsentFlowDescriptor"
p:storageService-ref="#{'%{idp.consent.StorageService:shibboleth.ClientPersistentStorageService}'.trim()}"
p:compareValues="%{idp.consent.compareValues:false}"
- p:lifetime="%{idp.consent.storageRecordLifetime:P1Y}"
+ p:lifetime="#{ environment.containsProperty('idp.consent.storageRecordLifetime') ? '%{idp.consent.storageRecordLifetime:0}' : null}"
p:maximumNumberOfStoredRecords="%{idp.consent.maxStoredRecords:10}"
p:expandedNumberOfStoredRecords="%{idp.consent.expandedMaxStoredRecords:0}"
p:expandedStorageThreshold="%{idp.consent.expandedStorageThreshold:1048576}"
diff --git a/idp-conf/src/main/resources/conf/idp.properties b/idp-conf/src/main/resources/conf/idp.properties
index d1f4a2bf0..32411e8f2 100644
--- a/idp-conf/src/main/resources/conf/idp.properties
+++ b/idp-conf/src/main/resources/conf/idp.properties
@@ -158,7 +158,8 @@ idp.session.secondaryServiceIndex = true
#idp.consent.expandedMaxStoredRecords = 0
# Time in milliseconds to expire consent storage records.
-#idp.consent.storageRecordLifetime = P1Y
+# Leave commented out for the default of infinite
+#idp.consent.storageRecordLifetime =
# Path to use with External interceptor flow
#idp.intercept.External.externalPath = contextRelative:intercept.jsp
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/impl/ConsentFlowDescriptor.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/impl/ConsentFlowDescriptor.java
index 6a8318006..33043da07 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/impl/ConsentFlowDescriptor.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/impl/ConsentFlowDescriptor.java
@@ -19,11 +19,10 @@ package net.shibboleth.idp.consent.flow.impl;
import java.time.Duration;
-import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import net.shibboleth.idp.profile.interceptor.ProfileInterceptorFlowDescriptor;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.logic.Constraint;
/**
* Descriptor for a consent flow.
@@ -37,7 +36,7 @@ public class ConsentFlowDescriptor extends ProfileInterceptorFlowDescriptor {
private boolean compareValues;
/** Time to expire consent storage records. Default value: 1 year. */
- @Nonnull private Duration lifetime;
+ @Nullable private Duration lifetime;
/** Maximum number of records stored in the storage service. */
private int maxStoredRecords;
@@ -50,7 +49,6 @@ public class ConsentFlowDescriptor extends ProfileInterceptorFlowDescriptor {
/** Constructor. */
public ConsentFlowDescriptor() {
- lifetime = Duration.ofDays(365);
expandedStorageThreshold = 1024 * 1024;
}
@@ -66,9 +64,9 @@ public class ConsentFlowDescriptor extends ProfileInterceptorFlowDescriptor {
/**
* Time to expire consent storage records.
*
- * @return time to expire consent storage records
+ * @return time to expire consent storage records, null for infinite.
*/
- @Nonnull public Duration getLifetime() {
+ @Nullable public Duration getLifetime() {
return lifetime;
}
@@ -113,12 +111,12 @@ public class ConsentFlowDescriptor extends ProfileInterceptorFlowDescriptor {
/**
* Set time to expire consent storage records.
*
- * @param consentLifetime time to expire consent storage records
+ * @param consentLifetime time to expire consent storage records. null means infinite
*/
- public void setLifetime(@Nonnull final Duration consentLifetime) {
+ public void setLifetime(@Nullable final Duration consentLifetime) {
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- lifetime = Constraint.isNotNull(consentLifetime, "Lifetime cannot be null");
+ lifetime = consentLifetime;
}
/**
@@ -155,5 +153,4 @@ public class ConsentFlowDescriptor extends ProfileInterceptorFlowDescriptor {
expandedStorageThreshold = size;
}
-
}
\ No newline at end of file
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/CreateGlobalConsentResult.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/CreateGlobalConsentResult.java
index 9cf9c95d3..96e36a935 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/CreateGlobalConsentResult.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/CreateGlobalConsentResult.java
@@ -18,6 +18,7 @@
package net.shibboleth.idp.consent.flow.storage.impl;
import java.io.IOException;
+import java.time.Duration;
import java.time.Instant;
import java.util.Collections;
@@ -58,7 +59,13 @@ public class CreateGlobalConsentResult extends AbstractConsentIndexedStorageActi
final String value =
getStorageSerializer().serialize(Collections.singletonMap(globalConsent.getId(), globalConsent));
- final Instant expiration = Instant.now().plus(getConsentFlowDescriptor().getLifetime());
+ final Duration lifetime = getConsentFlowDescriptor().getLifetime();
+ final Instant expiration;
+ if (lifetime == null) {
+ expiration = null;
+ } else {
+ expiration = Instant.now().plus(lifetime);
+ }
final ProfileInterceptorResult result =
new ConsentResult(getStorageContext(), getStorageKey(), value, expiration);
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/CreateResult.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/CreateResult.java
index 4fdcc0bdc..cd3584bc4 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/CreateResult.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/CreateResult.java
@@ -18,6 +18,7 @@
package net.shibboleth.idp.consent.flow.storage.impl;
import java.io.IOException;
+import java.time.Duration;
import java.time.Instant;
import java.util.Map;
@@ -71,8 +72,13 @@ public class CreateResult extends AbstractConsentIndexedStorageAction {
final Map<String, Consent> currentConsents = getConsentContext().getCurrentConsents();
final String value = getStorageSerializer().serialize(currentConsents);
- final Instant expiration = Instant.now().plus(getConsentFlowDescriptor().getLifetime());
-
+ final Duration lifetime = getConsentFlowDescriptor().getLifetime();
+ final Instant expiration;
+ if (lifetime == null) {
+ expiration = null;
+ } else {
+ expiration = Instant.now().plus(lifetime);
+ }
final ProfileInterceptorResult result =
new ConsentResult(getStorageContext(), getStorageKey(), value, expiration);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list