Bitte Hilfe: Anmeldung Kennwort geschuetzte Webseite..

L

Lucius1972

Neues Mitglied
0
Hallo Leute,

Ich moechte mich gerne an der Webseite von meinen Handy provider Inloggen MijnKPN - beheer uw KPN diensten einloggen, um danach auslesen zu koennen was mein Restgutenhaben meines Bundles ist.
Dies soll in meiner App angegeben werden.

Problem ist dass diese Seite kein php benutzt aber eine xml code, wenn Ich das gut gesehen habe.
Auch nutzt Sie "https" https://access.kpn.com/CAUT/AuthenticationServlet

Jetzt habe Ich schon folgende Codes gefunden wovan Ich nicht weiss ob diese zu gebrauchen sind fuer mein Vorhaben.

Set up an HTTP/HTTPS client:

Code:
public DefaultHttpClient getClient() {
        DefaultHttpClient ret = null;
 
        //sets up parameters
        HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, "utf-8");
        params.setBooleanParameter("http.protocol.expect-continue", false);
 
        //registers schemes for both http and https
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        final SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory();
        sslSocketFactory.setHostnameVerifier(SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
        registry.register(new Scheme("https", sslSocketFactory, 443));
 
        ThreadSafeClientConnManager manager = new ThreadSafeClientConnManager(params, registry);
        ret = new DefaultHttpClient(manager, params);
        return ret;
    }

POST method and retrieve the body of the HttpResponse using:

Code:
public static String getResponseBody(HttpResponse response) {
 
String response_text = null;
 
HttpEntity entity = null;
 
try {
 
entity = response.getEntity();
 
response_text = _getResponseBody(entity);
 
} catch (ParseException e) {
 
e.printStackTrace();
 
} catch (IOException e) {
 
if (entity != null) {
 
try {
 
entity.consumeContent();
 
} catch (IOException e1) {
 
}
 
}
 
}
 
return response_text;
 
}

Dass ganze wird dan mittels Parser ausgelesen:

Code:
public class OptionScraper {
 
    // example XPATH queries in the form of strings - will be used later
    private static final String NAME_XPATH = "//div[@class='yfi_quote']/div[@class='hd']/h2";
 
    private static final String TIME_XPATH = "//table[@id='time_table']/tbody/tr/td[@class='yfnc_tabledata1']";
 
    private static final String PRICE_XPATH = "//table[@id='price_table']//tr//span";
 
    // TagNode object, its use will come in later
    private static TagNode node;
 
    // a method that helps me retrieve the stock option's data based off the name (i.e. GOUAA is one of Google's stock options)
    public static Option getOptionFromName(String name) throws XPatherException, ParserConfigurationException,SAXException, IOException, XPatherException {
 
        // the URL whose HTML I want to retrieve and parse
        String option_url = "http://finance.yahoo.com/q?s=" + name.toUpperCase();
 
        // this is where the HtmlCleaner comes in, I initialize it here
        HtmlCleaner cleaner = new HtmlCleaner();
        CleanerProperties props = cleaner.getProperties();
        props.setAllowHtmlInsideAttributes(true);
        props.setAllowMultiWordAttributes(true);
        props.setRecognizeUnicodeChars(true);
        props.setOmitComments(true);
 
        // open a connection to the desired URL
        URL url = new URL(option_url);
        URLConnection conn = url.openConnection();
 
        //use the cleaner to "clean" the HTML and return it as a TagNode object
        node = cleaner.clean(new InputStreamReader(conn.getInputStream()));
 
        // once the HTML is cleaned, then you can run your XPATH expressions on the node, which will then return an array of TagNode objects (these are returned as Objects but get casted below)
        Object[] info_nodes = node.evaluateXPath(NAME_XPATH);
        Object[] time_nodes = node.evaluateXPath(TIME_XPATH);
        Object[] price_nodes = node.evaluateXPath(PRICE_XPATH);
 
        // here I just do a simple check to make sure that my XPATH was correct and that an actual node(s) was returned
        if (info_nodes.length > 0) {
            // casted to a TagNode
            TagNode info_node = (TagNode) info_nodes[0];
            // how to retrieve the contents as a string
            String info = info_node.getChildren().iterator().next().toString().trim();
 
            // some method that processes the string of information (in my case, this was the stock quote, etc)
            processInfoNode(o, info);
        }
 
        if (time_nodes.length > 0) {
            TagNode time_node = (TagNode) time_nodes[0];
            String date = time_node.getChildren().iterator().next().toString().trim();
 
            // date returned in 15-Jan-10 format, so this is some method I wrote to just parse that string into the format that I use
            processDateNode(o, date);
        }
 
        if (price_nodes.length > 0) {
            TagNode price_node = (TagNode) price_nodes[0];
            double price = Double.parseDouble(price_node.getChildren().iterator().next().toString().trim());
            o.setPremium(price);
        }
 
        return o;
    }
}
Koennte mir bitte Jemand hier helfen und einen Weg zeigen wie Ich dies in meiner App verarbeiten kann?
Wenn Ich es schon hinkriegen koennte mich ueber meiner App einzuloggen, waere schon Klasse.
PS: Ich benutze Eclipse Indigo..

Vielen Dank im voraus.
Gruss,
Lucius
 
Guten Morgen,

85 views und noch kein Tip :sad:
Koennte bitte jemand mal wenigstens einen Ansatz geben, wie Ich dies machen koennte?
Wie gesagt wenn das Einloggen schon mal klappt, das waere schon ein ganzer Schritt.
Mir wurde dieses Forum empfohlen, da mann hieranscheinend gut geholfen wird.

Danke euch.

Gruss,
Lucius
 
Hi Sixi,

Erstmal danke fuer den Google Tip, einsiges Problem die Webseite auf die Ich mich einloggen moechte benuetzt die method=post und nicht get.
Kann man die HTTP authentication trotsdem gebrauchen?

Danke im voraus,
Lucius
 
Also googlest du nach "android http post example" und findest z.B. dies hier - vielleicht sollte mal jemand 'nen google-tutorial schreiben ;)
 
Hallo Leute/Sixi,

Bin jetzt schon ertwas weiter, Ich habe ueber dem Firebug rausgefunden das 3 Parameter "usr_name" und "usr_password" ubergeben werden beim Post.
Der Parameter "swfrmsig", scheint aber verschluesselt zu sein
Code:
[FONT=Courier New]85647ghgg56khgi874637ftdyt[/FONT]
Die uebrgabe geht so:
Code:
[FONT=Courier New]usr_name=meinuser&usr_password=meinpass&swfrmsig=85647ghgg56khgi874637ftdyt[/FONT]
Beim korrekten einloggen gibt der Parameter "swfrmsig" den selben Wert, beim falschen User oder Paswort aendert der sich.
Kann mir bitte Jemand weiterhelfen?

Schonmal veieln Dank fuer eure Hilfe.

Mein Code:
Code:
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]try [/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]{[/SIZE]
 
[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Execute HTTP Get Request[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
 
[LEFT][SIZE=2]String [U]responseString[/U] = [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2];[/SIZE][/SIZE][/LEFT]
 
[LEFT][SIZE=2]HttpGet httpget = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] HttpGet([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"https://access.kpn.com/CAUT/AuthenticationServlet"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE][/LEFT]
 
[LEFT][SIZE=2]HttpResponse response = httpclient.execute(httpget);[/SIZE][/LEFT]
 
[LEFT][SIZE=2]HttpEntity entity = response.getEntity(); [/SIZE][/LEFT]
 
[LEFT][SIZE=2]StatusLine statusLine = response.getStatusLine();[/SIZE][/LEFT]
 
 
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2](statusLine.getStatusCode() == HttpStatus.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SC_OK[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]){ [/SIZE][/LEFT]
 
[LEFT][SIZE=2]System.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]out[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2].println([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"HTTP Get: "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + response.getStatusLine()); [/SIZE][/LEFT]
 
[LEFT][SIZE=2]ByteArrayOutputStream out = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ByteArrayOutputStream(); [/SIZE][/LEFT]
 
[LEFT][SIZE=2]response.getEntity().writeTo(out); [/SIZE][/LEFT]
 
[LEFT][SIZE=2]out.close(); [/SIZE]

[SIZE=2]responseString = out.toString(); [/SIZE]
[LEFT][SIZE=2]} [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]{ [/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//Closes the connection. [/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]response.getEntity().getContent().close(); [/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]throw[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] IOException(statusLine.getReasonPhrase()); [/SIZE]
[SIZE=2]} [/SIZE][/LEFT]
[/LEFT]

 
 
 
 
 
 
[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Execute HTTP Post Request[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
 
[LEFT][SIZE=2]HttpPost httppost = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] HttpPost([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"https://access.kpn.com/CAUT/AuthenticationServlet"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE][/LEFT]
 
[LEFT][SIZE=2]List<NameValuePair> nameValuePairs = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ArrayList<NameValuePair>(2);[/SIZE][/LEFT]
 
[LEFT][SIZE=2]nameValuePairs.add([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] BasicNameValuePair([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"usr_name"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],username));[/SIZE][/LEFT]
 
[LEFT][SIZE=2]nameValuePairs.add([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] BasicNameValuePair([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"usr_password"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],password));[/SIZE][/LEFT]
 
[LEFT][SIZE=2]httppost.setEntity([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] UrlEncodedFormEntity(nameValuePairs, HTTP.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]UTF_8[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2])); [/SIZE]
[SIZE=2]response = httpclient.execute(httppost); [/SIZE][/LEFT]
 
[LEFT][SIZE=2]entity = response.getEntity(); [/SIZE]
[SIZE=2]StatusLine statusLine1 = response.getStatusLine();[/SIZE][/LEFT]
 
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2](statusLine1.getStatusCode() == HttpStatus.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SC_OK[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]){[/SIZE][/LEFT]
 
[LEFT][SIZE=2]System.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]out[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2].println([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Login form get: "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + response.getStatusLine()); [/SIZE][/LEFT]
 
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] (entity != [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]) { [/SIZE][/LEFT]
 
[LEFT][SIZE=2]entity.consumeContent(); [/SIZE][/LEFT]
 
[LEFT][SIZE=2]} [/SIZE][/LEFT]
 

[LEFT][SIZE=2]}[/SIZE]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]{ [/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//Closes the connection. [/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]response.getEntity().getContent().close(); [/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]throw[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] IOException(statusLine.getReasonPhrase()); [/SIZE]
[SIZE=2]} [/SIZE][/LEFT]
[/LEFT]

 
 
 
 
 
[LEFT][SIZE=2]String str = inputStreamToString(response.getEntity().getContent()).toString();[/SIZE][/LEFT]
 
[LEFT][SIZE=2]System.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]out[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2].println(str);[/SIZE][/LEFT]
 
[LEFT][SIZE=2]} [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]catch[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] (ClientProtocolException e) {[/SIZE][/LEFT]
 
[LEFT][SIZE=2]e.printStackTrace();[/SIZE][/LEFT]
 
[LEFT][SIZE=2]} [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]catch[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] (IOException e) {[/SIZE][/LEFT]
 
[LEFT][SIZE=2]e.printStackTrace();[/SIZE][/LEFT]
 
 
 
[LEFT][SIZE=2]httpclient.getConnectionManager().shutdown(); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Disconnect[/COLOR][/SIZE][/COLOR][/SIZE] 
[SIZE=2]}[/SIZE][/LEFT]
 
Lucius1972 schrieb:
Der Parameter "swfrmsig", scheint aber verschluesselt zu sein
Code:
[FONT=Courier New]85647ghgg56khgi874637ftdyt[/FONT]

Das ist eine für die Webseite spezifische Verschlüsselung (will sagen, die hat sich der dortige Entwickler ausgedacht)

Da musst du wohl den Betreiber der Seite fragen, was er denn da haben will.
 
Hi,

Der Parameter "swfrmsig" ist aber Einzigartig schon bevor Ich mich an der Seite einlogge.
Der Parameter steht in den Sourcecode der Homepage.
Ich muss nen Weg finden den abzugleichen mit dem HttpPost, die Post muss naemlich 3 Parameter enthalten, usr_name, usr_password und die swfrmsig Variable.

Jemand eine Idee?

Danke im voraus.
Gruss,
Lucius
 

Ähnliche Themen

D
Antworten
17
Aufrufe
320
datNeMo
D
R
  • RudolfHagen
Antworten
1
Aufrufe
636
koje71
koje71
H
Antworten
0
Aufrufe
917
HoustonWeHaveAProblem
H
Zurück
Oben Unten