[java-plugin-shibd] branch main updated: Adjusting conventions to fit documentation.
Scott Cantor
cantor.2 at osu.edu
Tue Jun 18 17:50:08 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=35d03a667f53c6d3e6e375800a51b12e46089b7f
The following commit(s) were added to refs/heads/main by this push:
new 35d03a6 Adjusting conventions to fit documentation.
35d03a6 is described below
commit 35d03a667f53c6d3e6e375800a51b12e46089b7f
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Jun 18 13:50:05 2024 -0400
Adjusting conventions to fit documentation.
---
.../sp/config/impl/ParseAgentRequestMap.java | 3 +--
.../sp/profile/impl/DecodeAgentRequest.java | 20 +++++++++++++++++++-
.../java/net/shibboleth/sp/profile/impl/DoPing.java | 2 +-
.../sp/profile/impl/PrepareAgentErrorResponse.java | 20 +++++++-------------
.../sp/config/impl/ParseAgentRequestMapTest.java | 3 ---
5 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/config/impl/ParseAgentRequestMap.java b/sp-server-impl/src/main/java/net/shibboleth/sp/config/impl/ParseAgentRequestMap.java
index 0a96a2e..6b64e1b 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/config/impl/ParseAgentRequestMap.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/config/impl/ParseAgentRequestMap.java
@@ -123,9 +123,8 @@ public class ParseAgentRequestMap extends AbstractAgentRequestAction {
}
validate(root);
- final DDF output = new DDF("xml").structure();
+ final DDF output = new DDF().structure();
output.add(DDFSupport.fromElement(root));
-
ensureAgentRequestContext().setOutput(output);
} catch (final IOException | XMLParserException e) {
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/DecodeAgentRequest.java b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/DecodeAgentRequest.java
index dc64c2d..09cb170 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/DecodeAgentRequest.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/DecodeAgentRequest.java
@@ -28,6 +28,7 @@ import jakarta.servlet.http.HttpServletRequest;
import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.sp.context.AgentRequestContext;
import net.shibboleth.sp.ddf.DDF;
+import net.shibboleth.sp.messaging.impl.RemotedHttpServletRequest;
/**
* A profile action to decode an agent request and stash the resulting {@link DDF} in the
@@ -37,6 +38,12 @@ import net.shibboleth.sp.ddf.DDF;
* to use. The only supported type at present is "text/plain" representing a record-oriented
* syntax.</p>
*
+ * <p>An empty output message is also created and stored in the context.</p>
+ *
+ * <p>If the input message is a structure containing an "http" member, then a wrapped
+ * {@link HttpServletRequest} object backed by the input message is constructed and stored
+ * in the {@link AgentRequestContext}.</p>
+ *
* @event {@link EventIds#PROCEED_EVENT_ID}
* @event {@link EventIds#INVALID_PROFILE_CTX}
* @event {@link EventIds#INVALID_MESSAGE}
@@ -78,10 +85,21 @@ public class DecodeAgentRequest extends AbstractAgentRequestAction {
return;
}
+ final AgentRequestContext agentContext = ensureAgentRequestContext();
+
try (final InputStream in = request.getInputStream()) {
assert in != null;
final DDF msg = DDF.deserialize(in);
- ensureAgentRequestContext().setInput(msg);
+ agentContext.setInput(msg);
+
+ if (msg.isstruct()) {
+ final DDF httpreq = msg.getmember("http");
+ if (httpreq.isstruct()) {
+ log.debug("{} Wrapping tunnelled HTTP request", getLogPrefix());
+ agentContext.setWrappedHttpServletRequest(new RemotedHttpServletRequest(httpreq));
+ }
+ }
+
} catch (final IOException e) {
log.warn("{} Unable to parse input message from HttpServletRequest", getLogPrefix(), e);
ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/DoPing.java b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/DoPing.java
index 48d465c..2d05219 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/DoPing.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/DoPing.java
@@ -31,7 +31,7 @@ public class DoPing extends AbstractAgentRequestAction {
@Override
protected void doExecute(@Nonnull ProfileRequestContext profileRequestContext) {
- final DDF out = new DDF().longinteger(Instant.now().getEpochSecond());
+ final DDF out = new DDF().addmember("epoch").longinteger(Instant.now().getEpochSecond());
ensureAgentRequestContext().setOutput(out);
}
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/PrepareAgentErrorResponse.java b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/PrepareAgentErrorResponse.java
index e36307e..7c11827 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/PrepareAgentErrorResponse.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/PrepareAgentErrorResponse.java
@@ -33,6 +33,8 @@ import net.shibboleth.sp.ddf.DDF;
* A profile action to encode the current event (typically an error) into an agent response in a
* {@link AgentRequestContext}.
*
+ * <p>If no event can be identified a generic event of {@link EventIds#MESSAGE_PROC_ERROR}.</p>
+ *
* @event {@link EventIds#PROCEED_EVENT_ID}
* @event {@link EventIds#INVALID_PROFILE_CTX}
* @pre <pre>AgentRequestContext.getOutput() != null</pre>
@@ -64,26 +66,18 @@ public class PrepareAgentErrorResponse extends AbstractAgentRequestAction {
/** {@inheritDoc} */
@Override
- protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
-
- if (!super.doPreExecute(profileRequestContext)) {
- return false;
- }
-
- outputMessage = new DDF();
+ protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
+ outputMessage = new DDF().structure();
ensureAgentRequestContext().setOutput(outputMessage);
- return true;
- }
- /** {@inheritDoc} */
- @Override
- protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
final EventContext eventCtx = eventContextLookupStrategy.apply(profileRequestContext);
final Object event = eventCtx != null ? eventCtx.getEvent() : null;
if (event != null) {
final String eventString = event.toString();
- outputMessage.structure().addmember("result").string(eventString);
+ outputMessage.addmember("event").string(eventString);
+ } else {
+ outputMessage.addmember("event").string(EventIds.MESSAGE_PROC_ERROR);
}
}
diff --git a/sp-server-impl/src/test/java/net/shibboleth/sp/config/impl/ParseAgentRequestMapTest.java b/sp-server-impl/src/test/java/net/shibboleth/sp/config/impl/ParseAgentRequestMapTest.java
index aa38a65..9dbe090 100644
--- a/sp-server-impl/src/test/java/net/shibboleth/sp/config/impl/ParseAgentRequestMapTest.java
+++ b/sp-server-impl/src/test/java/net/shibboleth/sp/config/impl/ParseAgentRequestMapTest.java
@@ -30,7 +30,6 @@ import org.testng.annotations.Test;
import net.shibboleth.idp.profile.testing.ActionTestingSupport;
import net.shibboleth.shared.component.ComponentInitializationException;
-import net.shibboleth.shared.primitive.StringSupport;
import net.shibboleth.shared.spring.resource.ResourceHelper;
import net.shibboleth.shared.xml.ClasspathResolver;
import net.shibboleth.shared.xml.SchemaBuilder;
@@ -104,7 +103,6 @@ public class ParseAgentRequestMapTest extends BaseAgentRequestTest {
final DDF output = arc.getOutput();
assert output != null;
- Assert.assertEquals(output.name(), "xml");
Assert.assertTrue(output.isstruct());
Assert.assertTrue(output.getmember("RequestMap").isstruct());
Assert.assertEquals(output.getmember("RequestMap.xmlns").string(), SPConstants.SHIBSP4_REQUESTMAP_NS);
@@ -131,7 +129,6 @@ public class ParseAgentRequestMapTest extends BaseAgentRequestTest {
final DDF output = arc.getOutput();
assert output != null;
- Assert.assertEquals(output.name(), "xml");
Assert.assertTrue(output.isstruct());
Assert.assertTrue(output.getmember("RequestMap").isstruct());
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list