This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 514d127a184a75c433d0a7fa52df0be5d36faee2 Author: LanKhuat <[email protected]> AuthorDate: Wed Jul 29 17:43:05 2020 +0700 JAMES-3351 QueryParameter authentication strategy --- .../draft/methods/integration/cucumber/DownloadStepdefs.java | 12 +++++++----- .../QueryParameterAccessTokenAuthenticationStrategy.java | 8 +++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/draft/methods/integration/cucumber/DownloadStepdefs.java b/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/draft/methods/integration/cucumber/DownloadStepdefs.java index b5998c5..0dbae66 100644 --- a/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/draft/methods/integration/cucumber/DownloadStepdefs.java +++ b/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/draft/methods/integration/cucumber/DownloadStepdefs.java @@ -234,12 +234,14 @@ public class DownloadStepdefs { AttachmentAccessTokenKey key = new AttachmentAccessTokenKey(username, blobId); if (attachmentAccessTokens.containsKey(key)) { uriBuilder.addParameter("access_token", attachmentAccessTokens.get(key).serialize()); + return Request.Get(uriBuilder.build()); + } else { + Request request = Request.Get(uriBuilder.build()); + if (accessToken != null) { + request.addHeader("Authorization", accessToken.asString()); + } + return request; } - Request request = Request.Get(uriBuilder.build()); - if (accessToken != null) { - request.addHeader("Authorization", accessToken.asString()); - } - return request; } private Request queryParameterDownloadRequest(URIBuilder uriBuilder, String blobId, String username) throws URISyntaxException { diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/QueryParameterAccessTokenAuthenticationStrategy.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/QueryParameterAccessTokenAuthenticationStrategy.java index 144bf7f..7381b55 100644 --- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/QueryParameterAccessTokenAuthenticationStrategy.java +++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/http/QueryParameterAccessTokenAuthenticationStrategy.java @@ -20,6 +20,7 @@ package org.apache.james.jmap.http; import static org.apache.james.jmap.http.DownloadRoutes.BLOB_ID_PATH_PARAM; +import java.util.List; import java.util.Optional; import javax.inject.Inject; @@ -74,10 +75,11 @@ public class QueryParameterAccessTokenAuthenticationStrategy implements Authenti } private Optional<String> queryParam(String parameterName, String uri) { - return new QueryStringDecoder(uri) - .parameters() - .get(parameterName) + return Optional.ofNullable(new QueryStringDecoder(uri) + .parameters() + .get(parameterName)) .stream() + .flatMap(List::stream) .findFirst(); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
