[java-plugin-shibd] branch main updated: Refactoring of Agent on Application implementation to simplify config.
Scott Cantor
cantor.2 at osu.edu
Thu Aug 14 13:54:01 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=5d8607f6aae731442c7433d8d990c591fa7b1bb8
The following commit(s) were added to refs/heads/main by this push:
new 5d8607f Refactoring of Agent on Application implementation to simplify config.
5d8607f is described below
commit 5d8607f6aae731442c7433d8d990c591fa7b1bb8
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Aug 14 09:53:58 2025 -0400
Refactoring of Agent on Application implementation to simplify config.
---
.../META-INF/net.shibboleth.idp/postconfig.xml | 14 ++---
.../idp/flows/sp/abstract/sp-abstract-beans.xml | 2 +-
.../sp/token-consumer/token-consumer-beans.xml | 2 +-
.../net/shibboleth/idp/module/conf/sp/agents.xml | 14 ++---
.../shibboleth/idp/module/conf/sp/sp.properties | 6 +--
.../net/shibboleth/sp/conf/agents-system.xml | 37 ++++++-------
.../net/shibboleth/idp/module/conf/sp/agents.xml | 16 ++----
.../src/main/java/net/shibboleth/sp/Agent.java | 15 +-----
.../main/java/net/shibboleth/sp/Application.java | 7 +++
.../sp/profile/AbstractAgentRequestAction.java | 2 +-
.../java/net/shibboleth/sp/impl/BasicAgent.java | 60 ++++++++--------------
.../net/shibboleth/sp/impl/BasicApplication.java | 9 +++-
.../impl/AgentSecretCredentialValidatorTest.java | 20 +++-----
.../impl/InitializeAgentRequestContextTest.java | 11 ++++
.../sp/authn/impl/ValidateAgentAddressTest.java | 17 ++----
.../impl/ValidateCachedAuthenticationTest.java | 19 +++----
.../sp/profile/impl/BaseAgentRequestTest.java | 14 ++++-
.../sp/profile/impl/BaseAgplicationActionTest.java | 17 +-----
18 files changed, 118 insertions(+), 164 deletions(-)
diff --git a/sp-conf-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml b/sp-conf-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
index 2254916..1795b0e 100644
--- a/sp-conf-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
+++ b/sp-conf-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
@@ -15,20 +15,20 @@
<!-- Agent reseolver service. -->
- <bean id="shibboleth.AgentResolver" parent="shibboleth.ReloadableService"
+ <bean id="shibboleth.sp.AgentResolver" parent="shibboleth.ReloadableService"
c:claz="net.shibboleth.sp.impl.DefaultAgentResolver"
p:serviceConfigurations-ref="ExtendedAgentResolverResources"
p:failFast="%{sp.service.agents.failFast:%{idp.service.failFast:false}}"
p:reloadCheckDelay="%{sp.service.agents.checkInterval:PT0S}" />
- <util:list id="shibboleth.DefaultAgentResolverResources">
+ <util:list id="shibboleth.sp.DefaultAgentResolverResources">
<value>conditional:%{idp.home}/conf/sp/agents.xml</value>
</util:list>
<!-- Auto-append system config files to resource set. -->
<bean id ="ExtendedAgentResolverResources" class="net.shibboleth.shared.spring.factory.CombiningListFactoryBean"
- p:firstList="#{getObject('%{sp.service.agents.resources:shibboleth.AgentResolverResources}'.trim()) ?:
- getObject('shibboleth.DefaultAgentResolverResources')}">
+ p:firstList="#{getObject('%{sp.service.agents.resources:shibboleth.sp.AgentResolverResources}'.trim()) ?:
+ getObject('shibboleth.sp.DefaultAgentResolverResources')}">
<property name="secondList">
<util:list >
<value>classpath:/net/shibboleth/sp/conf/agents-system.xml</value>
@@ -41,11 +41,11 @@
<!-- Management bean to collect and expose TokenConsumerFlowDescriptors. -->
- <bean id="shibboleth.TokenConsumerFlowDescriptorManager"
+ <bean id="shibboleth.sp.TokenConsumerFlowDescriptorManager"
class="net.shibboleth.sp.profile.impl.TokenConsumerFlowDescriptorManager"
- p:components="#{getObject('shibboleth.AvailableTokenConsumerFlows')}" />
+ p:components="#{getObject('shibboleth.sp.AvailableTokenConsumerFlows')}" />
- <bean id="shibboleth.RemotedCookieManager" class="net.shibboleth.shared.net.CookieManager" lazy-init="true"
+ <bean id="shibboleth.sp.RemotedCookieManager" class="net.shibboleth.shared.net.CookieManager" lazy-init="true"
p:guardSetAttribute="false"
p:httpServletRequestSupplier-ref="shibboleth.RemotedHttpServletRequestSupplier"
p:httpServletResponseSupplier-ref="shibboleth.RemotedHttpServletResponseSupplier"
diff --git a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/abstract/sp-abstract-beans.xml b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/abstract/sp-abstract-beans.xml
index 2553e91..6b83890 100644
--- a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/abstract/sp-abstract-beans.xml
+++ b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/abstract/sp-abstract-beans.xml
@@ -30,7 +30,7 @@
<bean id="InitializeAgentRequestContext"
class="net.shibboleth.sp.authn.impl.InitializeAgentRequestContext" scope="prototype"
- p:agentResolver-ref="shibboleth.AgentResolver" />
+ p:agentResolver-ref="shibboleth.sp.AgentResolver" />
<bean id="ValidateAgentAddress"
class="net.shibboleth.sp.authn.impl.ValidateAgentAddress" scope="prototype"
diff --git a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/token-consumer/token-consumer-beans.xml b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/token-consumer/token-consumer-beans.xml
index ddf9bcb..c374136 100644
--- a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/token-consumer/token-consumer-beans.xml
+++ b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/token-consumer/token-consumer-beans.xml
@@ -12,6 +12,6 @@
<bean id="SelectTokenConsumerFlow"
class="net.shibboleth.sp.profile.impl.SelectTokenConsumerFlow" scope="prototype"
- p:availableFlows="#{getObject('shibboleth.TokenConsumerFlowDescriptorManager').getComponents()}" />
+ p:availableFlows="#{getObject('shibboleth.sp.TokenConsumerFlowDescriptorManager').getComponents()}" />
</beans>
diff --git a/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/agents.xml b/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/agents.xml
index b4392bd..7ab9090 100644
--- a/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/agents.xml
+++ b/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/agents.xml
@@ -23,20 +23,14 @@
<!-- ============ Agents and their Applications ============ -->
- <bean p:id="localhost" parent="shibboleth.Agent">
- <property name="applications">
- <set>
- <bean p:id="default" parent="shibboleth.Application" />
- </set>
- </property>
- </bean>
+ <bean p:id="localhost" parent="shibboleth.sp.Agent" />
<!-- ============ Profile defaults ============ -->
<!-- Used for all applications by default to provide a baseline for profile settings. -->
- <util:list id="shibboleth.DefaultProfileConfigurations">
+ <util:list id="shibboleth.sp.DefaultProfileConfigurations">
<!-- Your profiles here. -->
</util:list>
@@ -55,7 +49,7 @@
"Unverified" typically means the SP has no metadata, or equivalent way of assuring the identity and
legitimacy of an IdP system. To run an "open" SP, you can enable profiles here.
-->
- <bean id="shibboleth.UnverifiedRelyingParty" parent="RelyingParty">
+ <bean id="shibboleth.sp.UnverifiedRelyingParty" parent="RelyingParty">
<property name="profileConfigurations">
<list>
<!-- Your profiles here. -->
@@ -65,7 +59,7 @@
<!-- Container for any overrides you want to add, again used for all applications by default. -->
- <util:list id="shibboleth.RelyingPartyOverrides">
+ <util:list id="shibboleth.sp.RelyingPartyOverrides">
</util:list>
diff --git a/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/sp.properties b/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/sp.properties
index 2df6a69..b275a8d 100644
--- a/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/sp.properties
+++ b/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/sp.properties
@@ -6,7 +6,7 @@ sp.issuer = https://sp.example.org
# Controls configuration of service to resolve SP agents and applications
# Uncomment and define to override service resources
-#sp.service.agents.resources = shibboleth.AgentResolverResources
+#sp.service.agents.resources = shibboleth.sp.AgentResolverResources
#sp.service.agents.failFast = false
sp.service.agents.checkInterval = PT5M
@@ -32,8 +32,8 @@ sp.service.agents.checkInterval = PT5M
# Default state token management (SAML RelayState, etc.)
#sp.stateToken.errorsFatal = false
-# Set to shibboleth.CookieStateTokenManager to switch to cookie-based mechanism
-#sp.stateToken.Manager = shibboleth.StorageStateTokenManager
+# Set to shibboleth.sp.CookieStateTokenManager to switch to cookie-based mechanism
+#sp.stateToken.Manager = shibboleth.sp.StorageStateTokenManager
# Controls storage back-end for storage-based state tokens
#sp.stateToken.StorageService = shibboleth.StorageService
# Cookie prefix when using cookie-backed state
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 1227179..f73d7e3 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
@@ -16,7 +16,7 @@
<context:annotation-config />
<!-- Exposes auto-wired map of Agents. -->
- <bean id="shibboleth.AgentResolver" class="net.shibboleth.sp.impl.DefaultAgentResolver" />
+ <bean id="shibboleth.sp.AgentResolver" class="net.shibboleth.sp.impl.DefaultAgentResolver" />
<!-- Parent beans for Agents and Applications. -->
@@ -24,12 +24,13 @@
<constructor-arg type="java.lang.String" value="%{sp.authn.allowedAddressRanges:127.0.0.1/32,::1/128}" />
</bean>
- <bean id="shibboleth.Agent" class="net.shibboleth.sp.impl.BasicAgent" abstract="true"
+ <bean id="shibboleth.sp.Agent" parent="shibboleth.sp.Application" abstract="true"
+ class="net.shibboleth.sp.impl.BasicAgent"
p:authenticationMethod="%{sp.agent.authn.method:basic}"
p:allowedAddressRanges-ref="DefaultAllowedAddressRanges"
p:supportsCachedAuthentication="%{sp.agent.authn.cached:true}" />
- <bean id="shibboleth.Application" class="net.shibboleth.sp.impl.BasicApplication" abstract="true"
+ <bean id="shibboleth.sp.Application" class="net.shibboleth.sp.impl.BasicApplication" abstract="true"
p:issuer="#{'%{sp.issuer:}'.trim()}"
p:authenticatingAuthority="%{sp.defaultAuthority:}"
p:metadataResolver-ref="shibboleth.MetadataResolverService"
@@ -37,39 +38,39 @@
p:attributeResolver-ref="shibboleth.AttributeResolverService"
p:attributeFilter-ref="shibboleth.AttributeFilterService"
p:detailedErrorsPredicate="%{sp.errors.detailed:false}"
- p:securityConfiguration-ref="#{'%{sp.security.config:shibboleth.DefaultSecurityConfiguration}'.trim()}"
- p:profileConfigurations-ref="shibboleth.DefaultProfileConfigurations"
- p:unverifiedConfiguration-ref="shibboleth.UnverifiedRelyingParty"
- p:relyingPartyConfigurations-ref="shibboleth.RelyingPartyOverrides"
+ 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.SessionInitiators"
- p:tokenConsumers-ref="shibboleth.TokenConsumers"
- p:stateTokenManager-ref="#{'%{sp.stateToken.Manager:shibboleth.StorageStateTokenManager}'.trim()}" />
+ 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.SessionInitiators" parent="shibboleth.CommaDelimStringArray"
+ <bean id="shibboleth.sp.SessionInitiators" parent="shibboleth.CommaDelimStringArray"
c:_0="%{sp.application.sessionInitiators:}" />
- <bean id="shibboleth.TokenConsumers" parent="shibboleth.CommaDelimStringArray"
+ <bean id="shibboleth.sp.TokenConsumers" parent="shibboleth.CommaDelimStringArray"
c:_0="%{sp.application.tokenConsumers:}" />
- <bean id="shibboleth.PassthroughStateTokenManager" class="net.shibboleth.sp.impl.PassthroughStateTokenManager" lazy-init="true" />
+ <bean id="shibboleth.sp.PassthroughStateTokenManager" class="net.shibboleth.sp.impl.PassthroughStateTokenManager" lazy-init="true" />
- <bean id="shibboleth.StorageStateTokenManager" class="net.shibboleth.sp.impl.StorageServiceStateTokenManager" lazy-init="true"
+ <bean id="shibboleth.sp.StorageStateTokenManager" class="net.shibboleth.sp.impl.StorageServiceStateTokenManager" lazy-init="true"
p:storageService-ref="#{'%{sp.stateToken.StorageService:shibboleth.StorageService}'.trim()}" />
- <bean id="shibboleth.CookieStateTokenManager" class="net.shibboleth.sp.impl.CookieStateTokenManager" lazy-init="true"
- p:cookieManager-ref="shibboleth.RemotedCookieManager"
+ <bean id="shibboleth.sp.CookieStateTokenManager" class="net.shibboleth.sp.impl.CookieStateTokenManager" lazy-init="true"
+ p:cookieManager-ref="shibboleth.sp.RemotedCookieManager"
p:cookiePrefix="%{sp.stateToken.cookiePrefix:_Host-shibsp_state_}" />
<!-- More traditional beans akin to IdP service. -->
- <bean id="shibboleth.DefaultSecurityConfiguration" class="org.opensaml.security.config.BasicSecurityConfiguration" />
+ <bean id="shibboleth.sp.DefaultSecurityConfiguration" class="org.opensaml.security.config.BasicSecurityConfiguration" />
<!-- Parent bean for generic RelyingParty overrides that establishes defaults. -->
<bean id="RelyingParty" abstract="true" class="net.shibboleth.profile.relyingparty.BasicRelyingPartyConfiguration"
p:issuer="#{'%{sp.issuer:}'.trim()}"
p:detailedErrorsPredicate="%{sp.errors.detailed:false}"
- p:securityConfiguration-ref="#{'%{sp.security.config:shibboleth.DefaultSecurityConfiguration}'.trim()}"
+ p:securityConfiguration-ref="#{'%{sp.security.config:shibboleth.sp.DefaultSecurityConfiguration}'.trim()}"
p:profileConfigurations-ref="shibboleth.DefaultProfileConfigurations" />
<!-- Parent bean for RelyingParty overrides based on activation by name(s). -->
diff --git a/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/agents.xml b/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/agents.xml
index a4ab4bc..128fa21 100644
--- a/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/agents.xml
+++ b/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/agents.xml
@@ -23,22 +23,14 @@
<!-- ============ Agents and their Applications ============ -->
- <bean p:id="testsp.example.org" parent="shibboleth.Agent" p:sharedSecrets="foo">
- <property name="applications">
- <set>
- <bean p:id="default" parent="shibboleth.Application"
- p:issuer="https://sp.example.org"
- p:authenticatingAuthority="https://idp.example.org" />
- </set>
- </property>
- </bean>
+ <bean p:id="testsp.example.org" parent="shibboleth.sp.Agent" p:sharedSecrets="foo" />
<!-- ============ Profile defaults ============ -->
<!-- Used for all applications by default to provide a baseline for profile settings. -->
- <util:list id="shibboleth.DefaultProfileConfigurations">
+ <util:list id="shibboleth.sp.DefaultProfileConfigurations">
<!-- Your profiles here. -->
</util:list>
@@ -58,7 +50,7 @@
"Unverified" typically means the SP has no metadata, or equivalent way of assuring the identity and
legitimacy of an IdP system. To run an "open" SP, you can enable profiles here.
-->
- <bean id="shibboleth.UnverifiedRelyingParty" parent="RelyingParty">
+ <bean id="shibboleth.sp.UnverifiedRelyingParty" parent="RelyingParty">
<property name="profileConfigurations">
<list>
<!-- Your profiles here. -->
@@ -68,7 +60,7 @@
<!-- Container for any overrides you want to add. -->
- <util:list id="shibboleth.RelyingPartyOverrides">
+ <util:list id="shibboleth.sp.RelyingPartyOverrides">
</util:list>
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/Agent.java b/sp-server-api/src/main/java/net/shibboleth/sp/Agent.java
index df24a71..0e834ab 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/Agent.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/Agent.java
@@ -23,8 +23,6 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
-import org.opensaml.profile.context.ProfileRequestContext;
-
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.component.IdentifiedComponent;
import net.shibboleth.shared.net.IPRange;
@@ -88,18 +86,7 @@ public interface Agent extends IdentifiedComponent {
boolean isSupportsCachedAuthentication();
/**
- * Get the issuer value to use in various identity protocols when identifying this agent.
- *
- * <p>Note that this value may be overridden by {@link Application}.</p>
- *
- * @param profileRequestContext profile request context
- *
- * @return default issue value to use
- */
- @Nullable @NotEmpty String getIssuer(@Nonnull final ProfileRequestContext profileRequestContext);
-
- /**
- * Get the {@link Application} instances associated with this agent.
+ * Get an {@link Application} associated with this agent.
*
* @param id application id
*
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/Application.java b/sp-server-api/src/main/java/net/shibboleth/sp/Application.java
index 00c5e8c..8bc03d1 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/Application.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/Application.java
@@ -47,6 +47,13 @@ import net.shibboleth.sp.profile.StateTokenManager;
@ThreadSafe
public interface Application extends RelyingPartyConfigurationResolver {
+ /**
+ * Dedicated method to access application ID for explicitness.
+ *
+ * @return application ID
+ */
+ @Nonnull @NotEmpty String getApplicationId();
+
/**
* Gets the identifier of the authenticating authority (IdP, OP, etc.) to use for this application
* if not overridden.
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/profile/AbstractAgentRequestAction.java b/sp-server-api/src/main/java/net/shibboleth/sp/profile/AbstractAgentRequestAction.java
index f0e5d9b..9218f2f 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/profile/AbstractAgentRequestAction.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/profile/AbstractAgentRequestAction.java
@@ -127,7 +127,7 @@ public abstract class AbstractAgentRequestAction extends AbstractProfileAction {
}
final Application app = ctx.getApplication();
if (app != null) {
- s.append(" Application ").append(app.getId()).append(" - ");
+ s.append(" Application ").append(app.getApplicationId()).append(" - ");
}
}
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 b15506d..b0b1a2b 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
@@ -16,26 +16,22 @@
package net.shibboleth.sp.impl;
import java.net.InetAddress;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
-import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.opensaml.profile.context.ProfileRequestContext;
-
import com.google.common.base.Functions;
import com.google.common.base.MoreObjects;
-import net.shibboleth.profile.relyingparty.impl.DefaultRelyingPartyConfigurationResolver;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.logic.Constraint;
-import net.shibboleth.shared.logic.FunctionSupport;
import net.shibboleth.shared.net.IPRange;
import net.shibboleth.shared.primitive.StringSupport;
import net.shibboleth.sp.Agent;
@@ -44,8 +40,11 @@ import net.shibboleth.sp.Application;
/**
* Basic implementation of an {@link Agent}.
*/
-public class BasicAgent extends DefaultRelyingPartyConfigurationResolver implements Agent {
+public class BasicAgent extends BasicApplication implements Agent {
+ /** ID of default {@link Application}. */
+ @Nonnull @NotEmpty public static String DEFAULT_APPLICATION_ID = "default";
+
/** Whether cached authentication is supported. */
private boolean supportsCachedAuthentication;
@@ -61,9 +60,6 @@ public class BasicAgent extends DefaultRelyingPartyConfigurationResolver impleme
/** Application map. */
@Nonnull private Map<String,Application> applicationMap;
- /** Lookup strategy for issuer. */
- @Nonnull private Function<ProfileRequestContext,String> issuerLookupStrategy;
-
/** Constructor. */
public BasicAgent() {
supportsCachedAuthentication = true;
@@ -71,7 +67,12 @@ public class BasicAgent extends DefaultRelyingPartyConfigurationResolver impleme
authenticationMethod = AUTH_METHOD_BASIC;
sharedSecrets = CollectionSupport.emptySet();
applicationMap = CollectionSupport.emptyMap();
- issuerLookupStrategy = FunctionSupport.constant(null);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nonnull @NotEmpty public String getApplicationId() {
+ return DEFAULT_APPLICATION_ID;
}
/** {@inheritDoc} */
@@ -151,34 +152,6 @@ public class BasicAgent extends DefaultRelyingPartyConfigurationResolver impleme
supportsCachedAuthentication = flag;
}
- /** {@inheritDoc} */
- @Nullable @NotEmpty public String getIssuer(@Nullable final ProfileRequestContext profileRequestContext) {
- return issuerLookupStrategy.apply(profileRequestContext);
- }
-
- /**
- * Set default issuer value to use for this application.
- *
- * @param issuer issuer value
- */
- public void setIssuer(@Nullable @NotEmpty final String issuer) {
- checkSetterPreconditions();
-
- final String trimmed = Constraint.isNotNull(issuer, "Issuer cannot be null or empty");
- issuerLookupStrategy = FunctionSupport.constant(trimmed);
- }
-
- /**
- * Set default issuer lookup strategy to use for this application.
- *
- * @param strategy lookup strategy
- */
- public void setIssuer(@Nonnull final Function<ProfileRequestContext,String> strategy) {
- checkSetterPreconditions();
-
- issuerLookupStrategy = Constraint.isNotNull(strategy, "Issuer lookup strategy cannot be null");
- }
-
/**
* Sets the {@link Application} instances associated with this agent.
*
@@ -200,15 +173,22 @@ public class BasicAgent extends DefaultRelyingPartyConfigurationResolver impleme
@Nullable public Application getApplication(@Nonnull String id) {
checkComponentActive();
+ if (DEFAULT_APPLICATION_ID.equals(id)) {
+ return this;
+ }
+
return applicationMap.get(id);
}
/** {@inheritDoc} */
- @SuppressWarnings("null")
@Nonnull public Collection<Application> getApplications() {
checkComponentActive();
- return applicationMap.values();
+ final ArrayList<Application> apps = new ArrayList<>(applicationMap.size() + 1);
+ apps.add(this);
+ apps.addAll(applicationMap.values());
+
+ return CollectionSupport.copyToList(apps);
}
/** {@inheritDoc} */
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 370164a..e9e4cb4 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
@@ -92,7 +92,6 @@ public class BasicApplication extends DefaultRelyingPartyConfigurationResolver i
/** {@inheritDoc} */
@Override
protected void doInitialize() throws ComponentInitializationException {
-
// Init our default config and inject into parent class.
defaultRelyingPartyConfiguration.setId(getId());
defaultRelyingPartyConfiguration.initialize();
@@ -113,6 +112,14 @@ public class BasicApplication extends DefaultRelyingPartyConfigurationResolver i
}
}
+ /** {@inheritDoc} */
+ @SuppressWarnings("null")
+ @Override
+ @Nonnull @NotEmpty public String getApplicationId() {
+ checkComponentActive();
+ return getId();
+ }
+
/** {@inheritDoc} */
@Override
@Nullable public String getMetricName() {
diff --git a/sp-server-impl/src/test/java/net/shibboleth/sp/authn/impl/AgentSecretCredentialValidatorTest.java b/sp-server-impl/src/test/java/net/shibboleth/sp/authn/impl/AgentSecretCredentialValidatorTest.java
index 94b95d9..11ae904 100644
--- a/sp-server-impl/src/test/java/net/shibboleth/sp/authn/impl/AgentSecretCredentialValidatorTest.java
+++ b/sp-server-impl/src/test/java/net/shibboleth/sp/authn/impl/AgentSecretCredentialValidatorTest.java
@@ -19,9 +19,7 @@ import java.util.Set;
import javax.security.auth.Subject;
import javax.security.auth.login.LoginException;
-import org.opensaml.profile.context.ProfileRequestContext;
import org.opensaml.profile.testing.RequestContextBuilder;
-import org.springframework.mock.web.MockHttpServletRequest;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -32,33 +30,31 @@ import net.shibboleth.idp.authn.principal.UsernamePrincipal;
import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.sp.context.AgentRequestContext;
-import net.shibboleth.sp.impl.BasicAgent;
+import net.shibboleth.sp.profile.impl.BaseAgentRequestTest;
/**
* Unit test for {@link AgentSecretCredentialValidator}.
*/
@SuppressWarnings("javadoc")
-public class AgentSecretCredentialValidatorTest {
+public class AgentSecretCredentialValidatorTest extends BaseAgentRequestTest {
- private ProfileRequestContext prc;
private AuthenticationContext ac;
private UsernamePasswordContext upc;
- private MockHttpServletRequest request;
- private BasicAgent agent;
private AgentSecretCredentialValidator validator;
@BeforeMethod
public void setUp() throws ComponentInitializationException {
+ super.beforeMethod();
+
+ agent.setId("foo");
+
prc = new RequestContextBuilder().buildProfileRequestContext();
ac = prc.ensureSubcontext(AuthenticationContext.class);
upc = ac.ensureSubcontext(UsernamePasswordContext.class);
upc.setUsername("foo");
- agent = new BasicAgent();
- agent.setId("foo");
agent.setSharedSecrets(CollectionSupport.setOf("zork", "enchanter"));
- agent.initialize();
validator = new AgentSecretCredentialValidator();
validator.setId("test");
@@ -106,9 +102,7 @@ public class AgentSecretCredentialValidatorTest {
@Test
public void testIgnored() throws ComponentInitializationException {
- agent = new BasicAgent();
- agent.setId("foo");
- agent.initialize();
+ agent.setSharedSecrets(null);
prc.ensureSubcontext(AgentRequestContext.class).setAgent(agent);
upc.setPassword("enchanter");
diff --git a/sp-server-impl/src/test/java/net/shibboleth/sp/authn/impl/InitializeAgentRequestContextTest.java b/sp-server-impl/src/test/java/net/shibboleth/sp/authn/impl/InitializeAgentRequestContextTest.java
index dd9c37b..fd96267 100644
--- a/sp-server-impl/src/test/java/net/shibboleth/sp/authn/impl/InitializeAgentRequestContextTest.java
+++ b/sp-server-impl/src/test/java/net/shibboleth/sp/authn/impl/InitializeAgentRequestContextTest.java
@@ -28,8 +28,10 @@ import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileR
import net.shibboleth.idp.profile.testing.ActionTestingSupport;
import net.shibboleth.idp.profile.testing.RequestContextBuilder;
import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.testing.MockReloadableService;
import net.shibboleth.sp.context.AgentRequestContext;
import net.shibboleth.sp.impl.BasicAgent;
+import net.shibboleth.sp.impl.PassthroughStateTokenManager;
import net.shibboleth.sp.testing.MockAgentResolver;
/**
@@ -51,6 +53,15 @@ public class InitializeAgentRequestContextTest {
agent = new BasicAgent();
agent.setId("foo");
+ agent.setMetadataResolver(new MockReloadableService<>(null));
+ agent.setAttributeResolver(new MockReloadableService<>(null));
+ agent.setAttributeFilter(new MockReloadableService<>(null));
+ agent.setAttributeTranscoderRegistry(new MockReloadableService<>(null));
+
+ final PassthroughStateTokenManager manager = new PassthroughStateTokenManager();
+ manager.setId("test");
+ manager.initialize();
+ agent.setStateTokenManager(manager);
agent.initialize();
action = new InitializeAgentRequestContext();
diff --git a/sp-server-impl/src/test/java/net/shibboleth/sp/authn/impl/ValidateAgentAddressTest.java b/sp-server-impl/src/test/java/net/shibboleth/sp/authn/impl/ValidateAgentAddressTest.java
index 04b8c35..6cb6527 100644
--- a/sp-server-impl/src/test/java/net/shibboleth/sp/authn/impl/ValidateAgentAddressTest.java
+++ b/sp-server-impl/src/test/java/net/shibboleth/sp/authn/impl/ValidateAgentAddressTest.java
@@ -15,17 +15,12 @@
package net.shibboleth.sp.authn.impl;
import org.opensaml.profile.action.EventIds;
-import org.opensaml.profile.context.ProfileRequestContext;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.webflow.execution.Event;
-import org.springframework.webflow.execution.RequestContext;
-import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import net.shibboleth.idp.authn.AuthnEventIds;
import net.shibboleth.idp.authn.context.AuthenticationContext;
-import net.shibboleth.idp.authn.context.UsernamePasswordContext;
import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
import net.shibboleth.idp.profile.testing.ActionTestingSupport;
import net.shibboleth.idp.profile.testing.RequestContextBuilder;
@@ -34,28 +29,24 @@ import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.net.IPRange;
import net.shibboleth.shared.testing.ConstantSupplier;
import net.shibboleth.sp.context.AgentRequestContext;
-import net.shibboleth.sp.impl.BasicAgent;
+import net.shibboleth.sp.profile.impl.BaseAgentRequestTest;
/**
* Unit test for {@link ValidateAgentAddress} action.
*/
@SuppressWarnings("javadoc")
-public class ValidateAgentAddressTest {
+public class ValidateAgentAddressTest extends BaseAgentRequestTest {
- private RequestContext src;
- private ProfileRequestContext prc;
private MockHttpServletRequest request;
-
- private BasicAgent agent;
private ValidateAgentAddress action;
@BeforeMethod
public void setUp() throws ComponentInitializationException {
+ super.beforeMethod();
+
src = new RequestContextBuilder().buildRequestContext();
prc = new WebflowRequestContextProfileRequestContextLookup().apply(src);
- agent = new BasicAgent();
- agent.setId("foo");
agent.setAllowedAddressRanges(CollectionSupport.setOf(IPRange.parseCIDRBlock("127.0.0.1/32"),
IPRange.parseCIDRBlock("192.168.1.0/24")));
agent.initialize();
diff --git a/sp-server-impl/src/test/java/net/shibboleth/sp/authn/impl/ValidateCachedAuthenticationTest.java b/sp-server-impl/src/test/java/net/shibboleth/sp/authn/impl/ValidateCachedAuthenticationTest.java
index 0d9f681..aeaa4f9 100644
--- a/sp-server-impl/src/test/java/net/shibboleth/sp/authn/impl/ValidateCachedAuthenticationTest.java
+++ b/sp-server-impl/src/test/java/net/shibboleth/sp/authn/impl/ValidateCachedAuthenticationTest.java
@@ -19,11 +19,9 @@ import java.time.Instant;
import javax.annotation.Nonnull;
import org.opensaml.profile.action.EventIds;
-import org.opensaml.profile.context.ProfileRequestContext;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.webflow.execution.Event;
-import org.springframework.webflow.execution.RequestContext;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -37,25 +35,24 @@ import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.primitive.NonnullSupplier;
import net.shibboleth.shared.security.DataSealerException;
import net.shibboleth.sp.context.AgentRequestContext;
-import net.shibboleth.sp.impl.BasicAgent;
+import net.shibboleth.sp.profile.impl.BaseAgentRequestTest;
/**
* Unit test for {@link ValidateCachedAuthentication} action.
*/
@SuppressWarnings("javadoc")
-public class ValidateCachedAuthenticationTest {
+public class ValidateCachedAuthenticationTest extends BaseAgentRequestTest {
@Nonnull @NotEmpty protected static final String COOKIE_NAME = "_cookieName";
private MockHttpServletRequest request;
- private RequestContext src;
- private ProfileRequestContext prc;
- private BasicAgent agent;
private ValidateCachedAuthentication action;
@BeforeMethod
public void setUp() throws ComponentInitializationException {
+ super.beforeMethod();
+
src = new RequestContextBuilder().buildRequestContext();
prc = new WebflowRequestContextProfileRequestContextLookup().apply(src);
prc.ensureSubcontext(AuthenticationContext.class);
@@ -63,10 +60,6 @@ public class ValidateCachedAuthenticationTest {
request = new MockHttpServletRequest();
request.setRemoteAddr("127.0.0.1");
- agent = new BasicAgent();
- agent.setId("foo");
- agent.initialize();
-
action = new ValidateCachedAuthentication();
action.setHttpServletRequestSupplier(new NonnullSupplier<>() { @Nonnull public HttpServletRequest get() {return request;}});
action.initialize();
@@ -79,10 +72,10 @@ public class ValidateCachedAuthenticationTest {
@Test
public void testNoCaching() throws ComponentInitializationException {
- agent = new BasicAgent();
- agent.setId("foo");
agent.setSupportsCachedAuthentication(false);
agent.initialize();
+
+
prc.ensureSubcontext(AgentRequestContext.class).setAgent(agent);
final Event event = action.execute(src);
ActionTestingSupport.assertProceedEvent(event);
diff --git a/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/BaseAgentRequestTest.java b/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/BaseAgentRequestTest.java
index 25b92ec..004f70a 100644
--- a/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/BaseAgentRequestTest.java
+++ b/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/BaseAgentRequestTest.java
@@ -21,8 +21,10 @@ import org.springframework.webflow.execution.RequestContext;
import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
import net.shibboleth.idp.profile.testing.RequestContextBuilder;
import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.testing.MockReloadableService;
import net.shibboleth.sp.context.AgentRequestContext;
import net.shibboleth.sp.impl.BasicAgent;
+import net.shibboleth.sp.impl.PassthroughStateTokenManager;
/**
* Base class for unit tests that rely on set up of an agent request.
@@ -46,7 +48,17 @@ public abstract class BaseAgentRequestTest extends OpenSAMLInitBaseTestCase {
agent = new BasicAgent();
agent.setId("test");
- agent.initialize();
+ agent.setMetadataResolver(new MockReloadableService<>(null));
+ agent.setAttributeResolver(new MockReloadableService<>(null));
+ agent.setAttributeFilter(new MockReloadableService<>(null));
+ agent.setAttributeTranscoderRegistry(new MockReloadableService<>(null));
+
+ final PassthroughStateTokenManager manager = new PassthroughStateTokenManager();
+ manager.setId("test");
+ manager.initialize();
+ agent.setStateTokenManager(manager);
+
+ //agent.initialize();
arc.setAgent(agent);
}
diff --git a/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/BaseAgplicationActionTest.java b/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/BaseAgplicationActionTest.java
index 25aeeb8..7b60882 100644
--- a/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/BaseAgplicationActionTest.java
+++ b/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/BaseAgplicationActionTest.java
@@ -15,9 +15,7 @@
package net.shibboleth.sp.profile.impl;
import net.shibboleth.shared.component.ComponentInitializationException;
-import net.shibboleth.shared.testing.MockReloadableService;
import net.shibboleth.sp.impl.BasicApplication;
-import net.shibboleth.sp.impl.PassthroughStateTokenManager;
/**
* Base class for unit tests that rely on set up of an agent request with an application.
@@ -34,20 +32,7 @@ public abstract class BaseAgplicationActionTest extends BaseAgentRequestTest {
public void beforeMethod() throws ComponentInitializationException {
super.beforeMethod();
- application = new BasicApplication();
- application.setId("test");
-
- application.setMetadataResolver(new MockReloadableService<>(null));
- application.setAttributeResolver(new MockReloadableService<>(null));
- application.setAttributeFilter(new MockReloadableService<>(null));
- application.setAttributeTranscoderRegistry(new MockReloadableService<>(null));
-
- final PassthroughStateTokenManager manager = new PassthroughStateTokenManager();
- manager.setId("test");
- manager.initialize();
- application.setStateTokenManager(manager);
-
- //application.initialize();
+ application = agent;
arc.setApplication(application);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list