You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "arturobernalg (via GitHub)" <gi...@apache.org> on 2023/04/23 06:50:46 UTC

[GitHub] [httpcomponents-client] arturobernalg opened a new pull request, #436: Update NTCredentials to Determine Workstation Name at Runtime

arturobernalg opened a new pull request, #436:
URL: https://github.com/apache/httpcomponents-client/pull/436

   This pull request updates the NTCredentials class to automatically determine the local workstation name at runtime or request time, in line with the underlying NTLM implementation. This improvement eliminates the need to manually provide the workstation name as a parameter, making the library easier to use and more consistent with other popular implementations, such as curl.
   
   Changes:
   
   - Deprecated the constructor with the workstation parameter in NTCredentials
   - Added a new constructor that does not require the workstation parameter
   - Implemented the getWorkstationName() method to automatically retrieve the workstation name
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] ok2c commented on pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#issuecomment-1519517445

   @michael-o We cant, but why not making it a bit easier?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] michael-o commented on pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#issuecomment-1519498087

   > @michael-o I think we can still keep `NTCredentials` even after deprecation and removal of the NTLM auth scheme. `NTCredentials` can still be useful for other user name / password based schemes.
   
   For which which require additional information beyond username and password?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] arturobernalg commented on pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#issuecomment-1518966869

   Hey @michael-o 
   Please take a look at this change to address the issue mentioned in this ticket.
    [HTTPCLIENT-1580](https://issues.apache.org/jira/browse/HTTPCLIENT-1580)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] asfgit merged pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "asfgit (via GitHub)" <gi...@apache.org>.
asfgit merged PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] michael-o commented on pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#issuecomment-1519538699

   > @michael-o We cant, but why not making it a bit easier?
   
   For me, this is a violation of separation of concerns. The format of the Basic username isn't our concern. If the client requires a specific format I would expect him to subclass the UsernamePasswordPrincipal. usecase specific code for specific usecases out of our control, I'd say.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] michael-o commented on pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#issuecomment-1519566033

   I will merge this for the sake of completeness later this day.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] michael-o commented on a diff in pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#discussion_r1174605478


##########
httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java:
##########
@@ -192,15 +217,27 @@ private static String stripDotSuffix(final String value) {
         return value;
     }
 
-    /** Convert host to standard form */
-    private static String convertHost(final String host) {
-        return stripDotSuffix(host);
-    }
-
     /** Convert domain to standard form */
     private static String convertDomain(final String domain) {
         final String returnString = stripDotSuffix(domain);
         return returnString == null ? returnString : returnString.toUpperCase(Locale.ROOT);
     }
 
+
+    /**
+     * Retrieves the workstation name of the computer originating the request.
+     * This method attempts to get the local host name using the InetAddress class.
+     * If it fails to retrieve the host name due to an UnknownHostException, it returns "localhost" as a fallback.
+     *
+     * @return The workstation name as a String.
+     */
+    private static String getWorkstationName() {
+        try {
+            final InetAddress addr = InetAddress.getLocalHost();
+            return addr.getHostName();

Review Comment:
   The this isn't right. NetBIOS predates real DNS and does not have domain names. All hostnames are unqualified.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] michael-o commented on a diff in pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#discussion_r1174606733


##########
httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java:
##########
@@ -85,25 +89,46 @@ public NTCredentials(
      * Essentially, the computer name for this machine.
      * @param domain The domain to authenticate within.
      * @param netbiosDomain The netbios version of the domain name.
+     @deprecated (5.3) Use {@link #NTCredentials(char[], String, String, String)}
      */
+    @Deprecated
     public NTCredentials(
             final String userName,
             final char[] password,
             final String workstation,
             final String domain,
             final String netbiosDomain) {
+        this(password, userName,  domain, netbiosDomain);
+    }
+
+    /**
+     * Constructor to create an instance of NTCredentials.
+     *
+     * @param password      The password to use for authentication. Must not be null.
+     * @param userName      The user name for authentication. This should not include the domain to authenticate with.
+     *                      For example: "user" is correct whereas "DOMAIN&#x5c;user" is not. Must not be null.
+     * @param domain        The domain to authenticate within. Can be null.
+     * @param netbiosDomain The netbios version of the domain name. Can be null.

Review Comment:
   Yes, but there is no correlation to the NetBIOS *domain*.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] ok2c commented on pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#issuecomment-1519538600

   @michael-o At any rate I leave it up to you whether to merge this PR or close it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] arturobernalg commented on pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#issuecomment-1526169818

   > I will merge this for the sake of completeness later this day.
   
   @michael-o ping


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] arturobernalg commented on a diff in pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on code in PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#discussion_r1174610004


##########
httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java:
##########
@@ -85,25 +89,46 @@ public NTCredentials(
      * Essentially, the computer name for this machine.
      * @param domain The domain to authenticate within.
      * @param netbiosDomain The netbios version of the domain name.
+     @deprecated (5.3) Use {@link #NTCredentials(char[], String, String, String)}
      */
+    @Deprecated
     public NTCredentials(
             final String userName,
             final char[] password,
             final String workstation,
             final String domain,
             final String netbiosDomain) {
+        this(password, userName,  domain, netbiosDomain);
+    }
+
+    /**
+     * Constructor to create an instance of NTCredentials.
+     *
+     * @param password      The password to use for authentication. Must not be null.
+     * @param userName      The user name for authentication. This should not include the domain to authenticate with.
+     *                      For example: "user" is correct whereas "DOMAIN&#x5c;user" is not. Must not be null.
+     * @param domain        The domain to authenticate within. Can be null.
+     * @param netbiosDomain The netbios version of the domain name. Can be null.

Review Comment:
   changed.



##########
httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java:
##########
@@ -192,15 +217,27 @@ private static String stripDotSuffix(final String value) {
         return value;
     }
 
-    /** Convert host to standard form */
-    private static String convertHost(final String host) {
-        return stripDotSuffix(host);
-    }
-
     /** Convert domain to standard form */
     private static String convertDomain(final String domain) {
         final String returnString = stripDotSuffix(domain);
         return returnString == null ? returnString : returnString.toUpperCase(Locale.ROOT);
     }
 
+
+    /**
+     * Retrieves the workstation name of the computer originating the request.
+     * This method attempts to get the local host name using the InetAddress class.
+     * If it fails to retrieve the host name due to an UnknownHostException, it returns "localhost" as a fallback.
+     *
+     * @return The workstation name as a String.
+     */
+    private static String getWorkstationName() {
+        try {
+            final InetAddress addr = InetAddress.getLocalHost();
+            return addr.getHostName();

Review Comment:
   updated.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] michael-o commented on a diff in pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#discussion_r1174610108


##########
httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java:
##########
@@ -192,15 +218,33 @@ private static String stripDotSuffix(final String value) {
         return value;
     }
 
-    /** Convert host to standard form */
-    private static String convertHost(final String host) {
-        return stripDotSuffix(host);
-    }
-
     /** Convert domain to standard form */
     private static String convertDomain(final String domain) {
         final String returnString = stripDotSuffix(domain);
         return returnString == null ? returnString : returnString.toUpperCase(Locale.ROOT);
     }
 
+
+    /**
+     * Retrieves the workstation name of the computer originating the request.
+     * This method attempts to get the local host name using the InetAddress class.
+     * If it fails to retrieve the host name due to an UnknownHostException, it returns "localhost" as a fallback.
+     *
+     * @return The unqualified workstation name as a String.
+     */
+    private static String getWorkstationName() {
+        try {
+            final InetAddress addr = InetAddress.getLocalHost();
+            String hostName = addr.getHostName();
+            // Ensure the hostname is unqualified by removing any domain part
+            final int dotIndex = hostName.indexOf('.');
+            if (dotIndex > 0) {
+                hostName = hostName.substring(0, dotIndex);
+            }
+            return hostName;
+        } catch (final UnknownHostException e) {
+            return "localhost";
+        }
+    }

Review Comment:
   Now this duplicates `stripDotSuffix()`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] arturobernalg commented on a diff in pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on code in PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#discussion_r1174611232


##########
httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java:
##########
@@ -192,15 +218,33 @@ private static String stripDotSuffix(final String value) {
         return value;
     }
 
-    /** Convert host to standard form */
-    private static String convertHost(final String host) {
-        return stripDotSuffix(host);
-    }
-
     /** Convert domain to standard form */
     private static String convertDomain(final String domain) {
         final String returnString = stripDotSuffix(domain);
         return returnString == null ? returnString : returnString.toUpperCase(Locale.ROOT);
     }
 
+
+    /**
+     * Retrieves the workstation name of the computer originating the request.
+     * This method attempts to get the local host name using the InetAddress class.
+     * If it fails to retrieve the host name due to an UnknownHostException, it returns "localhost" as a fallback.
+     *
+     * @return The unqualified workstation name as a String.
+     */
+    private static String getWorkstationName() {
+        try {
+            final InetAddress addr = InetAddress.getLocalHost();
+            String hostName = addr.getHostName();
+            // Ensure the hostname is unqualified by removing any domain part
+            final int dotIndex = hostName.indexOf('.');
+            if (dotIndex > 0) {
+                hostName = hostName.substring(0, dotIndex);
+            }
+            return hostName;
+        } catch (final UnknownHostException e) {
+            return "localhost";
+        }
+    }

Review Comment:
   solved



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] arturobernalg commented on a diff in pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on code in PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#discussion_r1174603179


##########
httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java:
##########
@@ -192,15 +217,27 @@ private static String stripDotSuffix(final String value) {
         return value;
     }
 
-    /** Convert host to standard form */
-    private static String convertHost(final String host) {
-        return stripDotSuffix(host);
-    }
-
     /** Convert domain to standard form */
     private static String convertDomain(final String domain) {
         final String returnString = stripDotSuffix(domain);
         return returnString == null ? returnString : returnString.toUpperCase(Locale.ROOT);
     }
 
+
+    /**
+     * Retrieves the workstation name of the computer originating the request.
+     * This method attempts to get the local host name using the InetAddress class.
+     * If it fails to retrieve the host name due to an UnknownHostException, it returns "localhost" as a fallback.
+     *
+     * @return The workstation name as a String.
+     */
+    private static String getWorkstationName() {
+        try {
+            final InetAddress addr = InetAddress.getLocalHost();
+            return addr.getHostName();

Review Comment:
   It is not guaranteed that InetAddress.getLocalHost().getHostName() will consistently return the unqualified name (i.e., the local part without the domain name). The behavior of this method can vary depending on the system configuration, and in some cases, it may return the fully qualified domain name (FQDN).
   
   An alternative approach involves using NetworkInterface.getNetworkInterfaces(), but this can potentially be more resource-intensive, which might not be ideal. However, for most use cases, relying on InetAddress.getLocalHost().getHostName() should be sufficient to obtain the unqualified hostname.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] arturobernalg commented on pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#issuecomment-1526243122

   > > > I will merge this for the sake of completeness later this day.
   > > 
   > > 
   > > @michael-o ping
   > 
   > On my list, but low priority.
   
   @michael-o  cool,
   
   In the meantime, if there is anything else within the scope of the HTTP component, I am available to help.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] michael-o commented on pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#issuecomment-1526234071

   > > I will merge this for the sake of completeness later this day.
   > 
   > @michael-o ping
   
   On my list, but low priority.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] arturobernalg commented on a diff in pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on code in PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#discussion_r1174603279


##########
httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java:
##########
@@ -85,25 +89,46 @@ public NTCredentials(
      * Essentially, the computer name for this machine.
      * @param domain The domain to authenticate within.
      * @param netbiosDomain The netbios version of the domain name.
+     @deprecated (5.3) Use {@link #NTCredentials(char[], String, String, String)}
      */
+    @Deprecated
     public NTCredentials(
             final String userName,
             final char[] password,
             final String workstation,
             final String domain,
             final String netbiosDomain) {
+        this(password, userName,  domain, netbiosDomain);
+    }
+
+    /**
+     * Constructor to create an instance of NTCredentials.
+     *
+     * @param password      The password to use for authentication. Must not be null.
+     * @param userName      The user name for authentication. This should not include the domain to authenticate with.
+     *                      For example: "user" is correct whereas "DOMAIN&#x5c;user" is not. Must not be null.
+     * @param domain        The domain to authenticate within. Can be null.
+     * @param netbiosDomain The netbios version of the domain name. Can be null.

Review Comment:
   I'm confuse here, it's exactly the same that the other class.
   
   `    * @param netbiosDomain The netbios version of the domain name.`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] ok2c commented on pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#issuecomment-1519505820

   > > @michael-o I think we can still keep `NTCredentials` even after deprecation and removal of the NTLM auth scheme. `NTCredentials` can still be useful for other user name / password based schemes.
   > 
   > For which which require additional information beyond username and password?
   
   @michael-o The user name must be properly formatted and qualified with the domain name in order for BASIC and DIGEST to work correctly with NT credentials.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] michael-o commented on a diff in pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#discussion_r1174594598


##########
httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java:
##########
@@ -192,15 +217,27 @@ private static String stripDotSuffix(final String value) {
         return value;
     }
 
-    /** Convert host to standard form */
-    private static String convertHost(final String host) {
-        return stripDotSuffix(host);
-    }
-
     /** Convert domain to standard form */
     private static String convertDomain(final String domain) {
         final String returnString = stripDotSuffix(domain);
         return returnString == null ? returnString : returnString.toUpperCase(Locale.ROOT);
     }
 
+
+    /**
+     * Retrieves the workstation name of the computer originating the request.
+     * This method attempts to get the local host name using the InetAddress class.
+     * If it fails to retrieve the host name due to an UnknownHostException, it returns "localhost" as a fallback.
+     *
+     * @return The workstation name as a String.
+     */
+    private static String getWorkstationName() {
+        try {
+            final InetAddress addr = InetAddress.getLocalHost();
+            return addr.getHostName();

Review Comment:
   Is this guaranteed to return the local part only w/o the domain name? I.e., unqualified name?



##########
httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java:
##########
@@ -85,25 +89,46 @@ public NTCredentials(
      * Essentially, the computer name for this machine.
      * @param domain The domain to authenticate within.
      * @param netbiosDomain The netbios version of the domain name.
+     @deprecated (5.3) Use {@link #NTCredentials(char[], String, String, String)}
      */
+    @Deprecated
     public NTCredentials(
             final String userName,
             final char[] password,
             final String workstation,
             final String domain,
             final String netbiosDomain) {
+        this(password, userName,  domain, netbiosDomain);
+    }
+
+    /**
+     * Constructor to create an instance of NTCredentials.
+     *
+     * @param password      The password to use for authentication. Must not be null.
+     * @param userName      The user name for authentication. This should not include the domain to authenticate with.
+     *                      For example: "user" is correct whereas "DOMAIN&#x5c;user" is not. Must not be null.
+     * @param domain        The domain to authenticate within. Can be null.
+     * @param netbiosDomain The netbios version of the domain name. Can be null.

Review Comment:
   I am confused about this description. Is it now the NetBIOS version or the domain?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] [httpcomponents-client] michael-o commented on pull request #436: Update NTCredentials to Determine Workstation Name at Runtime

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on PR #436:
URL: https://github.com/apache/httpcomponents-client/pull/436#issuecomment-1519514807

   > > > @michael-o I think we can still keep `NTCredentials` even after deprecation and removal of the NTLM auth scheme. `NTCredentials` can still be useful for other user name / password based schemes.
   > > 
   > > 
   > > For which which require additional information beyond username and password?
   > 
   > @michael-o The user name must be properly formatted and qualified with the domain name in order for BASIC and DIGEST to work correctly with NT credentials.
   
   But this does not require this principal. If your `Basic`/`Digest` username uses this format then you simply need to supply `EXAMPLE\foo`. Shit in, shit out. We transport the data, we cannot guarantee their quality.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org