You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by kw...@apache.org on 2017/03/17 15:16:22 UTC

svn commit: r1787407 - in /httpcomponents/httpclient/branches/pull-66/httpclient/src: main/java/org/apache/http/impl/auth/ test/java/org/apache/http/impl/auth/

Author: kwright
Date: Fri Mar 17 15:16:22 2017
New Revision: 1787407

URL: http://svn.apache.org/viewvc?rev=1787407&view=rev
Log:
Use Certificate instead of X509Certificate where appropriate

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
    httpcomponents/httpclient/branches/pull-66/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.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=1787407&r1=1787406&r2=1787407&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 15:16:22 2017
@@ -344,7 +344,7 @@ public class CredSspScheme extends AuthS
             type2Message = new NTLMEngineImpl.Type2Message(
                 lastReceivedTsRequest.getNegoToken());
 
-            final X509Certificate peerServerCertificate = getPeerServerCertificate();
+            final Certificate peerServerCertificate = getPeerServerCertificate();
 
             type3Message = new NTLMEngineImpl.Type3Message(
                 ntcredentials.getDomain(),
@@ -424,7 +424,7 @@ public class CredSspScheme extends AuthS
     }
 
 
-    private X509Certificate getPeerServerCertificate() throws AuthenticationException
+    private Certificate getPeerServerCertificate() throws AuthenticationException
     {
         Certificate[] peerCertificates;
         try

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=1787407&r1=1787406&r2=1787407&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 15:16:22 2017
@@ -38,7 +38,7 @@ import javax.crypto.Cipher;
 import javax.crypto.spec.SecretKeySpec;
 import java.security.NoSuchAlgorithmException;
 import java.security.cert.CertificateEncodingException;
-import java.security.cert.X509Certificate;
+import java.security.cert.Certificate;
 
 import org.apache.commons.codec.binary.Base64;
 
@@ -186,7 +186,7 @@ final class NTLMEngineImpl implements NT
      *             If the messages cannot be retrieved.
      */
     static String getResponseFor(final String message, final String username, final String password,
-            final String host, final String domain, final X509Certificate peerServerCertificate) throws NTLMEngineException {
+            final String host, final String domain, final Certificate peerServerCertificate) throws NTLMEngineException {
 
         final String response;
         if (message == null || message.trim().equals("")) {
@@ -267,7 +267,7 @@ final class NTLMEngineImpl implements NT
      */
     static String getType3Message(final String user, final String password, final String host, final String domain,
             final byte[] nonce, final int type2Flags, final String target, final byte[] targetInformation,
-            final X509Certificate peerServerCertificate, final byte[] type1Message, final byte[] type2Message)
+            final Certificate peerServerCertificate, final byte[] type1Message, final byte[] type2Message)
             throws NTLMEngineException {
         return new Type3Message(domain, host, user, password, nonce, type2Flags, target,
                 targetInformation, peerServerCertificate, type1Message, type2Message).getResponse();
@@ -1536,7 +1536,7 @@ final class NTLMEngineImpl implements NT
             final int type2Flags,
             final String target,
             final byte[] targetInformation,
-            final X509Certificate peerServerCertificate,
+            final Certificate peerServerCertificate,
             final byte[] type1Message,
             final byte[] type2Message)
             throws NTLMEngineException {
@@ -1553,7 +1553,7 @@ final class NTLMEngineImpl implements NT
             final int type2Flags,
             final String target,
             final byte[] targetInformation,
-            final X509Certificate peerServerCertificate,
+            final Certificate peerServerCertificate,
             final byte[] type1Message,
             final byte[] type2Message)
             throws NTLMEngineException {
@@ -1811,7 +1811,7 @@ final class NTLMEngineImpl implements NT
          * Looks like this is needed if we want to use exported session key for GSS wrapping.
          */
         private byte[] addGssMicAvsToTargetInfo( final byte[] originalTargetInfo,
-            final X509Certificate peerServerCertificate ) throws NTLMEngineException
+            final Certificate peerServerCertificate ) throws NTLMEngineException
         {
             final byte[] newTargetInfo = new byte[originalTargetInfo.length + 8 + 20];
             final int appendLength = originalTargetInfo.length - 4; // last tag is MSV_AV_EOL, do not copy that

Modified: httpcomponents/httpclient/branches/pull-66/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/pull-66/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.java?rev=1787407&r1=1787406&r2=1787407&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/pull-66/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.java (original)
+++ httpcomponents/httpclient/branches/pull-66/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.java Fri Mar 17 15:16:22 2017
@@ -291,6 +291,19 @@ public class TestNTLMEngineImpl {
         final CertificateFactory cf = CertificateFactory.getInstance("X.509");
 
         final Certificate cert = cf.generateCertificate(fis);
+
+        final byte[] bytes2 = new NTLMEngineImpl.Type3Message(
+            new Random(1234),
+            1234L,
+            "me", "mypassword", "myhost", "mydomain",
+            toBytes("0001020304050607"),
+            0xffffffff,
+            "mytarget",
+            toBytes("02000c0044004f004d00410049004e0001000c005300450052005600450052000400140064006f006d00610069006e002e0063006f006d00030022007300650072007600650072002e0064006f006d00610069006e002e0063006f006d0000000000"),
+            cert,
+            toBytes("4E544C4D5353500001000000018208A20C000C003800000010001000280000000501280A0000000F6D00790064006F006D00610069006E004D00590048004F0053005400"),
+            toBytes("4E544C4D5353500001000000018208A20C000C003800000010001000280000000501280A0000000F6D00790064006F006D00610069006E004D00590048004F0053005400FFFEFDFCFBFA")).getBytes();
+
         //System.out.println(cert.toString());
     }