Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 52264 invoked from network); 26 Aug 2010 15:07:23 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 26 Aug 2010 15:07:23 -0000 Received: (qmail 12246 invoked by uid 500); 26 Aug 2010 15:07:23 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 12144 invoked by uid 500); 26 Aug 2010 15:07:22 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 12137 invoked by uid 99); 26 Aug 2010 15:07:22 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Aug 2010 15:07:22 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Aug 2010 15:07:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 883142388A41; Thu, 26 Aug 2010 15:05:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r989740 - /harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSessionImpl.java Date: Thu, 26 Aug 2010 15:05:44 -0000 To: commits@harmony.apache.org From: odeakin@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100826150544.883142388A41@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: odeakin Date: Thu Aug 26 15:05:44 2010 New Revision: 989740 URL: http://svn.apache.org/viewvc?rev=989740&view=rev Log: Implement some methods on SSLSessionImpl, mark methods still to be implemented with TODOs. Modified: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSessionImpl.java Modified: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSessionImpl.java URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSessionImpl.java?rev=989740&r1=989739&r2=989740&view=diff ============================================================================== --- harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSessionImpl.java (original) +++ harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSessionImpl.java Thu Aug 26 15:05:44 2010 @@ -49,6 +49,30 @@ public class SSLSessionImpl implements S public static final SSLSessionImpl NULL_SESSION = new SSLSessionImpl(null); /** + * Maximum length of allowed plain data fragment + * as specified by TLS specification. + */ + protected static final int MAX_DATA_LENGTH = 16384; // 2^14 + /** + * Maximum length of allowed compressed data fragment + * as specified by TLS specification. + */ + protected static final int MAX_COMPRESSED_DATA_LENGTH + = MAX_DATA_LENGTH + 1024; + /** + * Maximum length of allowed ciphered data fragment + * as specified by TLS specification. + */ + protected static final int MAX_CIPHERED_DATA_LENGTH + = MAX_COMPRESSED_DATA_LENGTH + 1024; + /** + * Maximum length of ssl record. It is counted as: + * type(1) + version(2) + length(2) + MAX_CIPHERED_DATA_LENGTH + */ + protected static final int MAX_SSL_PACKET_SIZE + = MAX_CIPHERED_DATA_LENGTH + 5; + + /** * Container class for the 'value' map's keys. */ private static final class ValueKey { @@ -160,7 +184,7 @@ public class SSLSessionImpl implements S /** * True if this entity is considered the server */ - final boolean isServer; + boolean isServer; // OpenSSL SSL_SESSION pointer private long SSL_SESSION; @@ -214,6 +238,10 @@ public class SSLSessionImpl implements S private native String getCipherNameImpl(long SSL); private native long getCreationTimeImpl(long SSL_SESSION); + // Used just for clone() + private SSLSessionImpl() { + } + public SSLSessionImpl(SSLParameters parms, long SSL) { sslParameters = parms; this.SSL = SSL; @@ -242,7 +270,7 @@ public class SSLSessionImpl implements S } public int getApplicationBufferSize() { - return SSLRecordProtocol.MAX_DATA_LENGTH; + return MAX_DATA_LENGTH; } public String getCipherSuite() { @@ -261,10 +289,12 @@ public class SSLSessionImpl implements S return lastAccessedTime; } + // TODO: implement public Certificate[] getLocalCertificates() { return localCertificates; } - + + // TODO: implement public Principal getLocalPrincipal() { if (localCertificates != null && localCertificates.length > 0) { return localCertificates[0].getSubjectX500Principal(); @@ -273,9 +303,10 @@ public class SSLSessionImpl implements S } public int getPacketBufferSize() { - return SSLRecordProtocol.MAX_SSL_PACKET_SIZE; + return MAX_SSL_PACKET_SIZE; } + // TODO: implement public javax.security.cert.X509Certificate[] getPeerCertificateChain() throws SSLPeerUnverifiedException { if (peerCertificates == null) { @@ -293,6 +324,7 @@ public class SSLSessionImpl implements S return certs; } + // TODO: implement public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException { if (peerCertificates == null) { throw new SSLPeerUnverifiedException("No peer certificate"); @@ -300,14 +332,17 @@ public class SSLSessionImpl implements S return peerCertificates; } + // TODO: implement public String getPeerHost() { return peerHost; } + // TODO: implement public int getPeerPort() { return peerPort; } + // TODO: implement public Principal getPeerPrincipal() throws SSLPeerUnverifiedException { if (peerCertificates == null) { throw new SSLPeerUnverifiedException("No peer certificate"); @@ -315,10 +350,12 @@ public class SSLSessionImpl implements S return peerCertificates[0].getSubjectX500Principal(); } + // TODO: implement public String getProtocol() { return protocol.name; } + // TODO: implement public SSLSessionContext getSessionContext() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { @@ -382,21 +419,28 @@ public class SSLSessionImpl implements S @Override public Object clone() { - try { - return super.clone(); - } catch (CloneNotSupportedException e) { - throw new AssertionError(e); - } - } + SSLSessionImpl clonedSession = new SSLSessionImpl(); + + clonedSession.creationTime = creationTime; + clonedSession.isValid = isValid; + clonedSession.values = new HashMap(values); + clonedSession.id = (byte[])id.clone(); + clonedSession.lastAccessedTime = lastAccessedTime; + clonedSession.protocol = protocol; + clonedSession.cipherSuite = cipherSuite; + clonedSession.context = context; + clonedSession.localCertificates = localCertificates.clone(); + clonedSession.peerCertificates = peerCertificates.clone(); + clonedSession.peerHost = peerHost; + clonedSession.master_secret = master_secret.clone(); + clonedSession.clientRandom = clientRandom.clone(); + clonedSession.serverRandom = serverRandom.clone(); + clonedSession.isServer = isServer; + clonedSession.SSL_SESSION = SSL_SESSION; + clonedSession.SSL = SSL; + clonedSession.sslParameters = (SSLParameters)sslParameters.clone(); + clonedSession.cipherName = cipherName; - /** - * Sets the address of the peer - * - * @param peerHost - * @param peerPort - */ - void setPeer(String peerHost, int peerPort) { - this.peerHost = peerHost; - this.peerPort = peerPort; + return clonedSession; } }