[java-identity-provider] 04/04: IDP-1593 Test and fix null-ness in UIInfo
Rod Widdowson
rdw at steadingsoftware.com
Sun Apr 19 10:54:24 EDT 2020
This is an automated email from the git hooks/post-receive script.
rdw 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=d5378c390c2a814c99daf416926565024401df6f
commit d5378c390c2a814c99daf416926565024401df6f
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sun Apr 19 15:52:04 2020 +0100
IDP-1593 Test and fix null-ness in UIInfo
https://issues.shibboleth.net/jira/browse/IDP-1593
This is slightly trickier since we are allowedlogos with no localization.
There is also the "what is an empty list? null or with with size 0".
This is now fixed in OpenSAML (where the answer is non-null, but empty)
---
.../shibboleth/idp/saml/metadata/IdPUIInfo.java | 20 +++++++++++--
.../idp/saml/metadata/IdPUIInfoTest.java | 20 ++++++++++---
idp-saml-api/src/test/resources/UIInfoBad.xml | 35 ++++++++++++++++++++++
3 files changed, 68 insertions(+), 7 deletions(-)
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/metadata/IdPUIInfo.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/metadata/IdPUIInfo.java
index adb43e4..c930779 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/metadata/IdPUIInfo.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/metadata/IdPUIInfo.java
@@ -70,9 +70,14 @@ public class IdPUIInfo {
private final Predicate<LocalizedURI> nullLanguageURL = new Predicate<>() {
public boolean test(final LocalizedURI u) {
if (u.getXMLLang() == null) {
- LOG.warn("URI with value {} has no language associated, ignoring", u.getURI());
+ LOG.warn("URI with value {} in <IdpUIInfo/> has no language associated, ignoring", u.getURI());
return false;
}
+ if (u.getURI() == null) {
+ LOG.warn("Ignoring empty URUI in <IdpUIInfo/>", u.getURI());
+ return false;
+ }
+
return true;
}
};
@@ -81,7 +86,11 @@ public class IdPUIInfo {
private final Predicate<LocalizedName> nullLanguageString = new Predicate<>() {
public boolean test(final LocalizedName u) {
if (u.getXMLLang() == null) {
- LOG.warn("String with value {} has no language associated, ignoring", u.getValue());
+ LOG.warn("String with value {} in <IdpUIInfo/> has no language associated, ignoring", u.getValue());
+ return false;
+ }
+ if (u.getValue()== null) {
+ LOG.warn("Ignoring empty string in <IdpUIInfo/>");
return false;
}
return true;
@@ -92,7 +101,8 @@ public class IdPUIInfo {
private final Predicate<Keywords> nullLanguageKeyword = new Predicate<>() {
public boolean test(final Keywords u) {
if (u.getXMLLang() == null) {
- LOG.warn("String with value {} has no language associated, ignoring", u.getKeywords().toString());
+ LOG.warn("Keyword with value {} in <IdpUIInfo/> has no language associated, ignoring",
+ u.getKeywords().toString());
return false;
}
return true;
@@ -145,6 +155,10 @@ public class IdPUIInfo {
final List<Logo> noLocaleLogo = new ArrayList<>();
final Map<Locale, List<Logo>> withLocaleLogo = new HashMap<>();
for (final Logo logo : uiInfo.getLogos()) {
+ if (logo.getURI() == null) {
+ LOG.warn("IdpUIInfo has Logo with null URL, ignoring");
+ continue;
+ }
if (logo.getXMLLang() != null) {
final Locale l = Locale.forLanguageTag(logo.getXMLLang());
if (withLocaleLogo.get(l) == null) {
diff --git a/idp-saml-api/src/test/java/net/shibboleth/idp/saml/metadata/IdPUIInfoTest.java b/idp-saml-api/src/test/java/net/shibboleth/idp/saml/metadata/IdPUIInfoTest.java
index e888be3..d654f88 100644
--- a/idp-saml-api/src/test/java/net/shibboleth/idp/saml/metadata/IdPUIInfoTest.java
+++ b/idp-saml-api/src/test/java/net/shibboleth/idp/saml/metadata/IdPUIInfoTest.java
@@ -31,12 +31,12 @@ import org.testng.annotations.Test;
*/
@SuppressWarnings("javadoc")
public class IdPUIInfoTest extends XMLObjectBaseTestCase {
-
+
@Test public void test() {
-
+
final UIInfo samluiinfo = unmarshallElement("/UIInfo.xml");
final IdPUIInfo uiInfo = new IdPUIInfo(samluiinfo);
-
+
assertEquals(uiInfo.getDisplayNames().size(), 2);
assertNotNull(uiInfo.getDisplayNames().get(Locale.forLanguageTag("en-us")));
assertEquals(uiInfo.getDescriptions().size(), 1);
@@ -46,6 +46,18 @@ public class IdPUIInfoTest extends XMLObjectBaseTestCase {
assertEquals(uiInfo.getNonLocaleLogos().size(), 1);
assertEquals(uiInfo.getInformationURLs().size(), 1);
assertEquals(uiInfo.getPrivacyStatementURLs().size(), 1);
-
+ }
+ @Test public void testBad() {
+
+ final UIInfo samluiinfo = unmarshallElement("/UIInfoBad.xml");
+ final IdPUIInfo uiInfo = new IdPUIInfo(samluiinfo);
+
+ assertEquals(uiInfo.getDisplayNames().size(), 1);
+ assertEquals(uiInfo.getDescriptions().size(), 1);
+ assertEquals(uiInfo.getKeywords().size(), 2); // one of which empty
+ assertEquals(uiInfo.getLocaleLogos().size(), 1);
+ assertEquals(uiInfo.getNonLocaleLogos().size(), 2);
+ assertEquals(uiInfo.getInformationURLs().size(), 1);
+ assertEquals(uiInfo.getPrivacyStatementURLs().size(), 1);
}
}
diff --git a/idp-saml-api/src/test/resources/UIInfoBad.xml b/idp-saml-api/src/test/resources/UIInfoBad.xml
new file mode 100644
index 0000000..3fab9c9
--- /dev/null
+++ b/idp-saml-api/src/test/resources/UIInfoBad.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<UIInfo xmlns="urn:oasis:names:tc:SAML:metadata:ui"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:oasis:names:tc:SAML:metadata:ui http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-metadata-ui/v1.0/cs01/xsd/sstc-saml-metadata-ui-v1.0.xsd">
+
+ <DisplayName xml:lang="en-us">Dn</DisplayName>
+ <DisplayName xml:lang="">Dn</DisplayName>
+ <DisplayName xml:lang="Fr"></DisplayName>
+ <DisplayName >Dn</DisplayName>
+
+ <Description xml:lang="fr">Desc</Description>
+ <Description xml:lang="en"></Description>
+ <Description xml:lang="">D</Description>
+ <Description >Desc</Description>
+
+ <Keywords xml:lang="en">a s r</Keywords>
+ <Keywords >a r s</Keywords>
+ <Keywords xml:lang="">a s t</Keywords>
+ <Keywords xml:lang="fr"></Keywords>
+
+ <InformationURL xml:lang="fr">infoURL</InformationURL>
+ <InformationURL xml:lang="">infoURL</InformationURL>
+ <InformationURL >infoURL</InformationURL>
+ <InformationURL xml:lang="en"></InformationURL>
+
+ <Logo height="100" width="110">Logo1</Logo>
+ <Logo height="100" width="110"/>
+ <Logo height="10" width="12" xml:lang="">Logo2</Logo>
+ <Logo height="10" width="12" xml:lang="en">Logo3</Logo>
+ <Logo height="10" width="12" xml:lang="fr"></Logo>
+
+ <PrivacyStatementURL xml:lang="fr">privateURL</PrivacyStatementURL>
+ <PrivacyStatementURL xml:lang="">privateURL</PrivacyStatementURL>
+ <PrivacyStatementURL >privateURL</PrivacyStatementURL>
+</UIInfo>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list