[java-identity-provider] branch master updated: Guard encoding of attributes with no values.
Scott Cantor
cantor.2 at osu.edu
Thu Jul 11 08:53:59 EDT 2019
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=9528e9ca8c860339fe9acfc4940603028b9da221
The following commit(s) were added to refs/heads/master by this push:
new 9528e9c Guard encoding of attributes with no values.
9528e9c is described below
commit 9528e9ca8c860339fe9acfc4940603028b9da221
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Jul 11 08:53:51 2019 -0400
Guard encoding of attributes with no values.
---
.../impl/AddAttributeStatementToAssertion.java | 4 +++-
.../impl/AddAttributeStatementToAssertion.java | 4 +++-
.../impl/AddAttributeStatementToAssertionTest.java | 23 ++++++++++++++++------
3 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/AddAttributeStatementToAssertion.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/AddAttributeStatementToAssertion.java
index 9a94785..353b8b8 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/AddAttributeStatementToAssertion.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/AddAttributeStatementToAssertion.java
@@ -143,7 +143,9 @@ public class AddAttributeStatementToAssertion extends BaseAddAttributeStatementT
throw new AttributeEncodingException("Attribute transoding service unavailable");
}
for (final IdPAttribute attribute : Collections2.filter(attributes, Predicates.notNull())) {
- encodeAttribute(component.getComponent(), profileRequestContext, attribute, encodedAttributes);
+ if (!attribute.getValues().isEmpty()) {
+ encodeAttribute(component.getComponent(), profileRequestContext, attribute, encodedAttributes);
+ }
}
} finally {
if (null != component) {
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/AddAttributeStatementToAssertion.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/AddAttributeStatementToAssertion.java
index d3e2f04..58c7559 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/AddAttributeStatementToAssertion.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/AddAttributeStatementToAssertion.java
@@ -145,7 +145,9 @@ public class AddAttributeStatementToAssertion extends BaseAddAttributeStatementT
throw new AttributeEncodingException("Attribute transoding service unavailable");
}
for (final IdPAttribute attribute : Collections2.filter(attributes, Predicates.notNull())) {
- encodeAttribute(component.getComponent(), profileRequestContext, attribute, encodedAttributes);
+ if (!attribute.getValues().isEmpty()) {
+ encodeAttribute(component.getComponent(), profileRequestContext, attribute, encodedAttributes);
+ }
}
} finally {
if (null != component) {
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/saml2/profile/impl/AddAttributeStatementToAssertionTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/saml2/profile/impl/AddAttributeStatementToAssertionTest.java
index f0e62c5..9864dd8 100644
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/saml2/profile/impl/AddAttributeStatementToAssertionTest.java
+++ b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/saml2/profile/impl/AddAttributeStatementToAssertionTest.java
@@ -71,6 +71,9 @@ public class AddAttributeStatementToAssertionTest extends OpenSAMLInitBaseTestCa
/** The name of the second attribute. */
private final static String MY_NAME_2 = "myName2";
+ /** The name of the third attribute. */
+ private final static String MY_NAME_3 = "myName3";
+
/** The second name of the first attribute. */
private final static String MY_ALTNAME_1 = "myAltName1";
@@ -120,10 +123,17 @@ public class AddAttributeStatementToAssertionTest extends OpenSAMLInitBaseTestCa
rule2_1.put(SAML2AttributeTranscoder.PROP_NAME, MY_NAME_2);
rule2_1.put(SAML2AttributeTranscoder.PROP_NAME_FORMAT, MY_NAMESPACE);
+ final Map<String,Object> rule3_1 = new HashMap<>();
+ rule3_1.put(AttributeTranscoderRegistry.PROP_ID, MY_NAME_3);
+ rule3_1.put(AttributeTranscoderRegistry.PROP_TRANSCODER, transcoder);
+ rule3_1.put(SAML2AttributeTranscoder.PROP_NAME, MY_NAME_3);
+ rule3_1.put(SAML2AttributeTranscoder.PROP_NAME_FORMAT, MY_NAMESPACE);
+
registry.setTranscoderRegistry(Arrays.asList(
new TranscodingRule(rule1_1),
new TranscodingRule(rule1_2),
- new TranscodingRule(rule2_1)));
+ new TranscodingRule(rule2_1),
+ new TranscodingRule(rule3_1)));
registry.initialize();
action = new AddAttributeStatementToAssertion();
@@ -265,7 +275,7 @@ public class AddAttributeStatementToAssertionTest extends OpenSAMLInitBaseTestCa
Assert.assertNotNull(assertion.getAttributeStatements());
Assert.assertEquals(assertion.getAttributeStatements().size(), 1);
- AttributeStatement attributeStatement = assertion.getAttributeStatements().get(0);
+ final AttributeStatement attributeStatement = assertion.getAttributeStatements().get(0);
testAttributeStatement(attributeStatement);
}
}
@@ -286,12 +296,11 @@ public class AddAttributeStatementToAssertionTest extends OpenSAMLInitBaseTestCa
final Response response = (Response) prc.getOutboundMessageContext().getMessage();
Assert.assertEquals(response.getAssertions().size(), 1);
- Assertion assertion = response.getAssertions().get(0);
+ final Assertion assertion = response.getAssertions().get(0);
Assert.assertNotNull(assertion.getAttributeStatements());
Assert.assertEquals(assertion.getAttributeStatements().size(), 1);
final AttributeStatement attributeStatement = assertion.getAttributeStatements().get(0);
-
testAttributeStatement(attributeStatement);
}
@@ -310,7 +319,7 @@ public class AddAttributeStatementToAssertionTest extends OpenSAMLInitBaseTestCa
final Response response = (Response) prc.getOutboundMessageContext().getMessage();
Assert.assertEquals(response.getAssertions().size(), 1);
- Assertion assertion = response.getAssertions().get(0);
+ final Assertion assertion = response.getAssertions().get(0);
Assert.assertNotNull(assertion.getAttributeStatements());
Assert.assertEquals(assertion.getAttributeStatements().size(), 1);
@@ -331,9 +340,11 @@ public class AddAttributeStatementToAssertionTest extends OpenSAMLInitBaseTestCa
final IdPAttribute attribute2 = new IdPAttribute(MY_NAME_2);
attribute2.setValues(Collections.singletonList(new StringAttributeValue(MY_VALUE_2)));
+
+ final IdPAttribute attribute3 = new IdPAttribute(MY_NAME_3);
final AttributeContext attribCtx = new AttributeContext();
- attribCtx.setIdPAttributes(Arrays.asList(attribute1, attribute2));
+ attribCtx.setIdPAttributes(Arrays.asList(attribute1, attribute2, attribute3));
return attribCtx;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list