[java-plugin-shibd] branch main updated: JSHIBD-14 - Implement agent-level issuer and authority properties

Scott Cantor cantor.2 at osu.edu
Mon Aug 18 15:08:11 UTC 2025


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

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

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

The following commit(s) were added to refs/heads/main by this push:
     new e3a1427  JSHIBD-14 - Implement agent-level issuer and authority properties
e3a1427 is described below

commit e3a14270dde29c5b1d34fbc8d360a9eb6af34d85
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Aug 18 11:07:50 2025 -0400

    JSHIBD-14 - Implement agent-level issuer and authority properties
    
    https://shibboleth.atlassian.net/browse/JSHIBD-14
    
    Refactor Agent/Application classes for inheritance of settings.
---
 .../net/shibboleth/sp/conf/agents-system.xml       |  14 +-
 .../java/net/shibboleth/sp/impl/BasicAgent.java    |   7 +-
 .../net/shibboleth/sp/impl/BasicApplication.java   | 528 +++++++++++++++------
 3 files changed, 394 insertions(+), 155 deletions(-)

diff --git a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/agents-system.xml b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/agents-system.xml
index 2425f94..9a35bfe 100644
--- a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/agents-system.xml
+++ b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/agents-system.xml
@@ -24,29 +24,33 @@
         <constructor-arg type="java.lang.String" value="%{sp.authn.allowedAddressRanges:127.0.0.1/32,::1/128}" />
     </bean>
 
-    <bean id="shibboleth.sp.Agent" parent="shibboleth.sp.Application" abstract="true" 
-        class="net.shibboleth.sp.impl.BasicAgent"
+    <bean id="shibboleth.sp.Agent" parent="shibboleth.sp.Application.NoInheritance"
+        class="net.shibboleth.sp.impl.BasicAgent" abstract="true"
         p:authenticationMethod="%{sp.agent.authn.method:}"
         p:allowedAddressRanges-ref="DefaultAllowedAddressRanges"
         p:supportsCachedAuthentication="%{sp.agent.authn.cached:true}" />
 
-    <bean id="shibboleth.sp.Application" class="net.shibboleth.sp.impl.BasicApplication" abstract="true"
-        p:issuer="#{'%{sp.issuer:}'.trim()}"
+    <bean id="shibboleth.sp.Application.NoInheritance" class="net.shibboleth.sp.impl.BasicApplication" abstract="true"
+        p:allowInheritance="false"
+        p:metricName="net.shibboleth.sp.relyingparty.configurations"
         p:authenticatingAuthority="%{sp.defaultAuthority:}"
         p:metadataResolver-ref="shibboleth.MetadataResolverService"
         p:attributeTranscoderRegistry-ref="shibboleth.AttributeRegistryService"
         p:attributeResolver-ref="shibboleth.AttributeResolverService"
         p:attributeFilter-ref="shibboleth.AttributeFilterService"
+        p:issuer="#{'%{sp.issuer:}'.trim()}"
         p:detailedErrorsPredicate="%{sp.errors.detailed:false}"
         p:securityConfiguration-ref="#{'%{sp.security.config:shibboleth.sp.DefaultSecurityConfiguration}'.trim()}"
         p:profileConfigurations-ref="shibboleth.sp.DefaultProfileConfigurations"
         p:unverifiedConfiguration-ref="shibboleth.sp.UnverifiedRelyingParty"
         p:relyingPartyConfigurations-ref="shibboleth.sp.RelyingPartyOverrides"
-        p:metricName="net.shibboleth.sp.relyingparty.configurations"
         p:sessionInitiators-ref="shibboleth.sp.SessionInitiators"
         p:tokenConsumers-ref="shibboleth.sp.TokenConsumers"
         p:stateTokenManager-ref="#{'%{sp.stateToken.Manager:shibboleth.sp.StorageStateTokenManager}'.trim()}" />
 
+    <bean id="shibboleth.sp.Application" class="net.shibboleth.sp.impl.BasicApplication" abstract="true"
+        p:metricName="net.shibboleth.sp.relyingparty.configurations" />
+
     <bean id="shibboleth.sp.SessionInitiators" parent="shibboleth.CommaDelimStringArray"
         c:_0="%{sp.application.sessionInitiators:}" />
 
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/impl/BasicAgent.java b/sp-server-impl/src/main/java/net/shibboleth/sp/impl/BasicAgent.java
index f7a23c2..efa9dae 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/impl/BasicAgent.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/impl/BasicAgent.java
@@ -68,6 +68,8 @@ public class BasicAgent extends BasicApplication implements Agent {
         authenticationMethod  = null;
         sharedSecrets = CollectionSupport.emptySet();
         applicationMap = CollectionSupport.emptyMap();
+        
+        setAllowInheritance(false);
     }
     
     /** {@inheritDoc} */
@@ -199,13 +201,10 @@ public class BasicAgent extends BasicApplication implements Agent {
     protected void doInitialize() throws ComponentInitializationException {
         super.doInitialize();
         
-        // Handle ourselves.
-        setAgent(this);
-
         // Install us into each child Application.
         for (final Application a : applicationMap.values()) {
             if (a instanceof BasicApplication app) {
-                app.setAgent(this);
+                app.setParent(this);
             }
         }
     }
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/impl/BasicApplication.java b/sp-server-impl/src/main/java/net/shibboleth/sp/impl/BasicApplication.java
index 846bb54..523c49c 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/impl/BasicApplication.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/impl/BasicApplication.java
@@ -20,7 +20,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.function.Function;
-import java.util.function.Predicate;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -28,6 +27,9 @@ import javax.annotation.Nullable;
 import org.opensaml.profile.context.ProfileRequestContext;
 import org.opensaml.saml.metadata.resolver.MetadataResolver;
 import org.opensaml.security.config.SecurityConfiguration;
+import org.opensaml.security.credential.Credential;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 
 import com.codahale.metrics.MetricRegistry;
 import com.google.common.base.MoreObjects;
@@ -37,26 +39,38 @@ import net.shibboleth.idp.attribute.resolver.AttributeResolver;
 import net.shibboleth.idp.attribute.transcoding.AttributeTranscoderRegistry;
 import net.shibboleth.profile.config.ProfileConfiguration;
 import net.shibboleth.profile.relyingparty.BasicRelyingPartyConfiguration;
+import net.shibboleth.profile.relyingparty.RelyingPartyConfiguration;
+import net.shibboleth.profile.relyingparty.VerifiedProfileCriterion;
 import net.shibboleth.profile.relyingparty.impl.DefaultRelyingPartyConfigurationResolver;
 import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
 import net.shibboleth.shared.annotation.constraint.NotEmpty;
 import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.component.ComponentInitializationException;
 import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.logic.ConstraintViolationException;
 import net.shibboleth.shared.logic.FunctionSupport;
 import net.shibboleth.shared.primitive.StringSupport;
+import net.shibboleth.shared.resolver.CriteriaSet;
+import net.shibboleth.shared.resolver.ResolverException;
 import net.shibboleth.shared.service.ReloadableService;
 import net.shibboleth.sp.Agent;
 import net.shibboleth.sp.Application;
 import net.shibboleth.sp.profile.StateTokenManager;
+import net.shibboleth.spring.security.CredentialHolder;
 
 /**
  * Basic implementation of an {@link Application}.
  */
-public class BasicApplication extends DefaultRelyingPartyConfigurationResolver implements Application {
+public class BasicApplication extends BasicRelyingPartyConfiguration implements Application {
 
+    /** Link to parent {@link Application}. */
+    @Nullable private Application parent;
+    
+    /** Whether inheritable settings should inherit from the parent. */
+    private boolean allowInheritance;
+    
     /** Our self-managed "defaults". */
-    @Nonnull private BasicRelyingPartyConfiguration defaultRelyingPartyConfiguration;
+    @NonnullAfterInit private ApplicationAwareRelyingPartyResolver relyingPartyResolver;
     
     /** Lookup strategy for authenticating authority. */
     @Nonnull private Function<ProfileRequestContext,String> authenticatingAuthorityLookupStrategy;
@@ -67,27 +81,27 @@ public class BasicApplication extends DefaultRelyingPartyConfigurationResolver i
     /** Token consumer list lookup strategy. */
     @Nonnull private Function<ProfileRequestContext,List<String>> tokenConsumerLookupStrategy;
 
-    /** Link to parent {@link Agent}. */
-    @Nullable private Agent agent;
-        
     /** State token management. */
-    @NonnullAfterInit private StateTokenManager stateTokenManager;
+    @Nullable private StateTokenManager stateTokenManager;
     
     /** Metadata source. */
-    @NonnullAfterInit private ReloadableService<MetadataResolver> metadataResolver;
+    @Nullable private ReloadableService<MetadataResolver> metadataResolver;
     
     /** Transcoding registry. */
-    @NonnullAfterInit private ReloadableService<AttributeTranscoderRegistry> transcodingRegistry;
+    @Nullable private ReloadableService<AttributeTranscoderRegistry> transcodingRegistry;
     
     /** Attribute resolver. */
-    @NonnullAfterInit private ReloadableService<AttributeResolver> attributeResolver;
+    @Nullable private ReloadableService<AttributeResolver> attributeResolver;
     
     /** Attribute filter. */
-    @NonnullAfterInit private ReloadableService<AttributeFilter> attributeFilter;
+    @Nullable private ReloadableService<AttributeFilter> attributeFilter;
     
     /** Constructor. */
     public BasicApplication() {
-        defaultRelyingPartyConfiguration = new BasicRelyingPartyConfiguration();
+        allowInheritance = true;
+        
+        relyingPartyResolver = new ApplicationAwareRelyingPartyResolver();
+        relyingPartyResolver.setDefaultConfiguration(this);
         
         authenticatingAuthorityLookupStrategy = FunctionSupport.constant(null);
         sessionInitiatorLookupStrategy = FunctionSupport.constant(CollectionSupport.emptyList());
@@ -98,151 +112,61 @@ public class BasicApplication extends DefaultRelyingPartyConfigurationResolver i
     @SuppressWarnings("null")
     @Override
     @Nonnull @NotEmpty public String getApplicationId() {
-        checkComponentActive();
         return getId();
     }
     
-    /** {@inheritDoc} */
-    @Override
-    @Nullable public String getMetricName() {
-        
-        final String base = super.getMetricName();
-        if (base != null) {
-            if (agent != null) {
-                return MetricRegistry.name(base, agent.getId(), getApplicationId());
-            } else {
-                // Just in case, but should not happen in practice.
-                return MetricRegistry.name(base, getApplicationId());
-            }
-        }
-        
-        return null;
-    }
-    
     /**
-     * Gets the parent {@link Agent}.
+     * Gets whether to inherit some settings from parent if one exists.
      * 
-     * @return app parent {@link Agent} or null
+     * @return true iff settings that can be inherited from parent should be
      */
-    @Nullable public Agent getAgent() {
-        return agent;
+    public boolean isAllowInheritance() {
+        return allowInheritance;
     }
     
     /**
-     * Sets the parent {@link Agent}.
+     * Sets whether to inherit some settings from parent if one exists.
      * 
-     * @param theAgent parent {@link Agent} or null
-     */
-    public void setAgent(@Nullable final Agent theAgent) {
-        checkSetterPreconditions();
-        
-        agent = theAgent;
-    }
-    
-    /**
-     * Set default issuer value to use for this application.
-     * 
-     * @param issuer issuer value
-     */
-    public void setIssuer(@Nullable @NotEmpty final String issuer) {
-        checkSetterPreconditions();
-        
-        defaultRelyingPartyConfiguration.setIssuer(issuer);
-    }
-
-    /**
-     * Set default issuer lookup strategy to use for this application.
+     * <p>Defaults to true.</p>
      * 
-     * @param strategy lookup strategy
+     * @param flag flag to set
      */
-    public void setIssuerLookupStrategy(@Nonnull final Function<ProfileRequestContext,String> strategy) {
+    public void setAllowInheritance(final boolean flag) {
         checkSetterPreconditions();
         
-        defaultRelyingPartyConfiguration.setIssuerLookupStrategy(strategy);
-    }
-
-    /**
-     * Set whether detailed information about errors should be exposed.
-     * 
-     * @param flag  flag to set
-     */
-    public void setDetailedErrors(final boolean flag) {
-        checkSetterPreconditions();
-        
-        defaultRelyingPartyConfiguration.setDetailedErrors(flag);
-    }
-
-    /**
-     * Set a condition to determine whether detailed information about errors should be exposed.
-     * 
-     * @param condition  condition to set
-     */
-    public void setDetailedErrorsPredicate(@Nonnull final Predicate<ProfileRequestContext> condition) {
-        checkSetterPreconditions();
-        
-        defaultRelyingPartyConfiguration.setDetailedErrorsPredicate(condition);
+        allowInheritance = flag;
     }
     
     /**
-     * Sets the security configuration for this profile.
-     * 
-     * @param configuration security configuration for this profile
-     */
-    public void setSecurityConfiguration(@Nullable final SecurityConfiguration configuration) {
-        checkSetterPreconditions();
-        
-        defaultRelyingPartyConfiguration.setSecurityConfiguration(configuration);
-    }
-
-    /**
-     * Set a lookup strategy for the security configuration.
-     *
-     * @param strategy  lookup strategy
-     */
-    public void setSecurityConfigurationLookupStrategy(
-            @Nonnull final Function<ProfileRequestContext,SecurityConfiguration> strategy) {
-        checkSetterPreconditions();
-        
-        defaultRelyingPartyConfiguration.setSecurityConfigurationLookupStrategy(strategy);
-    }
-
-    /**
-     * Set the profile configurations for this relying party.
+     * Gets the parent {@link Application} for inheritance-purposes.
      * 
-     * @param configs the configurations to set
+     * @return app parent {@link Application} or null
      */
-    public void setProfileConfigurations(@Nullable final Collection<ProfileConfiguration> configs) {
-        checkSetterPreconditions();
-        
-        defaultRelyingPartyConfiguration.setProfileConfigurations(configs);
+    @Nullable public Application getParent() {
+        return parent;
     }
-
-    /**
-     * Set a lookup strategy for the <code>profileConfigurations</code> property.
-     * 
-     * @param strategy lookup strategy
-     */
-    public void setProfileConfigurationsLookupStrategy(
-            @Nonnull final Function<ProfileRequestContext,Map<String,ProfileConfiguration>> strategy) {
-        checkSetterPreconditions();
-        
-        defaultRelyingPartyConfiguration.setProfileConfigurationsLookupStrategy(strategy);
-    }
-
+    
     /**
-     * Set the condition under which the relying party configuration should be active.
+     * Sets the parent {@link Application} for inheritance-purposes.
      * 
-     * @param condition the activation condition
+     * @param app parent {@link Application} or null
      */
-    public void setActivationCondition(@Nonnull final Predicate<ProfileRequestContext> condition) {
-        checkSetterPreconditions();
-        
-        defaultRelyingPartyConfiguration.setActivationCondition(condition);
+    public void setParent(@Nullable final Application app) {
+        parent = app;
     }
     
     /** {@inheritDoc} */
     @Nullable @NotEmpty public String getAuthenticatingAuthority(@Nullable ProfileRequestContext profileRequestContext) {
-        return authenticatingAuthorityLookupStrategy.apply(profileRequestContext);
+        final String ret = authenticatingAuthorityLookupStrategy.apply(profileRequestContext);
+        if (ret != null) {
+            return ret;
+        }
+        
+        if (parent != null && allowInheritance) {
+            return parent.getAuthenticatingAuthority(profileRequestContext);
+        }
+        
+        return null;
     }
     
     /**
@@ -274,7 +198,15 @@ public class BasicApplication extends DefaultRelyingPartyConfigurationResolver i
     /** {@inheritDoc} */
     @Nonnull public List<String> getSessionInitiators(@Nullable final ProfileRequestContext profileRequestContext) {
         final List<String> ret = sessionInitiatorLookupStrategy.apply(profileRequestContext);
-        return ret != null ? ret : CollectionSupport.emptyList(); 
+        if (ret != null && !ret.isEmpty()) {
+            return ret;
+        }
+        
+        if (parent != null && allowInheritance) {
+            return parent.getSessionInitiators(profileRequestContext);
+        }
+        
+        return CollectionSupport.emptyList(); 
     }
     
     /**
@@ -311,7 +243,15 @@ public class BasicApplication extends DefaultRelyingPartyConfigurationResolver i
     /** {@inheritDoc} */
     @Nonnull public List<String> getTokenConsumers(@Nullable final ProfileRequestContext profileRequestContext) {
         final List<String> ret = tokenConsumerLookupStrategy.apply(profileRequestContext);
-        return ret != null ? ret : CollectionSupport.emptyList(); 
+        if (ret != null && !ret.isEmpty()) {
+            return ret;
+        }
+
+        if (parent != null && allowInheritance) {
+            return parent.getTokenConsumers(profileRequestContext);
+        }
+        
+        return CollectionSupport.emptyList(); 
     }
     
     /**
@@ -345,8 +285,15 @@ public class BasicApplication extends DefaultRelyingPartyConfigurationResolver i
     /** {@inheritDoc} */
     @Nonnull public StateTokenManager getStateTokenManager() {
         checkComponentActive();
-        assert stateTokenManager != null;
-        return stateTokenManager;
+        if (stateTokenManager != null) {
+            return stateTokenManager;
+        }
+        
+        if (parent != null && allowInheritance) {
+            return parent.getStateTokenManager();
+        }
+        
+        throw new ConstraintViolationException("StateTokenManager cannot be null");
     }
     
     /**
@@ -363,8 +310,15 @@ public class BasicApplication extends DefaultRelyingPartyConfigurationResolver i
     /** {@inheritDoc} */
     @Nonnull public ReloadableService<MetadataResolver> getMetadataResolver() {
         checkComponentActive();
-        assert metadataResolver != null;
-        return metadataResolver;
+        if (metadataResolver != null) {
+            return metadataResolver;
+        }
+        
+        if (parent != null && allowInheritance) {
+            return parent.getMetadataResolver();
+        }
+        
+        throw new ConstraintViolationException("MetadataResolver cannot be null");
     }
     
     /**
@@ -381,8 +335,15 @@ public class BasicApplication extends DefaultRelyingPartyConfigurationResolver i
     /** {@inheritDoc} */
     @Nonnull public ReloadableService<AttributeTranscoderRegistry> getAttributeTranscoderRegistry() {
         checkComponentActive();
-        assert transcodingRegistry != null;
-        return transcodingRegistry;
+        if (transcodingRegistry != null) {
+            return transcodingRegistry;
+        }
+        
+        if (parent != null && allowInheritance) {
+            return parent.getAttributeTranscoderRegistry();
+        }
+        
+        throw new ConstraintViolationException("AttributeTranscoderRegistry cannot be null");
     }
     
     /**
@@ -399,8 +360,15 @@ public class BasicApplication extends DefaultRelyingPartyConfigurationResolver i
     /** {@inheritDoc} */
     @Nonnull public ReloadableService<AttributeResolver> getAttributeResolver() {
         checkComponentActive();
-        assert attributeResolver != null;
-        return attributeResolver;
+        if (attributeResolver != null) {
+            return attributeResolver;
+        }
+        
+        if (parent != null && allowInheritance) {
+            return parent.getAttributeResolver();
+        }
+        
+        throw new ConstraintViolationException("AttributeResolver cannot be null");
     }
 
     /**
@@ -417,8 +385,15 @@ public class BasicApplication extends DefaultRelyingPartyConfigurationResolver i
     /** {@inheritDoc} */
     @Nonnull public ReloadableService<AttributeFilter> getAttributeFilter() {
         checkComponentActive();
-        assert attributeFilter != null;
-        return attributeFilter;
+        if (attributeFilter != null) {
+            return attributeFilter;
+        }
+        
+        if (parent != null && allowInheritance) {
+            return parent.getAttributeFilter();
+        }
+        
+        throw new ConstraintViolationException("AttributeFilter cannot be null");
     }
 
     /**
@@ -432,16 +407,89 @@ public class BasicApplication extends DefaultRelyingPartyConfigurationResolver i
         attributeFilter = Constraint.isNotNull(service, "AttributeFilter service cannot be null");
     }
 
+    // Override RelyingPartyConfiguration getters for inheritance purposes.
+    
+    /** {@inheritDoc} */
+    @Override
+    @Nullable public String getIssuer(@Nullable ProfileRequestContext profileRequestContext) {
+        
+        final String ret = super.getIssuer(profileRequestContext);
+        if (ret != null) {
+            return ret;
+        }
+        
+        if (allowInheritance && parent instanceof BasicApplication basic) {
+            return basic.getIssuer(profileRequestContext);
+        }
+        
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    @Nullable public SecurityConfiguration getSecurityConfiguration(
+            
+            @Nullable ProfileRequestContext profileRequestContext) {
+        final var ret = super.getSecurityConfiguration(profileRequestContext);
+        if (ret != null) {
+            return ret;
+        }
+
+        if (allowInheritance && parent instanceof BasicApplication basic) {
+            return basic.getSecurityConfiguration(profileRequestContext);
+        }
+        
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    @Nonnull public Map<String, ProfileConfiguration> getProfileConfigurations(
+            @Nullable ProfileRequestContext profileRequestContext) {
+        
+        final var ret = super.getProfileConfigurations(profileRequestContext);
+        if (!ret.isEmpty()) {
+            return ret;
+        }
+        
+        if (allowInheritance && parent instanceof BasicApplication basic) {
+            return basic.getProfileConfigurations(profileRequestContext);
+        }
+        
+        return CollectionSupport.emptyMap();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    @Nullable public ProfileConfiguration getProfileConfiguration(@Nullable ProfileRequestContext profileRequestContext,
+            @Nullable String profileId) {
+        
+        final var ret = super.getProfileConfiguration(profileRequestContext, profileId);
+        if (ret != null) {
+            return ret;
+        }
+
+        if (allowInheritance && parent instanceof BasicApplication basic) {
+            return basic.getProfileConfiguration(profileRequestContext, profileId);
+        }
+        
+        return null;
+    }
+
     /** {@inheritDoc} */
     @Override
     protected void doInitialize() throws ComponentInitializationException {
-        // Init our default config and inject into parent class.
-        defaultRelyingPartyConfiguration.setId(getApplicationId());
-        defaultRelyingPartyConfiguration.initialize();
-        setDefaultConfiguration(defaultRelyingPartyConfiguration);
+        
+        relyingPartyResolver.setId(getApplicationId());
+        relyingPartyResolver.initialize();
         
         super.doInitialize();
         
+        if (allowInheritance) {
+            // Bypass component checking on the assumption the parent will handle it.
+            return;
+        }
+        
         if (stateTokenManager == null) {
             throw new ComponentInitializationException("StateTokenManager cannot be null");
         } else if (metadataResolver == null) {
@@ -474,4 +522,192 @@ public class BasicApplication extends DefaultRelyingPartyConfigurationResolver i
                 .add("id", getId()).toString();
     }
     
+    /**
+     * Subclass of default resolver that allows us to hook the configuration object getter methods to allow them to be
+     * inheritance-aware.
+     */
+    private class ApplicationAwareRelyingPartyResolver extends DefaultRelyingPartyConfigurationResolver {
+
+        /** {@inheritDoc} */
+        @Override
+        @Nullable public String getMetricName() {
+            
+            final String base = super.getMetricName();
+            if (base != null) {
+                if (BasicApplication.this instanceof Agent) {
+                    // Should be true for default Application.
+                    return MetricRegistry.name(base, getId(), getApplicationId());
+                } else if (parent instanceof Agent agent) {
+                    // Should be true for any child Application.
+                    return MetricRegistry.name(base, agent.getId(), getApplicationId());
+                } else {
+                    // Just in case, but should not happen.
+                    return MetricRegistry.name(base, getApplicationId());
+                }
+            }
+            
+            return null;
+        }
+        
+        /** {@inheritDoc} */
+        @Override
+        @Nonnull public Collection<? extends RelyingPartyConfiguration> getRelyingPartyConfigurations() {
+            final var ret = super.getRelyingPartyConfigurations();
+            if (ret != null && !ret.isEmpty()) {
+                return ret;
+            }
+            
+            if (allowInheritance && parent instanceof BasicApplication basic) {
+                return basic.relyingPartyResolver.getRelyingPartyConfigurations();
+            }
+            
+            return CollectionSupport.emptyList();
+        }
+
+        /** {@inheritDoc} */
+        @Override
+        @Nullable public RelyingPartyConfiguration getDefaultConfiguration() {
+            return BasicApplication.this;
+        }
+
+        /** {@inheritDoc} */
+        @Override
+        @Nullable public RelyingPartyConfiguration getUnverifiedConfiguration() {
+            final var ret = super.getUnverifiedConfiguration();
+            if (ret != null) {
+                return ret;
+            }
+
+            if (allowInheritance && parent instanceof BasicApplication basic) {
+                return basic.relyingPartyResolver.getUnverifiedConfiguration();
+            }
+            
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override
+        @Nonnull public Collection<Credential> getSigningCredentials() {
+            final var ret = super.getSigningCredentials();
+            if (!ret.isEmpty()) {
+                return ret;
+            }
+
+            if (allowInheritance && parent instanceof BasicApplication basic) {
+                return basic.getSigningCredentials();
+            }
+            
+            return CollectionSupport.emptyList();
+        }
+
+        /** {@inheritDoc} */
+        @Override
+        @Nonnull public Collection<Credential> getEncryptionCredentials() {
+            final var ret = super.getEncryptionCredentials();
+            if (!ret.isEmpty()) {
+                return ret;
+            }
+
+            if (allowInheritance && parent instanceof BasicApplication basic) {
+                return basic.getEncryptionCredentials();
+            }
+            
+            return CollectionSupport.emptyList();
+        }
+    }
+    
+    // Pass through the public resolver methods to the delegate.
+
+    
+    /** {@inheritDoc} */
+    @Nonnull public Collection<Credential> getSigningCredentials() {
+        checkComponentActive();
+        return relyingPartyResolver.getSigningCredentials();
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull public Collection<Credential> getEncryptionCredentials() {
+        checkComponentActive();
+        return relyingPartyResolver.getEncryptionCredentials();
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull public Iterable<RelyingPartyConfiguration> resolve(@Nullable CriteriaSet criteria) throws ResolverException {
+        checkComponentActive();
+        return relyingPartyResolver.resolve(criteria);
+    }
+
+    /** {@inheritDoc} */
+    @Nullable public RelyingPartyConfiguration resolveSingle(@Nullable CriteriaSet criteria) throws ResolverException {
+        checkComponentActive();
+        return relyingPartyResolver.resolveSingle(criteria);
+    }
+
+    /**
+     * Set the verified relying party configurations.
+     * 
+     * @param configs list of verified relying party configurations
+     */
+    public void setRelyingPartyConfigurations(@Nullable final Collection<? extends RelyingPartyConfiguration> configs) {
+        checkSetterPreconditions();
+        relyingPartyResolver.setRelyingPartyConfigurations(configs);
+    }
+
+    /**
+     * Set the {@link RelyingPartyConfiguration} to use if no other configuration is applicable.
+     * 
+     * @param configuration default configuration
+     */
+    public void setDefaultConfiguration(@Nullable final RelyingPartyConfiguration configuration) {
+        checkSetterPreconditions();
+        relyingPartyResolver.setDefaultConfiguration(configuration);
+    }
+
+    /**
+     * Set the {@link RelyingPartyConfiguration} to use if the configuration is found to be "unverified"
+     * (via use of {@link VerifiedProfileCriterion}).
+     * 
+     * @param configuration unverified configuration
+     */
+    public void setUnverifiedConfiguration(@Nullable final RelyingPartyConfiguration configuration) {
+        checkSetterPreconditions();
+        relyingPartyResolver.setUnverifiedConfiguration(configuration);
+    }
+
+    /**
+     * Set name of metric to use for counters to track use of configurations.
+     * 
+     * @param name name for counter metrics
+     * 
+     * @since 5.0.0
+     */
+    public void setMetricName(@Nullable final String name) {
+        checkSetterPreconditions();
+        relyingPartyResolver.setMetricName(name);
+    }
+
+    /**
+     * Set the list of all configured signing credentials.
+     * 
+     * @param credentials the list of signing credentials, may be null
+     */
+    @Autowired
+    @Qualifier("signing")
+    public void setSigningCredentials(@Nullable final List<CredentialHolder> credentials) {
+        checkSetterPreconditions();
+        relyingPartyResolver.setSigningCredentials(credentials);
+    }
+
+    /**
+     * Set the list of all configured encryption credentials.
+     * 
+     * @param credentials the list of encryption credentials, may be null
+     */
+    @Autowired
+    @Qualifier("encryption")
+    public void setEncryptionCredentials(@Nullable final List<CredentialHolder> credentials) {
+        checkSetterPreconditions();
+        relyingPartyResolver.setEncryptionCredentials(credentials);
+    }
+    
 }
\ 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