[java-identity-provider COMMIT] in /trunk/idp-ui/src: main/java/net/shibboleth/idp/ui/context/RelyingPartyUIContext.j...

noreply at shibboleth.net noreply at shibboleth.net
Wed Aug 13 11:04:06 EDT 2014


Author: rdw
Date: Wed Aug 13 11:04:06 2014
New Revision: 6418

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=6418&view=rev
Log:
IDP-245 Add Information and PrivacyURLs and better tests

Modified:
    trunk/idp-ui/src/main/java/net/shibboleth/idp/ui/context/RelyingPartyUIContext.java
    trunk/idp-ui/src/test/java/net/shibboleth/idp/ui/context/RelyingPartyUIContextTest.java

Modified: trunk/idp-ui/src/main/java/net/shibboleth/idp/ui/context/RelyingPartyUIContext.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-ui/src/main/java/net/shibboleth/idp/ui/context/RelyingPartyUIContext.java?rev=6418&r1=6417&r2=6418&view=diff
==============================================================================
--- trunk/idp-ui/src/main/java/net/shibboleth/idp/ui/context/RelyingPartyUIContext.java (original)
+++ trunk/idp-ui/src/main/java/net/shibboleth/idp/ui/context/RelyingPartyUIContext.java Wed Aug 13 11:04:06 2014
@@ -32,6 +32,8 @@
 import org.opensaml.messaging.context.BaseContext;
 import org.opensaml.saml.ext.saml2mdui.Description;
 import org.opensaml.saml.ext.saml2mdui.DisplayName;
+import org.opensaml.saml.ext.saml2mdui.InformationURL;
+import org.opensaml.saml.ext.saml2mdui.PrivacyStatementURL;
 import org.opensaml.saml.ext.saml2mdui.UIInfo;
 import org.opensaml.saml.saml2.metadata.AttributeConsumingService;
 import org.opensaml.saml.saml2.metadata.ContactPerson;
@@ -554,7 +556,7 @@
      * @param defaultValue what to provide if the lookup fails
      * @return An appropriate string or the default
      */
-    @Nullable public String getSurName(@Nullable String contactType, @Nullable final String defaultValue) {
+    @Nullable public String getContactSurName(@Nullable String contactType, @Nullable final String defaultValue) {
 
         final ContactPerson contact = getContactPerson(getContactType(contactType));
         if (null == contact || null == contact.getSurName()) {
@@ -570,7 +572,7 @@
      * @param defaultValue what to provide if the lookup fails
      * @return An appropriate string or the default
      */
-    @Nullable public String getGivenName(@Nullable String contactType, @Nullable final String defaultValue) {
+    @Nullable public String getContactGivenName(@Nullable String contactType, @Nullable final String defaultValue) {
 
         final ContactPerson contact = getContactPerson(getContactType(contactType));
         if (null == contact || null == contact.getGivenName()) {
@@ -580,13 +582,13 @@
     }
 
     /**
-     * look for the <ContactPerson> and within that the GivenName.
+     * look for the <ContactPerson> and within that the Email.
      * 
      * @param contactType the type of contact to look for
      * @param defaultValue what to provide if the lookup fails
      * @return An appropriate string or the default
      */
-    @Nullable public String getEmail(@Nullable String contactType, @Nullable final String defaultValue) {
+    @Nullable public String getContactEmail(@Nullable String contactType, @Nullable final String defaultValue) {
 
         final ContactPerson contact = getContactPerson(getContactType(contactType));
         if (null == contact || null == contact.getEmailAddresses() || contact.getEmailAddresses().isEmpty()) {
@@ -595,4 +597,64 @@
         return policyURLNonLogo(contact.getEmailAddresses().get(0).getAddress(), defaultValue);
     }
 
+    /**
+     * Get the <mdui:InformationURL>.
+     * 
+     * @param defaultValue what to return if we cannot find it
+     * @return the value or the default value
+     */
+    public String getInformationURL(String defaultValue) {
+
+        if (null == getRPUInfo() || null == rpUIInfo.getInformationURLs() || rpUIInfo.getInformationURLs().isEmpty()) {
+            log.debug("No UIInfo or InformationURLs returning {}", defaultValue);
+            return defaultValue;
+        }
+        for (final String lang : getBrowserLanguages()) {
+            for (final InformationURL url : rpUIInfo.getInformationURLs()) {
+                if (url.getXMLLang() == null) {
+                    continue;
+                } else {
+                    log.trace("Found InformationURL, language={}", url.getXMLLang());
+                }
+
+                if (url.getXMLLang().equals(lang)) {
+                    log.debug("returning InformationURL, {}", url.getValue());
+                    return policyURLNonLogo(url.getValue(), defaultValue);
+                }
+            }
+        }
+        log.debug("No relevant InformationURL with language match, returning {}", defaultValue);
+        return defaultValue;
+    }
+
+    /**
+     * Get the <mdui:PrivacyStatementURL>.
+     * 
+     * @param defaultValue what to return if we cannot find it
+     * @return the value or the default value
+     */
+    public String getPrivacyStatementURL(String defaultValue) {
+        if (null == getRPUInfo() || null == rpUIInfo.getPrivacyStatementURLs()
+                || rpUIInfo.getPrivacyStatementURLs().isEmpty()) {

[... 195 lines stripped ...]


More information about the commits mailing list