[java-opensaml] branch main updated: JMETAGEN-5 - Metadata generation

Scott Cantor cantor.2 at osu.edu
Wed Jul 12 20:29:07 UTC 2023


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

scantor pushed a commit to branch main
in repository java-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=e645c74f54e1851356fa49bc9626e50c72ef60a6

The following commit(s) were added to refs/heads/main by this push:
     new e645c74f5 JMETAGEN-5 - Metadata generation
e645c74f5 is described below

commit e645c74f54e1851356fa49bc9626e50c72ef60a6
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jul 12 16:29:00 2023 -0400

    JMETAGEN-5 - Metadata generation
    
    https://shibboleth.atlassian.net/browse/JMETAGEN-5
    
    UIInfo and contact support plus some bug fixes.
    Make all interface methods defaulted for ease of use.
---
 .../impl/MetadataGeneratorParameters.java          | 97 +++++++++++++++++++---
 .../templates/metadata/EntityDescriptor.vm         | 40 +++++++++
 2 files changed, 125 insertions(+), 12 deletions(-)

diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/generator/impl/MetadataGeneratorParameters.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/generator/impl/MetadataGeneratorParameters.java
index bf25ea31a..50f131cc3 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/generator/impl/MetadataGeneratorParameters.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/generator/impl/MetadataGeneratorParameters.java
@@ -23,12 +23,16 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import org.opensaml.core.xml.Namespace;
+import org.opensaml.saml.ext.saml2mdui.Logo;
 import org.opensaml.saml.saml2.metadata.AttributeAuthorityDescriptor;
+import org.opensaml.saml.saml2.metadata.ContactPerson;
+import org.opensaml.saml.saml2.metadata.Extensions;
 import org.opensaml.saml.saml2.metadata.IDPSSODescriptor;
 import org.opensaml.saml.saml2.metadata.SPSSODescriptor;
 
 import net.shibboleth.shared.annotation.constraint.NotLive;
 import net.shibboleth.shared.annotation.constraint.Unmodifiable;
+import net.shibboleth.shared.collection.CollectionSupport;
 
 /**
  * Inputs to metadata generation.
@@ -44,21 +48,36 @@ public interface MetadataGeneratorParameters {
      * 
      * @return the unique ID
      */
-    @Nullable String getEntityID();
+    @Nullable default String getEntityID() {
+        return null;
+    }
 
     /**
      * Whether to omit the namespace declarations on the root element.
      * 
      * @return true iff namespace declarations should be omitted
      */
-    boolean isOmitNamespaceDeclarations();
+    default boolean isOmitNamespaceDeclarations() {
+        return false;
+    }
+    
+    /**
+     * Whether to include an {@link Extensions} element in output.
+     * 
+     * @return whether to include extensions element
+     */
+    default boolean isRequiresExtensions() {
+        return getDisplayName() != null || getDescription() != null || getLogo() != null;
+    }
     
     /**
      * Get a set of additional namespaces to declare on root element.
      * 
      * @return additional namespaces
      */
-    @Nullable Set<Namespace> getAdditionalNamespaces();
+    @Nullable default Set<Namespace> getAdditionalNamespaces() {
+        return null;
+    }
 
     /**
      * Get the SP role to generate.
@@ -67,7 +86,9 @@ public interface MetadataGeneratorParameters {
      * 
      * @return SP role or null
      */
-    @Nullable SPSSODescriptor getSPSSODescriptor();
+    @Nullable default SPSSODescriptor getSPSSODescriptor() {
+        return null;
+    }
     
     /**
      * Get the IdP role to generate.
@@ -76,7 +97,9 @@ public interface MetadataGeneratorParameters {
      *  
      * @return IdP role or null
      */
-    @Nullable IDPSSODescriptor getIDPSSODescriptor();
+    @Nullable default IDPSSODescriptor getIDPSSODescriptor() {
+        return null;
+    }
 
     /**
      * Get the AA role to generate.
@@ -85,7 +108,9 @@ public interface MetadataGeneratorParameters {
      *  
      * @return AA role or null
      */
-    @Nullable AttributeAuthorityDescriptor getAttributeAuthorityDescriptor();
+    @Nullable default AttributeAuthorityDescriptor getAttributeAuthorityDescriptor() {
+        return null;
+    }
 
     /**
      * Dual-use certificates.
@@ -94,7 +119,9 @@ public interface MetadataGeneratorParameters {
      * 
      * @return base64-encoded certificates
      */
-    @Nonnull @Unmodifiable @NotLive List<String> getCertificates();
+    @Nonnull @Unmodifiable @NotLive default List<String> getCertificates() {
+        return CollectionSupport.emptyList();
+    }
 
     /**
      * Signing-only certificate path(s).
@@ -103,7 +130,9 @@ public interface MetadataGeneratorParameters {
      * 
      * @return base64-encoded certificates
      */
-    @Nonnull @Unmodifiable @NotLive List<String> getSigningCertificates();
+    @Nonnull @Unmodifiable @NotLive default List<String> getSigningCertificates() {
+        return CollectionSupport.emptyList();
+    }
 
     /**
      * Encryption-only certificate path(s).
@@ -112,27 +141,71 @@ public interface MetadataGeneratorParameters {
      * 
      * @return base64-encoded certificates
      */
-    @Nonnull @Unmodifiable @NotLive List<String> getEncryptionCertificates();
+    @Nonnull @Unmodifiable @NotLive default List<String> getEncryptionCertificates() {
+        return CollectionSupport.emptyList();
+    }
     
     /**
      * Get the language tag for language-specific content.
      *
      * @return language tag
      */
-    @Nullable String getLang();
+    @Nullable default String getLang() {
+        return null;
+    }
+    
+    /**
+     * Get the display name.
+     * 
+     * @return display name
+     */
+    @Nullable default String getDisplayName() {
+        return null;
+    }
+
+    /**
+     * Get the description.
+     * 
+     * @return description
+     */
+    @Nullable default String getDescription() {
+        return null;
+    }
+
+    /**
+     * Get the logo.
+     * 
+     * @return logo
+     */
+    @Nullable default Logo getLogo() {
+        return null;
+    }
     
     /**
      * Get the organization name.
      *
      * @return organization name
      */
-    @Nullable String getOrganizationName();
+    @Nullable default String getOrganizationName() {
+        return null;
+    }
 
     /**
      * Get the organization URL.
      *
      * @return organization URL
      */
-    @Nullable String getOrganizationURL();
+    @Nullable default String getOrganizationURL() {
+        return null;
+    }
+    
+    /**
+     * Get the contacts.
+     * 
+     * @return list of contacts
+     */
+    @Nonnull @Unmodifiable @NotLive default List<ContactPerson> getContactPersons() {
+        return CollectionSupport.emptyList();
+    }
 
 }
\ No newline at end of file
diff --git a/opensaml-saml-impl/src/main/resources/templates/metadata/EntityDescriptor.vm b/opensaml-saml-impl/src/main/resources/templates/metadata/EntityDescriptor.vm
index 7b3b56b49..f9ba18271 100644
--- a/opensaml-saml-impl/src/main/resources/templates/metadata/EntityDescriptor.vm
+++ b/opensaml-saml-impl/src/main/resources/templates/metadata/EntityDescriptor.vm
@@ -1,5 +1,22 @@
 <md:EntityDescriptor#if (!$params.omitNamespaceDeclarations)#foreach ($ns in $namespaces.entrySet()) xmlns:$ns.key="$ns.value"#end#end entityID="$params.entityID">
+#if ($params.requiresExtensions)
 
+    <md:Extensions>
+#if ($params.displayName || $params.description || $params.logo)
+        <mdui:UIInfo>
+#if ($params.displayName)
+            <mdui:DisplayName>$params.displayName</mdui:DisplayName>
+#end
+#if ($params.description)
+            <mdui:Description>$params.description</mdui:Description>
+#end
+#if ($params.logo)
+            <mdui:Logo#if ($params.lang) xml:lang="$params.lang"#end#if ($params.logo.width) width="$params.logo.width"#end#if ($params.logo.height) height="$params.logo.height"#end>$params.logo.URI</mdui:Logo>
+#end
+#end
+        </mdui:UIInfo>
+    </md:Extensions>
+#end
 #if ($params.IDPSSODescriptor)
 #parse("$params.templatePath/IDPSSODescriptor.vm")
 
@@ -14,9 +31,32 @@
 #end
 #if ($params.organizationName || $params.organizationURL)
     <md:Organization>
+#if ($params.organizationName)
         <md:OrganizationName#if ($params.lang) xml:lang="$params.lang"#end>$params.organizationName</md:OrganizationName>
         <md:OrganizationDisplayName#if ($params.lang) xml:lang="$params.lang"#end>$params.organizationName</md:OrganizationDisplayName>
+#end
+#if ($params.organizationURL)
         <md:OrganizationURL#if ($params.lang) xml:lang="$params.lang"#end>$params.organizationURL</md:OrganizationURL>
+#end
     </md:Organization>
 #end
+#foreach ($contact in $params.contactPersons)
+    <md:ContactPerson contactType="$contact.type">
+#if ($contact.company)
+        <md:Company>$contact.company.value</md:Company>
+#end
+#if ($contact.givenName)
+        <md:GivenName>$contact.givenName.value</md:GivenName>
+#end
+#if ($contact.surName)
+        <md:SurName>$contact.surName.value</md:SurName>
+#end
+#foreach ($mail in $contact.emailAddresses)
+        <md:EmailAddress>$mail.URI</md:EmailAddress>
+#end
+#foreach ($phone in $contact.telephoneNumbers)
+        <md:TelephoneNumber>$phone.value</md:TelephoneNumber>
+#end
+    </md:ContactPerson>
+#end
 </md:EntityDescriptor>

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


More information about the commits mailing list