From 30deed24005967e30b9d2a7221acb02d17a9de32 Mon Sep 17 00:00:00 2001 From: hariprasad-SAP <111269823+hariprasad-SAP@users.noreply.github.com> Date: Mon, 15 Aug 2022 13:48:28 +0530 Subject: [PATCH 1/2] For making ProtonSaslExternalImpl RFC compliant RFC-https://datatracker.ietf.org/doc/html/rfc4422#appendix-A.1 SASL External mechanism is capable of transferring an authorization identity string. The client sends the initial response to the intial challenge by the server. It can be empty or non-empty. Response is non-empty when the client is requesting to act as the identity represented by the (non-empty) string which is UTF-8 encoding of the requested authorization identity string. It is empty when the client is requesting to act as the identity the server associated with its authentication credentials. We can notice that the initial response is configured in Line 26. It is always set to EMPTY (empty byte array defined here) and cannot be configured to a custom string that we can use as identity string. Hence this library is NOT RFC compliant If we have to pass the authorization identity string to the server then we must configure the initial response of that client. --- .../io/vertx/proton/sasl/impl/ProtonSaslExternalImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/vertx/proton/sasl/impl/ProtonSaslExternalImpl.java b/src/main/java/io/vertx/proton/sasl/impl/ProtonSaslExternalImpl.java index edd3d81..ff17503 100644 --- a/src/main/java/io/vertx/proton/sasl/impl/ProtonSaslExternalImpl.java +++ b/src/main/java/io/vertx/proton/sasl/impl/ProtonSaslExternalImpl.java @@ -23,7 +23,11 @@ public class ProtonSaslExternalImpl extends ProtonSaslMechanismImpl { @Override public byte[] getInitialResponse() { - return EMPTY; + String username = getUsername(); + if(username == null || username.isEmpty()){ + return EMPTY; + } + return username.getBytes(StandardCharsets.UTF_8); } @Override From 53198c4f6a92090cec60af4d799a4775878bdfcb Mon Sep 17 00:00:00 2001 From: hariprasad-SAP <111269823+hariprasad-SAP@users.noreply.github.com> Date: Mon, 15 Aug 2022 14:17:52 +0530 Subject: [PATCH 2/2] Added the import statement for StandardCharsets --- .../java/io/vertx/proton/sasl/impl/ProtonSaslExternalImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/io/vertx/proton/sasl/impl/ProtonSaslExternalImpl.java b/src/main/java/io/vertx/proton/sasl/impl/ProtonSaslExternalImpl.java index ff17503..7178a9f 100644 --- a/src/main/java/io/vertx/proton/sasl/impl/ProtonSaslExternalImpl.java +++ b/src/main/java/io/vertx/proton/sasl/impl/ProtonSaslExternalImpl.java @@ -15,6 +15,7 @@ */ package io.vertx.proton.sasl.impl; +import java.nio.charset.StandardCharsets; import java.security.Principal; public class ProtonSaslExternalImpl extends ProtonSaslMechanismImpl {