[java-plugin-shibd] 01/02: Abstract flow for application lookup.

Scott Cantor cantor.2 at osu.edu
Mon Jul 8 17:31:13 UTC 2024


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=4b46b4a2620887aef8bb543e1f36027f66fcab29

commit 4b46b4a2620887aef8bb543e1f36027f66fcab29
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Jul 8 13:30:57 2024 -0400

    Abstract flow for application lookup.
---
 .../idp/flows/sp/application/application-beans.xml | 12 ++++
 .../idp/flows/sp/application/application-flow.xml  | 18 ++++++
 sp-server-api/pom.xml                              | 16 +++--
 .../java/net/shibboleth/sp/impl/BasicAgent.java    |  2 +-
 .../sp/profile/impl/ResolveApplication.java        | 70 ++++++++++++++++++++++
 5 files changed, 112 insertions(+), 6 deletions(-)

diff --git a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/application/application-beans.xml b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/application/application-beans.xml
new file mode 100644
index 0000000..d201acc
--- /dev/null
+++ b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/application/application-beans.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:c="http://www.springframework.org/schema/c"
+    xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
+    xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+                           http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
+    default-init-method="initialize" default-destroy-method="destroy">
+
+    <bean id="ResolveApplication" class="net.shibboleth.sp.profile.impl.ResolveApplication" scope="prototype" />
+
+</beans>
diff --git a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/application/application-flow.xml b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/application/application-flow.xml
new file mode 100644
index 0000000..1808157
--- /dev/null
+++ b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/application/application-flow.xml
@@ -0,0 +1,18 @@
+<flow xmlns="http://www.springframework.org/schema/webflow" 
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow.xsd"
+    parent="sp/abstract">
+
+    <!-- Resume flow operation after set up by parent. -->
+    <action-state id="DoOperation">
+        <evaluate expression="ResolveApplication" />
+        <evaluate expression="'proceed'" />
+        
+        <!-- Branch to child flow for actual work. -->
+        <transition on="proceed" to="DoApplicationOperation" />
+    </action-state>
+    
+    <!-- The file really exists in this directory, but it's referenced from extending flow-directories -->
+    <bean-import resource="classpath:/META-INF/net/shibboleth/idp/flows/sp/application/application-beans.xml" />
+
+</flow>
diff --git a/sp-server-api/pom.xml b/sp-server-api/pom.xml
index bdcf4ff..8a44599 100644
--- a/sp-server-api/pom.xml
+++ b/sp-server-api/pom.xml
@@ -24,29 +24,35 @@
 
         <!-- Provided dependencies -->
         <dependency>
-            <groupId>net.shibboleth</groupId>
+            <groupId>${idp.groupId}</groupId>
+            <artifactId>idp-profile-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+                
+        <dependency>
+            <groupId>${shib-profile.groupId}</groupId>
             <artifactId>shib-profile-api</artifactId>
             <scope>provided</scope>
         </dependency>
 
         <dependency>
-            <groupId>net.shibboleth</groupId>
+            <groupId>${shib-attribute.groupId}</groupId>
             <artifactId>shib-attribute-resolver-api</artifactId>
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>net.shibboleth</groupId>
+            <groupId>${shib-attribute.groupId}</groupId>
             <artifactId>shib-attribute-filter-api</artifactId>
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>net.shibboleth</groupId>
+            <groupId>${shib-metadata.groupId}</groupId>
             <artifactId>shib-metadata-api</artifactId>
             <scope>provided</scope>
         </dependency>
 
         <dependency>
-            <groupId>net.shibboleth</groupId>
+            <groupId>${shib-shared.groupId}</groupId>
             <artifactId>shib-service</artifactId>
             <scope>provided</scope>
         </dependency>
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 5803228..b15506d 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
@@ -200,7 +200,7 @@ public class BasicAgent extends DefaultRelyingPartyConfigurationResolver impleme
     @Nullable public Application getApplication(@Nonnull String id) {
         checkComponentActive();
         
-        return null;
+        return applicationMap.get(id);
     }
 
     /** {@inheritDoc} */
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/ResolveApplication.java b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/ResolveApplication.java
new file mode 100644
index 0000000..858fb28
--- /dev/null
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/ResolveApplication.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.sp.profile.impl;
+
+import javax.annotation.Nonnull;
+
+import org.opensaml.profile.action.ActionSupport;
+import org.opensaml.profile.action.EventIds;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.slf4j.Logger;
+
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.primitive.LoggerFactory;
+import net.shibboleth.sp.Agent;
+import net.shibboleth.sp.Application;
+import net.shibboleth.sp.ddf.DDF;
+
+/**
+ * An action that maps a message request from an agent to the corresponding {@link Application}
+ * defined for that agent.
+ * 
+ * @event {@link EventIds#PROCEED_EVENT_ID}
+ * @event {@link EventIds#INVALID_MESSAGE}
+ * @post <pre>AgentRequestContext.getApplication() != null</pre>
+ */
+public class ResolveApplication extends AbstractAgentAction {
+
+    /** Field member carrying application ID. */
+    @Nonnull @NotEmpty public static final String APPLICATION_ID = "application";
+    
+    /** Class logger. */
+    @Nonnull private final Logger log = LoggerFactory.getLogger(ResolveApplication.class);
+    
+    /** {@inheritDoc} */
+    @Override
+    protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
+        
+        final Agent agent = ensureAgent();
+        
+        final DDF input = ensureAgentRequestContext().getInput();
+        final String applicationId = input != null ? input.getmember(APPLICATION_ID).string() : null;
+        if (applicationId == null) {
+            log.warn("{} Request from agent '{}' missing {} specifier", getLogPrefix(), agent.getId(), APPLICATION_ID);
+            ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
+            return;
+        }
+        
+        final Application app = agent.getApplication(applicationId);
+        if (app != null) {
+            log.debug("{} Request from agent '{}' mapped to application '{}'", getLogPrefix(), agent.getId(), app.getId());
+            ensureAgentRequestContext().setApplication(app);
+        } else {
+            log.warn("{} Request from agent '{}' with unknown application '{}'", getLogPrefix(), agent.getId(), applicationId);
+            ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
+        }
+    }
+    
+}
\ 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