[java-oidc-common] branch main updated: Add option to fail on duplicates.
Scott Cantor
cantor.2 at osu.edu
Wed Mar 9 22:13:21 UTC 2022
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-oidc-common.
View the commit online:
http://git.shibboleth.net/view/?p=java-oidc-common.git;a=commit;h=56c659f5aa825e06841202ac30b8917ebd5c4547
The following commit(s) were added to refs/heads/main by this push:
new 56c659f Add option to fail on duplicates.
56c659f is described below
commit 56c659f5aa825e06841202ac30b8917ebd5c4547
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Mar 9 17:12:56 2022 -0500
Add option to fail on duplicates.
---
.../StorageServiceClientInformationManager.java | 32 +++++++++++++++++++---
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/StorageServiceClientInformationManager.java b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/StorageServiceClientInformationManager.java
index 0a6028d..4cec426 100644
--- a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/StorageServiceClientInformationManager.java
+++ b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/StorageServiceClientInformationManager.java
@@ -32,6 +32,7 @@ import com.nimbusds.openid.connect.sdk.rp.OIDCClientInformation;
import net.shibboleth.oidc.metadata.ClientInformationManager;
import net.shibboleth.oidc.metadata.ClientInformationManagerException;
+import net.shibboleth.utilities.java.support.component.ComponentSupport;
/**
* A {@link ClientInformationManager} exploiting {@link StorageService} for storing the data.
@@ -42,6 +43,22 @@ public class StorageServiceClientInformationManager extends BaseStorageServiceCl
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(StorageServiceClientInformationResolver.class);
+ /** Whether to raise an exception when a duplicate is stored. */
+ private boolean ignoreDuplicates;
+
+ /**
+ * Set whether attempts to insert a duplicate record should fail or be silently ignored.
+ *
+ * <p>Defaults to true.</p>
+ *
+ * @param flag flag to set
+ */
+ public void setIgnoreDuplicates(final boolean flag) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ ignoreDuplicates = flag;
+ }
+
/** {@inheritDoc} */
@Override
public void storeClientInformation(final OIDCClientInformation clientInformation,
@@ -51,13 +68,20 @@ public class StorageServiceClientInformationManager extends BaseStorageServiceCl
//TODO: configurable serialization
final String serialized = clientInformation.toJSONObject().toJSONString();
try {
- getStorageService().create(CONTEXT_NAME, clientId, serialized,
- expiration != null ? expiration.toEpochMilli() : null);
+ if (getStorageService().create(CONTEXT_NAME, clientId, serialized,
+ expiration != null ? expiration.toEpochMilli() : null)) {
+ log.info("Successfully stored the client information for ID {}", clientId);
+ } else {
+ if (ignoreDuplicates) {
+ log.warn("Attempt to store duplicate client information for ID {}", clientId);
+ } else {
+ throw new ClientInformationManagerException(
+ "Attempt to store duplicate client information for ID " + clientId);
+ }
+ }
} catch (final IOException e) {
- log.error("Could not store the client information", e);
throw new ClientInformationManagerException("Could not store the client information", e);
}
- log.info("Successfully stored the client information for id {}", clientId);
}
/** {@inheritDoc} */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list