hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1787355 - in /httpcomponents/httpclient/branches/pull-66/httpclient/src/main/java/org/apache/http/impl/auth: CredSspScheme.java NTLMEngineImpl.java
Date Fri, 17 Mar 2017 13:04:31 GMT
Author: kwright
Date: Fri Mar 17 13:04:31 2017
New Revision: 1787355

URL: http://svn.apache.org/viewvc?rev=1787355&view=rev
Log:
Get rid of Java 7 dependency.

Modified:
    httpcomponents/httpclient/branches/pull-66/httpclient/src/main/java/org/apache/http/impl/auth/CredSspScheme.java
    httpcomponents/httpclient/branches/pull-66/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java

Modified: httpcomponents/httpclient/branches/pull-66/httpclient/src/main/java/org/apache/http/impl/auth/CredSspScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/pull-66/httpclient/src/main/java/org/apache/http/impl/auth/CredSspScheme.java?rev=1787355&r1=1787354&r2=1787355&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/pull-66/httpclient/src/main/java/org/apache/http/impl/auth/CredSspScheme.java
(original)
+++ httpcomponents/httpclient/branches/pull-66/httpclient/src/main/java/org/apache/http/impl/auth/CredSspScheme.java
Fri Mar 17 13:04:31 2017
@@ -30,7 +30,7 @@ package org.apache.http.impl.auth;
 
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
+import org.apache.http.Consts;
 import java.security.KeyManagementException;
 import java.security.NoSuchAlgorithmException;
 import java.security.PublicKey;
@@ -732,13 +732,13 @@ public class CredSspScheme extends AuthS
         final int limit = buffer.limit();
         final byte[] bytes = new byte[limit];
         buffer.get( bytes );
-        return new String(Base64.encodeBase64(bytes), StandardCharsets.US_ASCII);
+        return new String(Base64.encodeBase64(bytes), Consts.ASCII);
     }
 
 
     private ByteBuffer decodeBase64( final String inputString )
     {
-        final byte[] inputBytes = Base64.decodeBase64(inputString.getBytes(StandardCharsets.US_ASCII));
+        final byte[] inputBytes = Base64.decodeBase64(inputString.getBytes(Consts.ASCII));
         final ByteBuffer buffer = ByteBuffer.wrap( inputBytes );
         return buffer;
     }

Modified: httpcomponents/httpclient/branches/pull-66/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/pull-66/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java?rev=1787355&r1=1787354&r2=1787355&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/pull-66/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
(original)
+++ httpcomponents/httpclient/branches/pull-66/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
Fri Mar 17 13:04:31 2017
@@ -27,7 +27,7 @@
 package org.apache.http.impl.auth;
 
 import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
+import org.apache.http.Consts;
 import java.security.Key;
 import java.security.MessageDigest;
 import java.util.Arrays;
@@ -53,7 +53,7 @@ final class NTLMEngineImpl implements NT
     /** Unicode encoding */
     private static final Charset UNICODE_LITTLE_UNMARKED = Charset.forName("UnicodeLittleUnmarked");
     /** Character encoding */
-    private static final Charset DEFAULT_CHARSET = StandardCharsets.US_ASCII;
+    private static final Charset DEFAULT_CHARSET = Consts.ASCII;
 
     // Flags we use; descriptions according to:
     // http://davenport.sourceforge.net/ntlm.html
@@ -121,11 +121,11 @@ final class NTLMEngineImpl implements NT
         "session key to client-to-server sealing key magic constant");
 
     // prefix for GSS API channel binding
-    private static final byte[] MAGIC_TLS_SERVER_ENDPOINT = "tls-server-end-point:".getBytes(StandardCharsets.US_ASCII);
+    private static final byte[] MAGIC_TLS_SERVER_ENDPOINT = "tls-server-end-point:".getBytes(Consts.ASCII);
 
     private static byte[] getNullTerminatedAsciiString( final String source )
     {
-        final byte[] bytesWithoutNull = source.getBytes(StandardCharsets.US_ASCII);
+        final byte[] bytesWithoutNull = source.getBytes(Consts.ASCII);
         final byte[] target = new byte[bytesWithoutNull.length + 1];
         System.arraycopy(bytesWithoutNull, 0, target, 0, bytesWithoutNull.length);
         target[bytesWithoutNull.length] = (byte) 0x00;
@@ -663,13 +663,13 @@ final class NTLMEngineImpl implements NT
      */
     private static byte[] lmHash(final String password) throws NTLMEngineException {
         try {
-            final byte[] oemPassword = password.toUpperCase(Locale.ROOT).getBytes(StandardCharsets.US_ASCII);
+            final byte[] oemPassword = password.toUpperCase(Locale.ROOT).getBytes(Consts.ASCII);
             final int length = Math.min(oemPassword.length, 14);
             final byte[] keyBytes = new byte[14];
             System.arraycopy(oemPassword, 0, keyBytes, 0, length);
             final Key lowKey = createDESKey(keyBytes, 0);
             final Key highKey = createDESKey(keyBytes, 7);
-            final byte[] magicConstant = "KGS!@#$%".getBytes(StandardCharsets.US_ASCII);
+            final byte[] magicConstant = "KGS!@#$%".getBytes(Consts.ASCII);
             final Cipher des = Cipher.getInstance("DES/ECB/NoPadding");
             des.init(Cipher.ENCRYPT_MODE, lowKey);
             final byte[] lowHash = des.doFinal(magicConstant);
@@ -1238,7 +1238,7 @@ final class NTLMEngineImpl implements NT
          * @return The response as above.
          */
         public String getResponse() {
-            return new String(Base64.encodeBase64(getBytes()), StandardCharsets.US_ASCII);
+            return new String(Base64.encodeBase64(getBytes()), Consts.ASCII);
         }
 
         public byte[] getBytes() {



Mime
View raw message