[java-identity-provider COMMIT] in /trunk/idp-consent/src: main/java/net/shibboleth/idp/consent/logic/AttributeValueL...
noreply at shibboleth.net
noreply at shibboleth.net
Thu Nov 20 13:07:16 EST 2014
Author: tzeller
Date: Thu Nov 20 13:07:16 2014
New Revision: 6968
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=6968&view=rev
Log:
Checkpoint consent cleanup and tests.
Added:
trunk/idp-consent/src/test/java/net/shibboleth/idp/consent/logic/AttributeValueLookupFunctionTest.java (with props)
trunk/idp-consent/src/test/java/net/shibboleth/idp/consent/logic/AttributeValuesHashFunctionTest.java (with props)
Modified:
trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributeValueLookupFunction.java
trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributeValuesHashFunction.java
Modified: trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributeValueLookupFunction.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributeValueLookupFunction.java?rev=6968&r1=6967&r2=6968&view=diff
==============================================================================
--- trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributeValueLookupFunction.java (original)
+++ trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributeValueLookupFunction.java Thu Nov 20 13:07:16 2014
@@ -41,7 +41,6 @@
/**
* {@link ContextDataLookupFunction} to return the value of an attribute from an {@link AttributeContext}.
*/
-// TODO tests
public class AttributeValueLookupFunction implements ContextDataLookupFunction<ProfileRequestContext, String> {
/** Class logger. */
@@ -68,6 +67,17 @@
new ChildContextLookup<ProfileRequestContext, RelyingPartyContext>(RelyingPartyContext.class));
}
+ /**
+ * Set the attribute context lookup strategy.
+ *
+ * @param strategy the attribute context lookup strategy
+ */
+ public void setAttributeContextLookupStrategy(
+ @Nonnull final Function<ProfileRequestContext, AttributeContext> strategy) {
+ attributeContextLookupStrategy =
+ Constraint.isNotNull(strategy, "Attribute context lookup strategy cannot be null");
+ }
+
/** {@inheritDoc} */
@Override @Nullable public String apply(@Nullable final ProfileRequestContext input) {
@@ -79,7 +89,7 @@
final IdPAttribute attribute = attributeContext.getIdPAttributes().get(attributeId);
if (attribute == null || attribute.getValues().isEmpty()) {
- log.debug("Attribute {} has no values", attributeId);
+ log.debug("Attribute '{}' does not exist or has no values", attributeId);
return null;
}
@@ -89,6 +99,8 @@
for (final IdPAttributeValue value : attribute.getValues()) {
if (value instanceof StringAttributeValue) {
+ log.debug("Returning value '{}' of attribute '{}'", ((StringAttributeValue) value).getValue(),
+ attributeId);
return ((StringAttributeValue) value).getValue();
}
}
Modified: trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributeValuesHashFunction.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributeValuesHashFunction.java?rev=6968&r1=6967&r2=6968&view=diff
==============================================================================
--- trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributeValuesHashFunction.java (original)
+++ trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/AttributeValuesHashFunction.java Thu Nov 20 13:07:16 2014
@@ -26,7 +26,7 @@
import javax.annotation.Nullable;
import net.shibboleth.idp.attribute.IdPAttributeValue;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
import org.cryptacular.util.CodecUtil;
import org.cryptacular.util.HashUtil;
@@ -34,11 +34,16 @@
import org.slf4j.LoggerFactory;
import com.google.common.base.Function;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Collections2;
/**
* Function to calculate the hash of the values of an IdP attribute.
*
- * TODO details
+ * Returns <code>null</code> for a <code>null</code> input or empty collection of IdP attribute values.
+ * <code>Null</code> IdP attribute values are ignored.
+ *
+ * The hash returned is the Base64 encoded representation of the SHA-256 digest.
*/
public class AttributeValuesHashFunction implements Function<Collection<IdPAttributeValue<?>>, String> {
@@ -46,9 +51,15 @@
@Nonnull private final Logger log = LoggerFactory.getLogger(AttributeValuesHashFunction.class);
/** {@inheritDoc} */
- @Nullable public String apply(@Nonnull @NonnullElements final Collection<IdPAttributeValue<?>> input) {
+ @Nullable public String apply(@Nullable @NullableElements final Collection<IdPAttributeValue<?>> input) {
- if (input.isEmpty()) {
+ if (input == null) {
[... 19 lines stripped ...]
More information about the commits
mailing list