[java-identity-provider] branch main updated: IDP-1835 Better logging from IdPUIInfo for empty strings

Rod Widdowson rdw at steadingsoftware.com
Tue Jul 20 10:38:46 UTC 2021


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch main
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=968ccadfc2c05e8e08505e26b930803f2c5e5e97

The following commit(s) were added to refs/heads/main by this push:
       new  968ccadfc IDP-1835 Better logging from IdPUIInfo for empty strings
968ccadfc is described below

commit 968ccadfc2c05e8e08505e26b930803f2c5e5e97
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Jul 20 11:38:14 2021 +0100

    IDP-1835 Better logging from IdPUIInfo for empty strings
    
    https://issues.shibboleth.net/jira/browse/IDP-1835
---
 .../shibboleth/idp/saml/metadata/IdPUIInfo.java    | 84 ++++++++++++----------
 1 file changed, 48 insertions(+), 36 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 deb137c81..7f0a2e52d 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
@@ -66,38 +66,7 @@ public class IdPUIInfo {
     
     /** The Privacy Statement URLs as a map from locale to actual value.*/ 
     @Nonnull @Unmodifiable private final Map<Locale, String> privacyStatementURLs; 
-    
-    /** Warning check against a non localized URL. */
-    private final Predicate<LocalizedURI> nullLanguageURL = new Predicate<>() {
-        public boolean test(final LocalizedURI u) {
-            if (u.getXMLLang() == null) {
-                LOG.warn("URI with value {} in <IdpUIInfo/> has no language associated, ignoring", u.getURI());
-                return false;
-            }
-            if (u.getURI() == null) {
-                LOG.warn("Ignoring empty URI in <IdpUIInfo/>", u.getURI());
-                return false;
-            }
-
-            return true;
-        }
-    };
-    
-    /** Warning check against a non localized String. */
-    private final Predicate<LocalizedName> nullLanguageString = new Predicate<>() {
-        public boolean test(final LocalizedName u) {
-            if (u.getXMLLang() == null) {
-                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;
-        }
-    };
-
+ 
     /** Warning check against a non localized keyword. */
     private final Predicate<Keywords> nullLanguageKeyword = new Predicate<>() {
         public boolean test(final Keywords u) {
@@ -120,7 +89,7 @@ public class IdPUIInfo {
         displayNames = uiInfo.
                 getDisplayNames().
                 stream().
-                filter(nullLanguageString).
+                filter(nullLanguageString("DisplayName")).
                 collect(Collectors.toUnmodifiableMap(
                         displayName -> Locale.forLanguageTag(displayName.getXMLLang()), 
                         displayName -> displayName.getValue(),
@@ -137,7 +106,7 @@ public class IdPUIInfo {
         descriptions = uiInfo.
                 getDescriptions().
                 stream().
-                filter(nullLanguageString).
+                filter(nullLanguageString("Description")).
                 collect(Collectors.toUnmodifiableMap(
                         description -> Locale.forLanguageTag(description.getXMLLang()), 
                         description -> description.getValue(),
@@ -146,7 +115,7 @@ public class IdPUIInfo {
         informationURLs = uiInfo.
                 getInformationURLs().
                 stream().
-                filter(nullLanguageURL).
+                filter(nullLanguageURL("InformationURL")).
                 collect(Collectors.toUnmodifiableMap(
                         url -> Locale.forLanguageTag(url.getXMLLang()), 
                         dn -> dn.getURI(),
@@ -155,7 +124,7 @@ public class IdPUIInfo {
         privacyStatementURLs = uiInfo.
                 getPrivacyStatementURLs().
                 stream().
-                filter(nullLanguageURL).
+                filter(nullLanguageURL("PrivacyStatementURL")).
                 collect(Collectors.toUnmodifiableMap(
                         url -> Locale.forLanguageTag(url.getXMLLang()), 
                         url -> url.getURI(),
@@ -181,7 +150,50 @@ public class IdPUIInfo {
         localeLogos = Collections.unmodifiableMap(withLocaleLogo);
         nonLocaleLogos = Collections.unmodifiableList(noLocaleLogo);
     }
+    
+    /** Warning check against a non localized String.
+     * @param inside further contextual info for logging
+     * @return true if the string inside the name is empty.
+     */
+    @Nonnull private final Predicate<LocalizedName> nullLanguageString(final String inside) {
+        return new Predicate<>() {
+            public boolean test(@Nonnull final LocalizedName u) {
+                if (u.getXMLLang() == null) {
+                    LOG.warn("String with value {} in <{}/> has no language associated, ignoring",
+                            u.getValue(), inside);
+                    return false;
+                }
+                if (u.getValue()== null) {
+                    LOG.warn("Ignoring empty string in <{}/>", inside);
+                    return false;
+                }
+                return true;
+            }
+        };
+    }
 
+    /** Warning check against a non localized URL.
+     * @param inside further contextual info for logging
+     * @return true if the string inside the name is empty.
+     */
+    private final Predicate<LocalizedURI> nullLanguageURL(@Nonnull final String inside) {
+        return new Predicate<>() {
+            public boolean test(final LocalizedURI u) {
+                if (u.getXMLLang() == null) {
+                    LOG.warn("URI with value {} in <{}/> has no language associated, ignoring",
+                            u.getURI(), inside);
+                    return false;
+                }
+                if (u.getURI() == null) {
+                    LOG.warn("Ignoring empty URI in <{}/>", inside);
+                    return false;
+                }
+    
+                return true;
+            }
+        };
+    }
+    
     /** 
      * Get the Display Names as a map from locale to actual value.
      * 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list