This updates some tests for the new Builder interfaces.
2006-06-28 Casey Marshall <[EMAIL PROTECTED]> * jessie-tests/testCertificate.java: update for Builder interface and API changes. * jessie-tests/testServerHello.java: likewise. * jessie-tests/testServerKeyExchange.java: likewise. Committed.
### Eclipse Workspace Patch 1.0 #P classpath-ssl-nio Index: jessie-tests/testServerHello.java =================================================================== RCS file: /cvsroot/classpath/classpath/jessie-tests/Attic/testServerHello.java,v retrieving revision 1.1.2.2 diff -u -r1.1.2.2 testServerHello.java --- jessie-tests/testServerHello.java 11 Jun 2006 07:23:24 -0000 1.1.2.2 +++ jessie-tests/testServerHello.java 29 Jun 2006 00:35:28 -0000 @@ -7,6 +7,7 @@ import gnu.javax.net.ssl.provider.ProtocolVersion; import gnu.javax.net.ssl.provider.Random; import gnu.javax.net.ssl.provider.ServerHello; +import gnu.javax.net.ssl.provider.ServerHelloBuilder; import java.nio.ByteBuffer; import java.util.Arrays; @@ -35,7 +36,7 @@ handshake.setType (Handshake.Type.SERVER_HELLO); handshake.setLength (alloc_len - 4); - ServerHello hello = (ServerHello) handshake.body (); + ServerHelloBuilder hello = new ServerHelloBuilder(); hello.setVersion (ProtocolVersion.TLS_1); Random random = hello.random (); @@ -60,26 +61,27 @@ exts.get(1).setValue(new byte[3]); handshake.setLength (hello.length ()); + handshake.bodyBuffer().put(hello.buffer()); System.err.println (handshake); handshake = new Handshake (buffer); - hello = (ServerHello) handshake.body (); - if (Arrays.equals (sessionId, hello.sessionId ())) + ServerHello hello2 = (ServerHello) handshake.body (); + if (Arrays.equals (sessionId, hello2.sessionId ())) System.out.println ("PASS: sessionId"); else System.out.println ("FAIL: sessionId"); - if (hello.cipherSuite () == CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA) + if (hello2.cipherSuite () == CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA) System.out.println ("PASS: cipherSuite"); else System.out.println ("FAIL: cipherSuite"); - if (hello.compressionMethod () == CompressionMethod.ZLIB) + if (hello2.compressionMethod () == CompressionMethod.ZLIB) System.out.println ("PASS: compressionMethod"); else System.out.println ("FAIL: compressionMethod"); - exts = hello.extensions(); + exts = hello2.extensions(); Extension e = exts.get(0); if (e.type() == Extension.Type.MAX_FRAGMENT_LENGTH) System.out.println ("PASS: extensions().get(0).type"); @@ -107,7 +109,7 @@ handshake.setType (Handshake.Type.SERVER_HELLO); handshake.setLength (70); - hello = (ServerHello) handshake.body (); + hello = new ServerHelloBuilder(); hello.setVersion (ProtocolVersion.TLS_1); // 2 random = hello.random (); @@ -122,9 +124,11 @@ hello.setSessionId (sessionId); // + 33 hello.setCipherSuite (CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA); // + 2 hello.setCompressionMethod (CompressionMethod.ZLIB); // + 1 + handshake.setLength(hello.length()); + handshake.bodyBuffer().put(hello.buffer()); handshake = new Handshake (buffer); - hello = (ServerHello) handshake.body(); + hello2 = (ServerHello) handshake.body(); if (hello.extensions() == null) System.out.println ("PASS: hello.extensions() == null"); else Index: jessie-tests/testServerKeyExchange.java =================================================================== RCS file: /cvsroot/classpath/classpath/jessie-tests/Attic/testServerKeyExchange.java,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 testServerKeyExchange.java --- jessie-tests/testServerKeyExchange.java 3 Jun 2006 07:44:41 -0000 1.1.2.1 +++ jessie-tests/testServerKeyExchange.java 29 Jun 2006 00:35:28 -0000 @@ -1,5 +1,6 @@ import gnu.javax.net.ssl.provider.CipherSuite; import gnu.javax.net.ssl.provider.Handshake; +import gnu.javax.net.ssl.provider.ProtocolVersion; import gnu.javax.net.ssl.provider.ServerKeyExchange; import gnu.javax.net.ssl.provider.ServerRSAParams; import gnu.javax.net.ssl.provider.Signature; @@ -26,7 +27,7 @@ static void check () throws Exception { ByteBuffer buffer = ByteBuffer.allocate (1024); - Handshake handshake = new Handshake (buffer, CipherSuite.SSL_RSA_WITH_NULL_MD5); + Handshake handshake = new Handshake (buffer, CipherSuite.TLS_RSA_WITH_NULL_MD5, ProtocolVersion.TLS_1_1); handshake.setType (Handshake.Type.SERVER_KEY_EXCHANGE); handshake.setLength (1019); @@ -46,7 +47,7 @@ handshake.setLength (kex.length ()); - handshake = new Handshake (buffer, CipherSuite.SSL_RSA_WITH_NULL_MD5); + handshake = new Handshake (buffer, CipherSuite.TLS_RSA_WITH_NULL_MD5, ProtocolVersion.TLS_1_1); kex = (ServerKeyExchange) handshake.body (); params = (ServerRSAParams) kex.params (); sig = kex.signature (); Index: jessie-tests/testCertificate.java =================================================================== RCS file: /cvsroot/classpath/classpath/jessie-tests/Attic/testCertificate.java,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 testCertificate.java --- jessie-tests/testCertificate.java 3 Jun 2006 07:44:41 -0000 1.1.2.1 +++ jessie-tests/testCertificate.java 29 Jun 2006 00:35:28 -0000 @@ -1,6 +1,9 @@ +import gnu.java.security.x509.Util; import gnu.javax.net.ssl.provider.Certificate; +import gnu.javax.net.ssl.provider.CertificateBuilder; +import gnu.javax.net.ssl.provider.CertificateType; import gnu.javax.net.ssl.provider.Handshake; import java.io.ByteArrayInputStream; @@ -53,12 +56,15 @@ handshake.setType (Handshake.Type.CERTIFICATE); handshake.setLength (alloc_len - 4); - Certificate _cert = (Certificate) handshake.body (); + CertificateBuilder _cert = new CertificateBuilder(CertificateType.X509); _cert.setCertificates (Collections.singletonList (cert)); System.err.println (_cert.certificates ()); System.err.println (_cert); handshake.setLength (_cert.length ()); + handshake.bodyBuffer().put(_cert.buffer()); + System.err.println(handshake); + Handshake handshake2 = new Handshake (buffer); Certificate _cert2 = (Certificate) handshake2.body (); List certs = _cert2.certificates ();
PGP.sig
Description: This is a digitally signed message part