Auf Cookies in Mozilla Firefox zugreifen

StupidAttack

Bekanntes Mitglied
Hallo liebe Community

ICh möchte auf Session Id's (Cookies) die nicht in cookies.sqlite oder permissions.sqlite abgespeichert werden zugreifen. Diese Cookies werden nicht gespeichert, da sie so lange "leben" bis die Session beendet ist. Und die cookies.sqlite werden erst beim Browser Beenden aktualisiert.

Via Javascript sieht das in etwa so aus, um den FF Cookiemanager anzusprechen:

Code:
var e = Components.classes["@mozilla.org/cookiemanager;1"]
                        .getService(Components.interfaces.nsICookieManager).enumerator;

Ich will aber nicht irgendetwas mit JS rummurksen sondern sofort mit Java darauf zugreifen. Für Eclispe habe ich auch schon ein Package gefunden, dass die Cookies während einer Session extrahiert:

Java:
01:        /* ***** BEGIN LICENSE BLOCK *****
02:         * Version: MPL 1.1
03:         *
04:         * The contents of this file are subject to the Mozilla Public License Version
05:         * 1.1 (the "License"); you may not use this file except in compliance with
06:         * the License. You may obtain a copy of the License at
07:         * [url=http://www.mozilla.org/MPL/]Mozilla Public License[/url]
08:         *
09:         * Software distributed under the License is distributed on an "AS IS" basis,
10:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11:         * for the specific language governing rights and limitations under the
12:         * License.
13:         *
14:         * The Original Code is Mozilla Communicator client code, released March 31, 1998.
15:         *
16:         * The Initial Developer of the Original Code is
17:         * Netscape Communications Corporation.
18:         * Portions created by Netscape are Copyright (C) 1998-1999
19:         * Netscape Communications Corporation.  All Rights Reserved.
20:         *
21:         * Contributor(s):
22:         *
23:         * IBM
24:         * -  Binding to permit interfacing between Mozilla and SWT
25:         * -  Copyright (C) 2005 IBM Corp.  All Rights Reserved.
26:         *
27:         * ***** END LICENSE BLOCK ***** */
28:        package org.eclipse.swt.internal.mozilla;
29:
30:        public class nsICookieManager extends nsISupports {
31:
32:            static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 3;
33:
34:            public static final String NS_ICOOKIEMANAGER_IID_STR = "aaab6710-0f2c-11d5-a53b-0010a401eb10";
35:
36:            public static final nsID NS_ICOOKIEMANAGER_IID = new nsID(
37:                    NS_ICOOKIEMANAGER_IID_STR);
38:
39:            public nsICookieManager(int /*long*/address) {
40:                super (address);
41:            }
42:
43:            public int RemoveAll() {
44:                return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1,
45:                        getAddress());
46:            }
47:
48:            public int GetEnumerator(int /*long*/[] aEnumerator) {
49:                return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2,
50:                        getAddress(), aEnumerator);
51:            }
52:
53:            public int Remove(int /*long*/aDomain, int /*long*/aName,
54:                    int /*long*/aPath, boolean aBlocked) {
55:                return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3,
56:                        getAddress(), aDomain, aName, aPath, aBlocked);
57:            }
58:        }


Jetzt die Frage, die eher ins Anfänger Forum passt: Kann ich dieses Package auch in Netbeans verwenden?😳


Liebe Grüsse
 
Hallo,

probier es doch einfach aus. 😀

Es sollte eigendlich egal sein, ob du das Programm mit einem Texteditor, Eclipse, Netbeans oder irgendeiner anderen IDE schreibst.
Du mußt nur dafür sorgen, daß du alle Packages hast, die du für dein Vorhaben brauchst.

MfG
hansmueller
 
Danke für die Antwort. Habe mir jetzt das ganze Eclipse Package gezogen und habe jetzt schwierigkeiten das Packet einzubinden...


Mein Klasse mit der ich jetzt auf Firefox Interface zugreifen will im Package http_request sieht jetzt so aus:
Java:
import org.eclipse.swt.internal.mozilla.*;
import org.eclipse.swt.internal.mozilla.XPCOM;
import org.eclipse.swt.internal.mozilla.nsID;
import org.eclipse.swt.internal.mozilla.nsISupports;


/**
 *
 * @author Böse Spinne :/
 */

       public class nsICookieManager extends nsISupports {

            static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 3;

            public static final String NS_ICOOKIEMANAGER_IID_STR = "aaab6710-0f2c-11d5-a53b-0010a401eb10";

           public static final nsID NS_ICOOKIEMANAGER_IID = new nsID(
                    NS_ICOOKIEMANAGER_IID_STR);

           public nsICookieManager(int /*long*/address) {
                super (address);
           }

            public int RemoveAll() {
                return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1,
                       getAddress());
           }

            public int GetEnumerator(int /*long*/[] aEnumerator) {
                return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2,
                       getAddress(), aEnumerator);
           }

           public int Remove(int /*long*/aDomain, int /*long*/aName,
                    int /*long*/aPath, boolean aBlocked) {
               return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3,
                        getAddress(), aDomain, aName, aPath, aBlocked);
           }
        }

Ich habe die Jar korrekt eingebunden, sonst würde Doktore Netbeans schon bei den Import Anweisungen meckern...

Aber hier die Fehlermeldung vor fast jeder Zeile in der ich auf die Lib zugreife:
cannot be accessed from outside package
da die LAST_METHOD_ID Beispielsweise nicht public ist...Hier die Klasse nsISupports von der ich erbe:
Java:
package org.eclipse.swt.internal.mozilla;

public class nsISupports {

    static final int LAST_METHOD_ID = 2;
    public static final String NS_ISUPPORTS_IID_STR = "00000000-0000-0000-c000-000000000046";
    public static final nsID NS_ISUPPORTS_IID;
    int address;

    public nsISupports(int address) {
        //compiled code
        throw new RuntimeException("Compiled Code");
    }

    public int getAddress() {
        //compiled code
        throw new RuntimeException("Compiled Code");
    }

    public int QueryInterface(nsID uuid, int[] result) {
        //compiled code
        throw new RuntimeException("Compiled Code");
    }

    public int AddRef() {
        //compiled code
        throw new RuntimeException("Compiled Code");
    }

    public int Release() {
        //compiled code
        throw new RuntimeException("Compiled Code");
    }
}

Achja: Es gibt schon eine Klasse nsICookieManager in dem Package, warum sollte ich nochmals eine schreiben? Sie sieht folgendermassen aus:
Java:
package org.eclipse.swt.internal.mozilla;

public class nsICookieManager extends nsISupports {

    static final int LAST_METHOD_ID = 5;
    public static final String NS_ICOOKIEMANAGER_IID_STR = "aaab6710-0f2c-11d5-a53b-0010a401eb10";
    public static final nsID NS_ICOOKIEMANAGER_IID;

    public nsICookieManager(int address) {
        //compiled code
        throw new RuntimeException("Compiled Code");
    }

    public int RemoveAll() {
        //compiled code
        throw new RuntimeException("Compiled Code");
    }

    public int GetEnumerator(int[] aEnumerator) {
        //compiled code
        throw new RuntimeException("Compiled Code");
    }

    public int Remove(int aDomain, int aName, int aPath, boolean aBlocked) {
        //compiled code
        throw new RuntimeException("Compiled Code");
    }
}

Das verwirrt mich jetzt schon sehr, immerhin habe ich obiges Beispiel wo ich das Package nutzen will bei mehreren Websites gefunden: org.eclipse.swt.internal.mozilla: nsICookieManager.java oder hier: Koders Code Search: nsICookieManager.java - Java

Ich weiss nicht wie das gedacht ist. Wie komme ich an die Cookies meines Firefox Browsers?

Bin verwirrt :/

Jagt mich jetzet net zum Daibel, aber ich habe auf mozilla Developer viele Beispiele gefunden, wie ich an die Cookies via JavaScript komme. Beispielsweise so:

[XML] var cookieMgr = Components.classes["@mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager);

for (var e = cookieMgr.enumerator; e.hasMoreElements()😉 {
var cookie = e.getNext().QueryInterface(Components.interfaces.nsICookie);
dump(cookie.host + ";" + cookie.name + "=" + cookie.value + "\n"); // see http://developer.mozilla.org/en/docs/nsICookie for a list of attributes on |cookie|
}[/XML]

Wie sähe sowas in Java aus?

Grüsse
 
Zuletzt bearbeitet:

Zurück
Oben