[java-opensaml] branch master updated: Switch to our "standard" digester instead of direct commons-codec call.
Scott Cantor
cantor.2 at osu.edu
Fri Sep 21 15:37:00 EDT 2018
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=abf510cc6487ca6c5c40ab7fc67f09408f18160c
The following commit(s) were added to refs/heads/master by this push:
new abf510c Switch to our "standard" digester instead of direct commons-codec call.
abf510c is described below
commit abf510cc6487ca6c5c40ab7fc67f09408f18160c
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Sep 21 15:36:57 2018 -0400
Switch to our "standard" digester instead of direct commons-codec call.
---
.../main/java/org/opensaml/storage/ReplayCache.java | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/opensaml-storage-api/src/main/java/org/opensaml/storage/ReplayCache.java b/opensaml-storage-api/src/main/java/org/opensaml/storage/ReplayCache.java
index 2aa2d46..a44d36d 100644
--- a/opensaml-storage-api/src/main/java/org/opensaml/storage/ReplayCache.java
+++ b/opensaml-storage-api/src/main/java/org/opensaml/storage/ReplayCache.java
@@ -18,18 +18,20 @@
package org.opensaml.storage;
import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
import javax.annotation.Nonnull;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.annotation.constraint.ThreadSafeAfterInit;
+import net.shibboleth.utilities.java.support.codec.StringDigester;
+import net.shibboleth.utilities.java.support.codec.StringDigester.OutputFormat;
import net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
-import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,8 +48,11 @@ public class ReplayCache extends AbstractIdentifiableInitializableComponent {
private final Logger log = LoggerFactory.getLogger(ReplayCache.class);
/** Backing storage for the replay cache. */
- private StorageService storage;
+ @NonnullAfterInit private StorageService storage;
+ /** Digester if key is too long. */
+ @NonnullAfterInit private StringDigester digester;
+
/** Flag controlling behavior on storage failure. */
private boolean strict;
@@ -60,7 +65,6 @@ public class ReplayCache extends AbstractIdentifiableInitializableComponent {
return storage;
}
-
/**
* Set the backing store for the cache.
*
@@ -76,7 +80,6 @@ public class ReplayCache extends AbstractIdentifiableInitializableComponent {
}
}
-
/**
* Get the strictness flag.
*
@@ -104,6 +107,12 @@ public class ReplayCache extends AbstractIdentifiableInitializableComponent {
if (storage == null) {
throw new ComponentInitializationException("StorageService cannot be null");
}
+
+ try {
+ digester = new StringDigester("SHA", OutputFormat.HEX_LOWER);
+ } catch (final NoSuchAlgorithmException e) {
+ throw new ComponentInitializationException(e);
+ }
}
/**
@@ -122,10 +131,10 @@ public class ReplayCache extends AbstractIdentifiableInitializableComponent {
final StorageCapabilities caps = storage.getCapabilities();
if (context.length() > caps.getContextSize()) {
- log.error("context {} too long for StorageService (limit {})", context, caps.getContextSize());
+ log.error("Context '{}' too long for StorageService (limit {})", context, caps.getContextSize());
return false;
} else if (s.length() > caps.getKeySize()) {
- key = DigestUtils.sha1Hex(s);
+ key = digester.apply(s);
} else {
key = s;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list