harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r993016 - in /harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse: SSLSessionContextImpl.java SSLSocketImpl.java
Date Mon, 06 Sep 2010 13:12:02 GMT
Author: odeakin
Date: Mon Sep  6 13:12:02 2010
New Revision: 993016

URL: http://svn.apache.org/viewvc?rev=993016&view=rev
Log:
Implement the removeOldest() method on SSLSessionContextImpl.

Modified:
    harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSessionContextImpl.java
    harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java

Modified: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSessionContextImpl.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/SSLSessionContextImpl.java?rev=993016&r1=993015&r2=993016&view=diff
==============================================================================
--- harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSessionContextImpl.java
(original)
+++ harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSessionContextImpl.java
Mon Sep  6 13:12:02 2010
@@ -16,9 +16,12 @@
  */
 package org.apache.harmony.xnet.provider.jsse;
 
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.List;
 
 import javax.net.ssl.SSLSession;
 import javax.net.ssl.SSLSessionContext;
@@ -36,6 +39,8 @@ public class SSLSessionContextImpl imple
 
     private final Hashtable<IdKey, SSLSessionImpl> sessions = new Hashtable<IdKey,
SSLSessionImpl>();
 
+    private final List<IdKey> keys = Collections.synchronizedList(new ArrayList<IdKey>(0));
+
     @SuppressWarnings("unchecked")
     public Enumeration getIds() {
         return new Enumeration() {
@@ -112,13 +117,19 @@ public class SSLSessionContextImpl imple
             removeOldest(1);
         }
         ses.context = this;
-        sessions.put(new IdKey(ses.getId()), ses);
+        IdKey idKey = new IdKey(ses.getId());
+        sessions.put(idKey, ses);
+        keys.add(idKey);
     }
 
     // removes invalidated/oldest sessions from the session cache
     private void removeOldest(int num) {
-        //TODO
-        // ses.context = null;
+        for (int i=0; i<num; i++) {
+            // The list is ordered. Since we always add to the end of it, 
+            // the element at index 0 will be the oldest
+            IdKey id = keys.remove(0);
+            sessions.remove(id);
+        }
     }
     
     private class IdKey {

Modified: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.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/SSLSocketImpl.java?rev=993016&r1=993015&r2=993016&view=diff
==============================================================================
--- harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java
(original)
+++ harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java
Mon Sep  6 13:12:02 2010
@@ -485,27 +485,30 @@ public class SSLSocketImpl extends SSLSo
                 throw new Error(e);
             }
 
+            SSLSessionContextImpl sessionContext;
             if (sslParameters.getUseClientMode()) {
                 if (logger != null) {
                     logger.println("SSLSocketImpl: CLIENT connecting");
                 }
 
                 sslConnectImpl(SSL, descriptor);
+                sessionContext = sslParameters.getClientSessionContext();
             } else {
                 if (logger != null) {
                     logger.println("SSLSocketImpl: SERVER accepting connection");
                 }
                 sslAcceptImpl(SSL, descriptor);
+                sessionContext = sslParameters.getServerSessionContext();
             }
+
+            session = new SSLSessionImpl(this, sslParameters, SSL);
+            sessionContext.putSession(session);
         }
 
         if (logger != null) {
             logger.println("SSLSocketImpl: Handshake complete, notifying listeners");
         }
 
-        session = new SSLSessionImpl(this, sslParameters, SSL);
-        sslParameters.getClientSessionContext().putSession(session);
-
         // Notify handshake completion listeners
         if (listeners != null) {
             HandshakeCompletedEvent event =



Mime
View raw message