[java-identity-provider] branch main updated: IDP-2190 - Include unfiltered attributes in resolvertest flow

Scott Cantor cantor.2 at osu.edu
Tue Nov 28 21:54:11 UTC 2023


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

scantor 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=d14a2c8cdff5f3236c9c08b06617fe310eb37151

The following commit(s) were added to refs/heads/main by this push:
     new d14a2c8cd IDP-2190 - Include unfiltered attributes in resolvertest flow
d14a2c8cd is described below

commit d14a2c8cdff5f3236c9c08b06617fe310eb37151
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Nov 28 16:54:08 2023 -0500

    IDP-2190 - Include unfiltered attributes in resolvertest flow
    
    https://shibboleth.atlassian.net/browse/IDP-2190
    
    Added "unfiltered" parameter.
---
 .../shibboleth/idp/cli/ResolverTestArguments.java  | 21 ++++++++++++++++++++
 .../idp/flows/admin/resolvertest-flow.xml          |  1 +
 .../net/shibboleth/idp/views/admin/resolvertest.vm | 11 ++++++++---
 .../idp/profile/impl/ResolverTestRequest.java      | 19 +++++++++++++++++-
 .../profile/impl/ResolverTestRequestDecoder.java   | 23 ++++++++++++++++++++--
 5 files changed, 69 insertions(+), 6 deletions(-)

diff --git a/idp-cli/src/main/java/net/shibboleth/idp/cli/ResolverTestArguments.java b/idp-cli/src/main/java/net/shibboleth/idp/cli/ResolverTestArguments.java
index d42a28a39..01ae4ab9d 100644
--- a/idp-cli/src/main/java/net/shibboleth/idp/cli/ResolverTestArguments.java
+++ b/idp-cli/src/main/java/net/shibboleth/idp/cli/ResolverTestArguments.java
@@ -49,6 +49,14 @@ public class ResolverTestArguments extends AbstractCommandLineArguments {
     @Parameter(names = {"--saml2"}, description = "Show results with SAML 2.0 encoding")
     private boolean saml2;
 
+    /**
+     * Show unfiltered results.
+     * 
+     * @since 5.1.0
+     */
+    @Parameter(names = {"--unfiltered"}, description = "Show unfiltered results")
+    private boolean unfiltered;
+
     /*
      * Below are legacy options from the 2.x AACLI tool that are no longer supported.
      */
@@ -70,23 +78,34 @@ public class ResolverTestArguments extends AbstractCommandLineArguments {
     @Nullable private String dummy4;
 
     
+// Checkstyle: CyclomaticComplexity OFF
     /** {@inheritDoc} */
     @Override
     public void validate() {
         if (saml1) {
             if (saml2 || protocol != null) {
                 throw new IllegalArgumentException("The saml1, saml2, and protocol options are mutually exclusive");
+            } else if (unfiltered) {
+                throw new IllegalArgumentException(
+                        "The unfiltered option is mutually exclusive with the protocol options");
             }
         } else if (saml2) {
             if (saml1 || protocol != null) {
                 throw new IllegalArgumentException("The saml1, saml2, and protocol options are mutually exclusive");
+            } else if (unfiltered) {
+                throw new IllegalArgumentException(
+                        "The unfiltered option is mutually exclusive with the protocol options");
             }
         } else if (protocol != null) {
             if (saml1 || saml2) {
                 throw new IllegalArgumentException("The saml1, saml2, and protocol options are mutually exclusive");
+            } else if (unfiltered) {
+                throw new IllegalArgumentException(
+                        "The unfiltered option is mutually exclusive with the protocol options");
             }
         }
     }
+// Checkstyle: CyclomaticComplexity ON
 
     /** {@inheritDoc} */
     @Override
@@ -115,6 +134,8 @@ public class ResolverTestArguments extends AbstractCommandLineArguments {
                 builder.append("&saml2");
             } else if (protocol != null) {
                 builder.append("&protocol=").append(URLEncoder.encode(protocol, "UTF-8"));
+            } else if (unfiltered) {
+                builder.append("&unfiltered");
             }
         } catch (final UnsupportedEncodingException e) {
             // UTF-8 is a required encoding. 
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/admin/resolvertest-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/admin/resolvertest-flow.xml
index f241a59dc..b1d053b0b 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/admin/resolvertest-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/admin/resolvertest-flow.xml
@@ -100,6 +100,7 @@
             <evaluate expression="environment" result="requestScope.environment" />
             <evaluate expression="opensamlProfileRequestContext" result="requestScope.profileRequestContext" />
             <evaluate expression="opensamlProfileRequestContext.ensureSubcontext(T(net.shibboleth.profile.context.RelyingPartyContext)).getSubcontext(T(net.shibboleth.idp.attribute.context.AttributeContext))" result="requestScope.attributeContext" />
+            <evaluate expression="opensamlProfileRequestContext.ensureInboundMessageContext().ensureMessage().getUnfiltered()" result="requestScope.includeUnfilteredAttributes" />
             <evaluate expression="T(org.opensaml.core.xml.util.XMLObjectSupport)" result="requestScope.XMLObjectSupport" />
             <evaluate expression="T(net.shibboleth.shared.xml.SerializeSupport)" result="requestScope.SerializeSupport" />
             <evaluate expression="T(net.shibboleth.shared.codec.HTMLEncoder)" result="requestScope.encoder" />
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/views/admin/resolvertest.vm b/idp-conf-impl/src/main/resources/net/shibboleth/idp/views/admin/resolvertest.vm
index 9a28d13cf..3af141d08 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/views/admin/resolvertest.vm
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/views/admin/resolvertest.vm
@@ -7,6 +7,7 @@
 ## response - HttpServletResponse
 ## profileRequestContext
 ## attributeContext
+## includeUnfilteredAttributes
 ## XMLObjectSupport
 ## SerializeSupport
 ## environment - Spring Environment object for property resolution
@@ -21,14 +22,18 @@
 $SerializeSupport.prettyPrintXML($XMLObjectSupport.marshall($profileRequestContext.getOutboundMessageContext().getMessage()))
     $response.setContentType("text/xml")
     #stop
-#end 
-
+#end
+#if ($includeUnfilteredAttributes)
+    #set ($attrs = $attributeContext.getUnfilteredIdPAttributes())
+#else
+    #set ($attrs = $attributeContext.getIdPAttributes())
+#end
 {
 "requester": "$profileRequestContext.getInboundMessageContext().getMessage().getRequesterId()",
 "principal": "$profileRequestContext.getInboundMessageContext().getMessage().getPrincipal()",
 "attributes": [
 
-#foreach ($attribute in $attributeContext.getIdPAttributes())
+#foreach ($attribute in $attrs)
 
   {
     "name": "$attribute.getId()",
diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolverTestRequest.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolverTestRequest.java
index 48485d935..21faa7fc4 100644
--- a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolverTestRequest.java
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolverTestRequest.java
@@ -44,6 +44,9 @@ public class ResolverTestRequest {
     
     /** Protocol identifier to simulate a response for. */
     @Nullable private final String protocol;
+    
+    /** Unfiltered flag. */
+    @Nullable private final Boolean unfiltered;
 
     /**
      * Constructor.
@@ -52,15 +55,17 @@ public class ResolverTestRequest {
      * @param requester ID of requester
      * @param index <code><AttributeConsumingService></code> index
      * @param prot protocol ID
+     * @param unfilteredFlag unfiltered flag
      */
     public ResolverTestRequest(@Nonnull @NotEmpty final String princ, @Nonnull @NotEmpty final String requester,
-            @Nullable final Integer index, @Nullable final String prot) {
+            @Nullable final Integer index, @Nullable final String prot, @Nullable final Boolean unfilteredFlag) {
         
         principal = Constraint.isNotNull(StringSupport.trimOrNull(princ), "Principal name cannot be null or empty");
         requesterId = Constraint.isNotNull(StringSupport.trimOrNull(requester),
                 "Requester name cannot be null or empty");
         acsIndex = index;
         protocol = StringSupport.trimOrNull(prot);
+        unfiltered = unfilteredFlag;
     }
 
     /**
@@ -98,6 +103,17 @@ public class ResolverTestRequest {
     @Nullable public String getProtocol() {
         return protocol;
     }
+    
+    /**
+     * Get whether to dump unfiltered attributes in protocol-neutral output.
+     * 
+     * @return whether to dump unfiltered attributes
+     * 
+     * @since 5.1.0
+     */
+    @Nullable public Boolean getUnfiltered() {
+        return unfiltered;
+    }
 
     /** {@inheritDoc} */
     @Override
@@ -107,6 +123,7 @@ public class ResolverTestRequest {
             .add("requesterId", requesterId)
             .add("acsIndex", acsIndex)
             .add("protocol", protocol)
+            .add("unfiltered", unfiltered)
             .toString();
     }
     
diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolverTestRequestDecoder.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolverTestRequestDecoder.java
index 80b8acd26..9c1fbea94 100644
--- a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolverTestRequestDecoder.java
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ResolverTestRequestDecoder.java
@@ -52,9 +52,15 @@ public class ResolverTestRequestDecoder extends AbstractHttpServletRequestMessag
     /** Name of the query parameter for the SAML 2 protocol: {@value} . */
     @Nonnull @NotEmpty public static final String SAML2_PARAM = "saml2";
 
+    /**
+     * Name of the query parameter for the unfiltered option: {@value} .
+     * 
+     * @since 5.1.0
+     */
+    @Nonnull @NotEmpty public static final String UNFILTERED_PARAM = "unfiltered";
+
     /** Constructor. */
     public ResolverTestRequestDecoder() {
-        super();
         setProtocolMessageLoggerSubCategory("ADMIN");
     }
 
@@ -67,7 +73,7 @@ public class ResolverTestRequestDecoder extends AbstractHttpServletRequestMessag
         }
         
         final ResolverTestRequest message = new ResolverTestRequest(getPrincipal(request), getRequesterId(request),
-                getIndex(request), getProtocol(request));
+                getIndex(request), getProtocol(request), getUnfiltered(request));
         final MessageContext messageContext = new MessageContext();
         messageContext.setMessage(message);
         setMessageContext(messageContext);
@@ -156,5 +162,18 @@ public class ResolverTestRequestDecoder extends AbstractHttpServletRequestMessag
         
         return null;
     }
+    
+    /**
+     * Get the unfiltered flag.
+     * 
+     * @param request current HTTP request
+     * 
+     * @return the unfiltered flag, or null
+     * 
+     * @since 5.1.0
+     */
+    @Nullable protected Boolean getUnfiltered(@Nonnull final HttpServletRequest request) {
+        return request.getParameter(UNFILTERED_PARAM) != null;
+    }
 
 }
\ No newline at end of file

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


More information about the commits mailing list