You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2012/04/26 12:33:35 UTC

svn commit: r1330760 - /chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisCookieStoreImpl.java

Author: fmui
Date: Thu Apr 26 10:33:35 2012
New Revision: 1330760

URL: http://svn.apache.org/viewvc?rev=1330760&view=rev
Log:
Respect cookie secure flage

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisCookieStoreImpl.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisCookieStoreImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisCookieStoreImpl.java?rev=1330760&r1=1330759&r2=1330760&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisCookieStoreImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisCookieStoreImpl.java Thu Apr 26 10:33:35 2012
@@ -96,16 +96,26 @@ class CmisCookieStoreImpl implements Ser
         for (URI u : uris) {
             // exclude the given URI
             if (!u.equals(uri)) {
+                boolean secure = false;
+                String scheme = u.getScheme();
+                if (scheme != null) {
+                    secure = scheme.toLowerCase().startsWith("https");
+                }
+
                 List<CmisHttpCookie> listCookie = storeMap.get(u);
-                for (CmisHttpCookie cookie : listCookie) {
+                Iterator<CmisHttpCookie> iter = listCookie.iterator();
+                while (iter.hasNext()) {
+                    CmisHttpCookie cookie = iter.next();
                     if (CmisHttpCookie.domainMatches(cookie.getDomain(), uri.getHost())) {
                         if (cookie.hasExpired()) {
-                            listCookie.remove(cookie);
+                            iter.remove();
                             if (listCookie.isEmpty()) {
                                 storeMap.remove(u);
                             }
                         } else if (!(cookie.hasExpired() || cookies.contains(cookie))) {
-                            cookies.add(cookie);
+                            if (!cookie.getSecure() || secure) {
+                                cookies.add(cookie);
+                            }
                         }
                     }
                 }
@@ -129,9 +139,11 @@ class CmisCookieStoreImpl implements Ser
         List<CmisHttpCookie> cookies = new ArrayList<CmisHttpCookie>();
         Collection<ArrayList<CmisHttpCookie>> values = storeMap.values();
         for (ArrayList<CmisHttpCookie> list : values) {
-            for (CmisHttpCookie cookie : list) {
+            Iterator<CmisHttpCookie> iter = list.iterator();
+            while (iter.hasNext()) {
+                CmisHttpCookie cookie = iter.next();
                 if (cookie.hasExpired()) {
-                    list.remove(cookie); // eliminate expired cookies
+                    iter.remove(); // eliminate expired cookies
                 } else if (!cookies.contains(cookie)) {
                     cookies.add(cookie);
                 }