OSDN Git Service

IE cookie 取得処理クラス実装開始
authoryukihane <yukihane.feather@gmail.com>
Sat, 17 Sep 2011 06:44:56 +0000 (15:44 +0900)
committeryukihane <yukihane.feather@gmail.com>
Sat, 17 Sep 2011 06:44:56 +0000 (15:44 +0900)
frontend/src/saccubus/net/BrowserInfo.java
frontend/src/saccubus/net/Cookie.java
frontend/src/saccubus/net/CookieWinMsIe.java [new file with mode: 0644]

index 1201a8d..2589ee3 100644 (file)
@@ -141,31 +141,6 @@ public class BrowserInfo {
      *  shuold use NLink.win32
      */
 
      *  shuold use NLink.win32
      */
 
-    /** <p>
-     *  IE7/IE8/IE9 から user_session を取得。<br/>
-     *  エラーが起こった場合、例外を投げずに空文字を返す
-     *  </p>
-     *  @return user_session
-     */
-    private String GetUserSessionFromMSIE() {
-        String user_session = "";
-
-        String profile_dir = System.getenv("USERPROFILE");
-        if (profile_dir == null || profile_dir.isEmpty()) {
-            return "";
-        }
-        String search_dir = profile_dir + "\\AppData\\Roaming\\Microsoft\\Windows\\Cookies\\Low\\";
-        user_session = GetUserSessionFromDirectory(search_dir);
-        if (user_session.isEmpty()) {
-            search_dir = profile_dir + "\\AppData\\Roaming\\Microsoft\\Windows\\Cookies\\";
-            user_session = GetUserSessionFromDirectory(search_dir);
-        }
-        if (user_session.isEmpty()) {
-            search_dir = profile_dir + "\\Cookies\\";
-            user_session = GetUserSessionFromDirectory(search_dir);
-        }
-        return user_session;
-    }
 
     /**
      * dir_name ディレクトリから MSIE のクッキーを見つけて user_session を返す
 
     /**
      * dir_name ディレクトリから MSIE のクッキーを見つけて user_session を返す
index ccfa485..96a4d38 100644 (file)
@@ -24,6 +24,8 @@ public abstract class Cookie {
                 return new CookieWinCrome();
             case FIREFOX:
                 return new CookieWinFirefox4();
                 return new CookieWinCrome();
             case FIREFOX:
                 return new CookieWinFirefox4();
+            case MSIE:
+                return new CookieWinMsIe();
             default:
                 throw new UnsupportedOperationException();
         }
             default:
                 throw new UnsupportedOperationException();
         }
diff --git a/frontend/src/saccubus/net/CookieWinMsIe.java b/frontend/src/saccubus/net/CookieWinMsIe.java
new file mode 100644 (file)
index 0000000..6ac6033
--- /dev/null
@@ -0,0 +1,37 @@
+package saccubus.net;
+
+import java.io.IOException;
+
+/**
+ *
+ * @author yuki
+ */
+public class CookieWinMsIe extends Cookie {
+
+    /** <p>
+     *  IE7/IE8/IE9 から user_session を取得。<br/>
+     *  エラーが起こった場合、例外を投げずに空文字を返す
+     *  </p>
+     *  @return user_session
+     */
+    @Override
+    public String getUserSessionString() throws IOException {
+        String user_session = "";
+
+        String profile_dir = System.getenv("USERPROFILE");
+        if (profile_dir == null || profile_dir.isEmpty()) {
+            return "";
+        }
+        String search_dir = profile_dir + "\\AppData\\Roaming\\Microsoft\\Windows\\Cookies\\Low\\";
+        user_session = GetUserSessionFromDirectory(search_dir);
+        if (user_session.isEmpty()) {
+            search_dir = profile_dir + "\\AppData\\Roaming\\Microsoft\\Windows\\Cookies\\";
+            user_session = GetUserSessionFromDirectory(search_dir);
+        }
+        if (user_session.isEmpty()) {
+            search_dir = profile_dir + "\\Cookies\\";
+            user_session = GetUserSessionFromDirectory(search_dir);
+        }
+        return user_session;
+    }
+}