[java-identity-provider COMMIT] /trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/CheckMessageRep...

noreply at shibboleth.net noreply at shibboleth.net
Tue Apr 30 23:17:09 EDT 2013


Author: scantor
Date: Tue Apr 30 23:17:08 2013
New Revision: 4434

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4434&view=rev
Log:
Rebase ReplayCache on top of storage API and fix tests.

Modified:
    trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/CheckMessageReplay.java

Modified: trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/CheckMessageReplay.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/CheckMessageReplay.java?rev=4434&r1=4433&r2=4434&view=diff
==============================================================================
--- trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/CheckMessageReplay.java (original)
+++ trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/CheckMessageReplay.java Tue Apr 30 23:17:08 2013
@@ -44,6 +44,27 @@
     /** Cache used to store message issuer/id pairs and check to see if a message is being replayed. */
     private ReplayCache replayCache;
 
+    /** Time in seconds to expire cache entries. Default value: (180) */
+    private long expires = 180L;
+
+    /**
+     * Gets the lifetime in seconds of replay entries.
+     * 
+     * @return lifetime in seconds of entries
+     */
+    public long getExpires() {
+        return expires;
+    }
+
+    /**
+     * Sets the lifetime in seconds of replay entries.
+     * 
+     * @param exp lifetime in seconds of entries
+     */
+    public void setExpires(long exp) {
+        expires = exp;
+    }
+    
     /** {@inheritDoc} */
     protected org.springframework.webflow.execution.Event
             doExecute(@Nonnull final RequestContext springRequestContext,
@@ -61,10 +82,14 @@
             return ActionSupport.buildEvent(this, EventIds.INVALID_MSG_MD);
         }
 
-        final String msgIssuer = msgMdCtx.getMessageIssuer();
+        String msgIssuer = msgMdCtx.getMessageIssuer();
         if (msgIssuer == null) {
-            log.debug("Action {}: Message metadata does not contain an issuer, unable to proceed", getId());
-            return ActionSupport.buildEvent(this, EventIds.INVALID_MSG_MD);
+            msgIssuer = "(unknown)";
+        }
+        
+        long msgIssueInstant = msgMdCtx.getMessageIssueInstant();
+        if (msgIssueInstant <= 0) {
+            msgIssueInstant = System.currentTimeMillis();
         }
 
         final String msgId = msgMdCtx.getMessageId();
@@ -73,7 +98,7 @@
             return ActionSupport.buildEvent(this, EventIds.INVALID_MSG_MD);
         }
 
-        if (replayCache.isReplay(msgIssuer, msgId)) {
+        if (!replayCache.check(getClass().getName(), msgId, msgIssueInstant / 1000 + expires)) {
             log.debug("Action {}: Message {} issued by {} has been replayed", new Object[] {getId(), msgId, msgIssuer});
             return ActionSupport.buildEvent(this, REPLAYED_MSG);
         }



More information about the commits mailing list