Moving OpenSSLSocketImpl native code to NativeCrypto (and other clearnup)

Summary:
- Finished consolidating OpenSSL native code into NativeCrypto
- fixing local vs global ref bug with AppData
  Added new ScopedGlobalRef as part of this fix
- fixed many historical memory leaks identified during code review
- fixed lack of error checking on allcoation with OpenSSL *_new routines
- Added to_SSL_CTX and to_SSL_SESSION to match to_SSL (renamed from getSslPointer)
- Replaced most uses of GetByteArrayElements with ScopedByteArray
  (including cases where we we using ReleaseByteArrayElements(..,...,0) instead of JNI_ABORT)
- Replaced uses of GetStringUTFChars with ScopedUtfChars

Details:

Finished consolidating OpenSSL native code into NativeCrypto

	OpenSSLSocketImpl	NativeCrypto
	---------------------------------------
	nativeread		SSL_read_byte
	nativeread		SSL_read
	nativewrite		SSL_write_byte
	nativewrite		SSL_write
	nativeinterrupt		SSL_interrupt
	nativeclose		SSL_shutdown
	nativeverifysignature	verifysignature

    Also removed dead code that was wrapping SSL_get1_session

	luni/src/main/java/org/apache/harmony/xnet/provider/jsse/NativeCrypto.java
	luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
	luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

Fixed NativeCrypto_SSL_write and NativeCrypto_d2i_SSL_SESSION to use
JNI_ABORT on release to avoid copy back of unchanged data (via ScopedByteArray).

	luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

While running the usual tests:
     adb shell run-core-tests tests.xnet.AllTests javax.net.ssl.AllTests
there was an abort from the JNI checking because in the recent
handshaking change, local refs were kept in AppData and then reused in
later calls. Added new ScopedGlobalRef to handle the book keeping of this.

	luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
	include/ScopedGlobalRef.h

Fixed various leaks on old error paths spotted by reviewer.

	luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

Tracking move of verifySignature, a non-SSL bit of code that was lurking in OpenSSLSocketImpl

	luni/src/main/java/org/apache/harmony/security/provider/cert/X509CertImpl.java

Change-Id: If1e409782bc99dc684039cfe3f53f8244e29346e
5 files changed