Skip to content

Commit

Permalink
PR #11883 - remove Multipart usage from jetty-siwe
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
  • Loading branch information
lachlan-roberts committed Jun 11, 2024
1 parent 478d6aa commit abba112
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public static CompletableFuture<Parts> from(Attributes attributes, String bounda
*/
public static CompletableFuture<Parts> from(Attributes attributes, MultiPartCompliance compliance, ComplianceViolation.Listener listener, String boundary, Function<Parser, CompletableFuture<Parts>> parse)
{
CompletableFuture<Parts> futureParts = get(attributes);
@SuppressWarnings("unchecked")
CompletableFuture<Parts> futureParts = (CompletableFuture<Parts>)attributes.getAttribute(MultiPartFormData.class.getName());
if (futureParts == null)
{
futureParts = parse.apply(new Parser(boundary, compliance, listener));
Expand All @@ -107,18 +108,6 @@ public static CompletableFuture<Parts> from(Attributes attributes, MultiPartComp
return futureParts;
}

/**
* Returns {@code multipart/form-data} parts if they have already been created.
*
* @param attributes the attributes where the futureParts are tracked
* @return the future parts
*/
@SuppressWarnings("unchecked")
public static CompletableFuture<Parts> get(Attributes attributes)
{
return (CompletableFuture<Parts>)attributes.getAttribute(MultiPartFormData.class.getName());
}

/**
* <p>An ordered list of {@link MultiPart.Part}s that can
* be accessed by index or by name, or iterated over.</p>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ public boolean process(Handler handler, Response response, Callback callback) th
_requestedSessionId = requestedSession.sessionId();
ManagedSession session = requestedSession.session();

// TODO: Implement a better mechanism in core to determine if the Session ID is from a Cookie.
response.getRequest().setAttribute("org.eclipse.jetty.session.sessionIdFromCookie", requestedSession.sessionIdFromCookie());

if (session != null)
{
_session.set(session);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
Expand All @@ -30,7 +29,6 @@
import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.http.MimeTypes;
import org.eclipse.jetty.http.MultiPartFormData;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.content.ByteBufferContentSource;
import org.eclipse.jetty.security.AuthenticationState;
Expand All @@ -42,7 +40,6 @@
import org.eclipse.jetty.security.authentication.LoginAuthenticator;
import org.eclipse.jetty.security.authentication.SessionAuthentication;
import org.eclipse.jetty.server.FormFields;
import org.eclipse.jetty.server.MultiPartFormFields;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Response;
import org.eclipse.jetty.server.Session;
Expand Down Expand Up @@ -447,11 +444,14 @@ protected SignedMessage parseMessage(Request request, Response response, Callbac
}
case MULTIPART_FORM_DATA ->
{
/*
// TODO: Waiting on https://github.com/jetty/jetty.project/pull/11906
MultiPartFormFields.Config config = new MultiPartFormFields.Config(10, 1024 * 8, -1, -1, null, null);
MultiPartFormData.Parts parts = MultiPartFormFields.from(request, contentSource, config).get();

signature = parts.getFirst("signature").getContentAsString(StandardCharsets.ISO_8859_1);
message = parts.getFirst("message").getContentAsString(StandardCharsets.ISO_8859_1);
*/
throw new ServerAuthException("Unsupported mime type: " + mimeType);
}
default -> throw new ServerAuthException("Unsupported mime type: " + mimeType);
};
Expand Down

0 comments on commit abba112

Please sign in to comment.