changeset 23052:241885315119

8032473: Restructure JSSE regression test hierarchy in jdk test Reviewed-by: weijun
author xuelei
date Wed, 05 Mar 2014 07:24:34 +0000
parents 501d8479f798
children 788f0ea9a703
files jdk/test/TEST.groups jdk/test/com/sun/net/ssl/SSLSecurity/ComKeyManagerFactoryImpl.java jdk/test/com/sun/net/ssl/SSLSecurity/ComSSLContextImpl.java jdk/test/com/sun/net/ssl/SSLSecurity/ComTrustManagerFactoryImpl.java jdk/test/com/sun/net/ssl/SSLSecurity/JavaxKeyManagerFactoryImpl.java jdk/test/com/sun/net/ssl/SSLSecurity/JavaxSSLContextImpl.java jdk/test/com/sun/net/ssl/SSLSecurity/JavaxTrustManagerFactoryImpl.java jdk/test/com/sun/net/ssl/SSLSecurity/ProviderTest.java jdk/test/com/sun/net/ssl/SSLSecurity/TruncateArray.java jdk/test/javax/net/ssl/Fix5070632.java jdk/test/javax/net/ssl/FixingJavadocs/ComURLNulls.java jdk/test/javax/net/ssl/FixingJavadocs/ImplicitHandshake.java jdk/test/javax/net/ssl/FixingJavadocs/JavaxURLNulls.java jdk/test/javax/net/ssl/FixingJavadocs/KMTMGetNothing.java jdk/test/javax/net/ssl/FixingJavadocs/SSLSessionNulls.java jdk/test/javax/net/ssl/FixingJavadocs/SSLSocketInherit.java jdk/test/javax/net/ssl/GetInstance.java jdk/test/javax/net/ssl/HttpsURLConnection/CriticalSubjectAltName.java jdk/test/javax/net/ssl/HttpsURLConnection/DelayDefaultContextLoading.java jdk/test/javax/net/ssl/HttpsURLConnection/GetResponseCode.java jdk/test/javax/net/ssl/HttpsURLConnection/crisubn.jks jdk/test/javax/net/ssl/HttpsURLConnection/trusted.jks jdk/test/javax/net/ssl/README jdk/test/javax/net/ssl/SSLEngine/AcceptLargeFragments.java jdk/test/javax/net/ssl/SSLEngine/ArgCheck.java jdk/test/javax/net/ssl/SSLEngine/Arrays.java jdk/test/javax/net/ssl/SSLEngine/Basics.java jdk/test/javax/net/ssl/SSLEngine/CheckStatus.java jdk/test/javax/net/ssl/SSLEngine/ConnectionTest.java jdk/test/javax/net/ssl/SSLEngine/ExtendedKeyEngine.java jdk/test/javax/net/ssl/SSLEngine/ExtendedKeySocket.java jdk/test/javax/net/ssl/SSLEngine/LargeBufs.java jdk/test/javax/net/ssl/SSLEngine/LargePacket.java jdk/test/javax/net/ssl/SSLEngine/MyX509ExtendedKeyManager.java jdk/test/javax/net/ssl/SSLEngine/MyX509KeyManager.java jdk/test/javax/net/ssl/SSLEngine/NoAuthClientAuth.java jdk/test/javax/net/ssl/SSLEngine/SSLEngineResultArgs.java jdk/test/javax/net/ssl/SSLEngine/SSLEngineService.java jdk/test/javax/net/ssl/SSLEngine/TestAllSuites.java jdk/test/javax/net/ssl/SSLEngineResult/Deserialize.java jdk/test/javax/net/ssl/SSLParameters/UseCipherSuitesOrder.java jdk/test/javax/net/ssl/SSLServerSocket/DefaultSSLServSocketFac.java jdk/test/javax/net/ssl/SSLSession/CheckMyTrustedKeystore.java jdk/test/javax/net/ssl/SSLSession/HttpsURLConnectionLocalCertificateChain.java jdk/test/javax/net/ssl/SSLSession/JSSERenegotiate.java jdk/test/javax/net/ssl/SSLSession/KeyManagerTrustManager.java jdk/test/javax/net/ssl/SSLSession/SSLCtxAccessToSessCtx.java jdk/test/javax/net/ssl/SSLSession/SessionCacheSizeTests.java jdk/test/javax/net/ssl/SSLSession/SessionTimeOutTests.java jdk/test/javax/net/ssl/SSLSession/testEnabledProtocols.java jdk/test/javax/net/ssl/ServerName/IllegalSNIName.java jdk/test/javax/net/ssl/ServerName/SSLEngineExplorer.java jdk/test/javax/net/ssl/ServerName/SSLEngineExplorerMatchedSNI.java jdk/test/javax/net/ssl/ServerName/SSLEngineExplorerUnmatchedSNI.java jdk/test/javax/net/ssl/ServerName/SSLEngineExplorerWithCli.java jdk/test/javax/net/ssl/ServerName/SSLEngineExplorerWithSrv.java jdk/test/javax/net/ssl/ServerName/SSLSocketConsistentSNI.java jdk/test/javax/net/ssl/ServerName/SSLSocketExplorer.java jdk/test/javax/net/ssl/ServerName/SSLSocketExplorerFailure.java jdk/test/javax/net/ssl/ServerName/SSLSocketExplorerMatchedSNI.java jdk/test/javax/net/ssl/ServerName/SSLSocketExplorerUnmatchedSNI.java jdk/test/javax/net/ssl/ServerName/SSLSocketExplorerWithCliSNI.java jdk/test/javax/net/ssl/ServerName/SSLSocketExplorerWithSrvSNI.java jdk/test/javax/net/ssl/ServerName/SSLSocketInconsistentSNI.java jdk/test/javax/net/ssl/ServerName/SSLSocketSNISensitive.java jdk/test/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java jdk/test/javax/net/ssl/TLSv11/ExportableBlockCipher.java jdk/test/javax/net/ssl/TLSv11/ExportableStreamCipher.java jdk/test/javax/net/ssl/TLSv11/GenericBlockCipher.java jdk/test/javax/net/ssl/TLSv11/GenericStreamCipher.java jdk/test/javax/net/ssl/TLSv12/DisabledShortRSAKeys.java jdk/test/javax/net/ssl/TLSv12/ShortRSAKey512.java jdk/test/javax/net/ssl/TLSv12/ShortRSAKeyGCM.java jdk/test/javax/net/ssl/etc/keystore jdk/test/javax/net/ssl/etc/truststore jdk/test/javax/net/ssl/etc/unknown_keystore jdk/test/javax/net/ssl/sanity/ciphersuites/CheckCipherSuites.java jdk/test/javax/net/ssl/sanity/ciphersuites/CipherSuitesInOrder.java jdk/test/javax/net/ssl/sanity/ciphersuites/NoKerberos.java jdk/test/javax/net/ssl/sanity/interop/CipherTest.java jdk/test/javax/net/ssl/sanity/interop/ClientJSSEServerJSSE.java jdk/test/javax/net/ssl/sanity/interop/JSSEClient.java jdk/test/javax/net/ssl/sanity/interop/JSSEServer.java jdk/test/javax/net/ssl/sanity/pluggability/CheckSSLContextExport.java jdk/test/javax/net/ssl/sanity/pluggability/CheckSockFacExport1.java jdk/test/javax/net/ssl/sanity/pluggability/CheckSockFacExport2.java jdk/test/javax/net/ssl/sanity/pluggability/CipherSuites.java jdk/test/javax/net/ssl/sanity/pluggability/MySSLContextImpl.java jdk/test/javax/net/ssl/sanity/pluggability/MySSLEngineImpl.java jdk/test/javax/net/ssl/sanity/pluggability/MySSLServerSocketFacImpl.java jdk/test/javax/net/ssl/sanity/pluggability/MySSLSocketFacImpl.java jdk/test/javax/net/ssl/templates/SSLCapabilities.java jdk/test/javax/net/ssl/templates/SSLEngineTemplate.java jdk/test/javax/net/ssl/templates/SSLExplorer.java jdk/test/javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java jdk/test/javax/net/ssl/templates/SSLSocketTemplate.java jdk/test/sun/net/www/protocol/https/AbstractCallback.java jdk/test/sun/net/www/protocol/https/ChunkedOutputStream.java jdk/test/sun/net/www/protocol/https/ClosedChannelList.java jdk/test/sun/net/www/protocol/https/HttpCallback.java jdk/test/sun/net/www/protocol/https/HttpTransaction.java jdk/test/sun/net/www/protocol/https/HttpsClient/MyKeyManager.java jdk/test/sun/net/www/protocol/https/HttpsClient/OriginServer.java jdk/test/sun/net/www/protocol/https/HttpsClient/ProxyAuthTest.java jdk/test/sun/net/www/protocol/https/HttpsClient/ProxyTunnelServer.java jdk/test/sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java jdk/test/sun/net/www/protocol/https/HttpsClient/dnsstore jdk/test/sun/net/www/protocol/https/HttpsClient/ipstore jdk/test/sun/net/www/protocol/https/HttpsURLConnection/B6216082.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/B6226610.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/CheckMethods.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/CloseKeepAliveCached.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/CookieHandlerTest.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/CookieHttpsClientTest.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/DNSIdentities.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/HttpsCreateSockTest.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/HttpsPost.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/HttpsProxyStackOverflow.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/HttpsSocketFacTest.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/IPAddressDNSIdentities.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/IPAddressIPIdentities.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/Identities.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/OriginServer.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.sh jdk/test/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.sh jdk/test/sun/net/www/protocol/https/HttpsURLConnection/ProxyTunnelServer.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/ReadTimeout.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/Redirect.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/RetryHttps.java jdk/test/sun/net/www/protocol/https/HttpsURLConnection/TunnelProxy.java jdk/test/sun/net/www/protocol/https/NewImpl/ComHTTPSConnection.java jdk/test/sun/net/www/protocol/https/NewImpl/ComHostnameVerifier.java jdk/test/sun/net/www/protocol/https/NewImpl/JavaxHTTPSConnection.java jdk/test/sun/net/www/protocol/https/NewImpl/JavaxHostnameVerifier.java jdk/test/sun/net/www/protocol/https/TestHttpsServer.java jdk/test/sun/security/ssl/AppInputStream/ReadBlocksClose.java jdk/test/sun/security/ssl/AppInputStream/ReadHandshake.java jdk/test/sun/security/ssl/AppInputStream/ReadZeroBytes.java jdk/test/sun/security/ssl/AppInputStream/RemoveMarkReset.java jdk/test/sun/security/ssl/AppOutputStream/NoExceptionOnClose.java jdk/test/sun/security/ssl/CipherSuite/SSL_NULL.java jdk/test/sun/security/ssl/ClientHandshaker/CipherSuiteOrder.java jdk/test/sun/security/ssl/ClientHandshaker/RSAExport.java jdk/test/sun/security/ssl/DHKeyExchange/DHEKeySizing.java jdk/test/sun/security/ssl/EngineArgs/DebugReportsOneExtraByte.java jdk/test/sun/security/ssl/EngineArgs/DebugReportsOneExtraByte.sh jdk/test/sun/security/ssl/GenSSLConfigs/ClientThread.java jdk/test/sun/security/ssl/GenSSLConfigs/Handler.java jdk/test/sun/security/ssl/GenSSLConfigs/ServerHandler.java jdk/test/sun/security/ssl/GenSSLConfigs/ServerThread.java jdk/test/sun/security/ssl/GenSSLConfigs/TestThread.java jdk/test/sun/security/ssl/GenSSLConfigs/Traffic.java jdk/test/sun/security/ssl/GenSSLConfigs/main.java jdk/test/sun/security/ssl/HandshakeOutStream/NullCerts.java jdk/test/sun/security/ssl/InputRecord/ClientHelloRead.java jdk/test/sun/security/ssl/InputRecord/OriginServer.java jdk/test/sun/security/ssl/InputRecord/ProxyTunnelServer.java jdk/test/sun/security/ssl/InputRecord/SSLSocketTimeoutNulls.java jdk/test/sun/security/ssl/ProtocolVersion/HttpsProtocols.java jdk/test/sun/security/ssl/README jdk/test/sun/security/ssl/SSLContextImpl/BadKSProvider.java jdk/test/sun/security/ssl/SSLContextImpl/BadTSProvider.java jdk/test/sun/security/ssl/SSLContextImpl/CustomizedDefaultProtocols.java jdk/test/sun/security/ssl/SSLContextImpl/DefaultEnabledProtocols.java jdk/test/sun/security/ssl/SSLContextImpl/GoodProvider.java jdk/test/sun/security/ssl/SSLContextImpl/IllegalProtocolProperty.java jdk/test/sun/security/ssl/SSLContextImpl/MD2InTrustAnchor.java jdk/test/sun/security/ssl/SSLContextImpl/NoOldVersionContext.java jdk/test/sun/security/ssl/SSLContextImpl/NullGetAcceptedIssuers.java jdk/test/sun/security/ssl/SSLContextImpl/SSLContextVersion.java jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java jdk/test/sun/security/ssl/SSLEngineImpl/CloseEngineException.java jdk/test/sun/security/ssl/SSLEngineImpl/CloseInboundException.java jdk/test/sun/security/ssl/SSLEngineImpl/CloseStart.java jdk/test/sun/security/ssl/SSLEngineImpl/DelegatedTaskWrongException.java jdk/test/sun/security/ssl/SSLEngineImpl/EmptyExtensionData.java jdk/test/sun/security/ssl/SSLEngineImpl/EngineEnforceUseClientMode.java jdk/test/sun/security/ssl/SSLEngineImpl/RehandshakeFinished.java jdk/test/sun/security/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java jdk/test/sun/security/ssl/SSLEngineImpl/SSLEngineDeadlock.java jdk/test/sun/security/ssl/SSLSessionContextImpl/Timeout.java jdk/test/sun/security/ssl/SSLSessionImpl/HashCodeMissing.java jdk/test/sun/security/ssl/SSLSocketImpl/AsyncSSLSocketClose.java jdk/test/sun/security/ssl/SSLSocketImpl/CheckMethods.java jdk/test/sun/security/ssl/SSLSocketImpl/ClientModeClientAuth.java jdk/test/sun/security/ssl/SSLSocketImpl/ClientTimeout.java jdk/test/sun/security/ssl/SSLSocketImpl/CloseSocket.java jdk/test/sun/security/ssl/SSLSocketImpl/CloseSocketException.java jdk/test/sun/security/ssl/SSLSocketImpl/InvalidateServerSessionRenegotiate.java jdk/test/sun/security/ssl/SSLSocketImpl/LoopbackSSLSocket.java jdk/test/sun/security/ssl/SSLSocketImpl/NewSocketMethods.java jdk/test/sun/security/ssl/SSLSocketImpl/NoImpactServerRenego.java jdk/test/sun/security/ssl/SSLSocketImpl/NonAutoClose.java jdk/test/sun/security/ssl/SSLSocketImpl/NotifyHandshakeTest.java jdk/test/sun/security/ssl/SSLSocketImpl/NotifyHandshakeTest.policy jdk/test/sun/security/ssl/SSLSocketImpl/NotifyHandshakeTest.sh jdk/test/sun/security/ssl/SSLSocketImpl/NotifyHandshakeTestHeyYou.java jdk/test/sun/security/ssl/SSLSocketImpl/RejectClientRenego.java jdk/test/sun/security/ssl/SSLSocketImpl/ReuseAddr.java jdk/test/sun/security/ssl/SSLSocketImpl/ReverseNameLookup.java jdk/test/sun/security/ssl/SSLSocketImpl/SSLSocketImplThrowsWrongExceptions.java jdk/test/sun/security/ssl/SSLSocketImpl/ServerTimeout.java jdk/test/sun/security/ssl/SSLSocketImpl/SetClientMode.java jdk/test/sun/security/ssl/SSLSocketImpl/UnconnectedSocketWrongExceptions.java jdk/test/sun/security/ssl/ServerHandshaker/AnonCipherWithWantClientAuth.java jdk/test/sun/security/ssl/ServerHandshaker/GetPeerHost.java jdk/test/sun/security/ssl/ServerHandshaker/GetPeerHostClient.java jdk/test/sun/security/ssl/ServerHandshaker/GetPeerHostServer.java jdk/test/sun/security/ssl/SocketCreation/SocketCreation.java jdk/test/sun/security/ssl/X509KeyManager/NullCases.java jdk/test/sun/security/ssl/X509KeyManager/PreferredKey.java jdk/test/sun/security/ssl/X509KeyManager/SelectOneKeyOutOfMany.java jdk/test/sun/security/ssl/X509TrustManagerImpl/BasicConstraints.java jdk/test/sun/security/ssl/X509TrustManagerImpl/CertRequestOverflow.java jdk/test/sun/security/ssl/X509TrustManagerImpl/CheckNullEntity.java jdk/test/sun/security/ssl/X509TrustManagerImpl/ClientServer.java jdk/test/sun/security/ssl/X509TrustManagerImpl/ComodoHacker.java jdk/test/sun/security/ssl/X509TrustManagerImpl/PKIXExtendedTM.java jdk/test/sun/security/ssl/X509TrustManagerImpl/SelfIssuedCert.java jdk/test/sun/security/ssl/X509TrustManagerImpl/SunX509ExtendedTM.java jdk/test/sun/security/ssl/X509TrustManagerImpl/X509ExtendedTMEnabled.java jdk/test/sun/security/ssl/com/sun/net/ssl/SSLSecurity/ComKeyManagerFactoryImpl.java jdk/test/sun/security/ssl/com/sun/net/ssl/SSLSecurity/ComSSLContextImpl.java jdk/test/sun/security/ssl/com/sun/net/ssl/SSLSecurity/ComTrustManagerFactoryImpl.java jdk/test/sun/security/ssl/com/sun/net/ssl/SSLSecurity/JavaxKeyManagerFactoryImpl.java jdk/test/sun/security/ssl/com/sun/net/ssl/SSLSecurity/JavaxSSLContextImpl.java jdk/test/sun/security/ssl/com/sun/net/ssl/SSLSecurity/JavaxTrustManagerFactoryImpl.java jdk/test/sun/security/ssl/com/sun/net/ssl/SSLSecurity/ProviderTest.java jdk/test/sun/security/ssl/com/sun/net/ssl/SSLSecurity/TruncateArray.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/AppInputStream/ReadBlocksClose.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/AppInputStream/ReadHandshake.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/AppInputStream/ReadZeroBytes.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/AppInputStream/RemoveMarkReset.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/AppOutputStream/NoExceptionOnClose.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/CipherSuite/SSL_NULL.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ClientHandshaker/CipherSuiteOrder.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ClientHandshaker/RSAExport.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.sh jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/GenSSLConfigs/ClientThread.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/GenSSLConfigs/Handler.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/GenSSLConfigs/ServerHandler.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/GenSSLConfigs/ServerThread.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/GenSSLConfigs/TestThread.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/GenSSLConfigs/Traffic.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/GenSSLConfigs/main.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/HandshakeOutStream/NullCerts.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/ClientHelloRead.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/OriginServer.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/ProxyTunnelServer.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/SSLSocketTimeoutNulls.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ProtocolVersion/HttpsProtocols.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/BadKSProvider.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/BadTSProvider.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/CustomizedDefaultProtocols.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/DefaultEnabledProtocols.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/GoodProvider.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/IllegalProtocolProperty.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/MD2InTrustAnchor.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/NoOldVersionContext.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/NullGetAcceptedIssuers.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/SSLContextVersion.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLContextImpl/TrustTrustedCert.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/CloseEngineException.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/CloseInboundException.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/CloseStart.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/DelegatedTaskWrongException.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/EmptyExtensionData.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/EngineEnforceUseClientMode.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/RehandshakeFinished.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineDeadlock.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSessionContextImpl/Timeout.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSessionImpl/HashCodeMissing.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/AsyncSSLSocketClose.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/CheckMethods.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/ClientModeClientAuth.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/ClientTimeout.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/CloseSocket.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/CloseSocketException.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/InvalidateServerSessionRenegotiate.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/LoopbackSSLSocket.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NewSocketMethods.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NoImpactServerRenego.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NonAutoClose.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NotifyHandshakeTest.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NotifyHandshakeTest.policy jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NotifyHandshakeTest.sh jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NotifyHandshakeTestHeyYou.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/RejectClientRenego.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/ReuseAddr.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/ReverseNameLookup.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/SSLSocketImplThrowsWrongExceptions.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/ServerTimeout.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/SetClientMode.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/UnconnectedSocketWrongExceptions.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ServerHandshaker/AnonCipherWithWantClientAuth.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ServerHandshaker/GetPeerHost.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ServerHandshaker/GetPeerHostClient.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ServerHandshaker/GetPeerHostServer.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SocketCreation/SocketCreation.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509KeyManager/NullCases.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509KeyManager/PreferredKey.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509KeyManager/SelectOneKeyOutOfMany.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/BasicConstraints.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/CertRequestOverflow.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/CheckNullEntity.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/ClientServer.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/ComodoHacker.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/PKIXExtendedTM.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/SelfIssuedCert.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/SunX509ExtendedTM.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/X509ExtendedTMEnabled.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/rsa/BrokenRSAPrivateCrtKey.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/spi/ProviderInit.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsClient/MyKeyManager.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsClient/OriginServer.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsClient/ProxyAuthTest.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsClient/ProxyTunnelServer.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsClient/ServerIdentityTest.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsClient/dnsstore jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsClient/ipstore jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnection/CriticalSubjectAltName.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnection/GetResponseCode.java jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnection/crisubn.jks jdk/test/sun/security/ssl/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnection/trusted.jks jdk/test/sun/security/ssl/etc/keystore jdk/test/sun/security/ssl/etc/truststore jdk/test/sun/security/ssl/etc/unknown_keystore jdk/test/sun/security/ssl/javax/net/ssl/Fix5070632.java jdk/test/sun/security/ssl/javax/net/ssl/FixingJavadocs/ComURLNulls.java jdk/test/sun/security/ssl/javax/net/ssl/FixingJavadocs/ImplicitHandshake.java jdk/test/sun/security/ssl/javax/net/ssl/FixingJavadocs/JavaxURLNulls.java jdk/test/sun/security/ssl/javax/net/ssl/FixingJavadocs/KMTMGetNothing.java jdk/test/sun/security/ssl/javax/net/ssl/FixingJavadocs/SSLSessionNulls.java jdk/test/sun/security/ssl/javax/net/ssl/FixingJavadocs/SSLSocketInherit.java jdk/test/sun/security/ssl/javax/net/ssl/GetInstance.java jdk/test/sun/security/ssl/javax/net/ssl/HttpsURLConnection/DelayDefaultContextLoading.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/CheckMyTrustedKeystore.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/HttpsURLConnectionLocalCertificateChain.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/JSSERenegotiate.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/KeyManagerTrustManager.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLCtxAccessToSessCtx.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/AcceptLargeFragments.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/ArgCheck.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/Arrays.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/Basics.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/CheckStatus.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/ConnectionTest.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/ExtendedKeyEngine.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/ExtendedKeySocket.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargeBufs.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargePacket.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/MyX509ExtendedKeyManager.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/MyX509KeyManager.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/NoAuthClientAuth.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/SSLEngineResultArgs.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/SSLEngineService.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/TestAllSuites.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngineResult/Deserialize.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/testEnabledProtocols.java jdk/test/sun/security/ssl/javax/net/ssl/SSLParameters/UseCipherSuitesOrder.java jdk/test/sun/security/ssl/javax/net/ssl/SSLServerSocket/DefaultSSLServSocketFac.java jdk/test/sun/security/ssl/javax/net/ssl/ServerName/IllegalSNIName.java jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLEngineExplorer.java jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLEngineExplorerMatchedSNI.java jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLEngineExplorerUnmatchedSNI.java jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLEngineExplorerWithCli.java jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLEngineExplorerWithSrv.java jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLSocketConsistentSNI.java jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLSocketExplorer.java jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLSocketExplorerFailure.java jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLSocketExplorerMatchedSNI.java jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLSocketExplorerUnmatchedSNI.java jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLSocketExplorerWithCliSNI.java jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLSocketExplorerWithSrvSNI.java jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLSocketInconsistentSNI.java jdk/test/sun/security/ssl/javax/net/ssl/ServerName/SSLSocketSNISensitive.java jdk/test/sun/security/ssl/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java jdk/test/sun/security/ssl/javax/net/ssl/TLSv11/ExportableBlockCipher.java jdk/test/sun/security/ssl/javax/net/ssl/TLSv11/ExportableStreamCipher.java jdk/test/sun/security/ssl/javax/net/ssl/TLSv11/GenericBlockCipher.java jdk/test/sun/security/ssl/javax/net/ssl/TLSv11/GenericStreamCipher.java jdk/test/sun/security/ssl/javax/net/ssl/TLSv12/DisabledShortRSAKeys.java jdk/test/sun/security/ssl/javax/net/ssl/TLSv12/ShortRSAKey512.java jdk/test/sun/security/ssl/javax/net/ssl/TLSv12/ShortRSAKeyGCM.java jdk/test/sun/security/ssl/rsa/BrokenRSAPrivateCrtKey.java jdk/test/sun/security/ssl/sanity/ciphersuites/CheckCipherSuites.java jdk/test/sun/security/ssl/sanity/ciphersuites/CipherSuitesInOrder.java jdk/test/sun/security/ssl/sanity/ciphersuites/NoKerberos.java jdk/test/sun/security/ssl/sanity/interop/CipherTest.java jdk/test/sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java jdk/test/sun/security/ssl/sanity/interop/JSSEClient.java jdk/test/sun/security/ssl/sanity/interop/JSSEServer.java jdk/test/sun/security/ssl/sanity/pluggability/CheckSSLContextExport.java jdk/test/sun/security/ssl/sanity/pluggability/CheckSockFacExport1.java jdk/test/sun/security/ssl/sanity/pluggability/CheckSockFacExport2.java jdk/test/sun/security/ssl/sanity/pluggability/CipherSuites.java jdk/test/sun/security/ssl/sanity/pluggability/MySSLContextImpl.java jdk/test/sun/security/ssl/sanity/pluggability/MySSLEngineImpl.java jdk/test/sun/security/ssl/sanity/pluggability/MySSLServerSocketFacImpl.java jdk/test/sun/security/ssl/sanity/pluggability/MySSLSocketFacImpl.java jdk/test/sun/security/ssl/spi/ProviderInit.java jdk/test/sun/security/ssl/sun/net/www/http/ChunkedOutputStream/Test.java jdk/test/sun/security/ssl/sun/net/www/httpstest/AbstractCallback.java jdk/test/sun/security/ssl/sun/net/www/httpstest/ClosedChannelList.java jdk/test/sun/security/ssl/sun/net/www/httpstest/HttpCallback.java jdk/test/sun/security/ssl/sun/net/www/httpstest/HttpTransaction.java jdk/test/sun/security/ssl/sun/net/www/httpstest/TestHttpsServer.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/B6216082.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/B6226610.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/CheckMethods.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/CloseKeepAliveCached.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/CookieHandlerTest.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/CookieHttpsClientTest.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/DNSIdentities.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/HttpsCreateSockTest.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/HttpsPost.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/HttpsProxyStackOverflow.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/HttpsSocketFacTest.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/IPAddressDNSIdentities.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/IPAddressIPIdentities.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/Identities.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/OriginServer.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.sh jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.sh jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/ProxyTunnelServer.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/ReadTimeout.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/Redirect.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/RetryHttps.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/TunnelProxy.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/NewImpl/ComHTTPSConnection.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/NewImpl/ComHostnameVerifier.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/NewImpl/JavaxHTTPSConnection.java jdk/test/sun/security/ssl/sun/net/www/protocol/https/NewImpl/JavaxHostnameVerifier.java jdk/test/sun/security/ssl/templates/SSLCapabilities.java jdk/test/sun/security/ssl/templates/SSLEngineTemplate.java jdk/test/sun/security/ssl/templates/SSLExplorer.java jdk/test/sun/security/ssl/templates/SSLSocketSSLEngineTemplate.java jdk/test/sun/security/ssl/templates/SSLSocketTemplate.java
diffstat 449 files changed, 60531 insertions(+), 60527 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/test/TEST.groups	Tue Mar 04 18:32:27 2014 -0800
+++ b/jdk/test/TEST.groups	Wed Mar 05 07:24:34 2014 +0000
@@ -101,7 +101,7 @@
 
 jdk_net = \
     java/net \
-    com/sun/net \
+    com/sun/net/httpserver \
     com/oracle/net \
     sun/net
 
@@ -126,6 +126,9 @@
     com/sun/security \
     com/sun/org/apache/xml/internal/security \
     sun/security \
+    javax/net \
+    sun/net/www/protocol/https \
+    com/sun/net/ssl \
     lib/security
 
 jdk_security = \
@@ -489,7 +492,7 @@
   sun/security/provider/PolicyFile/Alias.java \
   sun/security/provider/PolicyFile/Comparator.java \
   sun/security/provider/PolicyFile/SelfWildcard.java \
-  sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineDeadlock.java \
+  sun/security/ssl/SSLEngineImpl/SSLEngineDeadlock.java \
   sun/security/util/Oid/OidFormat.java \
   sun/security/util/Resources/Format.java \
   sun/security/util/Resources/NewNamesFormat.java
@@ -587,8 +590,8 @@
   java/util/zip/ZipFile/DeleteTempJar.java \
   javax/crypto/Cipher/CipherStreamClose.java \
   sun/misc/URLClassPath/ClassnameCharTest.java \
-  sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/HttpsCreateSockTest.java \
-  sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/HttpsSocketFacTest.java 
+  sun/net/www/protocol/https/HttpsURLConnection/HttpsCreateSockTest.java \
+  sun/net/www/protocol/https/HttpsURLConnection/HttpsSocketFacTest.java 
 
 # Compact 1 adds full VM tests
 #
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/net/ssl/SSLSecurity/ComKeyManagerFactoryImpl.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.security.*;
+import com.sun.net.ssl.*;
+
+public class ComKeyManagerFactoryImpl extends KeyManagerFactorySpi {
+
+    public ComKeyManagerFactoryImpl() {
+        System.out.println("ComKeyManagerFactoryImpl initialized");
+    }
+
+    protected void engineInit(KeyStore ks, char [] password)
+            throws KeyStoreException {
+        System.out.println("ComKeyManagerFactoryImpl init'd");
+    }
+
+    protected KeyManager[] engineGetKeyManagers()  {
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/net/ssl/SSLSecurity/ComSSLContextImpl.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.security.*;
+import com.sun.net.ssl.*;
+
+public class ComSSLContextImpl extends SSLContextSpi {
+
+    public ComSSLContextImpl() {
+        System.out.println("ComSSLContextImpl initialized");
+    }
+
+    protected void engineInit(KeyManager[] km,
+           TrustManager[] tm, SecureRandom sr) throws KeyManagementException {
+        System.out.println("ComSSLContextImpl init'd");
+    }
+
+    protected javax.net.ssl.SSLSocketFactory engineGetSocketFactory() {
+        return null;
+    }
+
+    protected javax.net.ssl.SSLServerSocketFactory
+            engineGetServerSocketFactory() {
+        return null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/net/ssl/SSLSecurity/ComTrustManagerFactoryImpl.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.security.*;
+import com.sun.net.ssl.*;
+
+public class ComTrustManagerFactoryImpl extends TrustManagerFactorySpi {
+
+    public ComTrustManagerFactoryImpl() {
+        System.out.println("ComTrustManagerFactoryImpl initialized");
+    }
+
+    protected void engineInit(KeyStore ks) throws KeyStoreException {
+        System.out.println("ComTrustManagerFactoryImpl init'd");
+    }
+
+    protected TrustManager[] engineGetTrustManagers()  {
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/net/ssl/SSLSecurity/JavaxKeyManagerFactoryImpl.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.security.*;
+import javax.net.ssl.*;
+
+public class JavaxKeyManagerFactoryImpl extends KeyManagerFactorySpi {
+
+    public JavaxKeyManagerFactoryImpl () {
+        System.out.println("JavaxKeyManagerFactoryImpl initialized");
+    }
+
+    protected void engineInit(KeyStore ks, char[] passwd)
+            throws KeyStoreException {
+        System.out.println("JavaxKeyManagerFactoryImpl init'd");
+    }
+
+    protected void engineInit(ManagerFactoryParameters spec)
+            throws InvalidAlgorithmParameterException {
+    }
+
+    protected KeyManager[] engineGetKeyManagers() {
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/net/ssl/SSLSecurity/JavaxSSLContextImpl.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.security.*;
+import javax.net.ssl.*;
+
+public class JavaxSSLContextImpl extends SSLContextSpi {
+
+    public JavaxSSLContextImpl() {
+        System.out.println("JavaxSSLContextImpl initialized");
+    }
+
+    protected void engineInit(KeyManager[] km,
+           TrustManager[] tm, SecureRandom sr) throws KeyManagementException {
+        System.out.println("JavaxSSLContextImpl init'd");
+    }
+
+    protected SSLEngine engineCreateSSLEngine() {
+        return null;
+    }
+
+    protected SSLEngine engineCreateSSLEngine(String host, int port) {
+        return null;
+    }
+
+    protected SSLSocketFactory engineGetSocketFactory() {
+        return null;
+    }
+
+    protected SSLServerSocketFactory engineGetServerSocketFactory() {
+        return null;
+    }
+
+    protected SSLSessionContext engineGetServerSessionContext() {
+        return null;
+    }
+
+    protected SSLSessionContext engineGetClientSessionContext() {
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/net/ssl/SSLSecurity/JavaxTrustManagerFactoryImpl.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.security.*;
+import javax.net.ssl.*;
+
+public class JavaxTrustManagerFactoryImpl extends TrustManagerFactorySpi {
+
+    public JavaxTrustManagerFactoryImpl () {
+        System.out.println("JavaxTrustManagerFactoryImpl initialized");
+    }
+
+    protected void engineInit(KeyStore ks) throws KeyStoreException {
+        System.out.println("JavaxTrustManagerFactoryImpl init'd");
+    }
+
+    protected void engineInit(ManagerFactoryParameters spec)
+            throws InvalidAlgorithmParameterException {
+    }
+
+    protected TrustManager[] engineGetTrustManagers() {
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/net/ssl/SSLSecurity/ProviderTest.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4667976
+ * @compile JavaxSSLContextImpl.java ComSSLContextImpl.java
+ *      JavaxTrustManagerFactoryImpl.java ComTrustManagerFactoryImpl.java
+ *      JavaxKeyManagerFactoryImpl.java ComKeyManagerFactoryImpl.java
+ * @run main/othervm ProviderTest
+ * @summary brokenness in the com.sun.net.ssl.SSLSecurity wrappers
+ */
+
+import java.security.*;
+import com.sun.net.ssl.*;
+
+public class ProviderTest {
+
+    public static void main(String args[]) throws Exception {
+        SSLContext sslc;
+        TrustManagerFactory tmf;
+        KeyManagerFactory kmf;
+
+        Provider extraProvider = new MyProvider();
+        Security.addProvider(extraProvider);
+        try {
+            System.out.println("getting a javax SSLContext");
+            sslc = SSLContext.getInstance("javax");
+            sslc.init(null, null, null);
+            System.out.println("\ngetting a com SSLContext");
+            sslc = SSLContext.getInstance("com");
+            sslc.init(null, null, null);
+
+            System.out.println("\ngetting a javax TrustManagerFactory");
+            tmf = TrustManagerFactory.getInstance("javax");
+            tmf.init((KeyStore) null);
+            System.out.println("\ngetting a com TrustManagerFactory");
+            tmf = TrustManagerFactory.getInstance("com");
+            tmf.init((KeyStore) null);
+
+            System.out.println("\ngetting a javax KeyManagerFactory");
+            kmf = KeyManagerFactory.getInstance("javax");
+            kmf.init((KeyStore) null, null);
+            System.out.println("\ngetting a com KeyManagerFactory");
+            kmf = KeyManagerFactory.getInstance("com");
+            kmf.init((KeyStore) null, null);
+        } finally {
+            Security.removeProvider(extraProvider.getName());
+        }
+    }
+}
+
+class MyProvider extends Provider {
+
+    private static String info = "Brad's provider";
+
+    /**
+     * Installs the JSSE provider.
+     */
+    public static synchronized void install()
+    {
+        /* nop. Remove this method in the future. */
+    }
+
+    public MyProvider()
+    {
+        super("BRAD", 1.0, info);
+
+        AccessController.doPrivileged(new java.security.PrivilegedAction() {
+            public Object run() {
+
+                put("SSLContext.javax", "JavaxSSLContextImpl");
+                put("SSLContext.com",   "ComSSLContextImpl");
+                put("TrustManagerFactory.javax",
+                                        "JavaxTrustManagerFactoryImpl");
+                put("TrustManagerFactory.com",
+                                        "ComTrustManagerFactoryImpl");
+                put("KeyManagerFactory.javax",
+                                        "JavaxKeyManagerFactoryImpl");
+                put("KeyManagerFactory.com",
+                                        "ComKeyManagerFactoryImpl");
+
+                return null;
+            }
+        });
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/net/ssl/SSLSecurity/TruncateArray.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4665824
+ * @summary JSSE - ClassCastException with 1.4
+ */
+
+import com.sun.net.ssl.*;
+
+public class TruncateArray {
+
+    public static void main(String args[]) throws Exception {
+        try {
+
+            TrustManager tms [] = new TrustManager [] {
+                new MyTM(), new MyTM(), new MyTM() };
+
+            KeyManager kms [] = new KeyManager [] {
+                new MyKM(), new MyKM(), new MyKM() };
+
+            SSLContext ctx = SSLContext.getInstance("TLS");
+            ctx.init(kms, tms, null);
+
+            KeyManagerFactory kmf = KeyManagerFactory.getInstance("SUNX509");
+            KeyManager[] km = kmf.getKeyManagers();
+
+            TrustManagerFactory tmf =
+                TrustManagerFactory.getInstance("SUNX509");
+            TrustManager[] tm = tmf.getTrustManagers();
+
+        } catch (ClassCastException e) {
+            throw e;
+        } catch (Throwable e) {
+            /*
+             * swallow anything else, we only are interested
+             * in class casting errors here.  For example, we soon
+             * may be catching methods called on uninitialized factories.
+             */
+            System.out.println("Caught something else");
+            e.printStackTrace();
+        }
+    }
+
+    static class MyTM implements TrustManager {
+    }
+
+    static class MyKM implements KeyManager {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/Fix5070632.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 5070632
+ * @summary Default SSLSockeFactory override createSocket() now
+ * @run main/othervm Fix5070632
+ *
+ *     SunJSSE does not support dynamic system properties, no way to re-use
+ *     system properties in samevm/agentvm mode.
+ * @author Weijun Wang
+ */
+
+import javax.net.ssl.SSLSocketFactory;
+import java.net.SocketException;
+import javax.net.SocketFactory;
+import java.security.*;
+
+public class Fix5070632 {
+    public static void main(String[] args) throws Exception {
+        // reserve the security properties
+        String reservedSFacProvider =
+            Security.getProperty("ssl.SocketFactory.provider");
+
+        // use a non-existing provider so that the DefaultSSLSocketFactory
+        // will be used, and then test against it.
+
+        Security.setProperty("ssl.SocketFactory.provider", "foo.NonExistant");
+        SSLSocketFactory fac = (SSLSocketFactory)SSLSocketFactory.getDefault();
+        try {
+            fac.createSocket();
+        } catch(SocketException se) {
+            // if exception caught, then it's ok
+            System.out.println("Throw SocketException");
+            se.printStackTrace();
+            return;
+        } finally {
+            // restore the security properties
+            if (reservedSFacProvider == null) {
+                reservedSFacProvider = "";
+            }
+            Security.setProperty("ssl.SocketFactory.provider",
+                                                reservedSFacProvider);
+        }
+
+        // if not caught, or other exception caught, then it's error
+        throw new Exception("should throw SocketException");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/FixingJavadocs/ComURLNulls.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4387882 4451038
+ * @summary Need to revisit the javadocs for JSSE, especially the
+ *      promoted classes, and HttpsURLConnection.getCipherSuite throws
+ *      NullPointerException
+ * @run main/othervm ComURLNulls
+ *
+ *     SunJSSE does not support dynamic system properties, no way to re-use
+ *     system properties in samevm/agentvm mode.
+ * @author Brad Wetmore
+ */
+
+import java.net.*;
+import java.io.*;
+import javax.net.ssl.*;
+import com.sun.net.ssl.HttpsURLConnection;
+import com.sun.net.ssl.HostnameVerifier;
+
+/*
+ * Tests that the com null argument changes made it in ok.
+ */
+
+public class ComURLNulls {
+
+    public static void main(String[] args) throws Exception {
+        HostnameVerifier reservedHV =
+            HttpsURLConnection.getDefaultHostnameVerifier();
+        try {
+            System.setProperty("java.protocol.handler.pkgs",
+                                    "com.sun.net.ssl.internal.www.protocol");
+            /**
+             * This test does not establish any connection to the specified
+             * URL, hence a dummy URL is used.
+             */
+            URL foobar = new URL("https://example.com/");
+
+            HttpsURLConnection urlc =
+                (HttpsURLConnection) foobar.openConnection();
+
+            try {
+                urlc.getCipherSuite();
+            } catch (IllegalStateException e) {
+                System.out.print("Caught proper exception: ");
+                System.out.println(e.getMessage());
+            }
+
+            try {
+                urlc.getServerCertificateChain();
+            } catch (IllegalStateException e) {
+                System.out.print("Caught proper exception: ");
+                System.out.println(e.getMessage());
+            }
+
+            try {
+                urlc.setDefaultHostnameVerifier(null);
+            } catch (IllegalArgumentException e) {
+                System.out.print("Caught proper exception: ");
+                System.out.println(e.getMessage());
+            }
+
+            try {
+                urlc.setHostnameVerifier(null);
+            } catch (IllegalArgumentException e) {
+                System.out.print("Caught proper exception: ");
+                System.out.println(e.getMessage());
+            }
+
+            try {
+                urlc.setDefaultSSLSocketFactory(null);
+            } catch (IllegalArgumentException e) {
+                System.out.print("Caught proper exception: ");
+                System.out.println(e.getMessage());
+            }
+
+            try {
+                urlc.setSSLSocketFactory(null);
+            } catch (IllegalArgumentException e) {
+                System.out.print("Caught proper exception");
+                System.out.println(e.getMessage());
+            }
+            System.out.println("TESTS PASSED");
+        } finally {
+            HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/FixingJavadocs/ImplicitHandshake.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,295 @@
+/*
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4387882
+ * @summary Need to revisit the javadocs for JSSE, especially the
+ *      promoted classes.
+ * @run main/othervm ImplicitHandshake
+ *
+ *     SunJSSE does not support dynamic system properties, no way to re-use
+ *     system properties in samevm/agentvm mode.
+ * @author Brad Wetmore
+ */
+
+import java.io.*;
+import java.net.*;
+import javax.net.ssl.*;
+
+public class ImplicitHandshake {
+
+    /*
+     * =============================================================
+     * Set the various variables needed for the tests, then
+     * specify what tests to run on each side.
+     */
+
+    /*
+     * Should we run the client or server in a separate thread?
+     * Both sides can throw exceptions, but do you have a preference
+     * as to which side should be the main thread.
+     */
+    static boolean separateServerThread = true;
+
+    /*
+     * Where do we find the keystores?
+     */
+    static String pathToStores = "../etc";
+    static String keyStoreFile = "keystore";
+    static String trustStoreFile = "truststore";
+    static String passwd = "passphrase";
+
+    /*
+     * Is the server ready to serve?
+     */
+    volatile static boolean serverReady = false;
+
+    /*
+     * Turn on SSL debugging?
+     */
+    static boolean debug = false;
+
+    /*
+     * If the client or server is doing some kind of object creation
+     * that the other side depends on, and that thread prematurely
+     * exits, you may experience a hang.  The test harness will
+     * terminate all hung threads after its timeout has expired,
+     * currently 3 minutes by default, but you might try to be
+     * smart about it....
+     */
+
+    /*
+     * Define the server side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doServerSide() throws Exception {
+        SSLServerSocketFactory sslssf =
+            (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
+        SSLServerSocket sslServerSocket =
+            (SSLServerSocket) sslssf.createServerSocket(serverPort);
+        serverPort = sslServerSocket.getLocalPort();
+
+        /*
+         * Signal Client, we're ready for his connect.
+         */
+        serverReady = true;
+
+        SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
+
+        /*
+         * For grins, let's mix it up here, to make sure you
+         * can have a server really be a client.  Don't think
+         * we have a test that does this yet.
+         */
+        sslSocket.setUseClientMode(true);
+
+        InputStream sslIS = sslSocket.getInputStream();
+        OutputStream sslOS = sslSocket.getOutputStream();
+
+        sslIS.read();
+        sslOS.write(85);
+        sslOS.flush();
+
+        sslSocket.close();
+    }
+
+    /*
+     * Define the client side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doClientSide() throws Exception {
+
+        /*
+         * Wait for server to get started.
+         */
+        while (!serverReady) {
+            Thread.sleep(50);
+        }
+
+        SSLSocketFactory sslsf =
+            (SSLSocketFactory) SSLSocketFactory.getDefault();
+        SSLSocket sslSocket = (SSLSocket)
+            sslsf.createSocket("localhost", serverPort);
+
+        /*
+         * This is bogus, we should no longer get an tho...
+         */
+        sslSocket.setUseClientMode(true);
+        sslSocket.setNeedClientAuth(true);
+
+        /*
+         * For grins, let's mix it up here, to make sure you
+         * can have a client really be a server.  Don't think
+         * we have a test that does this yet.
+         */
+        sslSocket.setUseClientMode(false);
+
+        System.out.println("Using Implicit handshake, ciphersuite is: " +
+            sslSocket.getSession().getCipherSuite());
+
+        InputStream sslIS = sslSocket.getInputStream();
+        OutputStream sslOS = sslSocket.getOutputStream();
+
+        sslOS.write(280);
+        sslOS.flush();
+        sslIS.read();
+
+        /*
+         * Lastly, checking that you can't change modes once you've
+         * started/completed handshaking.
+         */
+        try {
+            sslSocket.setUseClientMode(true);
+        } catch (IllegalArgumentException e) {
+            System.out.println("Caught proper exception");
+        }
+
+        sslSocket.close();
+    }
+
+    /*
+     * =============================================================
+     * The remainder is just support stuff
+     */
+
+    // use any free port by default
+    volatile int serverPort = 0;
+
+    volatile Exception serverException = null;
+    volatile Exception clientException = null;
+
+    public static void main(String[] args) throws Exception {
+        String keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+        String trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+        System.setProperty("javax.net.ssl.keyStore", keyFilename);
+        System.setProperty("javax.net.ssl.keyStorePassword", passwd);
+        System.setProperty("javax.net.ssl.trustStore", trustFilename);
+        System.setProperty("javax.net.ssl.trustStorePassword", passwd);
+
+        if (debug)
+            System.setProperty("javax.net.debug", "all");
+
+        /*
+         * Start the tests.
+         */
+        new ImplicitHandshake();
+    }
+
+    Thread clientThread = null;
+    Thread serverThread = null;
+
+    /*
+     * Primary constructor, used to drive remainder of the test.
+     *
+     * Fork off the other side, then do your work.
+     */
+    ImplicitHandshake() throws Exception {
+        if (separateServerThread) {
+            startServer(true);
+            startClient(false);
+        } else {
+            startClient(true);
+            startServer(false);
+        }
+
+        /*
+         * Wait for other side to close down.
+         */
+        if (separateServerThread) {
+            serverThread.join();
+        } else {
+            clientThread.join();
+        }
+
+        /*
+         * When we get here, the test is pretty much over.
+         *
+         * If the main thread excepted, that propagates back
+         * immediately.  If the other thread threw an exception, we
+         * should report back.
+         */
+        if (serverException != null) {
+            System.out.print("Server Exception:");
+            throw serverException;
+        }
+        if (clientException != null) {
+            System.out.print("Client Exception:");
+            throw clientException;
+        }
+    }
+
+    void startServer(boolean newThread) throws Exception {
+        if (newThread) {
+            serverThread = new Thread() {
+                public void run() {
+                    try {
+                        doServerSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our server thread just died.
+                         *
+                         * Release the client, if not active already...
+                         */
+                        System.err.println("Server died...");
+                        serverReady = true;
+                        serverException = e;
+                    }
+                }
+            };
+            serverThread.start();
+        } else {
+            doServerSide();
+        }
+    }
+
+    void startClient(boolean newThread) throws Exception {
+        if (newThread) {
+            clientThread = new Thread() {
+                public void run() {
+                    try {
+                        doClientSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our client thread just died.
+                         */
+                        System.err.println("Client died...");
+                        clientException = e;
+                    }
+                }
+            };
+            clientThread.start();
+        } else {
+            doClientSide();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/FixingJavadocs/JavaxURLNulls.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4387882
+ * @summary Need to revisit the javadocs for JSSE, especially the
+ *      promoted classes
+ * @author Brad Wetmore
+ */
+
+import java.net.*;
+import java.io.*;
+import javax.net.ssl.*;
+
+
+/*
+ * Tests that the javax null argument changes made it in ok.
+ */
+
+public class JavaxURLNulls {
+
+    public static void main(String[] args) throws Exception {
+
+        HostnameVerifier reservedHV =
+            HttpsURLConnection.getDefaultHostnameVerifier();
+        try {
+            /**
+             * This test does not establish any connection to the specified
+             * URL, hence a dummy URL is used.
+             */
+            URL foobar = new URL("https://example.com/");
+
+            HttpsURLConnection urlc =
+                (HttpsURLConnection) foobar.openConnection();
+
+            try {
+                urlc.getCipherSuite();
+            } catch (IllegalStateException e) {
+                System.out.print("Caught proper exception: ");
+                System.out.println(e.getMessage());
+            }
+
+            try {
+                urlc.getLocalCertificates();
+            } catch (IllegalStateException e) {
+                System.out.print("Caught proper exception: ");
+                System.out.println(e.getMessage());
+            }
+
+            try {
+                urlc.getServerCertificates();
+            } catch (IllegalStateException e) {
+                System.out.print("Caught proper exception: ");
+                System.out.println(e.getMessage());
+            }
+
+            try {
+                urlc.setDefaultHostnameVerifier(null);
+            } catch (IllegalArgumentException e) {
+                System.out.print("Caught proper exception: ");
+                System.out.println(e.getMessage());
+            }
+
+            try {
+                urlc.setHostnameVerifier(null);
+            } catch (IllegalArgumentException e) {
+                System.out.print("Caught proper exception: ");
+                System.out.println(e.getMessage());
+            }
+
+            try {
+                urlc.setDefaultSSLSocketFactory(null);
+            } catch (IllegalArgumentException e) {
+                System.out.print("Caught proper exception: ");
+                System.out.println(e.getMessage());
+            }
+
+            try {
+                urlc.setSSLSocketFactory(null);
+            } catch (IllegalArgumentException e) {
+                System.out.print("Caught proper exception: ");
+                System.out.println(e.getMessage());
+            }
+            System.out.println("TESTS PASSED");
+        } finally {
+            HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/FixingJavadocs/KMTMGetNothing.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4387882
+ * @summary Need to revisit the javadocs for JSSE, especially the
+ *      promoted classes
+ * @author Brad Wetmore
+ */
+
+import java.net.*;
+import java.io.*;
+import javax.net.ssl.*;
+import java.security.*;
+
+
+/*
+ * Tests that the null argument changes made it in ok.
+ */
+
+public class KMTMGetNothing {
+
+    KMTMGetNothing() throws Exception {
+        char[] passphrase = "none".toCharArray();
+        KeyStore ks = KeyStore.getInstance("JKS");
+        ks.load(null, passphrase);
+
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+        kmf.init(ks, passphrase);
+
+        X509KeyManager km = (X509KeyManager) kmf.getKeyManagers()[0];
+
+        if (km.getCertificateChain(null) != null) {
+            throw new Exception("km.getCertificateChain(null) != null");
+        }
+
+        if (km.getCertificateChain("fubar") != null) {
+            throw new Exception("km.getCertificateChain(\"fubar\") != null");
+        }
+
+        if (km.getPrivateKey(null) != null) {
+            throw new Exception("km.getPrivateKey(null) != null");
+        }
+
+        if (km.getPrivateKey("fubar") != null) {
+            throw new Exception("km.getPrivateKey(\"fubar\") != null");
+        }
+        System.out.println("KM TESTS PASSED");
+
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+        tmf.init(ks);
+
+        X509TrustManager tm = (X509TrustManager) tmf.getTrustManagers()[0];
+
+        if ((tm.getAcceptedIssuers() == null) ||
+                (tm.getAcceptedIssuers().length != 0)) {
+            throw new Exception("tm.getAcceptedIssuers() != null");
+        }
+        System.out.println("TM TESTS PASSED");
+
+        System.out.println("ALL TESTS PASSED");
+    }
+
+    public static void main(String[] args) throws Exception {
+        new KMTMGetNothing();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/FixingJavadocs/SSLSessionNulls.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,290 @@
+/*
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4387882
+ * @summary Need to revisit the javadocs for JSSE, especially the
+ *      promoted classes.
+ * @run main/othervm SSLSessionNulls
+ *
+ *     SunJSSE does not support dynamic system properties, no way to re-use
+ *     system properties in samevm/agentvm mode.
+ * @author Brad Wetmore
+ */
+
+import java.io.*;
+import java.net.*;
+import javax.net.ssl.*;
+
+public class SSLSessionNulls {
+
+    /*
+     * =============================================================
+     * Set the various variables needed for the tests, then
+     * specify what tests to run on each side.
+     */
+
+    /*
+     * Should we run the client or server in a separate thread?
+     * Both sides can throw exceptions, but do you have a preference
+     * as to which side should be the main thread.
+     */
+    static boolean separateServerThread = true;
+
+    /*
+     * Where do we find the keystores?
+     */
+    static String pathToStores = "../etc";
+    static String keyStoreFile = "keystore";
+    static String trustStoreFile = "truststore";
+    static String passwd = "passphrase";
+
+    /*
+     * Is the server ready to serve?
+     */
+    volatile static boolean serverReady = false;
+
+    /*
+     * Turn on SSL debugging?
+     */
+    static boolean debug = false;
+
+    /*
+     * If the client or server is doing some kind of object creation
+     * that the other side depends on, and that thread prematurely
+     * exits, you may experience a hang.  The test harness will
+     * terminate all hung threads after its timeout has expired,
+     * currently 3 minutes by default, but you might try to be
+     * smart about it....
+     */
+
+    /*
+     * Define the server side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doServerSide() throws Exception {
+        SSLServerSocketFactory sslssf =
+            (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
+        SSLServerSocket sslServerSocket =
+            (SSLServerSocket) sslssf.createServerSocket(serverPort);
+        serverPort = sslServerSocket.getLocalPort();
+
+        /*
+         * Signal Client, we're ready for his connect.
+         */
+        serverReady = true;
+
+        SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
+        InputStream sslIS = sslSocket.getInputStream();
+        OutputStream sslOS = sslSocket.getOutputStream();
+
+        sslIS.read();
+        sslOS.write(85);
+        sslOS.flush();
+
+        sslSocket.close();
+    }
+
+    /*
+     * Define the client side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doClientSide() throws Exception {
+
+        /*
+         * Wait for server to get started.
+         */
+        while (!serverReady) {
+            Thread.sleep(50);
+        }
+
+        SSLSocketFactory sslsf =
+            (SSLSocketFactory) SSLSocketFactory.getDefault();
+        SSLSocket sslSocket = (SSLSocket)
+            sslsf.createSocket("localhost", serverPort);
+
+        InputStream sslIS = sslSocket.getInputStream();
+        OutputStream sslOS = sslSocket.getOutputStream();
+
+        sslOS.write(280);
+        sslOS.flush();
+        sslIS.read();
+
+        SSLSession sslSession = sslSocket.getSession();
+
+        try {
+            sslSession.getValue(null);
+        } catch (IllegalArgumentException e) {
+            System.out.print("Caught proper exception: ");
+            System.out.println(e.getMessage());
+        }
+
+        try {
+            sslSession.putValue(null, null);
+        } catch (IllegalArgumentException e) {
+            System.out.print("Caught proper exception: ");
+            System.out.println(e.getMessage());
+        }
+
+        try {
+            sslSession.removeValue(null);
+        } catch (IllegalArgumentException e) {
+            System.out.print("Caught proper exception: ");
+            System.out.println(e.getMessage());
+        }
+
+        String [] names = sslSession.getValueNames();
+        if ((names == null) || (names.length != 0)) {
+            throw new IOException(
+                "getValueNames didn't return 0-length arrary");
+        }
+
+        sslSocket.close();
+    }
+
+    /*
+     * =============================================================
+     * The remainder is just support stuff
+     */
+
+    // use any free port by default
+    volatile int serverPort = 0;
+
+    volatile Exception serverException = null;
+    volatile Exception clientException = null;
+
+    public static void main(String[] args) throws Exception {
+        String keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+        String trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+        System.setProperty("javax.net.ssl.keyStore", keyFilename);
+        System.setProperty("javax.net.ssl.keyStorePassword", passwd);
+        System.setProperty("javax.net.ssl.trustStore", trustFilename);
+        System.setProperty("javax.net.ssl.trustStorePassword", passwd);
+
+        if (debug)
+            System.setProperty("javax.net.debug", "all");
+
+        /*
+         * Start the tests.
+         */
+        new SSLSessionNulls();
+    }
+
+    Thread clientThread = null;
+    Thread serverThread = null;
+
+    /*
+     * Primary constructor, used to drive remainder of the test.
+     *
+     * Fork off the other side, then do your work.
+     */
+    SSLSessionNulls() throws Exception {
+        if (separateServerThread) {
+            startServer(true);
+            startClient(false);
+        } else {
+            startClient(true);
+            startServer(false);
+        }
+
+        /*
+         * Wait for other side to close down.
+         */
+        if (separateServerThread) {
+            serverThread.join();
+        } else {
+            clientThread.join();
+        }
+
+        /*
+         * When we get here, the test is pretty much over.
+         *
+         * If the main thread excepted, that propagates back
+         * immediately.  If the other thread threw an exception, we
+         * should report back.
+         */
+        if (serverException != null) {
+            System.out.print("Server Exception:");
+            throw serverException;
+        }
+        if (clientException != null) {
+            System.out.print("Client Exception:");
+            throw clientException;
+        }
+    }
+
+    void startServer(boolean newThread) throws Exception {
+        if (newThread) {
+            serverThread = new Thread() {
+                public void run() {
+                    try {
+                        doServerSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our server thread just died.
+                         *
+                         * Release the client, if not active already...
+                         */
+                        System.err.println("Server died...");
+                        serverReady = true;
+                        serverException = e;
+                    }
+                }
+            };
+            serverThread.start();
+        } else {
+            doServerSide();
+        }
+    }
+
+    void startClient(boolean newThread) throws Exception {
+        if (newThread) {
+            clientThread = new Thread() {
+                public void run() {
+                    try {
+                        doClientSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our client thread just died.
+                         */
+                        System.err.println("Client died...");
+                        clientException = e;
+                    }
+                }
+            };
+            clientThread.start();
+        } else {
+            doClientSide();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/FixingJavadocs/SSLSocketInherit.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,244 @@
+/*
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4387882
+ * @summary Need to revisit the javadocs for JSSE, especially the
+ *      promoted classes.  This test checks to see if the settings
+ *      on the server sockets get propagated to the sockets.
+ * @run main/othervm SSLSocketInherit
+ *
+ *     SunJSSE does not support dynamic system properties, no way to re-use
+ *     system properties in samevm/agentvm mode.
+ * @author Brad Wetmore
+ */
+
+import java.net.*;
+import javax.net.ssl.*;
+
+public class SSLSocketInherit {
+    String pathToStores = "../etc";
+    static String keyStoreFile = "keystore";
+    static String trustStoreFile = "truststore";
+    static String passwd = "passphrase";
+
+    volatile int serverPort = 0;
+
+    /*
+     * Let's just create silly sockets to do a basic connection,
+     * that's all we really need.
+     */
+    Thread forkClient() {
+        Thread clientThread = new Thread() {
+            public void run() {
+                try {
+                    new Socket("localhost", serverPort);
+                } catch (Exception e) {
+                    // ignore for now...
+                }
+            }
+        };
+        clientThread.start();
+        return clientThread;
+    }
+
+    SSLSocketInherit() throws Exception {
+        Exception exc = null;
+
+        String keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+        String trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+        System.setProperty("javax.net.ssl.keyStore", keyFilename);
+        System.setProperty("javax.net.ssl.keyStorePassword", passwd);
+        System.setProperty("javax.net.ssl.trustStore", trustFilename);
+        System.setProperty("javax.net.ssl.trustStorePassword", passwd);
+
+        SSLServerSocketFactory sslssf =
+            (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
+        SSLServerSocket sslss =
+            (SSLServerSocket) sslssf.createServerSocket(0);
+        serverPort = sslss.getLocalPort();
+
+        Thread client = forkClient();
+
+        String [] ciphers =
+            new String [] { "SSL_RSA_WITH_DES_CBC_SHA" };
+
+        String [] protocols =
+            new String [] { "SSLv3" };
+
+        sslss.setEnabledCipherSuites(ciphers);
+        sslss.setEnabledProtocols(protocols);
+        sslss.setNeedClientAuth(true);
+        sslss.setUseClientMode(true);
+        sslss.setEnableSessionCreation(true);
+
+        SSLSocket ssls = (SSLSocket) sslss.accept();
+
+        if (((ciphers = ssls.getEnabledCipherSuites()) == null) ||
+                (ciphers.length != 1) ||
+                (ciphers[0].compareToIgnoreCase(
+                "SSL_RSA_WITH_DES_CBC_SHA") != 0)) {
+            exc = new Exception("problem with get/setEnabledCipherSuites()");
+        }
+
+        if (((protocols = ssls.getEnabledProtocols()) == null) ||
+                (protocols.length != 1) ||
+                (protocols[0].compareToIgnoreCase(
+                "SSLv3") != 0)) {
+            exc = new Exception("problem with get/setEnabledProtocols()");
+        }
+
+        if (ssls.getNeedClientAuth() != true) {
+            exc = new Exception("problem with get/setNeedClientAuth()");
+        }
+
+        if (ssls.getUseClientMode() != true) {
+            exc = new Exception("problem with get/setUseClientMode()");
+        }
+
+        client.join();
+
+        if (exc != null) {
+            throw exc;
+        }
+
+        System.out.println("First SSLSocket inherited right info");
+
+        /*
+         * Try it again.
+         */
+        client = forkClient();
+
+        ciphers = new String [] { "SSL_DH_anon_WITH_DES_CBC_SHA" };
+        protocols = new String [] { "TLSv1" };
+
+        sslss.setEnabledCipherSuites(ciphers);
+        sslss.setEnabledProtocols(protocols);
+        sslss.setWantClientAuth(true);
+        sslss.setUseClientMode(false);
+        sslss.setEnableSessionCreation(false);
+
+        ssls = (SSLSocket) sslss.accept();
+
+        if (((ciphers = ssls.getEnabledCipherSuites()) == null) ||
+                (ciphers.length != 1) ||
+                (ciphers[0].compareToIgnoreCase(
+                "SSL_DH_anon_WITH_DES_CBC_SHA") != 0)) {
+            exc = new Exception("problem with get/setEnabledCipherSuites()");
+        }
+
+        if (((protocols = ssls.getEnabledProtocols()) == null) ||
+                (protocols.length != 1) ||
+                (protocols[0].compareToIgnoreCase(
+                "TLSv1") != 0)) {
+            exc = new Exception("problem with get/setEnabledProtocols()");
+        }
+
+        if (ssls.getWantClientAuth() != true) {
+            exc = new Exception("problem with get/setWantClientAuth()");
+        }
+
+        if (ssls.getUseClientMode() != false) {
+            exc = new Exception("problem with get/setUseClientMode()");
+        }
+
+        client.join();
+
+        if (exc != null) {
+            throw exc;
+        }
+
+        System.out.println("Second SSLSocket inherited right info");
+
+        /*
+         * Lastly, try to set some wild suites, and make sure we
+         * catch it.
+         */
+
+        ciphers = sslss.getSupportedCipherSuites();
+        ciphers[1] = "this isn't a cipher suite";
+
+        try {
+            sslss.setEnabledCipherSuites(ciphers);
+            throw new Exception(
+                "server socket setEnabledCipherSuites didn't throw Exception");
+        } catch (IllegalArgumentException e) {
+            System.out.println("Caught proper Exception on server socket");
+        }
+
+        try {
+            ssls.setEnabledCipherSuites(ciphers);
+            throw new Exception(
+                "socket setEnabledCipherSuites didn't throw Exception");
+        } catch (IllegalArgumentException e) {
+            System.out.println("Caught proper Exception on socket");
+        }
+
+        try {
+            ssls.setEnabledProtocols(null);
+            throw new Exception(
+                "socket setEnabledProtocols null didn't throw Exception");
+        } catch (IllegalArgumentException e) {
+            System.out.println("Caught proper Exception on socket");
+        }
+
+        try {
+            sslss.setEnabledProtocols(null);
+            throw new Exception(
+                "server socket setEnabledProtocols null "+
+                "didn't throw Exception");
+        } catch (IllegalArgumentException e) {
+            System.out.println("Caught proper Exception on server socket");
+        }
+
+        try {
+            ssls.setEnabledCipherSuites(null);
+            throw new Exception(
+                "socket setEnabledCipherSuites null didn't throw Exception");
+        } catch (IllegalArgumentException e) {
+            System.out.println("Caught proper Exception on socket");
+        }
+
+        try {
+            sslss.setEnabledCipherSuites(null);
+            throw new Exception(
+                "server socket setEnabledCipherSuites null "+
+                "didn't throw Exception");
+        } catch (IllegalArgumentException e) {
+            System.out.println("Caught proper Exception on server socket");
+        }
+
+        System.out.println("All tests PASS!");
+
+    }
+
+    public static void main(String args[]) throws Exception {
+        new SSLSocketInherit();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/GetInstance.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4898428 7022855
+ * @summary verify getInstance() works using Provider.getService()
+ *          Export "PKIX" as the standard algorithm name of KeyManagerFactory
+ * @author Andreas Sterbenz
+ */
+
+import java.security.*;
+
+import javax.net.ssl.*;
+
+public class GetInstance {
+
+    private static void same(Provider p1, Provider p2) throws Exception {
+        if (p1 != p2) {
+            throw new Exception("not same object");
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        long start = System.currentTimeMillis();
+
+        Provider p = Security.getProvider("SunJSSE");
+
+        SSLContext context;
+        context = SSLContext.getInstance("SSL");
+        same(p, context.getProvider());
+        context = SSLContext.getInstance("SSL", "SunJSSE");
+        same(p, context.getProvider());
+        context = SSLContext.getInstance("SSL", p);
+        same(p, context.getProvider());
+
+        KeyManagerFactory kmf;
+        kmf = KeyManagerFactory.getInstance("SunX509");
+        same(p, kmf.getProvider());
+        kmf = KeyManagerFactory.getInstance("SunX509", "SunJSSE");
+        same(p, kmf.getProvider());
+        kmf = KeyManagerFactory.getInstance("SunX509", p);
+        same(p, kmf.getProvider());
+
+        kmf = KeyManagerFactory.getInstance("NewSunX509");
+        same(p, kmf.getProvider());
+        kmf = KeyManagerFactory.getInstance("NewSunX509", "SunJSSE");
+        same(p, kmf.getProvider());
+        kmf = KeyManagerFactory.getInstance("NewSunX509", p);
+        same(p, kmf.getProvider());
+
+        kmf = KeyManagerFactory.getInstance("PKIX");
+        same(p, kmf.getProvider());
+        kmf = KeyManagerFactory.getInstance("PKIX", "SunJSSE");
+        same(p, kmf.getProvider());
+        kmf = KeyManagerFactory.getInstance("PKIX", p);
+        same(p, kmf.getProvider());
+
+        TrustManagerFactory tmf;
+        tmf = TrustManagerFactory.getInstance("SunX509");
+        same(p, tmf.getProvider());
+        tmf = TrustManagerFactory.getInstance("SunX509", "SunJSSE");
+        same(p, tmf.getProvider());
+        tmf = TrustManagerFactory.getInstance("SunX509", p);
+        same(p, tmf.getProvider());
+
+        tmf = TrustManagerFactory.getInstance("PKIX");
+        same(p, tmf.getProvider());
+        tmf = TrustManagerFactory.getInstance("PKIX", "SunJSSE");
+        same(p, tmf.getProvider());
+        tmf = TrustManagerFactory.getInstance("PKIX", p);
+        same(p, tmf.getProvider());
+
+        tmf = TrustManagerFactory.getInstance("SunPKIX");
+        same(p, tmf.getProvider());
+        tmf = TrustManagerFactory.getInstance("SunPKIX", "SunJSSE");
+        same(p, tmf.getProvider());
+        tmf = TrustManagerFactory.getInstance("SunPKIX", p);
+        same(p, tmf.getProvider());
+
+        tmf = TrustManagerFactory.getInstance("X509");
+        same(p, tmf.getProvider());
+        tmf = TrustManagerFactory.getInstance("X509", "SunJSSE");
+        same(p, tmf.getProvider());
+        tmf = TrustManagerFactory.getInstance("X509", p);
+        same(p, tmf.getProvider());
+
+        tmf = TrustManagerFactory.getInstance("X.509");
+        same(p, tmf.getProvider());
+        tmf = TrustManagerFactory.getInstance("X.509", "SunJSSE");
+        same(p, tmf.getProvider());
+        tmf = TrustManagerFactory.getInstance("X.509", p);
+        same(p, tmf.getProvider());
+
+        testComSun();
+
+        long stop = System.currentTimeMillis();
+        System.out.println("Done (" + (stop - start) + " ms).");
+    }
+
+    private static void testComSun() throws Exception {
+        Provider p = Security.getProvider("SunJSSE");
+
+        com.sun.net.ssl.SSLContext context;
+        context = com.sun.net.ssl.SSLContext.getInstance("SSL");
+        same(p, context.getProvider());
+        context = com.sun.net.ssl.SSLContext.getInstance("SSL", "SunJSSE");
+        same(p, context.getProvider());
+        context = com.sun.net.ssl.SSLContext.getInstance("SSL", p);
+        same(p, context.getProvider());
+
+        com.sun.net.ssl.KeyManagerFactory kmf;
+        kmf = com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509");
+        same(p, kmf.getProvider());
+        kmf = com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509", "SunJSSE");
+        same(p, kmf.getProvider());
+        kmf = com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509", p);
+        same(p, kmf.getProvider());
+
+        com.sun.net.ssl.TrustManagerFactory tmf;
+        tmf = com.sun.net.ssl.TrustManagerFactory.getInstance("SunX509");
+        same(p, tmf.getProvider());
+        tmf = com.sun.net.ssl.TrustManagerFactory.getInstance("SunX509", "SunJSSE");
+        same(p, tmf.getProvider());
+        tmf = com.sun.net.ssl.TrustManagerFactory.getInstance("SunX509", p);
+        same(p, tmf.getProvider());
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/HttpsURLConnection/CriticalSubjectAltName.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,275 @@
+/*
+ * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//
+// SunJSSE does not support dynamic system properties, no way to re-use
+// system properties in samevm/agentvm mode.
+//
+
+/*
+ * @test
+ * @bug 6668231
+ * @summary Presence of a critical subjectAltName causes JSSE's SunX509 to
+ *          fail trusted checks
+ * @run main/othervm CriticalSubjectAltName
+ * @author Xuelei Fan
+ */
+
+/*
+ * This test depends on binary keystore, crisubn.jks and trusted.jks. Because
+ * JAVA keytool cannot generate X509 certificate with SubjectAltName extension,
+ * the certificates are generated with openssl toolkits and then imported into
+ * JAVA keystore.
+ *
+ * The crisubn.jks holds a private key entry and the corresponding X509
+ * certificate issued with an empty Subject field, and a critical
+ * SubjectAltName extension.
+ *
+ * The trusted.jks holds the trusted certificate.
+ */
+import java.io.*;
+import java.net.*;
+import javax.net.ssl.*;
+import java.security.Security;
+import java.security.cert.Certificate;
+
+public class CriticalSubjectAltName implements HostnameVerifier {
+    /*
+     * =============================================================
+     * Set the various variables needed for the tests, then
+     * specify what tests to run on each side.
+     */
+
+    /*
+     * Should we run the client or server in a separate thread?
+     * Both sides can throw exceptions, but do you have a preference
+     * as to which side should be the main thread.
+     */
+    static boolean separateServerThread = true;
+
+    /*
+     * Where do we find the keystores?
+     */
+    static String pathToStores = "./";
+    static String keyStoreFile = "crisubn.jks";
+    static String trustStoreFile = "trusted.jks";
+    static String passwd = "passphrase";
+
+    /*
+     * Is the server ready to serve?
+     */
+    volatile static boolean serverReady = false;
+
+    /*
+     * Turn on SSL debugging?
+     */
+    static boolean debug = false;
+
+    /*
+     * If the client or server is doing some kind of object creation
+     * that the other side depends on, and that thread prematurely
+     * exits, you may experience a hang.  The test harness will
+     * terminate all hung threads after its timeout has expired,
+     * currently 3 minutes by default, but you might try to be
+     * smart about it....
+     */
+
+    /*
+     * Define the server side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doServerSide() throws Exception {
+        SSLServerSocketFactory sslssf =
+            (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
+        SSLServerSocket sslServerSocket =
+            (SSLServerSocket) sslssf.createServerSocket(serverPort);
+        serverPort = sslServerSocket.getLocalPort();
+
+        /*
+         * Signal Client, we're ready for his connect.
+         */
+        serverReady = true;
+
+        SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
+        OutputStream sslOS = sslSocket.getOutputStream();
+        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(sslOS));
+        bw.write("HTTP/1.1 200 OK\r\n\r\n\r\n");
+        bw.flush();
+        Thread.sleep(5000);
+        sslSocket.close();
+    }
+
+    /*
+     * Define the client side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doClientSide() throws Exception {
+
+        /*
+         * Wait for server to get started.
+         */
+        while (!serverReady) {
+            Thread.sleep(50);
+        }
+
+        URL url = new URL("https://localhost:"+serverPort+"/index.html");
+        HttpsURLConnection urlc = (HttpsURLConnection)url.openConnection();
+        urlc.setHostnameVerifier(this);
+        urlc.getInputStream();
+
+        if (urlc.getResponseCode() == -1) {
+            throw new RuntimeException("getResponseCode() returns -1");
+        }
+    }
+
+    /*
+     * =============================================================
+     * The remainder is just support stuff
+     */
+
+    // use any free port by default
+    volatile int serverPort = 0;
+
+    volatile Exception serverException = null;
+    volatile Exception clientException = null;
+
+    public static void main(String[] args) throws Exception {
+        // MD5 is used in this test case, don't disable MD5 algorithm.
+        Security.setProperty(
+                "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024");
+
+        String keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+        String trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+        System.setProperty("javax.net.ssl.keyStore", keyFilename);
+        System.setProperty("javax.net.ssl.keyStorePassword", passwd);
+        System.setProperty("javax.net.ssl.trustStore", trustFilename);
+        System.setProperty("javax.net.ssl.trustStorePassword", passwd);
+
+        if (debug)
+            System.setProperty("javax.net.debug", "all");
+
+        /*
+         * Start the tests.
+         */
+        new CriticalSubjectAltName();
+    }
+
+    Thread clientThread = null;
+    Thread serverThread = null;
+
+    /*
+     * Primary constructor, used to drive remainder of the test.
+     *
+     * Fork off the other side, then do your work.
+     */
+    CriticalSubjectAltName() throws Exception {
+        if (separateServerThread) {
+            startServer(true);
+            startClient(false);
+        } else {
+            startClient(true);
+            startServer(false);
+        }
+
+        /*
+         * Wait for other side to close down.
+         */
+        if (separateServerThread) {
+            serverThread.join();
+        } else {
+            clientThread.join();
+        }
+
+        /*
+         * When we get here, the test is pretty much over.
+         *
+         * If the main thread excepted, that propagates back
+         * immediately.  If the other thread threw an exception, we
+         * should report back.
+         */
+        if (serverException != null)
+            throw serverException;
+        if (clientException != null)
+            throw clientException;
+    }
+
+    void startServer(boolean newThread) throws Exception {
+        if (newThread) {
+            serverThread = new Thread() {
+                public void run() {
+                    try {
+                        doServerSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our server thread just died.
+                         *
+                         * Release the client, if not active already...
+                         */
+                        System.err.println("Server died...");
+                        serverReady = true;
+                        serverException = e;
+                    }
+                }
+            };
+            serverThread.start();
+        } else {
+            doServerSide();
+        }
+    }
+
+    void startClient(boolean newThread) throws Exception {
+        if (newThread) {
+            clientThread = new Thread() {
+                public void run() {
+                    try {
+                        doClientSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our client thread just died.
+                         */
+                        System.err.println("Client died...");
+                        clientException = e;
+                    }
+                }
+            };
+            clientThread.start();
+        } else {
+            doClientSide();
+        }
+    }
+
+    // Simple test method to blindly agree that hostname and certname match
+    public boolean verify(String hostname, SSLSession session) {
+        return true;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/HttpsURLConnection/DelayDefaultContextLoading.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4417268
+ * @summary Update HttpsURLConnection to not call getDefault in initializer.
+ * @author Brad Wetmore
+ */
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.net.ssl.*;
+
+public class DelayDefaultContextLoading {
+
+    /*
+     * Pick some static method in HttpsURLConnection, and
+     * then run it.  If we're still broken, we'll call
+     * SSLSocketFactory.getDefault(), which will create a
+     * new SecureRandom number generator, which takes a while
+     * to load.
+     */
+    public static void main(String[] args) throws Exception {
+        Date date1 = new Date();
+        HttpsURLConnection.getDefaultHostnameVerifier();
+        Date date2 = new Date();
+        long delta = (date2.getTime() - date1.getTime()) / 1000;
+
+        /*
+         * Did it take longer than 5 second to run?
+         * If so, we're probably still loading incorrectly.
+         */
+        if (delta > 5) {
+            throw new Exception("FAILED:  HttpsURLConnection took " + delta +
+                " seconds to load");
+        }
+        System.out.println("PASSED:  HttpsURLConnection took " + delta +
+            " seconds to load");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/HttpsURLConnection/GetResponseCode.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,255 @@
+/*
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4482187
+ * @summary HttpsClient tests are failing for build 71
+ * @run main/othervm GetResponseCode
+ *
+ *     SunJSSE does not support dynamic system properties, no way to re-use
+ *     system properties in samevm/agentvm mode.
+ *
+ * @author Yingxian Wang
+ */
+import java.io.*;
+import java.net.*;
+import javax.net.ssl.*;
+import java.security.cert.Certificate;
+
+public class GetResponseCode implements HostnameVerifier {
+    /*
+     * =============================================================
+     * Set the various variables needed for the tests, then
+     * specify what tests to run on each side.
+     */
+
+    /*
+     * Should we run the client or server in a separate thread?
+     * Both sides can throw exceptions, but do you have a preference
+     * as to which side should be the main thread.
+     */
+    static boolean separateServerThread = true;
+
+    /*
+     * Where do we find the keystores?
+     */
+    static String pathToStores = "../etc";
+    static String keyStoreFile = "keystore";
+    static String trustStoreFile = "truststore";
+    static String passwd = "passphrase";
+
+    /*
+     * Is the server ready to serve?
+     */
+    volatile static boolean serverReady = false;
+
+    /*
+     * Turn on SSL debugging?
+     */
+    static boolean debug = false;
+
+    /*
+     * If the client or server is doing some kind of object creation
+     * that the other side depends on, and that thread prematurely
+     * exits, you may experience a hang.  The test harness will
+     * terminate all hung threads after its timeout has expired,
+     * currently 3 minutes by default, but you might try to be
+     * smart about it....
+     */
+
+    /*
+     * Define the server side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doServerSide() throws Exception {
+        SSLServerSocketFactory sslssf =
+            (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
+        SSLServerSocket sslServerSocket =
+            (SSLServerSocket) sslssf.createServerSocket(serverPort);
+        serverPort = sslServerSocket.getLocalPort();
+
+        /*
+         * Signal Client, we're ready for his connect.
+         */
+        serverReady = true;
+
+        SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
+        OutputStream sslOS = sslSocket.getOutputStream();
+        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(sslOS));
+        bw.write("HTTP/1.1 200 OK\r\n\r\n\r\n");
+        bw.flush();
+        Thread.sleep(5000);
+        sslSocket.close();
+    }
+
+    /*
+     * Define the client side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doClientSide() throws Exception {
+
+        /*
+         * Wait for server to get started.
+         */
+        while (!serverReady) {
+            Thread.sleep(50);
+        }
+
+        URL url = new URL("https://localhost:"+serverPort+"/index.html");
+        HttpsURLConnection urlc = (HttpsURLConnection)url.openConnection();
+        urlc.setHostnameVerifier(this);
+        urlc.getInputStream();
+
+        if (urlc.getResponseCode() == -1) {
+            throw new RuntimeException("getResponseCode() returns -1");
+        }
+    }
+
+    /*
+     * =============================================================
+     * The remainder is just support stuff
+     */
+
+    // use any free port by default
+    volatile int serverPort = 0;
+
+    volatile Exception serverException = null;
+    volatile Exception clientException = null;
+
+    public static void main(String[] args) throws Exception {
+        String keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+        String trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+        System.setProperty("javax.net.ssl.keyStore", keyFilename);
+        System.setProperty("javax.net.ssl.keyStorePassword", passwd);
+        System.setProperty("javax.net.ssl.trustStore", trustFilename);
+        System.setProperty("javax.net.ssl.trustStorePassword", passwd);
+
+        if (debug)
+            System.setProperty("javax.net.debug", "all");
+
+        /*
+         * Start the tests.
+         */
+        new GetResponseCode();
+    }
+
+    Thread clientThread = null;
+    Thread serverThread = null;
+
+    /*
+     * Primary constructor, used to drive remainder of the test.
+     *
+     * Fork off the other side, then do your work.
+     */
+    GetResponseCode() throws Exception {
+        if (separateServerThread) {
+            startServer(true);
+            startClient(false);
+        } else {
+            startClient(true);
+            startServer(false);
+        }
+
+        /*
+         * Wait for other side to close down.
+         */
+        if (separateServerThread) {
+            serverThread.join();
+        } else {
+            clientThread.join();
+        }
+
+        /*
+         * When we get here, the test is pretty much over.
+         *
+         * If the main thread excepted, that propagates back
+         * immediately.  If the other thread threw an exception, we
+         * should report back.
+         */
+        if (serverException != null)
+            throw serverException;
+        if (clientException != null)
+            throw clientException;
+    }
+
+    void startServer(boolean newThread) throws Exception {
+        if (newThread) {
+            serverThread = new Thread() {
+                public void run() {
+                    try {
+                        doServerSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our server thread just died.
+                         *
+                         * Release the client, if not active already...
+                         */
+                        System.err.println("Server died...");
+                        serverReady = true;
+                        serverException = e;
+                    }
+                }
+            };
+            serverThread.start();
+        } else {
+            doServerSide();
+        }
+    }
+
+    void startClient(boolean newThread) throws Exception {
+        if (newThread) {
+            clientThread = new Thread() {
+                public void run() {
+                    try {
+                        doClientSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our client thread just died.
+                         */
+                        System.err.println("Client died...");
+                        clientException = e;
+                    }
+                }
+            };
+            clientThread.start();
+        } else {
+            doClientSide();
+        }
+    }
+
+    // Simple test method to blindly agree that hostname and certname match
+    public boolean verify(String hostname, SSLSession session) {
+        return true;
+    }
+
+}
Binary file jdk/test/javax/net/ssl/HttpsURLConnection/crisubn.jks has changed
Binary file jdk/test/javax/net/ssl/HttpsURLConnection/trusted.jks has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/README	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,31 @@
+
+Use the test directory as you would for any other JDK regression test
+suite.  All bugs integrated into this workspace should have a
+corresponding test case checked in.  Ideally, every putback done should
+also include a run of the regression suite to make sure nothing was
+broken.
+
+
+templates
+=========
+This directory stores any useful templates for JSSE regression tests.
+
+JSSEClientServerTemplate
+	This template is to allow the quick set up of generic
+	client/server tests.  It forks off one thread to either be the
+	client or the server side (user-controlled), then runs the
+	tests in the main thread.
+
+	Modify the doClientSide and doServerSide as appropriate.
+
+
+etc
+===
+This directory stores keystore/truststores needed by the JSSE
+regression suite.  By consolidating the main keystores here, any
+expired certificates can be regenerated quickly.
+
+
+Expansions
+==========
+Please feel free to add any useful information here.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/AcceptLargeFragments.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6388456
+ * @summary Need adjustable TLS max record size for interoperability
+ *      with non-compliant stacks
+ * @run main/othervm AcceptLargeFragments
+ *
+ *     SunJSSE does not support dynamic system properties, no way to re-use
+ *     system properties in samevm/agentvm mode.
+ *
+ * Check the system property "jsse.SSLEngine.acceptLargeFragments"
+ *
+ * @author xuelei fan
+ */
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLSession;
+
+public class AcceptLargeFragments {
+    public static void main (String[] args) throws Exception {
+        SSLContext context = SSLContext.getDefault();
+
+        // set the property before initialization SSLEngine.
+        System.setProperty("jsse.SSLEngine.acceptLargeFragments", "true");
+
+        SSLEngine cliEngine = context.createSSLEngine();
+        cliEngine.setUseClientMode(true);
+
+        SSLEngine srvEngine = context.createSSLEngine();
+        srvEngine.setUseClientMode(false);
+
+        SSLSession cliSession = cliEngine.getSession();
+        SSLSession srvSession = srvEngine.getSession();
+
+        // check packet buffer sizes.
+        if (cliSession.getPacketBufferSize() < 33049 ||
+            srvSession.getPacketBufferSize() < 33049) {
+                throw new Exception("Don't accept large SSL/TLS fragments");
+        }
+
+        // check application data buffer sizes.
+        if (cliSession.getApplicationBufferSize() < 32768 ||
+            srvSession.getApplicationBufferSize() < 32768) {
+                throw new Exception(
+                        "Don't accept large SSL/TLS application data ");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/ArgCheck.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,281 @@
+/*
+ * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 5019096
+ * @summary Add scatter/gather APIs for SSLEngine
+ *
+ * Check to see if the args are being parsed properly.
+ *
+ */
+
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.*;
+import java.io.*;
+import java.security.*;
+import java.nio.*;
+
+public class ArgCheck {
+
+    private static boolean debug = false;
+
+    private static String pathToStores = "../etc";
+    private static String keyStoreFile = "keystore";
+    private static String trustStoreFile = "truststore";
+    private static String passwd = "passphrase";
+
+    private static String keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+    private static String trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+    private static void tryNull(SSLEngine ssle, ByteBuffer appData,
+            ByteBuffer netData) throws Exception {
+        try {
+            ssle.wrap(appData, netData);
+            throw new Exception();
+        } catch (IllegalArgumentException e) {
+            System.out.println("Caught right exception");
+        }
+
+        try {
+            ssle.unwrap(netData, appData);
+            throw new Exception();
+        } catch (IllegalArgumentException e) {
+            System.out.println("Caught right exception");
+        }
+    }
+
+    private static void tryNullArray(SSLEngine ssle, ByteBuffer [] appData,
+            ByteBuffer netData) throws Exception {
+        try {
+            ssle.wrap(appData, netData);
+            throw new Exception();
+        } catch (IllegalArgumentException e) {
+            System.out.println("Caught right exception");
+        }
+
+        try {
+            ssle.unwrap(netData, appData);
+            throw new Exception();
+        } catch (IllegalArgumentException e) {
+            System.out.println("Caught right exception");
+        }
+    }
+
+    private static void tryNullArrayLen(SSLEngine ssle, ByteBuffer [] appData,
+            int offset, int len, ByteBuffer netData) throws Exception {
+        try {
+            ssle.wrap(appData, offset, len, netData);
+            throw new Exception();
+        } catch (IllegalArgumentException e) {
+            System.out.println("Caught right exception");
+        }
+
+        try {
+            ssle.unwrap(netData, appData, offset, len);
+            throw new Exception();
+        } catch (IllegalArgumentException e) {
+            System.out.println("Caught right exception");
+        }
+    }
+
+    private static void tryReadOnly(SSLEngine ssle, ByteBuffer [] appData,
+            int offset, int len, ByteBuffer netData) throws Exception {
+        try {
+            if (netData.isReadOnly()) {
+                ssle.wrap(appData, offset, len, netData);
+                throw new Exception();
+            }
+        } catch (ReadOnlyBufferException e) {
+            System.out.println("Caught right exception");
+        }
+
+        try {
+            if (!netData.isReadOnly()) {
+                ssle.unwrap(netData, appData, offset, len);
+                throw new Exception();
+            }
+        } catch (ReadOnlyBufferException e) {
+            System.out.println("Caught right exception");
+        }
+    }
+
+    private static void tryOutOfBounds(SSLEngine ssle, ByteBuffer [] appData,
+            int offset, int len, ByteBuffer netData) throws Exception {
+        try {
+            ssle.wrap(appData, offset, len, netData);
+            throw new Exception();
+        } catch (IndexOutOfBoundsException e) {
+            System.out.println("Caught right exception");
+        }
+
+        try {
+            ssle.unwrap(netData, appData, offset, len);
+            throw new Exception();
+        } catch (IndexOutOfBoundsException e) {
+            System.out.println("Caught right exception");
+        }
+    }
+
+    private static void trySmallBufs(SSLEngine ssle,
+            ByteBuffer appBB, ByteBuffer smallNetBB,
+            ByteBuffer smallAppBB, ByteBuffer netBB) throws Exception {
+
+        SSLEngineResult res = ssle.wrap(appBB, smallNetBB);
+        if (res.getStatus() != Status.BUFFER_OVERFLOW) {
+            throw new Exception();
+        }
+
+        // For unwrap(), the BUFFER_OVERFLOW will not be generated
+        // until received SSL/TLS application data.
+        // Test test/javax/net/ssl/NewAPIs/SSLEngine/LargePacket will check
+        // BUFFER_OVERFLOW/UNDERFLOW for both wrap() and unwrap().
+        //
+        //res = ssle.unwrap(netBB, smallAppBB);
+        //if (res.getStatus() != Status.BUFFER_OVERFLOW) {
+        //    throw new Exception();
+        //}
+    }
+
+    private static void trySmallBufsArray(SSLEngine ssle,
+            ByteBuffer [] appBB, ByteBuffer smallNetBB,
+            ByteBuffer [] smallAppBB, ByteBuffer netBB) throws Exception {
+
+        SSLEngineResult res = ssle.wrap(appBB, 0, appBB.length, smallNetBB);
+        if (res.getStatus() != Status.BUFFER_OVERFLOW) {
+            throw new Exception();
+        }
+
+        // For unwrap(), the BUFFER_OVERFLOW will not be generated
+        // until received SSL/TLS application data.
+        // Test test/javax/net/ssl/NewAPIs/SSLEngine/LargePacket will check
+        // BUFFER_OVERFLOW/UNDERFLOW for both wrap() and unwrap().
+        //
+        //res = ssle.unwrap(netBB, smallAppBB, 0, appBB.length);
+        //if (res.getStatus() != Status.BUFFER_OVERFLOW) {
+        //    throw new Exception();
+        //}
+    }
+
+    private static void runTest(SSLEngine ssle) throws Exception {
+        ByteBuffer [] bufs;
+
+        ByteBuffer roBB = ByteBuffer.allocate(40).asReadOnlyBuffer();
+
+        ByteBuffer bb1K = ByteBuffer.allocate(1024);
+        ByteBuffer bb2K = ByteBuffer.allocate(2048);
+        ByteBuffer bb4K = ByteBuffer.allocate(5096);
+        ByteBuffer bb8K = ByteBuffer.allocate(10192);
+
+        SSLSession ssls = ssle.getSession();
+
+        ByteBuffer netBBMinus1 = ByteBuffer.allocate(
+            ssls.getPacketBufferSize() - 1);
+        ByteBuffer appBBMinus1 = ByteBuffer.allocate(
+            ssls.getApplicationBufferSize() - 1);
+
+        ByteBuffer bbNet = ByteBuffer.allocate(
+            ssls.getPacketBufferSize());
+        ByteBuffer bbApp = ByteBuffer.allocate(
+            ssls.getApplicationBufferSize());
+
+        bufs = new ByteBuffer [] { bb1K, bb2K, bb4K, bb8K};
+
+        tryNull(ssle, null, null);
+        tryNull(ssle, bb1K, null);
+        tryNull(ssle, null, bb1K);
+
+        tryNullArray(ssle, null, null);
+        tryNullArray(ssle, bufs, null);
+        tryNullArray(ssle, null, bb1K);
+
+        tryNullArrayLen(ssle, null, 0, 4, null);
+        tryNullArrayLen(ssle, bufs, 0, 4, null);
+        tryNullArrayLen(ssle, null, 0, 4, bb1K);
+
+        bufs[2] = null;
+        tryNullArray(ssle, bufs, bb1K);
+
+        bufs[2] = bb4K;
+        tryReadOnly(ssle, bufs, 0, 4, roBB);
+
+        bufs[2] = roBB;
+        tryReadOnly(ssle, bufs, 0, 4, bb4K);
+
+        bufs[2] = bb4K;
+        tryOutOfBounds(ssle, bufs, -1, 0, bb1K);
+        tryOutOfBounds(ssle, bufs, 0, -1, bb1K);
+        tryOutOfBounds(ssle, bufs, 0, bufs.length + 1, bb1K);
+        tryOutOfBounds(ssle, bufs, bufs.length, 1, bb1K);
+
+        bufs[3].position(bufs[3].limit());
+        trySmallBufs(ssle, bb1K, netBBMinus1, appBBMinus1, bb1K);
+        trySmallBufsArray(ssle, bufs, netBBMinus1, bufs, bb1K);
+        bufs[3].rewind();
+
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        SSLEngine ssle = createSSLEngine(keyFilename, trustFilename);
+        runTest(ssle);
+
+        System.out.println("Test Passed.");
+    }
+
+    /*
+     * Create an initialized SSLContext to use for this test.
+     */
+    static private SSLEngine createSSLEngine(String keyFile, String trustFile)
+            throws Exception {
+
+        SSLEngine ssle;
+
+        KeyStore ks = KeyStore.getInstance("JKS");
+        KeyStore ts = KeyStore.getInstance("JKS");
+
+        char[] passphrase = "passphrase".toCharArray();
+
+        ks.load(new FileInputStream(keyFile), passphrase);
+        ts.load(new FileInputStream(trustFile), passphrase);
+
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+        kmf.init(ks, passphrase);
+
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+        tmf.init(ts);
+
+        SSLContext sslCtx = SSLContext.getInstance("TLS");
+
+        sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+        ssle = sslCtx.createSSLEngine("client", 1001);
+        ssle.setUseClientMode(true);
+
+        return ssle;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/Arrays.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,294 @@
+/*
+ * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 5019096
+ * @summary Add scatter/gather APIs for SSLEngine
+ *
+ */
+
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.*;
+import java.io.*;
+import java.security.*;
+import java.nio.*;
+
+public class Arrays {
+
+    private static boolean debug = false;
+
+    private SSLContext sslc;
+    private SSLEngine ssle1;    // client
+    private SSLEngine ssle2;    // server
+
+    private static String pathToStores = "../etc";
+    private static String keyStoreFile = "keystore";
+    private static String trustStoreFile = "truststore";
+    private static String passwd = "passphrase";
+
+    private static String keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+    private static String trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+    private ByteBuffer [] appOutArray1;
+    private ByteBuffer [] appInArray1;
+
+    private ByteBuffer appOut2;         // write side of ssle2
+    private ByteBuffer appIn2;          // read side of ssle2
+
+    private ByteBuffer oneToTwo;        // "reliable" transport ssle1->ssle2
+    private ByteBuffer twoToOne;        // "reliable" transport ssle2->ssle1
+
+    /*
+     * Majority of the test case is here, setup is done below.
+     */
+    private void createSSLEngines() throws Exception {
+        ssle1 = sslc.createSSLEngine("client", 1);
+        ssle1.setUseClientMode(true);
+
+        ssle2 = sslc.createSSLEngine();
+        ssle2.setUseClientMode(false);
+        ssle2.setNeedClientAuth(true);
+    }
+
+    private void runTest() throws Exception {
+        boolean dataDone = false;
+
+        createSSLEngines();
+        createBuffers();
+
+        SSLEngineResult result1;        // ssle1's results from last operation
+        SSLEngineResult result2;        // ssle2's results from last operation
+
+        while (!isEngineClosed(ssle1) || !isEngineClosed(ssle2)) {
+
+            log("================");
+
+            result1 = ssle1.wrap(appOutArray1, oneToTwo);
+            result2 = ssle2.wrap(appOut2, twoToOne);
+
+            log("wrap1:  " + result1);
+            log("oneToTwo  = " + oneToTwo);
+            log("");
+
+            log("wrap2:  " + result2);
+            log("twoToOne  = " + twoToOne);
+
+            runDelegatedTasks(result1, ssle1);
+            runDelegatedTasks(result2, ssle2);
+
+            oneToTwo.flip();
+            twoToOne.flip();
+
+            log("----");
+
+            result1 = ssle1.unwrap(twoToOne, appInArray1);
+            result2 = ssle2.unwrap(oneToTwo, appIn2);
+
+            log("unwrap1: " + result1);
+            log("twoToOne  = " + twoToOne);
+            log("");
+
+            log("unwrap2: " + result2);
+            log("oneToTwo  = " + oneToTwo);
+
+            runDelegatedTasks(result1, ssle1);
+            runDelegatedTasks(result2, ssle2);
+
+            oneToTwo.compact();
+            twoToOne.compact();
+
+            /*
+             * If we've transfered all the data between app1 and app2,
+             * we try to close and see what that gets us.
+             */
+            if (!dataDone) {
+                boolean done = true;
+
+                for (int i = 0; i < appOutArray1.length; i++) {
+                    if (appOutArray1[i].remaining() != 0) {
+                        done = false;
+                    }
+                }
+
+                if (appOut2.remaining() != 0) {
+                    done = false;
+                }
+
+                if (done) {
+                    log("Closing ssle1's *OUTBOUND*...");
+                    for (int i = 0; i < appOutArray1.length; i++) {
+                        appOutArray1[i].rewind();
+                    }
+                    ssle1.closeOutbound();
+                    dataDone = true;
+                }
+            }
+        }
+        checkTransfer(appOutArray1,  appIn2);
+        appInArray1[appInArray1.length - 1].limit(
+            appInArray1[appInArray1.length - 1].position());
+        checkTransfer(appInArray1, appOut2);
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        Arrays test;
+
+        test = new Arrays();
+
+        test.createSSLEngines();
+
+        test.runTest();
+
+        System.out.println("Test Passed.");
+    }
+
+    /*
+     * **********************************************************
+     * Majority of the test case is above, below is just setup stuff
+     * **********************************************************
+     */
+
+    public Arrays() throws Exception {
+        sslc = getSSLContext(keyFilename, trustFilename);
+    }
+
+    /*
+     * Create an initialized SSLContext to use for this test.
+     */
+    private SSLContext getSSLContext(String keyFile, String trustFile)
+            throws Exception {
+
+        KeyStore ks = KeyStore.getInstance("JKS");
+        KeyStore ts = KeyStore.getInstance("JKS");
+
+        char[] passphrase = "passphrase".toCharArray();
+
+        ks.load(new FileInputStream(keyFile), passphrase);
+        ts.load(new FileInputStream(trustFile), passphrase);
+
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+        kmf.init(ks, passphrase);
+
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+        tmf.init(ts);
+
+        SSLContext sslCtx = SSLContext.getInstance("TLS");
+
+        sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+        return sslCtx;
+    }
+
+    private void createBuffers() {
+        // Size the buffers as appropriate.
+
+        SSLSession session = ssle1.getSession();
+        int appBufferMax = session.getApplicationBufferSize();
+        int netBufferMax = session.getPacketBufferSize();
+
+        appIn2 = ByteBuffer.allocateDirect(appBufferMax + 50);
+
+        oneToTwo = ByteBuffer.allocateDirect(netBufferMax);
+        twoToOne = ByteBuffer.allocateDirect(netBufferMax);
+
+        ByteBuffer strBB = ByteBuffer.wrap(
+            "Hi Engine2, I'm SSLEngine1, So Be it" .getBytes());
+
+        strBB.position(0);
+        strBB.limit(5);
+        ByteBuffer appOut1a = strBB.slice();
+
+        strBB.position(5);
+        strBB.limit(15);
+        ByteBuffer appOut1b = strBB.slice();
+
+        strBB.position(15);
+        strBB.limit(strBB.capacity());
+        ByteBuffer appOut1c = strBB.slice();
+
+        strBB.rewind();
+
+        appOutArray1 = new ByteBuffer [] { appOut1a, appOut1b, appOut1c };
+
+        appOut2 = ByteBuffer.wrap("Hello Engine1, I'm SSLEngine2".getBytes());
+
+        ByteBuffer appIn1a = ByteBuffer.allocateDirect(5);
+        ByteBuffer appIn1b = ByteBuffer.allocateDirect(10);
+        ByteBuffer appIn1c = ByteBuffer.allocateDirect(appBufferMax + 50);
+        appInArray1 = new ByteBuffer [] { appIn1a, appIn1b, appIn1c };
+
+        log("AppOut1a = " + appOut1a);
+        log("AppOut1a = " + appOut1b);
+        log("AppOut1a = " + appOut1c);
+        log("AppOut2 = " + appOut2);
+        log("");
+    }
+
+    private static void runDelegatedTasks(SSLEngineResult result,
+            SSLEngine engine) throws Exception {
+
+        if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+            Runnable runnable;
+            while ((runnable = engine.getDelegatedTask()) != null) {
+                log("running delegated task...");
+                runnable.run();
+            }
+        }
+    }
+
+    private static boolean isEngineClosed(SSLEngine engine) {
+        return (engine.isOutboundDone() && engine.isInboundDone());
+    }
+
+    private static void checkTransfer(ByteBuffer [] a, ByteBuffer b)
+            throws Exception {
+
+        b.flip();
+
+        for (int i = 0; i < a.length; i++) {
+            a[i].rewind();
+
+            b.limit(b.position() + a[i].remaining());
+
+            if (!a[i].equals(b)) {
+                throw new Exception("Data didn't transfer cleanly");
+            }
+
+            b.position(b.limit());
+        }
+
+        log("Data transferred cleanly");
+    }
+
+    private static void log(String str) {
+        if (debug) {
+            System.out.println(str);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/Basics.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,294 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4495742
+ * @summary Add non-blocking SSL/TLS functionality, usable with any
+ *      I/O abstraction
+ * @ignore JSSE supported cipher suites are changed with CR 6916074,
+ *     need to update this test case in JDK 7 soon
+ *
+ * This is intended to test many of the basic API calls to the SSLEngine
+ * interface.  This doesn't really exercise much of the SSL code.
+ *
+ * @author Brad Wetmore
+ */
+
+import java.security.*;
+import java.io.*;
+import java.nio.*;
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.*;
+
+public class Basics {
+
+    private static String pathToStores = "../etc";
+    private static String keyStoreFile = "keystore";
+    private static String trustStoreFile = "truststore";
+    private static String passwd = "passphrase";
+
+    private static String keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+    private static String trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+    public static void main(String args[]) throws Exception {
+
+        KeyStore ks = KeyStore.getInstance("JKS");
+        KeyStore ts = KeyStore.getInstance("JKS");
+        char[] passphrase = "passphrase".toCharArray();
+
+        ks.load(new FileInputStream(keyFilename), passphrase);
+        ts.load(new FileInputStream(trustFilename), passphrase);
+
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+        kmf.init(ks, passphrase);
+
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+        tmf.init(ks);
+
+        SSLContext sslCtx = SSLContext.getInstance("TLS");
+
+        sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+        SSLEngine ssle = sslCtx.createSSLEngine();
+
+        System.out.println(ssle);
+
+        String [] suites = ssle.getSupportedCipherSuites();
+        String secondSuite = suites[1];
+        String [] oneSuites = new String [] { secondSuite };
+
+        printStrings("Supported Ciphersuites", suites);
+        printStrings("Enabled Ciphersuites", ssle.getEnabledCipherSuites());
+        ssle.setEnabledCipherSuites(oneSuites);
+        printStrings("Set Ciphersuites", ssle.getEnabledCipherSuites());
+
+        suites = ssle.getEnabledCipherSuites();
+        if ((ssle.getEnabledCipherSuites().length != 1) ||
+                !(suites[0].equals(secondSuite))) {
+            throw new Exception("set ciphers not what was expected");
+        }
+
+        System.out.println();
+
+        String [] protocols = ssle.getSupportedProtocols();
+        String secondProtocol = protocols[1];
+        String [] oneProtocols = new String [] { protocols[1] };
+
+        printStrings("Supported Protocols", protocols);
+        printStrings("Enabled Protocols", ssle.getEnabledProtocols());
+        ssle.setEnabledProtocols(oneProtocols);
+        printStrings("Set Protocols", ssle.getEnabledProtocols());
+
+        protocols = ssle.getEnabledProtocols();
+        if ((ssle.getEnabledProtocols().length != 1) ||
+                !(protocols[0].equals(secondProtocol))) {
+            throw new Exception("set protocols not what was expected");
+        }
+
+        System.out.println("Checking get/setUseClientMode");
+
+        ssle.setUseClientMode(true);
+        if (ssle.getUseClientMode() != true) {
+            throw new Exception("set/getUseClientMode false");
+        }
+
+        ssle.setUseClientMode(false);
+        if (ssle.getUseClientMode() != false) {
+            throw new Exception("set/getUseClientMode true");
+        }
+
+
+        System.out.println("Checking get/setClientAuth");
+
+        ssle.setNeedClientAuth(false);
+        if (ssle.getNeedClientAuth() != false) {
+            throw new Exception("set/getNeedClientAuth true");
+        }
+
+        ssle.setNeedClientAuth(true);
+        if (ssle.getNeedClientAuth() != true) {
+            throw new Exception("set/getNeedClientAuth false");
+        }
+
+        ssle.setWantClientAuth(true);
+
+        if (ssle.getNeedClientAuth() == true) {
+            throw new Exception("set/getWantClientAuth need = true");
+        }
+
+        if (ssle.getWantClientAuth() != true) {
+            throw new Exception("set/getNeedClientAuth false");
+        }
+
+        ssle.setWantClientAuth(false);
+        if (ssle.getWantClientAuth() != false) {
+            throw new Exception("set/getNeedClientAuth true");
+        }
+
+        /*
+         * Reset back to client mode
+         */
+        ssle.setUseClientMode(true);
+
+        System.out.println("checking session creation");
+
+        ssle.setEnableSessionCreation(false);
+        if (ssle.getEnableSessionCreation() != false) {
+            throw new Exception("set/getSessionCreation true");
+        }
+
+        ssle.setEnableSessionCreation(true);
+        if (ssle.getEnableSessionCreation() != true) {
+            throw new Exception("set/getSessionCreation false");
+        }
+
+        /* Checking for overflow wrap/unwrap() */
+        ByteBuffer smallBB = ByteBuffer.allocate(10);
+
+        if (ssle.wrap(smallBB, smallBB).getStatus() !=
+                Status.BUFFER_OVERFLOW) {
+            throw new Exception("wrap should have overflowed");
+        }
+
+        // For unwrap(), the BUFFER_OVERFLOW will not be generated
+        // until received SSL/TLS application data.
+        // Test test/javax/net/ssl/NewAPIs/SSLEngine/LargePacket will check
+        // BUFFER_OVERFLOW/UNDERFLOW for both wrap() and unwrap().
+        //
+        //if (ssle.unwrap(smallBB, smallBB).getStatus() !=
+        //      Status.BUFFER_OVERFLOW) {
+        //    throw new Exception("unwrap should have overflowed");
+        //}
+
+        SSLSession ssls = ssle.getSession();
+
+        ByteBuffer appBB =
+            ByteBuffer.allocate(ssls.getApplicationBufferSize());
+        ByteBuffer netBB =
+            ByteBuffer.allocate(ssls.getPacketBufferSize());
+        appBB.position(10);
+
+        /*
+         * start handshake, drain buffer
+         */
+        if (ssle.wrap(appBB, netBB).getHandshakeStatus() !=
+                HandshakeStatus.NEED_UNWRAP) {
+            throw new Exception("initial client hello needs unwrap");
+        }
+
+        /* Checking for overflow wrap/unwrap() */
+
+        if (ssle.wrap(appBB, netBB).getStatus() !=
+                Status.BUFFER_OVERFLOW) {
+            throw new Exception("unwrap should have overflowed");
+        }
+
+        ByteBuffer ro = appBB.asReadOnlyBuffer();
+
+        System.out.println("checking for wrap/unwrap on RO Buffers");
+        try {
+            ssle.wrap(netBB, ro);
+            throw new Exception("wrap wasn't ReadOnlyBufferException");
+        } catch (ReadOnlyBufferException e) {
+            System.out.println("Caught the ReadOnlyBuffer: " + e);
+        }
+
+        try {
+            ssle.unwrap(netBB, ro);
+            throw new Exception("unwrap wasn't ReadOnlyBufferException");
+        } catch (ReadOnlyBufferException e) {
+            System.out.println("Caught the ReadOnlyBuffer: " + e);
+        }
+
+        appBB.position(0);
+        System.out.println("Check various UNDERFLOW conditions");
+
+        SSLEngineResult sslER;
+
+        if ((sslER =
+                ssle.unwrap(ByteBuffer.wrap(smallSSLHeader),
+                appBB)).getStatus() !=
+                Status.BUFFER_UNDERFLOW) {
+            System.out.println(sslER);
+            throw new Exception("unwrap should underflow");
+        }
+
+        if ((sslER =
+                ssle.unwrap(ByteBuffer.wrap(incompleteSSLHeader),
+                appBB)).getStatus() !=
+                Status.BUFFER_UNDERFLOW) {
+            System.out.println(sslER);
+            throw new Exception("unwrap should underflow");
+        }
+
+        if ((sslER =
+                ssle.unwrap(ByteBuffer.wrap(smallv2Header),
+                appBB)).getStatus() !=
+                Status.BUFFER_UNDERFLOW) {
+            System.out.println(sslER);
+            throw new Exception("unwrap should underflow");
+        }
+
+        // junk inbound message
+        try {
+            ssle.unwrap(ByteBuffer.wrap(gobblydegook), appBB);
+            throw new Exception("Didn't catch the nasty SSLException");
+        } catch (SSLException e) {
+            System.out.println("caught the nasty SSLException: " + e);
+        }
+
+        System.out.println("Test PASSED");
+
+    }
+
+    static byte [] smallSSLHeader = new byte [] {
+        (byte) 0x16, (byte) 0x03, (byte) 0x01,
+        (byte) 0x05 };
+
+    static byte [] incompleteSSLHeader = new byte [] {
+        (byte) 0x16, (byte) 0x03, (byte) 0x01,
+        (byte) 0x00, (byte) 0x5,  // 5 bytes
+        (byte) 0x16, (byte) 0x03, (byte) 0x01, (byte) 0x00 };
+
+    static byte [] smallv2Header = new byte [] {
+        (byte) 0x80, (byte) 0x03, (byte) 0x01,
+        (byte) 0x00 };
+
+    static byte [] gobblydegook = new byte [] {
+        // "HELLO HELLO"
+        (byte) 0x48, (byte) 0x45, (byte) 0x4C, (byte) 0x4C, (byte) 0x20,
+        (byte) 0x48, (byte) 0x45, (byte) 0x4C, (byte) 0x4C };
+
+    static void printStrings(String label, String [] strs) {
+        System.out.println(label);
+
+        for (int i = 0; i < strs.length; i++) {
+            System.out.println("    " + strs[i]);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/CheckStatus.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,726 @@
+/*
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4948079
+ * @summary SSLEngineResult needs updating [none yet]
+ *
+ * This is a simple hack to test a bunch of conditions and check
+ * their return codes.
+ *
+ * @run main/othervm -Djsse.enableCBCProtection=false CheckStatus
+ *
+ * @author Brad Wetmore
+ */
+
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.*;
+import java.io.*;
+import java.security.*;
+import java.nio.*;
+
+public class CheckStatus {
+
+    private static boolean debug = true;
+
+    private SSLContext sslc;
+    private SSLEngine ssle1;    // client
+    private SSLEngine ssle2;    // server
+
+    private static String pathToStores = "../etc";
+    private static String keyStoreFile = "keystore";
+    private static String trustStoreFile = "truststore";
+    private static String passwd = "passphrase";
+
+    private static String keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+    private static String trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+    private ByteBuffer appOut1;         // write side of ssle1
+    private ByteBuffer appIn1;          // read side of ssle1
+    private ByteBuffer appOut2;         // write side of ssle2
+    private ByteBuffer appIn2;          // read side of ssle2
+
+    private ByteBuffer oneToTwo;        // "reliable" transport ssle1->ssle2
+    private ByteBuffer twoToOne;        // "reliable" transport ssle2->ssle1
+
+    /*
+     * Majority of the test case is here, setup is done below.
+     */
+
+    private void createSSLEngines() throws Exception {
+        ssle1 = sslc.createSSLEngine("client", 1);
+        ssle1.setUseClientMode(true);
+
+        ssle2 = sslc.createSSLEngine("server", 2);
+        ssle2.setUseClientMode(false);
+    }
+
+    private boolean isHandshaking(SSLEngine e) {
+        return (e.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING);
+    }
+
+    private void checkResult(ByteBuffer bbIn, ByteBuffer bbOut,
+            SSLEngineResult result,
+            Status status, HandshakeStatus hsStatus,
+            int consumed, int produced)
+            throws Exception {
+
+        if ((status != null) && (result.getStatus() != status)) {
+            throw new Exception("Unexpected Status: need = " + status +
+                " got = " + result.getStatus());
+        }
+
+        if ((hsStatus != null) && (result.getHandshakeStatus() != hsStatus)) {
+            throw new Exception("Unexpected hsStatus: need = " + hsStatus +
+                " got = " + result.getHandshakeStatus());
+        }
+
+        if ((consumed != -1) && (consumed != result.bytesConsumed())) {
+            throw new Exception("Unexpected consumed: need = " + consumed +
+                " got = " + result.bytesConsumed());
+        }
+
+        if ((produced != -1) && (produced != result.bytesProduced())) {
+            throw new Exception("Unexpected produced: need = " + produced +
+                " got = " + result.bytesProduced());
+        }
+
+        if ((consumed != -1) && (bbIn.position() != result.bytesConsumed())) {
+            throw new Exception("Consumed " + bbIn.position() +
+                " != " + consumed);
+        }
+
+        if ((produced != -1) && (bbOut.position() != result.bytesProduced())) {
+            throw new Exception("produced " + bbOut.position() +
+                " != " + produced);
+        }
+    }
+
+    private void test() throws Exception {
+        createSSLEngines();
+        createBuffers();
+
+        SSLEngineResult result1;        // ssle1's results from last operation
+        SSLEngineResult result2;        // ssle2's results from last operation
+
+        String [] suite1 = new String [] {
+            "SSL_RSA_WITH_RC4_128_MD5" };
+        String [] suite2 = new String [] {
+            "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA" };
+
+        ssle1.setEnabledCipherSuites(suite1);
+        ssle2.setEnabledCipherSuites(suite1);
+
+        log("================");
+
+        log("unexpected empty unwrap");
+        twoToOne.limit(0);
+        result1 = ssle1.unwrap(twoToOne, appIn1);
+        checkResult(twoToOne, appIn1, result1,
+            Status.OK, HandshakeStatus.NEED_WRAP, 0, 0);
+        twoToOne.limit(twoToOne.capacity());
+
+        log("======================================");
+        log("client hello");
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(appOut1, oneToTwo, result1,
+             Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1);
+
+        oneToTwo.flip();
+        result2 = ssle2.unwrap(oneToTwo, appIn2);
+
+        checkResult(oneToTwo, appIn2, result2,
+             Status.OK, HandshakeStatus.NEED_TASK, result1.bytesProduced(), 0);
+        runDelegatedTasks(ssle2);
+
+        oneToTwo.compact();
+
+        log("Check for unwrap when wrap needed");
+        result2 = ssle2.unwrap(oneToTwo, appIn2);
+        checkResult(oneToTwo, appIn2, result2,
+            Status.OK, HandshakeStatus.NEED_WRAP, 0, 0);
+
+        log("======================================");
+        log("ServerHello");
+
+        result2 = ssle2.wrap(appOut2, twoToOne);
+        checkResult(appOut2, twoToOne, result2,
+            Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1);
+        twoToOne.flip();
+
+        result1 = ssle1.unwrap(twoToOne, appIn1);
+        checkResult(twoToOne, appIn1, result1,
+            Status.OK, HandshakeStatus.NEED_TASK, result2.bytesProduced(), 0);
+        twoToOne.compact();
+
+        runDelegatedTasks(ssle1);
+
+        log("======================================");
+        log("Key Exchange");
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(appOut1, oneToTwo, result1,
+             Status.OK, HandshakeStatus.NEED_WRAP, 0, -1);
+
+        oneToTwo.flip();
+        result2 = ssle2.unwrap(oneToTwo, appIn2);
+
+        checkResult(oneToTwo, appIn2, result2,
+             Status.OK, HandshakeStatus.NEED_TASK, result1.bytesProduced(), 0);
+        runDelegatedTasks(ssle2);
+
+        oneToTwo.compact();
+
+        log("======================================");
+        log("CCS");
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(appOut1, oneToTwo, result1,
+             Status.OK, HandshakeStatus.NEED_WRAP, 0, -1);
+
+        oneToTwo.flip();
+        result2 = ssle2.unwrap(oneToTwo, appIn2);
+
+        checkResult(oneToTwo, appIn2, result2,
+             Status.OK, HandshakeStatus.NEED_UNWRAP,
+             result1.bytesProduced(), 0);
+
+        oneToTwo.compact();
+
+        log("======================================");
+        log("Finished");
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(appOut1, oneToTwo, result1,
+             Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1);
+
+        oneToTwo.flip();
+        result2 = ssle2.unwrap(oneToTwo, appIn2);
+
+        checkResult(oneToTwo, appIn2, result2,
+             Status.OK, HandshakeStatus.NEED_WRAP, result1.bytesProduced(), 0);
+
+        oneToTwo.compact();
+
+        log("======================================");
+        log("CCS");
+
+        result2 = ssle2.wrap(appOut2, twoToOne);
+        checkResult(appOut2, twoToOne, result2,
+            Status.OK, HandshakeStatus.NEED_WRAP, 0, -1);
+        twoToOne.flip();
+
+        result1 = ssle1.unwrap(twoToOne, appIn1);
+        checkResult(twoToOne, appIn1, result1,
+            Status.OK, HandshakeStatus.NEED_UNWRAP, result2.bytesProduced(), 0);
+        twoToOne.compact();
+
+        log("======================================");
+        log("FINISHED");
+
+        result2 = ssle2.wrap(appOut2, twoToOne);
+        checkResult(appOut2, twoToOne, result2,
+            Status.OK, HandshakeStatus.FINISHED, 0, -1);
+        twoToOne.flip();
+
+        result1 = ssle1.unwrap(twoToOne, appIn1);
+        checkResult(twoToOne, appIn1, result1,
+            Status.OK, HandshakeStatus.FINISHED, result2.bytesProduced(), 0);
+        twoToOne.compact();
+
+        log("======================================");
+        log("Check Session/Ciphers");
+
+        String suite = ssle1.getSession().getCipherSuite();
+        if (!suite.equals(suite1[0])) {
+            throw new Exception("suites not equal: " + suite + "/" +
+                suite1[0]);
+        }
+
+        suite = ssle2.getSession().getCipherSuite();
+        if (!suite.equals(suite1[0])) {
+            throw new Exception("suites not equal: " + suite + "/" +
+                suite1[0]);
+        }
+
+        log("======================================");
+        log("DATA");
+
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(appOut1, oneToTwo, result1,
+            Status.OK, HandshakeStatus.NOT_HANDSHAKING,
+            appOut1.capacity(), -1);
+        oneToTwo.flip();
+
+        result2 = ssle2.wrap(appOut2, twoToOne);
+        checkResult(appOut2, twoToOne, result2,
+            Status.OK, HandshakeStatus.NOT_HANDSHAKING,
+            appOut2.capacity(), -1);
+        twoToOne.flip();
+
+        SSLEngineResult result3 = ssle1.unwrap(twoToOne, appIn1);
+        checkResult(twoToOne, appIn1, result3,
+            Status.OK, HandshakeStatus.NOT_HANDSHAKING,
+            result2.bytesProduced(), result2.bytesConsumed());
+        twoToOne.compact();
+
+        SSLEngineResult result4 = ssle2.unwrap(oneToTwo, appIn2);
+        checkResult(oneToTwo, appIn2, result4,
+            Status.OK, HandshakeStatus.NOT_HANDSHAKING,
+            result1.bytesProduced(), result1.bytesConsumed());
+        oneToTwo.compact();
+
+        appIn1.clear();
+        appIn2.clear();
+        appOut1.rewind();
+        appOut2.rewind();
+
+        log("======================================");
+        log("RENEGOTIATE");
+
+        ssle2.getSession().invalidate();
+        ssle2.setNeedClientAuth(true);
+
+        ssle1.setEnabledCipherSuites(suite2);
+        ssle2.setEnabledCipherSuites(suite2);
+
+        ssle2.beginHandshake();
+
+        log("======================================");
+        log("HelloRequest");
+
+        result2 = ssle2.wrap(appOut2, twoToOne);
+        checkResult(appOut2, twoToOne, result2,
+            Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1);
+        twoToOne.flip();
+
+        result1 = ssle1.unwrap(twoToOne, appIn1);
+        checkResult(twoToOne, appIn1, result1,
+            Status.OK, HandshakeStatus.NEED_TASK, result2.bytesProduced(), 0);
+        twoToOne.compact();
+
+        runDelegatedTasks(ssle1);
+
+        log("======================================");
+        log("ClientHello");
+
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(appOut1, oneToTwo, result1,
+             Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1);
+
+        oneToTwo.flip();
+        result2 = ssle2.unwrap(oneToTwo, appIn2);
+
+        checkResult(oneToTwo, appIn2, result2,
+             Status.OK, HandshakeStatus.NEED_TASK, result1.bytesProduced(), 0);
+        runDelegatedTasks(ssle2);
+
+        oneToTwo.compact();
+
+        log("======================================");
+        log("CLIENT->SERVER DATA IN MIDDLE OF HANDSHAKE");
+
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(appOut1, oneToTwo, result1,
+            Status.OK, HandshakeStatus.NEED_UNWRAP,
+            appOut1.capacity(), -1);
+        oneToTwo.flip();
+
+        result4 = ssle2.unwrap(oneToTwo, appIn2);
+        checkResult(oneToTwo, appIn2, result4,
+            Status.OK, HandshakeStatus.NEED_WRAP,
+            result1.bytesProduced(), result1.bytesConsumed());
+        oneToTwo.compact();
+
+        appIn2.clear();
+        appOut1.rewind();
+
+        log("======================================");
+        log("ServerHello");
+
+        result2 = ssle2.wrap(appOut2, twoToOne);
+        checkResult(appOut2, twoToOne, result2,
+            Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1);
+        twoToOne.flip();
+
+        result1 = ssle1.unwrap(twoToOne, appIn1);
+        checkResult(twoToOne, appIn1, result1,
+            Status.OK, HandshakeStatus.NEED_TASK, result2.bytesProduced(), 0);
+        twoToOne.compact();
+
+        runDelegatedTasks(ssle1);
+
+        log("======================================");
+        log("SERVER->CLIENT DATA IN MIDDLE OF HANDSHAKE");
+
+        result2 = ssle2.wrap(appOut2, twoToOne);
+        checkResult(appOut2, twoToOne, result2,
+            Status.OK, HandshakeStatus.NEED_UNWRAP,
+            appOut2.capacity(), -1);
+        twoToOne.flip();
+
+        result3 = ssle1.unwrap(twoToOne, appIn1);
+        checkResult(twoToOne, appIn1, result3,
+            Status.OK, HandshakeStatus.NEED_WRAP,
+            result2.bytesProduced(), result2.bytesConsumed());
+        twoToOne.compact();
+
+        appIn1.clear();
+        appOut2.rewind();
+
+        log("======================================");
+        log("Client Cert");
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(appOut1, oneToTwo, result1,
+             Status.OK, HandshakeStatus.NEED_WRAP, 0, -1);
+
+        oneToTwo.flip();
+        result2 = ssle2.unwrap(oneToTwo, appIn2);
+
+        checkResult(oneToTwo, appIn2, result2,
+             Status.OK, HandshakeStatus.NEED_TASK, result1.bytesProduced(), 0);
+        runDelegatedTasks(ssle2);
+
+        oneToTwo.compact();
+
+        log("======================================");
+        log("Key Exchange");
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(appOut1, oneToTwo, result1,
+             Status.OK, HandshakeStatus.NEED_WRAP, 0, -1);
+
+        oneToTwo.flip();
+        result2 = ssle2.unwrap(oneToTwo, appIn2);
+
+        checkResult(oneToTwo, appIn2, result2,
+             Status.OK, HandshakeStatus.NEED_TASK,
+             result1.bytesProduced(), 0);
+        runDelegatedTasks(ssle2);
+
+        oneToTwo.compact();
+
+        log("======================================");
+        log("CCS");
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(appOut1, oneToTwo, result1,
+             Status.OK, HandshakeStatus.NEED_WRAP, 0, -1);
+
+        oneToTwo.flip();
+        result2 = ssle2.unwrap(oneToTwo, appIn2);
+
+        checkResult(oneToTwo, appIn2, result2,
+             Status.OK, HandshakeStatus.NEED_UNWRAP,
+             result1.bytesProduced(), 0);
+
+        oneToTwo.compact();
+
+        log("======================================");
+        log("Finished");
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(appOut1, oneToTwo, result1,
+             Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1);
+
+        oneToTwo.flip();
+        result2 = ssle2.unwrap(oneToTwo, appIn2);
+
+        checkResult(oneToTwo, appIn2, result2,
+             Status.OK, HandshakeStatus.NEED_WRAP, result1.bytesProduced(), 0);
+
+        oneToTwo.compact();
+
+        log("======================================");
+        log("CCS");
+
+        result2 = ssle2.wrap(appOut2, twoToOne);
+        checkResult(appOut2, twoToOne, result2,
+            Status.OK, HandshakeStatus.NEED_WRAP, 0, -1);
+        twoToOne.flip();
+
+        result1 = ssle1.unwrap(twoToOne, appIn1);
+        checkResult(twoToOne, appIn1, result1,
+            Status.OK, HandshakeStatus.NEED_UNWRAP, result2.bytesProduced(), 0);
+        twoToOne.compact();
+
+        log("======================================");
+        log("FINISHED");
+
+        result2 = ssle2.wrap(appOut2, twoToOne);
+        checkResult(appOut2, twoToOne, result2,
+            Status.OK, HandshakeStatus.FINISHED, 0, -1);
+        twoToOne.flip();
+
+        result1 = ssle1.unwrap(twoToOne, appIn1);
+        checkResult(twoToOne, appIn1, result1,
+            Status.OK, HandshakeStatus.FINISHED, result2.bytesProduced(), 0);
+        twoToOne.compact();
+
+        log("======================================");
+        log("Check Session/Ciphers");
+
+        suite = ssle1.getSession().getCipherSuite();
+        if (!suite.equals(suite2[0])) {
+            throw new Exception("suites not equal: " + suite + "/" +
+                suite2[0]);
+        }
+
+        suite = ssle2.getSession().getCipherSuite();
+        if (!suite.equals(suite2[0])) {
+            throw new Exception("suites not equal: " + suite + "/" +
+                suite2[0]);
+        }
+
+        log("======================================");
+        log("DATA USING NEW SESSION");
+
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(appOut1, oneToTwo, result1,
+            Status.OK, HandshakeStatus.NOT_HANDSHAKING,
+            appOut1.capacity(), -1);
+        oneToTwo.flip();
+
+        result2 = ssle2.wrap(appOut2, twoToOne);
+        checkResult(appOut2, twoToOne, result2,
+            Status.OK, HandshakeStatus.NOT_HANDSHAKING,
+            appOut2.capacity(), -1);
+        twoToOne.flip();
+
+        result3 = ssle1.unwrap(twoToOne, appIn1);
+        checkResult(twoToOne, appIn1, result3,
+            Status.OK, HandshakeStatus.NOT_HANDSHAKING,
+            result2.bytesProduced(), result2.bytesConsumed());
+        twoToOne.compact();
+
+        result4 = ssle2.unwrap(oneToTwo, appIn2);
+        checkResult(oneToTwo, appIn2, result4,
+            Status.OK, HandshakeStatus.NOT_HANDSHAKING,
+            result1.bytesProduced(), result1.bytesConsumed());
+        oneToTwo.compact();
+
+        appIn1.clear();
+        appIn2.clear();
+        appOut1.rewind();
+        appOut2.rewind();
+
+        log("======================================");
+        log("CN");
+
+        if (isHandshaking(ssle1)) {
+            throw new Exception("ssle1 IS handshaking");
+        }
+
+        if (isHandshaking(ssle2)) {
+            throw new Exception("ssle2 IS handshaking");
+        }
+
+        ssle2.closeOutbound();
+
+        if (!isHandshaking(ssle2)) {
+            throw new Exception("ssle1 IS NOT handshaking");
+        }
+
+        appOut1.rewind();
+        appOut2.rewind();
+
+        result2 = ssle2.wrap(appOut2, twoToOne);
+        checkResult(appOut2, twoToOne, result2,
+            Status.CLOSED, HandshakeStatus.NEED_UNWRAP, 0, -1);
+        twoToOne.flip();
+
+        if (ssle1.isInboundDone()) {
+            throw new Exception("ssle1 inboundDone");
+        }
+
+        result1 = ssle1.unwrap(twoToOne, appIn1);
+        checkResult(twoToOne, appIn1, result1,
+            Status.CLOSED, HandshakeStatus.NEED_WRAP,
+            result2.bytesProduced(), 0);
+        twoToOne.compact();
+
+        if (!ssle1.isInboundDone()) {
+            throw new Exception("ssle1 inboundDone");
+        }
+
+        if (!isHandshaking(ssle1)) {
+            throw new Exception("ssle1 IS NOT handshaking");
+        }
+
+        result2 = ssle2.wrap(appOut2, twoToOne);
+        checkResult(appOut2, twoToOne, result2,
+            Status.CLOSED, HandshakeStatus.NEED_UNWRAP, 0, 0);
+        twoToOne.flip();
+
+        log("======================================");
+        log("CN response");
+
+        if (ssle1.isOutboundDone()) {
+            throw new Exception("ssle1 outboundDone");
+        }
+
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(appOut1, oneToTwo, result1,
+             Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, 0, -1);
+
+        if (!ssle1.isOutboundDone()) {
+            throw new Exception("ssle1 outboundDone is NOT done");
+        }
+
+        if (isHandshaking(ssle1)) {
+            throw new Exception("ssle1 IS handshaking");
+        }
+
+        oneToTwo.flip();
+
+        if (!ssle2.isOutboundDone()) {
+            throw new Exception("ssle1 outboundDone");
+        }
+
+        if (ssle2.isInboundDone()) {
+            throw new Exception("ssle1 inboundDone");
+        }
+
+        result2 = ssle2.unwrap(oneToTwo, appIn2);
+
+        checkResult(oneToTwo, appIn2, result2,
+             Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING,
+             result1.bytesProduced(), 0);
+
+        if (!ssle2.isOutboundDone()) {
+            throw new Exception("ssle1 outboundDone is NOT done");
+        }
+
+        if (!ssle2.isInboundDone()) {
+            throw new Exception("ssle1 inboundDone is NOT done");
+        }
+
+        if (isHandshaking(ssle2)) {
+            throw new Exception("ssle1 IS handshaking");
+        }
+
+        oneToTwo.compact();
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        CheckStatus cs;
+
+        cs = new CheckStatus();
+
+        cs.createSSLEngines();
+
+        cs.test();
+
+        System.out.println("Test Passed.");
+    }
+
+    /*
+     * **********************************************************
+     * Majority of the test case is above, below is just setup stuff
+     * **********************************************************
+     */
+
+    public CheckStatus() throws Exception {
+        sslc = getSSLContext(keyFilename, trustFilename);
+    }
+
+    /*
+     * Create an initialized SSLContext to use for this test.
+     */
+    private SSLContext getSSLContext(String keyFile, String trustFile)
+            throws Exception {
+
+        KeyStore ks = KeyStore.getInstance("JKS");
+        KeyStore ts = KeyStore.getInstance("JKS");
+
+        char[] passphrase = "passphrase".toCharArray();
+
+        ks.load(new FileInputStream(keyFile), passphrase);
+        ts.load(new FileInputStream(trustFile), passphrase);
+
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+        kmf.init(ks, passphrase);
+
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+        tmf.init(ts);
+
+        SSLContext sslCtx = SSLContext.getInstance("TLS");
+
+        sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+        return sslCtx;
+    }
+
+    private void createBuffers() {
+        // Size the buffers as appropriate.
+
+        SSLSession session = ssle1.getSession();
+        int appBufferMax = session.getApplicationBufferSize();
+        int netBufferMax = session.getPacketBufferSize();
+
+        appIn1 = ByteBuffer.allocateDirect(appBufferMax + 50);
+        appIn2 = ByteBuffer.allocateDirect(appBufferMax + 50);
+
+        oneToTwo = ByteBuffer.allocateDirect(netBufferMax);
+        twoToOne = ByteBuffer.allocateDirect(netBufferMax);
+
+        appOut1 = ByteBuffer.wrap("Hi Engine2, I'm SSLEngine1".getBytes());
+        appOut2 = ByteBuffer.wrap("Hello Engine1, I'm SSLEngine2".getBytes());
+
+        log("AppOut1 = " + appOut1);
+        log("AppOut2 = " + appOut2);
+        log("");
+    }
+
+    private static void runDelegatedTasks(SSLEngine engine) throws Exception {
+
+        Runnable runnable;
+        while ((runnable = engine.getDelegatedTask()) != null) {
+            log("running delegated task...");
+            runnable.run();
+        }
+    }
+
+    private static void checkTransfer(ByteBuffer a, ByteBuffer b)
+            throws Exception {
+        a.flip();
+        b.flip();
+
+        if (!a.equals(b)) {
+            throw new Exception("Data didn't transfer cleanly");
+        } else {
+            log("Data transferred cleanly");
+        }
+
+        a.position(a.limit());
+        b.position(b.limit());
+        a.limit(a.capacity());
+        b.limit(b.capacity());
+    }
+
+    private static void log(String str) {
+        if (debug) {
+            System.out.println(str);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/ConnectionTest.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,675 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4495742
+ * @summary Add non-blocking SSL/TLS functionality, usable with any
+ *      I/O abstraction
+ *
+ * This is a bit hacky, meant to test various conditions.  The main
+ * thing I wanted to do with this was to do buffer reads/writes
+ * when buffers were not empty.  (buffer.position() = 10)
+ * The code could certainly be tightened up a lot.
+ *
+ * @author Brad Wetmore
+ */
+
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.*;
+import java.io.*;
+import java.security.*;
+import java.nio.*;
+
+public class ConnectionTest {
+
+    private SSLContext sslc;
+    private SSLEngine ssle1;
+    private SSLEngine ssle2;
+
+    private static String pathToStores = "../etc";
+    private static String keyStoreFile = "keystore";
+    private static String trustStoreFile = "truststore";
+    private static String passwd = "passphrase";
+
+    private static String keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+    private static String trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+    private ByteBuffer appIn1, appOut1;
+    private ByteBuffer appIn2, appOut2;
+    private ByteBuffer oneToTwo, twoToOne;
+    private ByteBuffer emptyBuffer;
+
+    private ByteBuffer  oneToTwoShifter, twoToOneShifter;
+
+    private String hostname = "hostname";
+    private int portNumber = 77;
+
+    public ConnectionTest()
+            throws Exception {
+
+        sslc = getSSLContext();
+        ssle1 = sslc.createSSLEngine(hostname, portNumber);
+        ssle2 = sslc.createSSLEngine();
+
+        ssle1.setEnabledCipherSuites(new String [] {
+            "SSL_RSA_WITH_RC4_128_MD5"});
+
+        createBuffers();
+    }
+
+    private SSLContext getSSLContext() throws Exception {
+        KeyStore ks = KeyStore.getInstance("JKS");
+        KeyStore ts = KeyStore.getInstance("JKS");
+        char[] passphrase = "passphrase".toCharArray();
+
+        ks.load(new FileInputStream(keyFilename), passphrase);
+        ts.load(new FileInputStream(trustFilename), passphrase);
+
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+        kmf.init(ks, passphrase);
+
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+        tmf.init(ts);
+
+        SSLContext sslCtx = SSLContext.getInstance("TLS");
+
+        sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+        return sslCtx;
+    }
+
+    private void createBuffers() {
+        // Size the buffers as appropriate.
+        SSLSession session = ssle1.getSession();
+        int appBufferMax = session.getApplicationBufferSize();
+        int netBufferMax = session.getPacketBufferSize();
+
+        appIn1 = ByteBuffer.allocateDirect(appBufferMax + 10);
+        appIn2 = ByteBuffer.allocateDirect(appBufferMax + 10);
+
+        appIn1.position(10);
+        appIn2.position(10);
+
+        oneToTwo = ByteBuffer.allocateDirect(netBufferMax + 10);
+        twoToOne = ByteBuffer.allocateDirect(netBufferMax + 10);
+
+        oneToTwo.position(10);
+        twoToOne.position(10);
+        oneToTwoShifter = oneToTwo.slice();
+        twoToOneShifter = twoToOne.slice();
+
+        appOut1 = ByteBuffer.wrap("Hi Engine2, I'm SSLEngine1".getBytes());
+        appOut2 = ByteBuffer.wrap("Hello Engine1, I'm SSLEngine2".getBytes());
+
+        emptyBuffer = ByteBuffer.allocate(10);
+        emptyBuffer.limit(5);
+        emptyBuffer.position(emptyBuffer.limit());
+
+        System.out.println("AppOut1 = " + appOut1);
+        System.out.println("AppOut2 = " + appOut2);
+        System.out.println();
+    }
+
+    private void checkResult(SSLEngineResult result, Status status,
+            HandshakeStatus hsStatus, int consumed, int produced,
+            boolean done) throws Exception {
+
+        if ((status != null) && (result.getStatus() != status)) {
+            throw new Exception("Unexpected Status: need = " + status +
+                " got = " + result.getStatus());
+        }
+
+        if ((hsStatus != null) && (result.getHandshakeStatus() != hsStatus)) {
+            throw new Exception("Unexpected hsStatus: need = " + hsStatus +
+                " got = " + result.getHandshakeStatus());
+        }
+
+        if ((consumed != -1) && (consumed != result.bytesConsumed())) {
+            throw new Exception("Unexpected consumed: need = " + consumed +
+                " got = " + result.bytesConsumed());
+        }
+
+        if ((produced != -1) && (produced != result.bytesProduced())) {
+            throw new Exception("Unexpected produced: need = " + produced +
+                " got = " + result.bytesProduced());
+        }
+
+        if (done && (hsStatus == HandshakeStatus.FINISHED)) {
+            throw new Exception(
+                "Handshake already reported finished");
+        }
+
+    }
+
+    private boolean isHandshaking(SSLEngine e) {
+        return (e.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING);
+    }
+
+    private void test() throws Exception {
+        ssle1.setUseClientMode(true);
+        ssle2.setUseClientMode(false);
+        ssle2.setNeedClientAuth(true);
+
+        System.out.println("Testing for early unwrap/wrap");
+        SSLEngineResult result1 = ssle1.unwrap(twoToOne, appIn1);
+        SSLEngineResult result2 = ssle2.wrap(appOut2, oneToTwo);
+
+        /*
+         * These should not consume/produce data, because they
+         * are client and server, respectively, and don't
+         * start handshaking this way.
+         */
+        checkResult(result1, Status.OK, HandshakeStatus.NEED_WRAP,
+            0, 0, false);
+        checkResult(result2, Status.OK, HandshakeStatus.NEED_UNWRAP,
+            0, 0, false);
+
+        System.out.println("Doing Initial Handshake");
+
+        boolean done1 = false;
+        boolean done2 = false;
+
+        /*
+         * Do initial handshaking
+         */
+        while (isHandshaking(ssle1) ||
+                isHandshaking(ssle2)) {
+
+            System.out.println("================");
+
+            result1 = ssle1.wrap(emptyBuffer, oneToTwo);
+            checkResult(result1, null, null, 0, -1, done1);
+            result2 = ssle2.wrap(emptyBuffer, twoToOne);
+            checkResult(result2, null, null, 0, -1, done2);
+
+            if (result1.getHandshakeStatus() == HandshakeStatus.FINISHED) {
+                done1 = true;
+            }
+
+            if (result2.getHandshakeStatus() == HandshakeStatus.FINISHED) {
+                done2 = true;
+            }
+
+            System.out.println("wrap1 = " + result1);
+            System.out.println("wrap2 = " + result2);
+
+            if (result1.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+                Runnable runnable;
+                while ((runnable = ssle1.getDelegatedTask()) != null) {
+                    runnable.run();
+                }
+            }
+
+            if (result2.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+                Runnable runnable;
+                while ((runnable = ssle2.getDelegatedTask()) != null) {
+                    runnable.run();
+                }
+            }
+
+            oneToTwo.flip();
+            twoToOne.flip();
+
+            oneToTwo.position(10);
+            twoToOne.position(10);
+
+            System.out.println("----");
+
+            result1 = ssle1.unwrap(twoToOne, appIn1);
+            checkResult(result1, null, null, -1, 0, done1);
+            result2 = ssle2.unwrap(oneToTwo, appIn2);
+            checkResult(result2, null, null, -1, 0, done2);
+
+            if (result1.getHandshakeStatus() == HandshakeStatus.FINISHED) {
+                done1 = true;
+            }
+
+            if (result2.getHandshakeStatus() == HandshakeStatus.FINISHED) {
+                done2 = true;
+            }
+
+            if (result1.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+                Runnable runnable;
+                while ((runnable = ssle1.getDelegatedTask()) != null) {
+                    runnable.run();
+                }
+            }
+
+            if (result2.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+                Runnable runnable;
+                while ((runnable = ssle2.getDelegatedTask()) != null) {
+                    runnable.run();
+                }
+            }
+
+            System.out.println("unwrap1 = " + result1);
+            System.out.println("unwrap2 = " + result2);
+
+            oneToTwoShifter.position(oneToTwo.position() - 10);
+            oneToTwoShifter.limit(oneToTwo.limit() - 10);
+            twoToOneShifter.position(twoToOne.position() - 10);
+            twoToOneShifter.limit(twoToOne.limit() - 10);
+            oneToTwoShifter.compact();
+            twoToOneShifter.compact();
+            oneToTwo.position(oneToTwoShifter.position() + 10);
+            oneToTwo.limit(oneToTwoShifter.limit() + 10);
+            twoToOne.position(twoToOneShifter.position() + 10);
+            twoToOne.limit(twoToOneShifter.limit() + 10);
+        }
+
+        System.out.println("\nDONE HANDSHAKING");
+        System.out.println("================");
+
+        if (!done1 || !done2) {
+            throw new Exception("Both should be true:\n" +
+                " done1 = " + done1 + " done2 = " + done2);
+        }
+
+        String host = ssle1.getPeerHost();
+        int port = ssle1.getPeerPort();
+        if (!host.equals(hostname) || (port != portNumber)) {
+            throw new Exception("unexpected host/port " + host + ":" + port);
+        }
+
+        host = ssle2.getPeerHost();
+        port = ssle2.getPeerPort();
+        if ((host != null) || (port != -1)) {
+            throw new Exception("unexpected host/port " + host + ":" + port);
+        }
+
+        SSLSession ssls1 = ssle1.getSession();
+
+        host = ssls1.getPeerHost();
+        port = ssls1.getPeerPort();
+        if (!host.equals(hostname) || (port != portNumber)) {
+            throw new Exception("unexpected host/port " + host + ":" + port);
+        }
+
+        SSLSession ssls2 = ssle2.getSession();
+
+        host = ssls2.getPeerHost();
+        port = ssls2.getPeerPort();
+        if ((host != null) || (port != -1)) {
+            throw new Exception("unexpected host/port " + host + ":" + port);
+        }
+
+        /*
+         * Should be able to write/read a small buffer like this.
+         */
+        int appOut1Len = appOut1.remaining();
+        int appOut2Len = appOut2.remaining();
+        int net1Len;
+        int net2Len;
+
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(result1, Status.OK, HandshakeStatus.NOT_HANDSHAKING,
+            appOut1Len, -1, false);
+        result2 = ssle2.wrap(appOut2, twoToOne);
+        checkResult(result2, Status.OK, HandshakeStatus.NOT_HANDSHAKING,
+            appOut2Len, -1, false);
+        net1Len = result1.bytesProduced();
+        net2Len = result2.bytesProduced();
+
+        System.out.println("wrap1 = " + result1);
+        System.out.println("wrap2 = " + result2);
+
+        oneToTwo.flip();
+        twoToOne.flip();
+
+        oneToTwo.position(10);
+        twoToOne.position(10);
+
+        System.out.println("----");
+
+        result1 = ssle1.unwrap(twoToOne, appIn1);
+        checkResult(result1, Status.OK, HandshakeStatus.NOT_HANDSHAKING,
+            net2Len, appOut2Len, false);
+        result2 = ssle2.unwrap(oneToTwo, appIn2);
+        checkResult(result2, Status.OK, HandshakeStatus.NOT_HANDSHAKING,
+            net1Len, appOut1Len, false);
+
+        System.out.println("unwrap1 = " + result1);
+        System.out.println("unwrap2 = " + result2);
+
+        oneToTwoShifter.position(oneToTwo.position() - 10);
+        oneToTwoShifter.limit(oneToTwo.limit() - 10);
+        twoToOneShifter.position(twoToOne.position() - 10);
+        twoToOneShifter.limit(twoToOne.limit() - 10);
+        oneToTwoShifter.compact();
+        twoToOneShifter.compact();
+        oneToTwo.position(oneToTwoShifter.position() + 10);
+        oneToTwo.limit(oneToTwoShifter.limit() + 10);
+        twoToOne.position(twoToOneShifter.position() + 10);
+        twoToOne.limit(twoToOneShifter.limit() + 10);
+
+        ssls2.invalidate();
+        ssle2.beginHandshake();
+
+        System.out.println("\nRENEGOTIATING");
+        System.out.println("=============");
+
+        done1 = false;
+        done2 = false;
+
+        appIn1.clear();
+        appIn2.clear();
+
+        /*
+         * Do a quick test to see if this can do a switch
+         * into client mode, at this point, you shouldn't be able
+         * to switch back.
+         */
+        try {
+            System.out.println("Try to change client mode");
+            ssle2.setUseClientMode(true);
+            throw new Exception("Should have thrown IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            System.out.println("Caught correct IllegalArgumentException");
+        }
+
+        while (isHandshaking(ssle1) ||
+                isHandshaking(ssle2)) {
+
+            System.out.println("================");
+
+            result1 = ssle1.wrap(emptyBuffer, oneToTwo);
+            checkResult(result1, null, null, 0, -1, done1);
+            result2 = ssle2.wrap(emptyBuffer, twoToOne);
+            checkResult(result2, null, null, 0, -1, done2);
+
+            if (result1.getHandshakeStatus() == HandshakeStatus.FINISHED) {
+                done1 = true;
+            }
+
+            if (result2.getHandshakeStatus() == HandshakeStatus.FINISHED) {
+                done2 = true;
+            }
+
+            System.out.println("wrap1 = " + result1);
+            System.out.println("wrap2 = " + result2);
+
+            if (result1.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+                Runnable runnable;
+                while ((runnable = ssle1.getDelegatedTask()) != null) {
+                    runnable.run();
+                }
+            }
+
+            if (result2.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+                Runnable runnable;
+                while ((runnable = ssle2.getDelegatedTask()) != null) {
+                    runnable.run();
+                }
+            }
+
+            oneToTwo.flip();
+            twoToOne.flip();
+
+            oneToTwo.position(10);
+            twoToOne.position(10);
+
+            System.out.println("----");
+
+            result1 = ssle1.unwrap(twoToOne, appIn1);
+            checkResult(result1, null, null, -1, 0, done1);
+            result2 = ssle2.unwrap(oneToTwo, appIn2);
+            checkResult(result2, null, null, -1, 0, done2);
+
+            if (result1.getHandshakeStatus() == HandshakeStatus.FINISHED) {
+                done1 = true;
+            }
+
+            if (result2.getHandshakeStatus() == HandshakeStatus.FINISHED) {
+                done2 = true;
+            }
+
+            System.out.println("unwrap1 = " + result1);
+            System.out.println("unwrap2 = " + result2);
+
+            if (result1.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+                Runnable runnable;
+                while ((runnable = ssle1.getDelegatedTask()) != null) {
+                    runnable.run();
+                }
+            }
+
+            if (result2.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+                Runnable runnable;
+                while ((runnable = ssle2.getDelegatedTask()) != null) {
+                    runnable.run();
+                }
+            }
+
+            oneToTwoShifter.position(oneToTwo.position() - 10);
+            oneToTwoShifter.limit(oneToTwo.limit() - 10);
+            twoToOneShifter.position(twoToOne.position() - 10);
+            twoToOneShifter.limit(twoToOne.limit() - 10);
+            oneToTwoShifter.compact();
+            twoToOneShifter.compact();
+            oneToTwo.position(oneToTwoShifter.position() + 10);
+            oneToTwo.limit(oneToTwoShifter.limit() + 10);
+            twoToOne.position(twoToOneShifter.position() + 10);
+            twoToOne.limit(twoToOneShifter.limit() + 10);
+        }
+
+        host = ssle1.getPeerHost();
+        port = ssle1.getPeerPort();
+        if (!host.equals(hostname) || (port != portNumber)) {
+            throw new Exception("unexpected host/port " + host + ":" + port);
+        }
+
+        host = ssle2.getPeerHost();
+        port = ssle2.getPeerPort();
+        if ((host != null) || (port != -1)) {
+            throw new Exception("unexpected host/port " + host + ":" + port);
+        }
+
+        SSLSession ssls3 = ssle2.getSession();
+
+        host = ssls1.getPeerHost();
+        port = ssls1.getPeerPort();
+        if (!host.equals(hostname) || (port != portNumber)) {
+            throw new Exception("unexpected host/port " + host + ":" + port);
+        }
+
+        SSLSession ssls4 = ssle2.getSession();
+
+        host = ssls2.getPeerHost();
+        port = ssls2.getPeerPort();
+        if ((host != null) || (port != -1)) {
+            throw new Exception("unexpected host/port " + host + ":" + port);
+        }
+
+        System.out.println("\nDoing close");
+        System.out.println("===========");
+
+        ssle1.closeOutbound();
+        ssle2.closeOutbound();
+
+        oneToTwo.flip();
+        twoToOne.flip();
+        oneToTwo.position(10);
+        twoToOne.position(10);
+
+        appIn1.clear();
+        appIn2.clear();
+
+        System.out.println("LAST UNWRAP");
+        result1 = ssle1.unwrap(twoToOne, appIn1);
+        checkResult(result1, Status.BUFFER_UNDERFLOW,
+            HandshakeStatus.NEED_WRAP, 0, 0, false);
+        result2 = ssle2.unwrap(oneToTwo, appIn2);
+        checkResult(result2, Status.BUFFER_UNDERFLOW,
+            HandshakeStatus.NEED_WRAP, 0, 0, false);
+
+        System.out.println("unwrap1 = " + result1);
+        System.out.println("unwrap2 = " + result2);
+
+        oneToTwoShifter.position(oneToTwo.position() - 10);
+        oneToTwoShifter.limit(oneToTwo.limit() - 10);
+        twoToOneShifter.position(twoToOne.position() - 10);
+        twoToOneShifter.limit(twoToOne.limit() - 10);
+        oneToTwoShifter.compact();
+        twoToOneShifter.compact();
+        oneToTwo.position(oneToTwoShifter.position() + 10);
+        oneToTwo.limit(oneToTwoShifter.limit() + 10);
+        twoToOne.position(twoToOneShifter.position() + 10);
+        twoToOne.limit(twoToOneShifter.limit() + 10);
+
+        System.out.println("LAST WRAP");
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(result1, Status.CLOSED, HandshakeStatus.NEED_UNWRAP,
+            0, -1, false);
+        result2 = ssle2.wrap(appOut2, twoToOne);
+        checkResult(result2, Status.CLOSED, HandshakeStatus.NEED_UNWRAP,
+            0, -1, false);
+
+        System.out.println("wrap1 = " + result1);
+        System.out.println("wrap2 = " + result2);
+
+        net1Len = result1.bytesProduced();
+        net2Len = result2.bytesProduced();
+
+        oneToTwo.flip();
+        twoToOne.flip();
+
+        oneToTwo.position(10);
+        twoToOne.position(10);
+
+        result1 = ssle1.unwrap(twoToOne, appIn1);
+        checkResult(result1, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING,
+            net1Len, 0, false);
+        result2 = ssle2.unwrap(oneToTwo, appIn2);
+        checkResult(result2, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING,
+            net2Len, 0, false);
+
+        System.out.println("unwrap1 = " + result1);
+        System.out.println("unwrap2 = " + result2);
+
+        oneToTwoShifter.position(oneToTwo.position() - 10);
+        oneToTwoShifter.limit(oneToTwo.limit() - 10);
+        twoToOneShifter.position(twoToOne.position() - 10);
+        twoToOneShifter.limit(twoToOne.limit() - 10);
+        oneToTwoShifter.compact();
+        twoToOneShifter.compact();
+        oneToTwo.position(oneToTwoShifter.position() + 10);
+        oneToTwo.limit(oneToTwoShifter.limit() + 10);
+        twoToOne.position(twoToOneShifter.position() + 10);
+        twoToOne.limit(twoToOneShifter.limit() + 10);
+
+        System.out.println("EXTRA WRAP");
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(result1, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING,
+            0, 0, false);
+        result2 = ssle2.wrap(appOut2, twoToOne);
+        checkResult(result2, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING,
+            0, 0, false);
+
+        System.out.println("wrap1 = " + result1);
+        System.out.println("wrap2 = " + result2);
+
+        oneToTwo.flip();
+        twoToOne.flip();
+        oneToTwo.position(10);
+        twoToOne.position(10);
+
+        System.out.println("EXTRA UNWRAP");
+        result1 = ssle1.unwrap(twoToOne, appIn1);
+        checkResult(result1, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING,
+            0, 0, false);
+        result2 = ssle2.unwrap(oneToTwo, appIn2);
+        checkResult(result2, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING,
+            0, 0, false);
+
+        System.out.println("unwrap1 = " + result1);
+        System.out.println("unwrap2 = " + result2);
+
+        checkSession(ssls1, ssls2, ssls3, ssls4);
+        System.out.println(ssle1);
+        System.out.println(ssle2);
+    }
+
+    private static void checkSession(SSLSession ssls1, SSLSession ssls2,
+            SSLSession ssls3, SSLSession ssls4) throws Exception {
+        System.out.println("\nSession Info for SSLEngine1");
+        System.out.println(ssls1);
+        System.out.println(ssls1.getCreationTime());
+        String peer1 = ssls1.getPeerHost();
+        System.out.println(peer1);
+        String protocol1 = ssls1.getProtocol();
+        System.out.println(protocol1);
+        java.security.cert.Certificate cert1 = ssls1.getPeerCertificates()[0];
+        System.out.println(cert1);
+        String ciphersuite1 = ssls1.getCipherSuite();
+        System.out.println(ciphersuite1);
+        System.out.println();
+
+        System.out.println("\nSession Info for SSLEngine2");
+        System.out.println(ssls2);
+        System.out.println(ssls2.getCreationTime());
+        String peer2 = ssls2.getPeerHost();
+        System.out.println(peer2);
+        String protocol2 = ssls2.getProtocol();
+        System.out.println(protocol2);
+        java.security.cert.Certificate cert2 = ssls2.getPeerCertificates()[0];
+        System.out.println(cert2);
+        String ciphersuite2 = ssls2.getCipherSuite();
+        System.out.println(ciphersuite2);
+        System.out.println();
+
+        if (peer1.equals(peer2)) {
+            throw new Exception("peer hostnames not equal");
+        }
+
+        if (!protocol1.equals(protocol2)) {
+            throw new Exception("protocols not equal");
+        }
+
+        if (!cert1.equals(cert2)) {
+            throw new Exception("certs not equal");
+        }
+
+        if (!ciphersuite1.equals(ciphersuite2)) {
+            throw new Exception("ciphersuites not equal");
+        }
+
+        System.out.println("\nSession Info for SSLEngine3");
+        System.out.println(ssls3);
+        System.out.println("\nSession Info for SSLEngine4");
+        System.out.println(ssls4);
+
+        if (ssls3.equals(ssls1) || ssls4.equals(ssls2)) {
+            throw new Exception("sessions should not be equals");
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+        ConnectionTest ct = new ConnectionTest();
+        ct.test();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/ExtendedKeyEngine.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,274 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4981697
+ * @summary Rework the X509KeyManager to avoid incompatibility issues
+ * @author Brad R. Wetmore
+ */
+
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.*;
+import java.io.*;
+import java.security.*;
+import java.nio.*;
+
+public class ExtendedKeyEngine {
+
+    private static boolean debug = false;
+
+    private SSLContext sslc;
+    private SSLEngine ssle1;    // client
+    private SSLEngine ssle2;    // server
+
+    private static String pathToStores = "../etc";
+    private static String keyStoreFile = "keystore";
+    private static String trustStoreFile = "truststore";
+    private static String passwd = "passphrase";
+
+    private static String keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+    private static String trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+    private ByteBuffer appOut1;         // write side of ssle1
+    private ByteBuffer appIn1;          // read side of ssle1
+    private ByteBuffer appOut2;         // write side of ssle2
+    private ByteBuffer appIn2;          // read side of ssle2
+
+    private ByteBuffer oneToTwo;        // "reliable" transport ssle1->ssle2
+    private ByteBuffer twoToOne;        // "reliable" transport ssle2->ssle1
+
+    /*
+     * Majority of the test case is here, setup is done below.
+     */
+    private void createSSLEngines() throws Exception {
+        ssle1 = sslc.createSSLEngine("client", 1);
+        ssle1.setUseClientMode(true);
+
+        ssle2 = sslc.createSSLEngine();
+        ssle2.setUseClientMode(false);
+        ssle2.setNeedClientAuth(true);
+    }
+
+    private void runTest() throws Exception {
+        boolean dataDone = false;
+
+        createSSLEngines();
+        createBuffers();
+
+        SSLEngineResult result1;        // ssle1's results from last operation
+        SSLEngineResult result2;        // ssle2's results from last operation
+
+        while (!isEngineClosed(ssle1) || !isEngineClosed(ssle2)) {
+
+            log("================");
+
+            result1 = ssle1.wrap(appOut1, oneToTwo);
+            result2 = ssle2.wrap(appOut2, twoToOne);
+
+            log("wrap1:  " + result1);
+            log("oneToTwo  = " + oneToTwo);
+            log("");
+
+            log("wrap2:  " + result2);
+            log("twoToOne  = " + twoToOne);
+
+            runDelegatedTasks(result1, ssle1);
+            runDelegatedTasks(result2, ssle2);
+
+            oneToTwo.flip();
+            twoToOne.flip();
+
+            log("----");
+
+            result1 = ssle1.unwrap(twoToOne, appIn1);
+            result2 = ssle2.unwrap(oneToTwo, appIn2);
+
+            log("unwrap1: " + result1);
+            log("twoToOne  = " + twoToOne);
+            log("");
+
+            log("unwrap2: " + result2);
+            log("oneToTwo  = " + oneToTwo);
+
+            runDelegatedTasks(result1, ssle1);
+            runDelegatedTasks(result2, ssle2);
+
+            oneToTwo.compact();
+            twoToOne.compact();
+
+            /*
+             * If we've transfered all the data between app1 and app2,
+             * we try to close and see what that gets us.
+             */
+            if (!dataDone && (appOut1.limit() == appIn2.position()) &&
+                    (appOut2.limit() == appIn1.position())) {
+
+                checkTransfer(appOut1, appIn2);
+                checkTransfer(appOut2, appIn1);
+
+                log("Closing ssle1's *OUTBOUND*...");
+                ssle1.closeOutbound();
+                dataDone = true;
+            }
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        ExtendedKeyEngine test;
+
+        System.out.println("This test should run to completion");
+        test = new ExtendedKeyEngine(true);
+        test.createSSLEngines();
+        test.runTest();
+        System.out.println("Done!");
+
+        System.out.println("This test should fail with a Handshake Error");
+        test = new ExtendedKeyEngine(false);
+        test.createSSLEngines();
+
+        try {
+            test.runTest();
+        } catch (SSLHandshakeException e) {
+            System.out.println(
+                "Caught proper exception, should be 'no suites in common'");
+            e.printStackTrace();
+        }
+
+        System.out.println("Test Passed.");
+    }
+
+    /*
+     * **********************************************************
+     * Majority of the test case is above, below is just setup stuff
+     * **********************************************************
+     */
+
+    public ExtendedKeyEngine(boolean abs) throws Exception {
+        sslc = getSSLContext(keyFilename, trustFilename, abs);
+    }
+
+    /*
+     * Create an initialized SSLContext to use for this test.
+     */
+    private SSLContext getSSLContext(String keyFile, String trustFile,
+            boolean abs) throws Exception {
+
+        KeyStore ks = KeyStore.getInstance("JKS");
+        KeyStore ts = KeyStore.getInstance("JKS");
+
+        char[] passphrase = "passphrase".toCharArray();
+
+        ks.load(new FileInputStream(keyFile), passphrase);
+        ts.load(new FileInputStream(trustFile), passphrase);
+
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+        kmf.init(ks, passphrase);
+
+        KeyManager [] kms = kmf.getKeyManagers();
+        if (abs) {
+            kms = new KeyManager [] {
+                new MyX509ExtendedKeyManager((X509ExtendedKeyManager)kms[0])
+            };
+        } else {
+            kms = new KeyManager [] {
+                new MyX509KeyManager((X509KeyManager)kms[0])
+            };
+        }
+
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+        tmf.init(ts);
+        TrustManager [] tms = tmf.getTrustManagers();
+
+        SSLContext sslCtx = SSLContext.getInstance("TLS");
+
+        sslCtx.init(kms, tms, null);
+
+        return sslCtx;
+    }
+
+    private void createBuffers() {
+        // Size the buffers as appropriate.
+
+        SSLSession session = ssle1.getSession();
+        int appBufferMax = session.getApplicationBufferSize();
+        int netBufferMax = session.getPacketBufferSize();
+
+        appIn1 = ByteBuffer.allocateDirect(appBufferMax + 50);
+        appIn2 = ByteBuffer.allocateDirect(appBufferMax + 50);
+
+        oneToTwo = ByteBuffer.allocateDirect(netBufferMax);
+        twoToOne = ByteBuffer.allocateDirect(netBufferMax);
+
+        appOut1 = ByteBuffer.wrap("Hi Engine2, I'm SSLEngine1".getBytes());
+        appOut2 = ByteBuffer.wrap("Hello Engine1, I'm SSLEngine2".getBytes());
+
+        log("AppOut1 = " + appOut1);
+        log("AppOut2 = " + appOut2);
+        log("");
+    }
+
+    private static void runDelegatedTasks(SSLEngineResult result,
+            SSLEngine engine) throws Exception {
+
+        if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+            Runnable runnable;
+            while ((runnable = engine.getDelegatedTask()) != null) {
+                log("running delegated task...");
+                runnable.run();
+            }
+        }
+    }
+
+    private static boolean isEngineClosed(SSLEngine engine) {
+        return (engine.isOutboundDone() && engine.isInboundDone());
+    }
+
+    private static void checkTransfer(ByteBuffer a, ByteBuffer b)
+            throws Exception {
+        a.flip();
+        b.flip();
+
+        if (!a.equals(b)) {
+            throw new Exception("Data didn't transfer cleanly");
+        } else {
+            log("Data transferred cleanly");
+        }
+
+        a.position(a.limit());
+        b.position(b.limit());
+        a.limit(a.capacity());
+        b.limit(b.capacity());
+    }
+
+    private static void log(String str) {
+        if (debug) {
+            System.out.println(str);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/ExtendedKeySocket.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,350 @@
+/*
+ * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4981697
+ * @summary Rework the X509KeyManager to avoid incompatibility issues
+ * @run main/othervm ExtendedKeySocket
+ *
+ *     SunJSSE does not support dynamic system properties, no way to re-use
+ *     system properties in samevm/agentvm mode.
+ * @author Brad R. Wetmore
+ */
+
+import java.io.*;
+import java.net.*;
+import javax.net.ssl.*;
+import java.security.*;
+
+public class ExtendedKeySocket {
+
+    /*
+     * =============================================================
+     * Set the various variables needed for the tests, then
+     * specify what tests to run on each side.
+     */
+
+    /*
+     * Should we run the client or server in a separate thread?
+     * Both sides can throw exceptions, but do you have a preference
+     * as to which side should be the main thread.
+     */
+    static boolean separateServerThread = false;
+
+    /*
+     * Where do we find the keystores?
+     */
+    static String pathToStores = "../etc";
+    static String keyStoreFile = "keystore";
+    static String trustStoreFile = "truststore";
+    static char [] passwd = "passphrase".toCharArray();
+
+    /*
+     * Is the server ready to serve?
+     */
+    volatile static boolean serverReady = false;
+
+    /*
+     * Turn on SSL debugging?
+     */
+    static boolean debug = false;
+
+    /*
+     * If the client or server is doing some kind of object creation
+     * that the other side depends on, and that thread prematurely
+     * exits, you may experience a hang.  The test harness will
+     * terminate all hung threads after its timeout has expired,
+     * currently 3 minutes by default, but you might try to be
+     * smart about it....
+     */
+
+    private String keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+    private String trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+    SSLContext getSSLContext(boolean abs) throws Exception {
+        SSLContext ctx = SSLContext.getInstance("TLS");
+
+        KeyStore keyKS = KeyStore.getInstance("JKS");
+        keyKS.load(new FileInputStream(keyFilename), passwd);
+
+        KeyStore trustKS = KeyStore.getInstance("JKS");
+        trustKS.load(new FileInputStream(trustFilename), passwd);
+
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+        kmf.init(keyKS, passwd);
+
+        KeyManager [] kms = kmf.getKeyManagers();
+        if (!(kms[0] instanceof X509ExtendedKeyManager)) {
+            throw new Exception("kms[0] not X509ExtendedKeyManager");
+        }
+
+        if (abs) {
+            kms = new KeyManager [] {
+                new MyX509ExtendedKeyManager((X509ExtendedKeyManager)kms[0])
+            };
+        } else {
+            kms = new KeyManager [] {
+                new MyX509KeyManager((X509KeyManager)kms[0])
+            };
+        }
+
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+        tmf.init(trustKS);
+        TrustManager [] tms = tmf.getTrustManagers();
+
+        ctx.init(kms, tms, null);
+
+        return ctx;
+    }
+
+    /*
+     * Define the server side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doServerSide() throws Exception {
+        System.out.println("Starting Server1");
+        doServerTest(getSSLContext(true));
+
+        System.out.println("Starting Server2");
+        doServerTest(getSSLContext(false));
+
+        System.out.println("Finishing Server");
+    }
+
+    void doServerTest(SSLContext ctx) throws Exception {
+        serverPort = 0;
+        SSLServerSocketFactory sslssf = ctx.getServerSocketFactory();
+        SSLServerSocket sslServerSocket =
+            (SSLServerSocket) sslssf.createServerSocket(serverPort);
+        sslServerSocket.setNeedClientAuth(true);
+
+        serverPort = sslServerSocket.getLocalPort();
+
+        /*
+         * Signal Client, we're ready for his connect.
+         */
+        serverReady = true;
+
+        SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
+        InputStream sslIS = sslSocket.getInputStream();
+        OutputStream sslOS = sslSocket.getOutputStream();
+
+        sslIS.read();
+        sslOS.write(85);
+        sslOS.flush();
+
+        sslSocket.close();
+    }
+
+    /*
+     * Define the client side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doClientSide() throws Exception {
+        System.out.println("Starting Client1");
+        doClientTest(getSSLContext(true));
+        System.out.println("Starting Client2");
+        doClientTest(getSSLContext(false));
+        System.out.println("Finishing Client");
+    }
+
+    void doClientTest(SSLContext ctx) throws Exception {
+        /*
+         * Wait for server to get started.
+         */
+        while (!serverReady) {
+            Thread.sleep(50);
+        }
+
+        /*
+         * Reset for next time through.
+         */
+        serverReady = false;
+
+        SSLSocketFactory sslsf = ctx.getSocketFactory();
+        SSLSocket sslSocket = (SSLSocket)
+            sslsf.createSocket("localhost", serverPort);
+
+        InputStream sslIS = sslSocket.getInputStream();
+        OutputStream sslOS = sslSocket.getOutputStream();
+
+        sslOS.write(280);
+        sslOS.flush();
+        sslIS.read();
+
+        sslSocket.close();
+    }
+
+    /*
+     * =============================================================
+     * The remainder is just support stuff
+     */
+
+    // use any free port by default
+    volatile int serverPort = 0;
+
+    volatile Exception serverException = null;
+    volatile Exception clientException = null;
+
+    public static void main(String[] args) throws Exception {
+        if (debug)
+            System.setProperty("javax.net.debug", "all");
+
+        /*
+         * Start the tests.
+         */
+        new ExtendedKeySocket();
+    }
+
+    Thread clientThread = null;
+    Thread serverThread = null;
+
+    /*
+     * Primary constructor, used to drive remainder of the test.
+     *
+     * Fork off the other side, then do your work.
+     */
+    ExtendedKeySocket() throws Exception {
+        try {
+            if (separateServerThread) {
+                startServer(true);
+                startClient(false);
+            } else {
+                startClient(true);
+                startServer(false);
+            }
+        } catch (Exception e) {
+            // swallow for now.  Show later
+        }
+
+        /*
+         * Wait for other side to close down.
+         */
+        if (separateServerThread) {
+            serverThread.join();
+        } else {
+            clientThread.join();
+        }
+
+        /*
+         * When we get here, the test is pretty much over.
+         * Which side threw the error?
+         */
+        Exception local;
+        Exception remote;
+        String whichRemote;
+
+        if (separateServerThread) {
+            remote = serverException;
+            local = clientException;
+            whichRemote = "server";
+        } else {
+            remote = clientException;
+            local = serverException;
+            whichRemote = "client";
+        }
+
+        /*
+         * If both failed, return the curthread's exception, but also
+         * print the remote side Exception
+         */
+        if ((local != null) && (remote != null)) {
+            System.out.println(whichRemote + " also threw:");
+            remote.printStackTrace();
+            System.out.println();
+            throw local;
+        }
+
+        if (remote != null) {
+            throw remote;
+        }
+
+        if (local != null) {
+            throw local;
+        }
+    }
+
+    void startServer(boolean newThread) throws Exception {
+        if (newThread) {
+            serverThread = new Thread() {
+                public void run() {
+                    try {
+                        doServerSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our server thread just died.
+                         *
+                         * Release the client, if not active already...
+                         */
+                        System.err.println("Server died...");
+                        serverReady = true;
+                        serverException = e;
+                    }
+                }
+            };
+            serverThread.start();
+        } else {
+            try {
+                doServerSide();
+            } catch (Exception e) {
+                serverException = e;
+            } finally {
+                serverReady = true;
+            }
+        }
+    }
+
+    void startClient(boolean newThread) throws Exception {
+        if (newThread) {
+            clientThread = new Thread() {
+                public void run() {
+                    try {
+                        doClientSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our client thread just died.
+                         */
+                        System.err.println("Client died...");
+                        clientException = e;
+                    }
+                }
+            };
+            clientThread.start();
+        } else {
+            try {
+                doClientSide();
+            } catch (Exception e) {
+                clientException = e;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/LargeBufs.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,302 @@
+/*
+ * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4495742
+ * @summary Add non-blocking SSL/TLS functionality, usable with any
+ *      I/O abstraction
+ *
+ * This is to test larger buffer arrays, and make sure the maximum
+ * is being passed.
+ *
+ * @run main/othervm -Djsse.enableCBCProtection=false LargeBufs
+ *
+ * @author Brad R. Wetmore
+ */
+
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.*;
+import java.io.*;
+import java.security.*;
+import java.nio.*;
+import java.util.Random;
+
+public class LargeBufs {
+
+    private static boolean debug = false;
+
+    private SSLContext sslc;
+    static private SSLEngine ssle1;     // client
+    static private SSLEngine ssle2;     // server
+
+    private static String pathToStores = "../etc";
+    private static String keyStoreFile = "keystore";
+    private static String trustStoreFile = "truststore";
+    private static String passwd = "passphrase";
+
+    private static String keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+    private static String trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+    private ByteBuffer appOut1;         // write side of ssle1
+    private ByteBuffer appIn1;          // read side of ssle1
+    private ByteBuffer appOut2;         // write side of ssle2
+    private ByteBuffer appIn2;          // read side of ssle2
+
+    private ByteBuffer oneToTwo;        // "reliable" transport ssle1->ssle2
+    private ByteBuffer twoToOne;        // "reliable" transport ssle2->ssle1
+
+    private int appBufferMax;
+    private int netBufferMax;
+    private int OFFSET = 37;
+
+    /*
+     * Majority of the test case is here, setup is done below.
+     */
+    private void createSSLEngines() throws Exception {
+        ssle1 = sslc.createSSLEngine("client", 1);
+        ssle1.setUseClientMode(true);
+
+        ssle2 = sslc.createSSLEngine();
+        ssle2.setUseClientMode(false);
+        ssle2.setNeedClientAuth(true);
+    }
+
+    private void runTest(String cipher) throws Exception {
+        boolean dataDone = false;
+
+        createSSLEngines();
+
+        System.out.println("Using " + cipher);
+        ssle2.setEnabledCipherSuites(new String [] { cipher });
+
+        createBuffers();
+
+        SSLEngineResult result1;        // ssle1's results from last operation
+        SSLEngineResult result2;        // ssle2's results from last operation
+
+        while (!isEngineClosed(ssle1) || !isEngineClosed(ssle2)) {
+
+            log("================");
+
+            result1 = ssle1.wrap(appOut1, oneToTwo);
+            result2 = ssle2.wrap(appOut2, twoToOne);
+
+            if ((result1.bytesConsumed() != 0) &&
+                (result1.bytesConsumed() != appBufferMax) &&
+                (result1.bytesConsumed() != OFFSET)) {
+                throw new Exception("result1: " + result1);
+            }
+
+            if ((result2.bytesConsumed() != 0) &&
+                (result2.bytesConsumed() != appBufferMax) &&
+                (result2.bytesConsumed() != 2 * OFFSET)) {
+                throw new Exception("result1: " + result1);
+            }
+
+            log("wrap1:  " + result1);
+            log("oneToTwo  = " + oneToTwo);
+            log("");
+
+            log("wrap2:  " + result2);
+            log("twoToOne  = " + twoToOne);
+
+            runDelegatedTasks(result1, ssle1);
+            runDelegatedTasks(result2, ssle2);
+
+            oneToTwo.flip();
+            twoToOne.flip();
+
+            log("----");
+
+            result1 = ssle1.unwrap(twoToOne, appIn1);
+            result2 = ssle2.unwrap(oneToTwo, appIn2);
+
+            if ((result1.bytesProduced() != 0) &&
+                (result1.bytesProduced() != appBufferMax) &&
+                (result1.bytesProduced() != 2 * OFFSET)) {
+                throw new Exception("result1: " + result1);
+            }
+
+            if ((result2.bytesProduced() != 0) &&
+                (result2.bytesProduced() != appBufferMax) &&
+                (result2.bytesProduced() != OFFSET)) {
+                throw new Exception("result1: " + result1);
+            }
+
+            log("unwrap1: " + result1);
+            log("twoToOne  = " + twoToOne);
+            log("");
+
+            log("unwrap2: " + result2);
+            log("oneToTwo  = " + oneToTwo);
+
+            runDelegatedTasks(result1, ssle1);
+            runDelegatedTasks(result2, ssle2);
+
+            oneToTwo.compact();
+            twoToOne.compact();
+
+            /*
+             * If we've transfered all the data between app1 and app2,
+             * we try to close and see what that gets us.
+             */
+            if (!dataDone && (appOut1.limit() == appIn2.position()) &&
+                    (appOut2.limit() == appIn1.position())) {
+
+                checkTransfer(appOut1, appIn2);
+                checkTransfer(appOut2, appIn1);
+
+                log("Closing ssle1's *OUTBOUND*...");
+                ssle1.closeOutbound();
+                dataDone = true;
+            }
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        LargeBufs test;
+
+        test = new LargeBufs();
+        test.runTest("SSL_RSA_WITH_RC4_128_MD5");
+
+        test = new LargeBufs();
+        test.runTest("SSL_RSA_WITH_3DES_EDE_CBC_SHA");
+
+        System.out.println("Test Passed.");
+    }
+
+    /*
+     * **********************************************************
+     * Majority of the test case is above, below is just setup stuff
+     * **********************************************************
+     */
+
+    public LargeBufs() throws Exception {
+        sslc = getSSLContext(keyFilename, trustFilename);
+    }
+
+    /*
+     * Create an initialized SSLContext to use for this test.
+     */
+    private SSLContext getSSLContext(String keyFile, String trustFile)
+            throws Exception {
+
+        KeyStore ks = KeyStore.getInstance("JKS");
+        KeyStore ts = KeyStore.getInstance("JKS");
+
+        char[] passphrase = "passphrase".toCharArray();
+
+        ks.load(new FileInputStream(keyFile), passphrase);
+        ts.load(new FileInputStream(trustFile), passphrase);
+
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+        kmf.init(ks, passphrase);
+
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+        tmf.init(ts);
+
+        SSLContext sslCtx = SSLContext.getInstance("TLS");
+
+        sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+        return sslCtx;
+    }
+
+    private void createBuffers() {
+        // Size the buffers as appropriate.
+
+        SSLSession session = ssle1.getSession();
+
+        // The maximum application buffer should calculate like
+        // appBufferMax = session.getApplicationBufferSize();
+        // however, the getApplicationBufferSize() doesn't guarantee
+        // that the ability to concume or produce applicaton data upto
+        // the size. 16384 is the default JSSE implementation maximum
+        // application size that could be consumed and produced.
+        appBufferMax = 16384;
+        netBufferMax = session.getPacketBufferSize();
+
+        Random random = new Random();
+        byte [] one = new byte [appBufferMax * 5 + OFFSET];
+        byte [] two = new byte [appBufferMax * 5 + 2 * OFFSET];
+
+        random.nextBytes(one);
+        random.nextBytes(two);
+
+        appOut1 = ByteBuffer.wrap(one);
+        appOut2 = ByteBuffer.wrap(two);
+
+        appIn1 = ByteBuffer.allocate(appBufferMax * 6);
+        appIn2 = ByteBuffer.allocate(appBufferMax * 6);
+
+        oneToTwo = ByteBuffer.allocateDirect(netBufferMax);
+        twoToOne = ByteBuffer.allocateDirect(netBufferMax);
+
+        System.out.println("Testing arrays of: " + one.length +
+            " and " + two.length);
+
+        log("AppOut1 = " + appOut1);
+        log("AppOut2 = " + appOut2);
+        log("");
+    }
+
+    private static void runDelegatedTasks(SSLEngineResult result,
+            SSLEngine engine) throws Exception {
+
+        if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+            Runnable runnable;
+            while ((runnable = engine.getDelegatedTask()) != null) {
+                log("running delegated task...");
+                runnable.run();
+            }
+        }
+    }
+
+    private static boolean isEngineClosed(SSLEngine engine) {
+        return (engine.isOutboundDone() && engine.isInboundDone());
+    }
+
+    private static void checkTransfer(ByteBuffer a, ByteBuffer b)
+            throws Exception {
+        a.flip();
+        b.flip();
+
+        if (!a.equals(b)) {
+            throw new Exception("Data didn't transfer cleanly");
+        } else {
+            log("Data transferred cleanly");
+        }
+    }
+
+    private static void log(String str) {
+        if (debug) {
+            System.out.println(str);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/LargePacket.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,258 @@
+/*
+ * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//
+// SunJSSE does not support dynamic system properties, no way to re-use
+// system properties in samevm/agentvm mode.
+//
+
+/*
+ * @test
+ *
+ * @bug 6388456
+ * @summary Need adjustable TLS max record size for interoperability
+ *      with non-compliant
+ * @run main/othervm LargePacket
+ *
+ * @author Xuelei Fan
+ */
+
+import javax.net.ssl.*;
+import java.nio.channels.*;
+import java.net.*;
+
+public class LargePacket extends SSLEngineService {
+
+    /*
+     * =============================================================
+     * Set the various variables needed for the tests, then
+     * specify what tests to run on each side.
+     */
+
+    /*
+     * Should we run the client or server in a separate thread?
+     * Both sides can throw exceptions, but do you have a preference
+     * as to which side should be the main thread.
+     */
+    static boolean separateServerThread = true;
+
+    // Is the server ready to serve?
+    volatile static boolean serverReady = false;
+
+    /*
+     * Turn on SSL debugging?
+     */
+    static boolean debug = false;
+
+    /*
+     * Define the server side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doServerSide() throws Exception {
+        // create SSLEngine.
+        SSLEngine ssle = createSSLEngine(false);
+
+        // Create a server socket channel.
+        InetSocketAddress isa =
+                new InetSocketAddress(InetAddress.getLocalHost(), serverPort);
+        ServerSocketChannel ssc = ServerSocketChannel.open();
+        ssc.socket().bind(isa);
+        serverPort = ssc.socket().getLocalPort();
+
+        // Signal Client, we're ready for his connect.
+        serverReady = true;
+
+        // Accept a socket channel.
+        SocketChannel sc = ssc.accept();
+
+        // Complete connection.
+        while (!sc.finishConnect()) {
+            // waiting for the connection completed.
+        }
+
+        // handshaking
+        handshaking(ssle, sc, null);
+
+        // receive application data
+        receive(ssle, sc);
+
+        // send out application data
+        deliver(ssle, sc);
+
+        // close the socket channel.
+        sc.close();
+        ssc.close();
+    }
+
+    /*
+     * Define the client side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doClientSide() throws Exception {
+        // create SSLEngine.
+        SSLEngine ssle = createSSLEngine(true);
+
+        /*
+         * Wait for server to get started.
+         */
+        while (!serverReady) {
+            Thread.sleep(50);
+        }
+
+        // Create a non-blocking socket channel.
+        SocketChannel sc = SocketChannel.open();
+        sc.configureBlocking(false);
+        InetSocketAddress isa =
+                new InetSocketAddress(InetAddress.getLocalHost(), serverPort);
+        sc.connect(isa);
+
+        // Complete connection.
+        while (!sc.finishConnect() ) {
+            // waiting for the connection completed.
+        }
+
+        // handshaking
+        handshaking(ssle, sc, null);
+
+        // send out application data
+        deliver(ssle, sc);
+
+        // receive application data
+        receive(ssle, sc);
+
+        // close the socket channel.
+        sc.close();
+    }
+
+    /*
+     * =============================================================
+     * The remainder is just support stuff
+     */
+    volatile Exception serverException = null;
+    volatile Exception clientException = null;
+
+    // use any free port by default
+    volatile int serverPort = 0;
+
+    public static void main(String args[]) throws Exception {
+        if (debug)
+            System.setProperty("javax.net.debug", "all");
+
+        new LargePacket();
+    }
+
+    Thread clientThread = null;
+    Thread serverThread = null;
+
+    /*
+     * Primary constructor, used to drive remainder of the test.
+     *
+     * Fork off the other side, then do your work.
+     */
+    LargePacket() throws Exception {
+        super("../etc");
+
+        if (separateServerThread) {
+            startServer(true);
+            startClient(false);
+        } else {
+            startClient(true);
+            startServer(false);
+        }
+
+        /*
+         * Wait for other side to close down.
+         */
+        if (separateServerThread) {
+            serverThread.join();
+        } else {
+            clientThread.join();
+        }
+
+        /*
+         * When we get here, the test is pretty much over.
+         *
+         * If the main thread excepted, that propagates back
+         * immediately.  If the other thread threw an exception, we
+         * should report back.
+         */
+        if (serverException != null) {
+            System.out.print("Server Exception:");
+            throw serverException;
+        }
+        if (clientException != null) {
+            System.out.print("Client Exception:");
+            throw clientException;
+        }
+    }
+
+    void startServer(boolean newThread) throws Exception {
+        if (newThread) {
+            serverThread = new Thread() {
+                public void run() {
+                    try {
+                        doServerSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our server thread just died.
+                         *
+                         * Release the client, if not active already...
+                         */
+                        System.err.println("Server died...");
+                        System.err.println(e);
+                        serverReady = true;
+                        serverException = e;
+                    }
+                }
+            };
+            serverThread.start();
+        } else {
+            doServerSide();
+        }
+    }
+
+    void startClient(boolean newThread) throws Exception {
+        if (newThread) {
+            clientThread = new Thread() {
+                public void run() {
+                    try {
+                        doClientSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our client thread just died.
+                         */
+                        System.err.println("Client died...");
+                        clientException = e;
+                    }
+                }
+            };
+            clientThread.start();
+        } else {
+            doClientSide();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/MyX509ExtendedKeyManager.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.net.ssl.*;
+import java.security.*;
+import java.net.*;
+import java.security.cert.*;
+
+class MyX509ExtendedKeyManager extends X509ExtendedKeyManager {
+
+    X509ExtendedKeyManager akm;
+
+    MyX509ExtendedKeyManager(X509ExtendedKeyManager akm) {
+        this.akm = akm;
+    }
+
+    public String[] getClientAliases(String keyType, Principal[] issuers) {
+        System.out.println("Calling from X509ExtendedKeyManager");
+        return akm.getClientAliases(keyType, issuers);
+    }
+
+    public String chooseClientAlias(String[] keyType, Principal[] issuers,
+            Socket socket) {
+        System.out.println("Calling from X509ExtendedKeyManager");
+        return akm.chooseClientAlias(keyType, issuers, socket);
+    }
+
+    public String[] getServerAliases(String keyType, Principal[] issuers) {
+        System.out.println("Calling from X509ExtendedKeyManager");
+        return akm.getServerAliases(keyType, issuers);
+    }
+
+    public String chooseServerAlias(String keyType, Principal[] issuers,
+            Socket socket) {
+        System.out.println("Calling from X509ExtendedKeyManager");
+        return akm.chooseServerAlias(keyType, issuers, socket);
+    }
+
+    public X509Certificate[] getCertificateChain(String alias) {
+        System.out.println("Calling from X509ExtendedKeyManager");
+        return akm.getCertificateChain(alias);
+    }
+
+    public PrivateKey getPrivateKey(String alias) {
+        System.out.println("Calling from X509ExtendedKeyManager");
+        return akm.getPrivateKey(alias);
+    }
+
+    public String chooseEngineClientAlias(String[] keyType,
+            Principal[] issuers, SSLEngine engine) {
+        System.out.println("Calling from X509ExtendedKeyManager");
+        return akm.chooseEngineClientAlias(keyType, issuers, engine);
+    }
+
+    public String chooseEngineServerAlias(String keyType,
+            Principal[] issuers, SSLEngine engine) {
+        System.out.println("Calling from X509ExtendedKeyManager");
+        return akm.chooseEngineServerAlias(keyType, issuers, engine);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/MyX509KeyManager.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.net.ssl.*;
+import java.net.*;
+import java.security.*;
+import java.security.cert.*;
+
+class MyX509KeyManager implements X509KeyManager  {
+
+    X509KeyManager km;
+
+    MyX509KeyManager(X509KeyManager km) {
+        this.km = km;
+    }
+
+    public String[] getClientAliases(String keyType, Principal[] issuers) {
+        System.out.println("Calling from X509KeyManager");
+        return km.getClientAliases(keyType, issuers);
+    }
+
+    public String chooseClientAlias(String[] keyType, Principal[] issuers,
+            Socket socket) {
+        System.out.println("Calling from X509KeyManager");
+        return km.chooseClientAlias(keyType, issuers, socket);
+    }
+
+    public String[] getServerAliases(String keyType, Principal[] issuers) {
+        System.out.println("Calling from X509KeyManager");
+        return km.getServerAliases(keyType, issuers);
+    }
+
+    public String chooseServerAlias(String keyType, Principal[] issuers,
+            Socket socket) {
+        System.out.println("Calling from X509KeyManager");
+        return km.chooseServerAlias(keyType, issuers, socket);
+    }
+
+    public X509Certificate[] getCertificateChain(String alias) {
+        System.out.println("Calling from X509KeyManager");
+        return km.getCertificateChain(alias);
+    }
+
+    public PrivateKey getPrivateKey(String alias) {
+        System.out.println("Calling from X509KeyManager");
+        return km.getPrivateKey(alias);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/NoAuthClientAuth.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,399 @@
+/*
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4495742
+ * @summary Demonstrate SSLEngine switch from no client auth to client auth.
+ * @run main/othervm NoAuthClientAuth
+ *
+ *     SunJSSE does not support dynamic system properties, no way to re-use
+ *     system properties in samevm/agentvm mode.
+ *
+ * @author Brad R. Wetmore
+ */
+
+/**
+ * A SSLEngine usage example which simplifies the presentation
+ * by removing the I/O and multi-threading concerns.
+ *
+ * The test creates two SSLEngines, simulating a client and server.
+ * The "transport" layer consists two byte buffers:  think of them
+ * as directly connected pipes.
+ *
+ * Note, this is a *very* simple example: real code will be much more
+ * involved.  For example, different threading and I/O models could be
+ * used, transport mechanisms could close unexpectedly, and so on.
+ *
+ * When this application runs, notice that several messages
+ * (wrap/unwrap) pass before any application data is consumed or
+ * produced.  (For more information, please see the SSL/TLS
+ * specifications.)  There may several steps for a successful handshake,
+ * so it's typical to see the following series of operations:
+ *
+ *      client          server          message
+ *      ======          ======          =======
+ *      wrap()          ...             ClientHello
+ *      ...             unwrap()        ClientHello
+ *      ...             wrap()          ServerHello/Certificate
+ *      unwrap()        ...             ServerHello/Certificate
+ *      wrap()          ...             ClientKeyExchange
+ *      wrap()          ...             ChangeCipherSpec
+ *      wrap()          ...             Finished
+ *      ...             unwrap()        ClientKeyExchange
+ *      ...             unwrap()        ChangeCipherSpec
+ *      ...             unwrap()        Finished
+ *      ...             wrap()          ChangeCipherSpec
+ *      ...             wrap()          Finished
+ *      unwrap()        ...             ChangeCipherSpec
+ *      unwrap()        ...             Finished
+ *
+ * In this example, we do a rehandshake and make sure that completes
+ * correctly.
+ */
+
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.*;
+import java.io.*;
+import java.security.*;
+import java.nio.*;
+
+public class NoAuthClientAuth {
+
+    /*
+     * Enables logging of the SSLEngine operations.
+     */
+    private static boolean logging = true;
+
+    /*
+     * Enables the JSSE system debugging system property:
+     *
+     *     -Djavax.net.debug=all
+     *
+     * This gives a lot of low-level information about operations underway,
+     * including specific handshake messages, and might be best examined
+     * after gaining some familiarity with this application.
+     */
+    private static boolean debug = false;
+
+    private SSLContext sslc;
+
+    private SSLEngine clientEngine;     // client Engine
+    private ByteBuffer clientOut;       // write side of clientEngine
+    private ByteBuffer clientIn;        // read side of clientEngine
+
+    private SSLEngine serverEngine;     // server Engine
+    private ByteBuffer serverOut;       // write side of serverEngine
+    private ByteBuffer serverIn;        // read side of serverEngine
+
+    /*
+     * For data transport, this example uses local ByteBuffers.  This
+     * isn't really useful, but the purpose of this example is to show
+     * SSLEngine concepts, not how to do network transport.
+     */
+    private ByteBuffer cTOs;            // "reliable" transport client->server
+    private ByteBuffer sTOc;            // "reliable" transport server->client
+
+    /*
+     * The following is to set up the keystores.
+     */
+    private static String pathToStores = "../etc";
+    private static String keyStoreFile = "keystore";
+    private static String trustStoreFile = "truststore";
+    private static String passwd = "passphrase";
+
+    private static String keyFilename =
+            System.getProperty("test.src", ".") + "/" + pathToStores +
+                "/" + keyStoreFile;
+    private static String trustFilename =
+            System.getProperty("test.src", ".") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+    /*
+     * Main entry point for this test.
+     */
+    public static void main(String args[]) throws Exception {
+        if (debug) {
+            System.setProperty("javax.net.debug", "all");
+        }
+
+        NoAuthClientAuth test = new NoAuthClientAuth();
+        test.runTest();
+
+        System.out.println("Test Passed.");
+    }
+
+    /*
+     * Create an initialized SSLContext to use for these tests.
+     */
+    public NoAuthClientAuth() throws Exception {
+
+        KeyStore ks = KeyStore.getInstance("JKS");
+        KeyStore ts = KeyStore.getInstance("JKS");
+
+        char[] passphrase = "passphrase".toCharArray();
+
+        ks.load(new FileInputStream(keyFilename), passphrase);
+        ts.load(new FileInputStream(trustFilename), passphrase);
+
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+        kmf.init(ks, passphrase);
+
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+        tmf.init(ts);
+
+        SSLContext sslCtx = SSLContext.getInstance("TLS");
+
+        sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+        sslc = sslCtx;
+    }
+
+    /*
+     * Run the test.
+     *
+     * Sit in a tight loop, both engines calling wrap/unwrap regardless
+     * of whether data is available or not.  We do this until both engines
+     * report back they are closed.
+     *
+     * The main loop handles all of the I/O phases of the SSLEngine's
+     * lifetime:
+     *
+     *     initial handshaking
+     *     application data transfer
+     *     engine closing
+     *
+     * One could easily separate these phases into separate
+     * sections of code.
+     */
+    private void runTest() throws Exception {
+
+        createSSLEngines();
+        createBuffers();
+
+        SSLEngineResult clientResult;   // results from client's last operation
+        SSLEngineResult serverResult;   // results from server's last operation
+
+        /*
+         * Examining the SSLEngineResults could be much more involved,
+         * and may alter the overall flow of the application.
+         *
+         * For example, if we received a BUFFER_OVERFLOW when trying
+         * to write to the output pipe, we could reallocate a larger
+         * pipe, but instead we wait for the peer to drain it.
+         */
+        int hsCompleted = 0;
+        while (!isEngineClosed(clientEngine) ||
+                !isEngineClosed(serverEngine)) {
+
+            log("================");
+
+            clientResult = clientEngine.wrap(clientOut, cTOs);
+            log("client wrap: ", clientResult);
+            runDelegatedTasks(clientResult, clientEngine);
+            clientOut.rewind();
+
+            serverResult = serverEngine.wrap(serverOut, sTOc);
+            log("server wrap: ", serverResult);
+            runDelegatedTasks(serverResult, serverEngine);
+            serverOut.rewind();
+
+            // Jeanfrancois:
+            // Here is the main rehandshaking step.
+            if (serverResult.getHandshakeStatus() ==
+                    HandshakeStatus.FINISHED) {
+                hsCompleted++;
+                log("\t" + hsCompleted + " handshake completed");
+                if (hsCompleted == 1) {
+                    try {
+                        serverEngine.getSession().getPeerCertificates();
+                        throw new Exception("Should have got exception");
+                    } catch (SSLPeerUnverifiedException e) {
+                        System.out.println("Caught proper exception." + e);
+                    }
+                    log("\tInvalidating session, setting client auth, " +
+                        " starting rehandshake");
+                    serverEngine.getSession().invalidate();
+                    serverEngine.setNeedClientAuth(true);
+                    serverEngine.beginHandshake();
+                } else if (hsCompleted == 2) {
+                    java.security.cert.Certificate [] certs =
+                        serverEngine.getSession().getPeerCertificates();
+                    System.out.println("Client Certificate(s) received");
+                    for (java.security.cert.Certificate c : certs) {
+                        System.out.println(c);
+                    }
+                    log("Closing server.");
+                    serverEngine.closeOutbound();
+                } // nothing.
+            }
+
+            cTOs.flip();
+            sTOc.flip();
+
+            log("----");
+
+            clientResult = clientEngine.unwrap(sTOc, clientIn);
+            log("client unwrap: ", clientResult);
+            runDelegatedTasks(clientResult, clientEngine);
+            clientIn.clear();
+
+            serverResult = serverEngine.unwrap(cTOs, serverIn);
+            log("server unwrap: ", serverResult);
+            runDelegatedTasks(serverResult, serverEngine);
+            serverIn.clear();
+
+            cTOs.compact();
+            sTOc.compact();
+        }
+    }
+
+    /*
+     * Using the SSLContext created during object creation,
+     * create/configure the SSLEngines we'll use for this test.
+     */
+    private void createSSLEngines() throws Exception {
+        /*
+         * Configure the serverEngine to act as a server in the SSL/TLS
+         * handshake.  Also, require SSL client authentication.
+         */
+        serverEngine = sslc.createSSLEngine();
+        serverEngine.setUseClientMode(false);
+        serverEngine.setNeedClientAuth(false);
+
+        /*
+         * Similar to above, but using client mode instead.
+         */
+        clientEngine = sslc.createSSLEngine("client", 80);
+        clientEngine.setUseClientMode(true);
+    }
+
+    /*
+     * Create and size the buffers appropriately.
+     */
+    private void createBuffers() {
+
+        /*
+         * We'll assume the buffer sizes are the same
+         * between client and server.
+         */
+        SSLSession session = clientEngine.getSession();
+        int appBufferMax = session.getApplicationBufferSize();
+        int netBufferMax = session.getPacketBufferSize();
+
+        /*
+         * We'll make the input buffers a bit bigger than the max needed
+         * size, so that unwrap()s following a successful data transfer
+         * won't generate BUFFER_OVERFLOWS.
+         *
+         * We'll use a mix of direct and indirect ByteBuffers for
+         * tutorial purposes only.  In reality, only use direct
+         * ByteBuffers when they give a clear performance enhancement.
+         */
+        clientIn = ByteBuffer.allocate(appBufferMax + 50);
+        serverIn = ByteBuffer.allocate(appBufferMax + 50);
+
+        cTOs = ByteBuffer.allocateDirect(netBufferMax);
+        sTOc = ByteBuffer.allocateDirect(netBufferMax);
+
+        clientOut = ByteBuffer.wrap("Hi Server, I'm Client".getBytes());
+        serverOut = ByteBuffer.wrap("Hello Client, I'm Server".getBytes());
+    }
+
+    /*
+     * If the result indicates that we have outstanding tasks to do,
+     * go ahead and run them in this thread.
+     */
+    private static void runDelegatedTasks(SSLEngineResult result,
+            SSLEngine engine) throws Exception {
+
+        if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+            Runnable runnable;
+            while ((runnable = engine.getDelegatedTask()) != null) {
+                log("\trunning delegated task...");
+                runnable.run();
+            }
+            HandshakeStatus hsStatus = engine.getHandshakeStatus();
+            if (hsStatus == HandshakeStatus.NEED_TASK) {
+                throw new Exception(
+                    "handshake shouldn't need additional tasks");
+            }
+            log("\tnew HandshakeStatus: " + hsStatus);
+        }
+    }
+
+    private static boolean isEngineClosed(SSLEngine engine) {
+        return (engine.isOutboundDone() && engine.isInboundDone());
+    }
+
+    /*
+     * Simple check to make sure everything came across as expected.
+     */
+    private static void checkTransfer(ByteBuffer a, ByteBuffer b)
+            throws Exception {
+        a.flip();
+        b.flip();
+
+        if (!a.equals(b)) {
+            throw new Exception("Data didn't transfer cleanly");
+        } else {
+            log("\tData transferred cleanly");
+        }
+
+        a.position(a.limit());
+        b.position(b.limit());
+        a.limit(a.capacity());
+        b.limit(b.capacity());
+    }
+
+    /*
+     * Logging code
+     */
+    private static boolean resultOnce = true;
+
+    private static void log(String str, SSLEngineResult result) {
+        if (!logging) {
+            return;
+        }
+        if (resultOnce) {
+            resultOnce = false;
+            System.out.println("The format of the SSLEngineResult is: \n" +
+                "\t\"getStatus() / getHandshakeStatus()\" +\n" +
+                "\t\"bytesConsumed() / bytesProduced()\"\n");
+        }
+        HandshakeStatus hsStatus = result.getHandshakeStatus();
+        log(str +
+            result.getStatus() + "/" + hsStatus + ", " +
+            result.bytesConsumed() + "/" + result.bytesProduced() +
+            " bytes");
+        if (hsStatus == HandshakeStatus.FINISHED) {
+            log("\t...ready for application data");
+        }
+    }
+
+    private static void log(String str) {
+        if (logging) {
+            System.out.println(str);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/SSLEngineResultArgs.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4965868
+ * @summary SSLEngineResult constructor needs null argument description
+ *
+ * @author Brad Wetmore
+ */
+
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.*;
+
+public class SSLEngineResultArgs {
+
+    private static void test(int i) throws Exception {
+        SSLEngineResult result;
+        try {
+            switch (i) {
+            case 0:
+                result = new SSLEngineResult(
+                    null, HandshakeStatus.NOT_HANDSHAKING, 0, 0);
+                return;
+            case 1:
+                result = new SSLEngineResult(
+                    Status.OK, null, 0, 0);
+                return;
+            case 2:
+                result = new SSLEngineResult(
+                    Status.OK, HandshakeStatus.NOT_HANDSHAKING, -1, 0);
+                return;
+            case 3:
+                result = new SSLEngineResult(
+                    Status.OK, HandshakeStatus.NOT_HANDSHAKING, 0, -1);
+                return;
+            }
+            throw new Exception("Didn't throw IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            System.out.println("Threw right Exception");
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+        test(0);
+        test(1);
+        test(2);
+        test(3);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/SSLEngineService.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,411 @@
+/*
+ * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @bug 6388456
+ * @summary Need adjustable TLS max record size for interoperability
+ *      with non-compliant stacks
+ *
+ * Helper class of SSL/TLS client/server communication.
+ *
+ * @author Xuelei Fan
+ */
+
+import javax.net.ssl.*;
+
+import java.io.*;
+import java.security.*;
+import java.nio.*;
+import java.nio.channels.*;
+
+public class SSLEngineService {
+
+    private static String keyStoreFile = "keystore";
+    private static String trustStoreFile = "truststore";
+    private static char[] passphrase = "passphrase".toCharArray();
+
+    private String pathToStores;
+    private String keyFilename;
+    private String trustFilename;
+
+    protected SSLEngineService() {
+        init("../etc");
+    }
+
+    protected SSLEngineService(String pathToStores) {
+        init(pathToStores);
+    }
+
+    private void init(String pathToStores) {
+        this.pathToStores = pathToStores;
+        this.keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+        this.trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+    }
+
+    // deliver local application data.
+    protected static void deliver(SSLEngine ssle, SocketChannel sc)
+        throws Exception {
+
+        // create buufer.
+        int appBufferMax = ssle.getSession().getApplicationBufferSize();
+        int netBufferMax = ssle.getSession().getPacketBufferSize();
+        int length = appBufferMax * (Integer.SIZE / 8);
+
+        // allocate more in order to check large packet
+        ByteBuffer localAppData = ByteBuffer.allocate(length);
+
+        // allocate less in order to check BUFFER_OVERFLOW/BUFFER_UNDERFLOW
+        ByteBuffer localNetData = ByteBuffer.allocate(netBufferMax/2);
+
+        // prepare local application data
+        localAppData.putInt(length);
+        for (int i = 1; i < appBufferMax; i++) {
+            localAppData.putInt(i);
+        }
+        localAppData.flip();
+
+
+        while (localAppData.hasRemaining()) {
+            // empty the local network packet buffer.
+            localNetData.clear();
+
+            // generated local network packet.
+            SSLEngineResult res = ssle.wrap(localAppData, localNetData);
+
+            // checking status
+            switch (res.getStatus()) {
+
+            case OK :
+                localNetData.flip();
+
+                // send the network packet
+                while (localNetData.hasRemaining()) {
+                    if (sc.write(localNetData) < 0) {
+                        throw new IOException("Unable write to socket channel");
+                    }
+                }
+
+                if (res.getHandshakeStatus() ==
+                        SSLEngineResult.HandshakeStatus.NEED_TASK) {
+                    Runnable runnable;
+                    while ((runnable = ssle.getDelegatedTask()) != null) {
+                        runnable.run();
+                    }
+                }
+
+                // detect large buffer
+                if (res.bytesProduced() >= Short.MAX_VALUE) {
+                    System.out.println("Generate a " +
+                        res.bytesProduced() + " bytes large packet ");
+                }
+                break;
+
+            case BUFFER_OVERFLOW :
+                // maybe need to enlarge the local network packet buffer.
+                int size = ssle.getSession().getPacketBufferSize();
+                if (size > localNetData.capacity()) {
+                    System.out.println("resize destination buffer upto " +
+                                size + " bytes for BUFFER_OVERFLOW");
+                    localNetData = enlargeBuffer(localNetData, size);
+                }
+                break;
+
+            default : // BUFFER_UNDERFLOW or CLOSED :
+                throw new IOException("Received invalid" + res.getStatus() +
+                        "during transfer application data");
+            }
+        }
+    }
+
+
+    // receive peer application data.
+    protected static void receive(SSLEngine ssle, SocketChannel sc)
+        throws Exception {
+
+        // create buufers.
+        int appBufferMax = ssle.getSession().getApplicationBufferSize();
+        int netBufferMax = ssle.getSession().getPacketBufferSize();
+
+        // allocate less in order to check BUFFER_OVERFLOW/BUFFER_UNDERFLOW
+        ByteBuffer peerAppData = ByteBuffer.allocate(appBufferMax/2);
+        ByteBuffer peerNetData = ByteBuffer.allocate(netBufferMax/2);
+        int received = -1;
+
+        boolean needToReadMore = true;
+        while (received != 0) {
+            if (needToReadMore) {
+                if (ssle.isInboundDone() || sc.read(peerNetData) < 0) {
+                    break;
+                }
+            }
+
+            peerNetData.flip();
+            SSLEngineResult res = ssle.unwrap(peerNetData, peerAppData);
+            peerNetData.compact();
+
+            // checking status
+            switch (res.getStatus()) {
+
+            case OK :
+                if (res.getHandshakeStatus() ==
+                        SSLEngineResult.HandshakeStatus.NEED_TASK) {
+                    Runnable runnable;
+                    while ((runnable = ssle.getDelegatedTask()) != null) {
+                        runnable.run();
+                    }
+                }
+
+                if (received < 0 && res.bytesProduced() < 4 ) {
+                    break;
+                }
+
+                if (received < 0) {
+                    received = peerAppData.getInt(0);
+                }
+
+                System.out.println("received " + peerAppData.position() +
+                        " bytes client application data");
+                System.out.println("\tcomsumed " + res.bytesConsumed() +
+                        " byes network data");
+                peerAppData.clear();
+
+                received -= res.bytesProduced();
+
+                // detect large buffer
+                if (res.bytesConsumed() >= Short.MAX_VALUE) {
+                    System.out.println("Consumes a " + res.bytesConsumed() +
+                        " bytes large packet ");
+                }
+
+                needToReadMore = (peerNetData.position() > 0) ? false : true;
+
+                break;
+
+            case BUFFER_OVERFLOW :
+                // maybe need to enlarge the peer application data buffer.
+                int size = ssle.getSession().getApplicationBufferSize();
+                if (size > peerAppData.capacity()) {
+                    System.out.println("resize destination buffer upto " +
+                        size + " bytes for BUFFER_OVERFLOW");
+                    peerAppData = enlargeBuffer(peerAppData, size);
+                }
+                break;
+
+            case BUFFER_UNDERFLOW :
+                // maybe need to enlarge the peer network packet data buffer.
+                size = ssle.getSession().getPacketBufferSize();
+                if (size > peerNetData.capacity()) {
+                    System.out.println("resize source buffer upto " + size +
+                        " bytes for BUFFER_UNDERFLOW");
+                    peerNetData = enlargeBuffer(peerNetData, size);
+                }
+
+                needToReadMore = true;
+                break;
+
+            default : // CLOSED :
+                throw new IOException("Received invalid" + res.getStatus() +
+                        "during transfer application data");
+            }
+        }
+    }
+
+    protected static void handshaking(SSLEngine ssle, SocketChannel sc,
+            ByteBuffer additional) throws Exception {
+
+        int appBufferMax = ssle.getSession().getApplicationBufferSize();
+        int netBufferMax = ssle.getSession().getPacketBufferSize();
+
+        // allocate less in order to check BUFFER_OVERFLOW/BUFFER_UNDERFLOW
+        ByteBuffer localAppData = ByteBuffer.allocate(appBufferMax/10);
+        ByteBuffer peerAppData = ByteBuffer.allocate(appBufferMax/10);
+        ByteBuffer localNetData = ByteBuffer.allocate(netBufferMax/10);
+        ByteBuffer peerNetData = ByteBuffer.allocate(netBufferMax/10);
+
+        // begin handshake
+        ssle.beginHandshake();
+        SSLEngineResult.HandshakeStatus hs = ssle.getHandshakeStatus();
+
+        // start handshaking from unwrap
+        byte[] buffer = new byte[0xFF];
+        boolean underflow = false;
+        do {
+            switch (hs) {
+
+            case NEED_UNWRAP :
+                if (peerNetData.position() == 0) {
+                    if (additional != null && additional.hasRemaining()) {
+                        do {
+                            int len = Math.min(buffer.length,
+                                                peerNetData.remaining());
+                            len = Math.min(len, additional.remaining());
+                            if (len != 0) {
+                                additional.get(buffer, 0, len);
+                                peerNetData.put(buffer, 0, len);
+                            }
+                        } while (peerNetData.remaining() > 0 &&
+                                    additional.hasRemaining());
+                    } else {
+                        if (sc.read(peerNetData) < 0) {
+                            ssle.closeInbound();
+                            return;
+                        }
+                    }
+                }
+
+                if (underflow) {
+                    if (sc.read(peerNetData) < 0) {
+                        ssle.closeInbound();
+                        return;
+                    }
+
+                    underflow = false;
+                }
+
+                peerNetData.flip();
+                SSLEngineResult res = ssle.unwrap(peerNetData, peerAppData);
+                peerNetData.compact();
+                hs = res.getHandshakeStatus();
+
+                switch (res.getStatus()) {
+                case OK :
+                    break;
+                case BUFFER_UNDERFLOW :
+                    // maybe need to enlarge the peer network packet buffer.
+                    int size = ssle.getSession().getPacketBufferSize();
+                    if (size > peerNetData.capacity()) {
+                        System.out.println("resize source buffer upto " +
+                                size + " bytes for BUFFER_UNDERFLOW");
+                        peerNetData = enlargeBuffer(peerNetData, size);
+                    }
+
+                    underflow = true;
+                    break;
+                case BUFFER_OVERFLOW :
+                    // maybe need to enlarge the peer application data buffer.
+                    size = ssle.getSession().getApplicationBufferSize();
+                    if (size > peerAppData.capacity()) {
+                        System.out.println("resize destination buffer upto " +
+                                size + " bytes for BUFFER_OVERFLOW");
+                        peerAppData = enlargeBuffer(peerAppData, size);
+                    }
+                    break;
+                default : //CLOSED
+                    throw new IOException("Received invalid" + res.getStatus() +
+                        "during initial handshaking");
+                }
+                break;
+
+            case NEED_WRAP :
+                // empty the local network packet buffer.
+                localNetData.clear();
+
+                // generated local network packet.
+                res = ssle.wrap(localAppData, localNetData);
+                hs = res.getHandshakeStatus();
+
+                // checking status
+                switch (res.getStatus()) {
+                case OK :
+                    localNetData.flip();
+
+                    // send the network packet
+                    while (localNetData.hasRemaining()) {
+                        if (sc.write(localNetData) < 0) {
+                            throw new IOException(
+                                "Unable write to socket channel");
+                        }
+                    }
+                    break;
+
+                case BUFFER_OVERFLOW :
+                    // maybe need to enlarge the local network packet buffer.
+                    int size = ssle.getSession().getPacketBufferSize();
+                    if (size > localNetData.capacity()) {
+                        System.out.println("resize destination buffer upto " +
+                                size + " bytes for BUFFER_OVERFLOW");
+                        localNetData = enlargeBuffer(localNetData, size);
+                    }
+                    break;
+
+                default : // BUFFER_UNDERFLOW or CLOSED :
+                    throw new IOException("Received invalid" + res.getStatus() +
+                        "during initial handshaking");
+                }
+                break;
+
+            case NEED_TASK :
+                Runnable runnable;
+                while ((runnable = ssle.getDelegatedTask()) != null) {
+                    runnable.run();
+                }
+                hs = ssle.getHandshakeStatus();
+                break;
+
+            default : // FINISHED or NOT_HANDSHAKING
+                // do nothing
+            }
+        } while (hs != SSLEngineResult.HandshakeStatus.FINISHED &&
+                hs != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING);
+    }
+
+    private static ByteBuffer enlargeBuffer(ByteBuffer buffer, int size) {
+        ByteBuffer bb = ByteBuffer.allocate(size);
+        buffer.flip();
+        bb.put(buffer);
+
+        return bb;
+    }
+
+    /*
+     * Create an initialized SSLContext to use for this test.
+     */
+    protected SSLEngine createSSLEngine(boolean mode) throws Exception {
+
+        SSLEngine ssle;
+
+        KeyStore ks = KeyStore.getInstance("JKS");
+        KeyStore ts = KeyStore.getInstance("JKS");
+
+        ks.load(new FileInputStream(keyFilename), passphrase);
+        ts.load(new FileInputStream(trustFilename), passphrase);
+
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+        kmf.init(ks, passphrase);
+
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+        tmf.init(ts);
+
+        SSLContext sslCtx = SSLContext.getInstance("TLS");
+        sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+        ssle = sslCtx.createSSLEngine();
+        ssle.setUseClientMode(mode);
+
+        return ssle;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngine/TestAllSuites.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,355 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4495742
+ * @ignore JSSE supported cipher suites are changed with CR 6916074,
+ *     need to update this test case in JDK 7 soon
+ * @run main/timeout=180 TestAllSuites
+ * @summary Add non-blocking SSL/TLS functionality, usable with any
+ *      I/O abstraction
+ *
+ * Iterate through all the suites using both TLS and SSLv3, and turn
+ * SSLv2Hello off and on.  Exchange some bytes and shutdown.
+ *
+ * @author Brad Wetmore
+ */
+
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.*;
+import java.io.*;
+import java.security.*;
+import java.nio.*;
+import java.util.*;
+
+public class TestAllSuites {
+
+    private static boolean debug = false;
+
+    private SSLContext sslc;
+    private SSLEngine ssle1;    // client
+    private SSLEngine ssle2;    // server
+
+    private static String pathToStores = "../etc";
+    private static String keyStoreFile = "keystore";
+    private static String trustStoreFile = "truststore";
+    private static String passwd = "passphrase";
+
+    private static String keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+    private static String trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+    private ByteBuffer appOut1;         // write side of ssle1
+    private ByteBuffer appIn1;          // read side of ssle1
+    private ByteBuffer appOut2;         // write side of ssle2
+    private ByteBuffer appIn2;          // read side of ssle2
+
+    private ByteBuffer oneToTwo;        // "reliable" transport ssle1->ssle2
+    private ByteBuffer twoToOne;        // "reliable" transport ssle2->ssle1
+
+    String [][] protocols = new String [][] {
+        { "SSLv3" },
+        { "TLSv1" },
+        { "SSLv3", "SSLv2Hello"},
+        { "TLSv1", "SSLv2Hello"}
+    };
+
+    /*
+     * Majority of the test case is here, setup is done below.
+     */
+
+    private void createSSLEngines() throws Exception {
+        ssle1 = sslc.createSSLEngine("client", 1);
+        ssle1.setUseClientMode(true);
+
+        ssle2 = sslc.createSSLEngine("server", 2);
+        ssle2.setUseClientMode(false);
+    }
+
+    private void test() throws Exception {
+
+        createSSLEngines();
+        String [] suites = ssle1.getSupportedCipherSuites();
+
+        for (int i = 0; i < suites.length; i++) {
+            for (int j = 0; j < protocols.length; j++) {
+                createSSLEngines();
+                runTest(suites[i], protocols[j]);
+            }
+        }
+    }
+
+    private void runTest(String suite, String [] protocols) throws Exception {
+
+        boolean dataDone = false;
+
+        System.out.println("======================================");
+        System.out.println("Testing: " + suite);
+        for (int i = 0; i < protocols.length; i++) {
+            System.out.print(protocols[i] + " ");
+        }
+
+        /*
+         * Don't run the Kerberized suites for now.
+         */
+        if (suite.startsWith("TLS_KRB5")) {
+            System.out.println("Ignoring Kerberized suite");
+            return;
+        }
+
+        /*
+         * Don't run the SCSV suite
+         */
+        if (suite.equals("TLS_EMPTY_RENEGOTIATION_INFO_SCSV")) {
+            System.out.println("Ignoring SCSV suite");
+            return;
+        }
+
+
+        if (!suite.contains("DH_anon")) {
+            ssle2.setNeedClientAuth(true);
+        }
+
+        String [] suites = new String [] { suite };
+
+        ssle1.setEnabledCipherSuites(suites);
+        ssle2.setEnabledCipherSuites(suites);
+
+        ssle1.setEnabledProtocols(protocols);
+        ssle2.setEnabledProtocols(protocols);
+
+        createBuffers();
+
+        SSLEngineResult result1;        // ssle1's results from last operation
+        SSLEngineResult result2;        // ssle2's results from last operation
+
+        Date start = new Date();
+        while (!isEngineClosed(ssle1) || !isEngineClosed(ssle2)) {
+
+            log("----------------");
+
+            result1 = ssle1.wrap(appOut1, oneToTwo);
+            result2 = ssle2.wrap(appOut2, twoToOne);
+
+            log("wrap1:  " + result1);
+            log("oneToTwo  = " + oneToTwo);
+            log("");
+
+            log("wrap2:  " + result2);
+            log("twoToOne  = " + twoToOne);
+
+            runDelegatedTasks(result1, ssle1);
+            runDelegatedTasks(result2, ssle2);
+
+            oneToTwo.flip();
+            twoToOne.flip();
+
+            log("----");
+
+            result1 = ssle1.unwrap(twoToOne, appIn1);
+            result2 = ssle2.unwrap(oneToTwo, appIn2);
+
+            log("unwrap1: " + result1);
+            log("twoToOne  = " + twoToOne);
+            log("");
+
+            log("unwrap2: " + result2);
+            log("oneToTwo  = " + oneToTwo);
+
+            runDelegatedTasks(result1, ssle1);
+            runDelegatedTasks(result2, ssle2);
+
+            oneToTwo.compact();
+            twoToOne.compact();
+
+            /*
+             * If we've transfered all the data between app1 and app2,
+             * we try to close and see what that gets us.
+             */
+            if (!dataDone && (appOut1.limit() == appIn2.position()) &&
+                    (appOut2.limit() == appIn1.position())) {
+
+                checkTransfer(appOut1, appIn2);
+                checkTransfer(appOut2, appIn1);
+
+                log("Closing ssle1's *OUTBOUND*...");
+                ssle1.closeOutbound();
+                dataDone = true;
+            }
+        }
+
+        /*
+         * Just for grins, try closing again, make sure nothing
+         * strange is happening after we're closed.
+         */
+        ssle1.closeInbound();
+        ssle1.closeOutbound();
+
+        ssle2.closeInbound();
+        ssle2.closeOutbound();
+
+        appOut1.rewind();
+        appIn1.clear();
+        oneToTwo.clear();
+
+        result1 = ssle1.wrap(appOut1, oneToTwo);
+        checkResult(result1);
+
+        result1 = ssle1.unwrap(oneToTwo, appIn1);
+        checkResult(result1);
+
+        System.out.println("Test Passed.");
+        System.out.println("\n======================================");
+
+        Date end = new Date();
+        elapsed += end.getTime() - start.getTime();
+
+    }
+
+    static long elapsed = 0;
+
+    private static void checkResult(SSLEngineResult result) throws Exception {
+        if ((result.getStatus() != Status.CLOSED) ||
+                (result.getHandshakeStatus() !=
+                    HandshakeStatus.NOT_HANDSHAKING) ||
+                (result.bytesConsumed() != 0) ||
+                (result.bytesProduced() != 0)) {
+            throw new Exception("Unexpected close status");
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        TestAllSuites tas;
+
+        tas = new TestAllSuites();
+
+        tas.createSSLEngines();
+
+        tas.test();
+
+        System.out.println("All Tests Passed.");
+        System.out.println("Elapsed time: " + elapsed / 1000.0);
+    }
+
+    /*
+     * **********************************************************
+     * Majority of the test case is above, below is just setup stuff
+     * **********************************************************
+     */
+
+    public TestAllSuites() throws Exception {
+        sslc = getSSLContext(keyFilename, trustFilename);
+    }
+
+    /*
+     * Create an initialized SSLContext to use for this test.
+     */
+    private SSLContext getSSLContext(String keyFile, String trustFile)
+            throws Exception {
+
+        KeyStore ks = KeyStore.getInstance("JKS");
+        KeyStore ts = KeyStore.getInstance("JKS");
+
+        char[] passphrase = "passphrase".toCharArray();
+
+        ks.load(new FileInputStream(keyFile), passphrase);
+        ts.load(new FileInputStream(trustFile), passphrase);
+
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+        kmf.init(ks, passphrase);
+
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+        tmf.init(ts);
+
+        SSLContext sslCtx = SSLContext.getInstance("TLS");
+
+        sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+        return sslCtx;
+    }
+
+    private void createBuffers() {
+        // Size the buffers as appropriate.
+
+        SSLSession session = ssle1.getSession();
+        int appBufferMax = session.getApplicationBufferSize();
+        int netBufferMax = session.getPacketBufferSize();
+
+        appIn1 = ByteBuffer.allocateDirect(appBufferMax + 50);
+        appIn2 = ByteBuffer.allocateDirect(appBufferMax + 50);
+
+        oneToTwo = ByteBuffer.allocateDirect(netBufferMax);
+        twoToOne = ByteBuffer.allocateDirect(netBufferMax);
+
+        appOut1 = ByteBuffer.wrap("Hi Engine2, I'm SSLEngine1".getBytes());
+        appOut2 = ByteBuffer.wrap("Hello Engine1, I'm SSLEngine2".getBytes());
+
+        log("AppOut1 = " + appOut1);
+        log("AppOut2 = " + appOut2);
+        log("");
+    }
+
+    private static void runDelegatedTasks(SSLEngineResult result,
+            SSLEngine engine) throws Exception {
+
+        if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+            Runnable runnable;
+            while ((runnable = engine.getDelegatedTask()) != null) {
+                log("running delegated task...");
+                runnable.run();
+            }
+        }
+    }
+
+    private static boolean isEngineClosed(SSLEngine engine) {
+        return (engine.isOutboundDone() && engine.isInboundDone());
+    }
+
+    private static void checkTransfer(ByteBuffer a, ByteBuffer b)
+            throws Exception {
+        a.flip();
+        b.flip();
+
+        if (!a.equals(b)) {
+            throw new Exception("Data didn't transfer cleanly");
+        } else {
+            log("Data transferred cleanly");
+        }
+
+        a.position(a.limit());
+        b.position(b.limit());
+        a.limit(a.capacity());
+        b.limit(b.capacity());
+    }
+
+    private static void log(String str) {
+        if (debug) {
+            System.out.println(str);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLEngineResult/Deserialize.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 5013482
+ * @summary Deserialization of enums in javax.net.ssl.SSLEngineResult fails
+ *
+ * @author A Russian Test Team member (Yuri Gayevski?)
+ * @author Brad Wetmore made modifications to fit in reg test suite.
+ */
+
+import java.io.*;
+import javax.net.ssl.*;
+
+public class Deserialize {
+
+    public static void main(String[] args) throws Exception {
+
+        System.out.println("Serialize to file foo ...");
+
+        SSLEngineResult.Status obj = SSLEngineResult.Status.OK;
+
+        File file = new File("deserial-test-file");
+
+        ObjectOutputStream oos = new ObjectOutputStream(
+            new FileOutputStream(file));
+        oos.writeObject(obj);
+        oos.flush();
+        oos.close();
+        System.out.println("Done");
+
+        System.out.println("Deserialize from file foo...");
+        ObjectInputStream ois = new ObjectInputStream(
+            new FileInputStream(file));
+
+        obj = (SSLEngineResult.Status) ois.readObject();
+
+        ois.close();
+        System.out.println("Passed.");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLParameters/UseCipherSuitesOrder.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,357 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//
+// SunJSSE does not support dynamic system properties, no way to re-use
+// system properties in samevm/agentvm mode.
+//
+
+/*
+ * @test
+ * @bug 7188657
+ * @summary There should be a way to reorder the JSSE ciphers
+ * @run main/othervm UseCipherSuitesOrder
+ *     TLS_RSA_WITH_AES_128_CBC_SHA,SSL_RSA_WITH_RC4_128_SHA
+ */
+
+import java.io.*;
+import java.net.*;
+import javax.net.ssl.*;
+import java.util.Arrays;
+
+public class UseCipherSuitesOrder {
+
+    /*
+     * =============================================================
+     * Set the various variables needed for the tests, then
+     * specify what tests to run on each side.
+     */
+
+    /*
+     * Should we run the client or server in a separate thread?
+     * Both sides can throw exceptions, but do you have a preference
+     * as to which side should be the main thread.
+     */
+    static boolean separateServerThread = false;
+
+    /*
+     * Where do we find the keystores?
+     */
+    static String pathToStores = "../etc";
+    static String keyStoreFile = "keystore";
+    static String trustStoreFile = "truststore";
+    static String passwd = "passphrase";
+
+    /*
+     * Is the server ready to serve?
+     */
+    volatile static boolean serverReady = false;
+
+    /*
+     * Turn on SSL debugging?
+     */
+    static boolean debug = false;
+
+    /*
+     * If the client or server is doing some kind of object creation
+     * that the other side depends on, and that thread prematurely
+     * exits, you may experience a hang.  The test harness will
+     * terminate all hung threads after its timeout has expired,
+     * currently 3 minutes by default, but you might try to be
+     * smart about it....
+     */
+
+    /*
+     * Define the server side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doServerSide() throws Exception {
+        SSLServerSocketFactory sslssf =
+            (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
+        SSLServerSocket sslServerSocket =
+            (SSLServerSocket) sslssf.createServerSocket(serverPort);
+        serverPort = sslServerSocket.getLocalPort();
+
+        // use local cipher suites preference
+        SSLParameters params = sslServerSocket.getSSLParameters();
+        params.setUseCipherSuitesOrder(true);
+        params.setCipherSuites(srvEnabledCipherSuites);
+        sslServerSocket.setSSLParameters(params);
+
+        /*
+         * Signal Client, we're ready for his connect.
+         */
+        serverReady = true;
+
+        SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
+        InputStream sslIS = sslSocket.getInputStream();
+        OutputStream sslOS = sslSocket.getOutputStream();
+
+        sslIS.read();
+        sslOS.write(85);
+        sslOS.flush();
+
+        SSLSession session = sslSocket.getSession();
+        if (!srvEnabledCipherSuites[0].equals(session.getCipherSuite())) {
+            throw new Exception(
+                "Expected to negotiate " + srvEnabledCipherSuites[0] +
+                " , but not " + session.getCipherSuite());
+        }
+
+        sslSocket.close();
+    }
+
+    /*
+     * Define the client side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doClientSide() throws Exception {
+
+        /*
+         * Wait for server to get started.
+         */
+        while (!serverReady) {
+            Thread.sleep(50);
+        }
+
+        SSLSocketFactory sslsf =
+            (SSLSocketFactory) SSLSocketFactory.getDefault();
+        SSLSocket sslSocket = (SSLSocket)
+            sslsf.createSocket("localhost", serverPort);
+        sslSocket.setEnabledCipherSuites(cliEnabledCipherSuites);
+
+        InputStream sslIS = sslSocket.getInputStream();
+        OutputStream sslOS = sslSocket.getOutputStream();
+
+        sslOS.write(280);
+        sslOS.flush();
+        sslIS.read();
+
+        sslSocket.close();
+    }
+
+    // client enabled cipher suites
+    private static String[] cliEnabledCipherSuites;
+
+    // server enabled cipher suites
+    private static String[] srvEnabledCipherSuites;
+
+    private static void parseArguments(String[] args) throws Exception {
+        if (args.length != 1) {
+            System.out.println("Usage: java UseCipherSuitesOrder ciphersuites");
+            System.out.println("\tciphersuites: " +
+                    "a list of enabled cipher suites, separated with comma");
+            throw new Exception("Incorrect usage");
+        }
+
+        cliEnabledCipherSuites = args[0].split(",");
+
+        if (cliEnabledCipherSuites.length < 2) {
+            throw new Exception("Need to enable at least two cipher suites");
+        }
+
+        // Only need to use 2 cipher suites in server side.
+        srvEnabledCipherSuites = Arrays.<String>copyOf(
+                                            cliEnabledCipherSuites, 2);
+
+        // Reverse the cipher suite preference in server side.
+        srvEnabledCipherSuites[0] = cliEnabledCipherSuites[1];
+        srvEnabledCipherSuites[1] = cliEnabledCipherSuites[0];
+    }
+
+    /*
+     * =============================================================
+     * The remainder is just support stuff
+     */
+
+    // use any free port by default
+    volatile int serverPort = 0;
+
+    volatile Exception serverException = null;
+    volatile Exception clientException = null;
+
+    public static void main(String[] args) throws Exception {
+        // parse the arguments
+        parseArguments(args);
+
+        String keyFilename =
+            System.getProperty("test.src", ".") + "/" + pathToStores +
+                "/" + keyStoreFile;
+        String trustFilename =
+            System.getProperty("test.src", ".") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+        System.setProperty("javax.net.ssl.keyStore", keyFilename);
+        System.setProperty("javax.net.ssl.keyStorePassword", passwd);
+        System.setProperty("javax.net.ssl.trustStore", trustFilename);
+        System.setProperty("javax.net.ssl.trustStorePassword", passwd);
+
+        if (debug)
+            System.setProperty("javax.net.debug", "all");
+
+        /*
+         * Start the tests.
+         */
+        new UseCipherSuitesOrder();
+    }
+
+    Thread clientThread = null;
+    Thread serverThread = null;
+
+    /*
+     * Primary constructor, used to drive remainder of the test.
+     *
+     * Fork off the other side, then do your work.
+     */
+    UseCipherSuitesOrder() throws Exception {
+        Exception startException = null;
+        try {
+            if (separateServerThread) {
+                startServer(true);
+                startClient(false);
+            } else {
+                startClient(true);
+                startServer(false);
+            }
+        } catch (Exception e) {
+            startException = e;
+        }
+
+        /*
+         * Wait for other side to close down.
+         */
+        if (separateServerThread) {
+            if (serverThread != null) {
+                serverThread.join();
+            }
+        } else {
+            if (clientThread != null) {
+                clientThread.join();
+            }
+        }
+
+        /*
+         * When we get here, the test is pretty much over.
+         * Which side threw the error?
+         */
+        Exception local;
+        Exception remote;
+
+        if (separateServerThread) {
+            remote = serverException;
+            local = clientException;
+        } else {
+            remote = clientException;
+            local = serverException;
+        }
+
+        Exception exception = null;
+
+        /*
+         * Check various exception conditions.
+         */
+        if ((local != null) && (remote != null)) {
+            // If both failed, return the curthread's exception.
+            local.initCause(remote);
+            exception = local;
+        } else if (local != null) {
+            exception = local;
+        } else if (remote != null) {
+            exception = remote;
+        } else if (startException != null) {
+            exception = startException;
+        }
+
+        /*
+         * If there was an exception *AND* a startException,
+         * output it.
+         */
+        if (exception != null) {
+            if (exception != startException && startException != null) {
+                exception.addSuppressed(startException);
+            }
+            throw exception;
+        }
+
+        // Fall-through: no exception to throw!
+    }
+
+    void startServer(boolean newThread) throws Exception {
+        if (newThread) {
+            serverThread = new Thread() {
+                public void run() {
+                    try {
+                        doServerSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our server thread just died.
+                         *
+                         * Release the client, if not active already...
+                         */
+                        System.err.println("Server died...");
+                        serverReady = true;
+                        serverException = e;
+                    }
+                }
+            };
+            serverThread.start();
+        } else {
+            try {
+                doServerSide();
+            } catch (Exception e) {
+                serverException = e;
+            } finally {
+                serverReady = true;
+            }
+        }
+    }
+
+    void startClient(boolean newThread) throws Exception {
+        if (newThread) {
+            clientThread = new Thread() {
+                public void run() {
+                    try {
+                        doClientSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our client thread just died.
+                         */
+                        System.err.println("Client died...");
+                        clientException = e;
+                    }
+                }
+            };
+            clientThread.start();
+        } else {
+            try {
+                doClientSide();
+            } catch (Exception e) {
+                clientException = e;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLServerSocket/DefaultSSLServSocketFac.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6449579
+ * @summary DefaultSSLServerSocketFactory does not override createServerSocket()
+ * @run main/othervm DefaultSSLServSocketFac
+ *
+ *     SunJSSE does not support dynamic system properties, no way to re-use
+ *     system properties in samevm/agentvm mode.
+ */
+import java.security.Security;
+import javax.net.ServerSocketFactory;
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.SSLServerSocketFactory;
+
+public class DefaultSSLServSocketFac {
+    public static void main(String[] args) throws Exception {
+        // reserve the security properties
+        String reservedSSFacProvider =
+            Security.getProperty("ssl.ServerSocketFactory.provider");
+
+        try {
+            Security.setProperty("ssl.ServerSocketFactory.provider", "oops");
+            ServerSocketFactory ssocketFactory =
+                        SSLServerSocketFactory.getDefault();
+            SSLServerSocket sslServerSocket =
+                        (SSLServerSocket)ssocketFactory.createServerSocket();
+        } catch (Exception e) {
+            if (!(e.getCause() instanceof ClassNotFoundException)) {
+                throw e;
+            }
+            // get the expected exception
+        } finally {
+            // restore the security properties
+            if (reservedSSFacProvider == null) {
+                reservedSSFacProvider = "";
+            }
+            Security.setProperty("ssl.ServerSocketFactory.provider",
+                                                    reservedSSFacProvider);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/SSLSession/CheckMyTrustedKeystore.java	Wed Mar 05 07:24:34 2014 +0000
@@ -0,0 +1,406 @@
+/*
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// SunJSSE does not support dynamic system properties, no way to re-use
+// system properties in samevm/agentvm mode.
+
+/*
+ * @test
+ * @bug 4329114
+ * @summary Need better way of reflecting the reason when a chain is
+ *      rejected as untrusted.
+ * @ignore JSSE supports algorithm constraints with CR 6916074,
+ *      need to update this test case in JDK 7 soon
+ * @run main/othervm CheckMyTrustedKeystore
+ *
+ * @a