[java-identity-provider COMMIT] in /trunk: idp-session-api/src/main/java/net/shibboleth/idp/session/AbstractIdPSessio...

noreply at shibboleth.net noreply at shibboleth.net
Sun Sep 29 22:52:04 EDT 2013


Author: scantor
Date: Sun Sep 29 22:52:04 2013
New Revision: 4808

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4808&view=rev
Log:
"Complete" implementation ready for testing.

Modified:
    trunk/idp-session-api/src/main/java/net/shibboleth/idp/session/AbstractIdPSession.java
    trunk/idp-session-api/src/main/java/net/shibboleth/idp/session/AbstractServiceSessionSerializer.java
    trunk/idp-session-api/src/main/java/net/shibboleth/idp/session/IdPSession.java
    trunk/idp-session-impl/src/main/java/net/shibboleth/idp/session/impl/BasicServiceSessionSerializer.java
    trunk/idp-session-impl/src/main/java/net/shibboleth/idp/session/impl/StorageBackedIdPSession.java
    trunk/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/BasicServiceSessionSerializerTest.java
    trunk/idp-session-impl/src/test/java/net/shibboleth/idp/session/impl/StorageBackedIdPSessionSerializerTest.java

Modified: trunk/idp-session-api/src/main/java/net/shibboleth/idp/session/AbstractIdPSession.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-session-api/src/main/java/net/shibboleth/idp/session/AbstractIdPSession.java?rev=4808&r1=4807&r2=4808&view=diff
==============================================================================
--- trunk/idp-session-api/src/main/java/net/shibboleth/idp/session/AbstractIdPSession.java (original)
+++ trunk/idp-session-api/src/main/java/net/shibboleth/idp/session/AbstractIdPSession.java Sun Sep 29 22:52:04 2013
@@ -224,8 +224,9 @@
     }
 
     /** {@inheritDoc} */
-    public void addAuthenticationResult(@Nonnull final AuthenticationResult result) throws SessionException {
-        doAddAuthenticationResult(result);
+    @Nullable public AuthenticationResult addAuthenticationResult(@Nonnull final AuthenticationResult result)
+            throws SessionException {
+        return doAddAuthenticationResult(result);
     }
 
     /** {@inheritDoc} */
@@ -242,8 +243,10 @@
      * other persistence requirements.</p>
      * 
      * @param result the result to add
-     */
-    public void doAddAuthenticationResult(@Nonnull final AuthenticationResult result) {
+     * 
+     * @return a previously existing result replaced by the new one, if any
+     */
+    @Nullable public AuthenticationResult doAddAuthenticationResult(@Nonnull final AuthenticationResult result) {
         Constraint.isNotNull(result, "AuthenticationResult cannot be null");
     
         Optional<AuthenticationResult> prev =
@@ -251,7 +254,9 @@
         if (prev != null && prev.isPresent()) {
             log.debug("IdPSession {}: replaced old AuthenticationResult for flow ID {}", id,
                     prev.get().getAuthenticationFlowId());
-        }
+            return prev.get();
+        }
+        return null;
     }
 
     /**
@@ -268,7 +273,12 @@
     public boolean doRemoveAuthenticationResult(@Nonnull final AuthenticationResult result) {
         Constraint.isNotNull(result, "Authentication event can not be null");
     
-        return authenticationResults.remove(result.getAuthenticationFlowId(), Optional.of(result));
+        // Record may be actually present, or not yet loaded.
+        if (authenticationResults.remove(result.getAuthenticationFlowId(), Optional.of(result))) {
+            return true;
+        } else {
+            return authenticationResults.remove(result.getAuthenticationFlowId(), Optional.absent());
+        }
     }
 
     /** {@inheritDoc} */
@@ -282,8 +292,9 @@
     }
 
     /** {@inheritDoc} */
-    public void addServiceSession(@Nonnull final ServiceSession serviceSession) throws SessionException {
-        doAddServiceSession(serviceSession);
+    @Nullable public ServiceSession addServiceSession(@Nonnull final ServiceSession serviceSession)
+            throws SessionException {
+        return doAddServiceSession(serviceSession);
     }
 
     /** {@inheritDoc} */
@@ -299,14 +310,18 @@
      * method must be implemented to support other persistence requirements.</p>
      * 
      * @param serviceSession the service session
-     */
-    public void doAddServiceSession(@Nonnull final ServiceSession serviceSession) {
+     * 
+     * @return a previously existing ServiceSession replaced by the new one, if any
+     */
+    @Nullable public ServiceSession doAddServiceSession(@Nonnull final ServiceSession serviceSession) {
         Constraint.isNotNull(serviceSession, "Service session cannot be null");
     
         Optional<ServiceSession> prev = serviceSessions.put(serviceSession.getId(), Optional.of(serviceSession));
         if (prev != null && prev.isPresent()) {
             log.debug("IdPSession {}: replaced old ServiceSession for service {}", id, prev.get().getId());
-        }
+            return prev.get();
+        }
+        return null;
     }
 
     /**
@@ -322,7 +337,12 @@
     public boolean doRemoveServiceSession(@Nonnull final ServiceSession session) {
         Constraint.isNotNull(session, "Service session cannot be null");
     
-        return serviceSessions.remove(session.getId(), Optional.of(session));

[... 582 lines stripped ...]


More information about the commits mailing list