[java-identity-provider COMMIT] in /trunk/idp-consent/src: main/java/net/shibboleth/idp/consent/logic/FlowIdLookupFun...

noreply at shibboleth.net noreply at shibboleth.net
Thu Nov 20 23:32:49 EST 2014


Author: tzeller
Date: Thu Nov 20 23:32:49 2014
New Revision: 6981

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=6981&view=rev
Log:
Checkpoint consent cleanup and tests.

Added:
    trunk/idp-consent/src/test/java/net/shibboleth/idp/consent/storage/ConsentSerializerTest.java
      - copied, changed from r6967, trunk/idp-consent/src/test/java/net/shibboleth/idp/consent/storage/AttributeConsentSerializerTest.java
Modified:
    trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/FlowIdLookupFunction.java
    trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/storage/ConsentSerializer.java
    trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/storage/StorageIndexSerializer.java
    trunk/idp-consent/src/test/java/net/shibboleth/idp/consent/storage/AttributeConsentSerializerTest.java
    trunk/idp-consent/src/test/java/net/shibboleth/idp/consent/storage/StorageIndexSerializerTest.java

Modified: trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/FlowIdLookupFunction.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/FlowIdLookupFunction.java?rev=6981&r1=6980&r2=6981&view=diff
==============================================================================
--- trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/FlowIdLookupFunction.java (original)
+++ trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/FlowIdLookupFunction.java Thu Nov 20 23:32:49 2014
@@ -32,23 +32,17 @@
 
 /**
  * {@link ContextDataLookupFunction} that returns the current flow id.
- * 
- * TODO details
  */
-// TODO tests
 public class FlowIdLookupFunction implements ContextDataLookupFunction<ProfileRequestContext, String> {
 
     /** Class logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(FlowIdLookupFunction.class);
 
     /** {@inheritDoc} */
-    @Override
-    @Nullable public String apply(@Nullable final ProfileRequestContext input) {
+    @Override @Nullable public String apply(@Nullable final ProfileRequestContext input) {
         if (input == null) {
             return null;
         }
-
-        // TODO log null checks ?
 
         final SpringRequestContext springRequestContext = input.getSubcontext(SpringRequestContext.class, false);
         if (springRequestContext == null) {

Modified: trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/storage/ConsentSerializer.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/storage/ConsentSerializer.java?rev=6981&r1=6980&r2=6981&view=diff
==============================================================================
--- trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/storage/ConsentSerializer.java (original)
+++ trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/storage/ConsentSerializer.java Thu Nov 20 23:32:49 2014
@@ -20,6 +20,7 @@
 import java.io.IOException;
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.util.Collection;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -46,12 +47,12 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Predicates;
+import com.google.common.collect.Collections2;
+
 /**
  * Serializes {@link Consent}.
- * 
- * TODO details
  */
-// TODO handle null consent values
 public class ConsentSerializer extends AbstractInitializableComponent implements
         StorageSerializer<Map<String, Consent>> {
 
@@ -109,32 +110,27 @@
                 }
             }
 
-            log.debug("Deserialized context '{}' key '{}' value '{}' expiration '{}' as '{}", new Object[] {context,
+            log.debug("Deserialized context '{}' key '{}' value '{}' expiration '{}' as '{}'", new Object[] {context,
                     key, value, expiration, consents,});
             return consents;
         } catch (final NullPointerException | ClassCastException | ArithmeticException | JsonException e) {
-            log.error("Exception while parsing AttributeConsent", e);
-            throw new IOException("Found invalid data structure while parsing AttributeConsent", e);
+            log.error("Exception while parsing consent", e);
+            throw new IOException("Found invalid data structure while parsing consent", e);
         }
     }
 
     /** {@inheritDoc} */
-    @Nonnull
-    @NotEmpty
-    public String serialize(@Nonnull final Map<String, Consent> consents) throws IOException {
+    @Nonnull @NotEmpty public String serialize(@Nonnull final Map<String, Consent> consents) throws IOException {
         Constraint.isNotNull(consents, "Consents cannot be null");
 
-        // TODO what should be returned in this case ?
-
-        if (consents.isEmpty()) {
-            return "";
-        }
+        final Collection<Consent> filteredConsents = Collections2.filter(consents.values(), Predicates.notNull());
+        Constraint.isNotEmpty(filteredConsents, "Consents cannot be empty");
 

[... 228 lines stripped ...]


More information about the commits mailing list