[java-plugin-shibd] branch main updated: Pass Agent's charset into remoted request constructor.

Codeberg noreply at shibboleth.net
Tue Jun 9 13:22:58 UTC 2026


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

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

View the commit online:
https://codeberg.org/Shibboleth/java-plugin-shibd/commit/0d3a1e87544f94c084a325bd99c1d33a231ab9d4

The following commit(s) were added to refs/heads/main by this push:
     new 0d3a1e8  Pass Agent's charset into remoted request constructor.
0d3a1e8 is described below

commit 0d3a1e87544f94c084a325bd99c1d33a231ab9d4
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Tue Jun 9 09:22:45 2026 -0400

    Pass Agent's charset into remoted request constructor.
---
 sp-server-api/src/main/java/net/shibboleth/sp/Agent.java   |  2 +-
 .../shibboleth/sp/messaging/RemotedHttpServletRequest.java | 14 ++++++++++----
 .../net/shibboleth/sp/profile/impl/DecodeAgentRequest.java | 11 +++++++----
 3 files changed, 18 insertions(+), 9 deletions(-)

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 0065e23..bc18fbd 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
@@ -117,7 +117,7 @@ public interface Agent extends IdentifiedComponent {
     @NonNegative long getPostLimit();
     
     /**
-     * Gets the character encoding to apply during POST recovery.
+     * Gets the character encoding to apply during URI processing and POST recovery.
      * 
      * <p>Defaults to UTF-8.</p>
      * 
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/messaging/RemotedHttpServletRequest.java b/sp-server-api/src/main/java/net/shibboleth/sp/messaging/RemotedHttpServletRequest.java
index aae72ae..0ebab49 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/messaging/RemotedHttpServletRequest.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/messaging/RemotedHttpServletRequest.java
@@ -22,9 +22,11 @@ import java.io.InputStreamReader;
 import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
 import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CodingErrorAction;
 import java.nio.charset.StandardCharsets;
+import java.nio.charset.UnsupportedCharsetException;
 import java.security.Principal;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -141,7 +143,7 @@ public class RemotedHttpServletRequest implements HttpServletRequest {
     @Nullable private String reconstructedURL;
     
     /** Decoder to apply to byte array data. */
-    @Nonnull private final CharsetDecoder decoder;
+    @Nonnull private CharsetDecoder decoder;
     
     /** Cookie array. */
     @NonnullElements private List<Cookie> cookies;
@@ -192,12 +194,16 @@ public class RemotedHttpServletRequest implements HttpServletRequest {
 
     /** {@inheritDoc} */
     public String getCharacterEncoding() {
-        return StandardCharsets.UTF_8.name();
+        return decoder.charset().name();
     }
 
     /** {@inheritDoc} */
-    public void setCharacterEncoding(final String env) throws UnsupportedEncodingException {
-        throw new UnsupportedOperationException("setCharacterEncoding");
+    public void setCharacterEncoding(final String enc) throws UnsupportedEncodingException {
+        try {
+            decoder = Charset.forName(enc).newDecoder();
+        } catch (final UnsupportedCharsetException e) {
+            throw new UnsupportedEncodingException();
+        }
     }
 
     /** {@inheritDoc} */
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 bd7b67c..7f5d25e 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
@@ -29,10 +29,11 @@ import org.slf4j.MDC;
 
 import net.shibboleth.shared.annotation.constraint.NotEmpty;
 import net.shibboleth.shared.primitive.LoggerFactory;
+import net.shibboleth.sp.Agent;
 import net.shibboleth.sp.context.AgentRequestContext;
 import net.shibboleth.sp.ddf.DDF;
 import net.shibboleth.sp.messaging.RemotedHttpServletRequest;
-import net.shibboleth.sp.profile.AbstractAgentRequestAction;
+import net.shibboleth.sp.profile.AbstractAgentAction;
 import net.shibboleth.sp.profile.SPConstants;
 
 /**
@@ -50,9 +51,9 @@ import net.shibboleth.sp.profile.SPConstants;
  * @event {@link EventIds#PROCEED_EVENT_ID}
  * @event {@link EventIds#INVALID_PROFILE_CTX}
  * @event {@link EventIds#INVALID_MESSAGE}
- * @post <pre>AgentRequestContext.getInput() != null</pre>
+ * @post <pre>ProfileRequestContext.ensureSubcontext(AgentRequestContext.class).getInput() != null</pre>
  */
-public class DecodeAgentRequest extends AbstractAgentRequestAction {
+public class DecodeAgentRequest extends AbstractAgentAction {
 
     /** MDC attribute name for application ID. */
     @Nonnull @NotEmpty public static final String APPLICATION_ID_MDC_ATTRIBUTE = "sp.application_id";
@@ -105,6 +106,7 @@ public class DecodeAgentRequest extends AbstractAgentRequestAction {
             }
 
             final AgentRequestContext agentContext = ensureAgentRequestContext();
+            final Agent agent = agentContext.getAgent();
             
             try (final InputStream in = request.getInputStream()) {
                 assert in != null;
@@ -115,7 +117,8 @@ public class DecodeAgentRequest extends AbstractAgentRequestAction {
                     final DDF httpreq = msg.getmember(RemotedHttpServletRequest.STRUCTURE_NAME);
                     if (httpreq.isstruct()) {
                         log.debug("{} Wrapping tunnelled HTTP request", getLogPrefix());
-                        agentContext.setRemotedHttpServletRequest(new RemotedHttpServletRequest(httpreq));
+                        agentContext.setRemotedHttpServletRequest(new RemotedHttpServletRequest(httpreq,
+                                ensureAgent().getCharacterEncoding().newDecoder()));
                     }
                 }
                 

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


More information about the commits mailing list