如何登录到使用Android这个CAS系统 [英] How to log in to this CAS system via Android

查看:198
本文介绍了如何登录到使用Android这个CAS系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力了一个月的大部分时间弄清楚如何登录到Android的通过我的大学的CAS系统。我是一个总的小白HTTP和验证,我花了很多时间谷歌搜索方面,但我得到了他们的pretty多下来了。

I've been trying for the better part of a month to figure out how to login to my university's CAS system via Android. I'm a total noob to HTTP and authentication, I've spent a lot of time googling terms, but I've got them pretty much down now.

无论如何,我试图登录CAS系统,我能找到的系统是如何工作的,我已经贴在下面的图示。

Anyway, I'm trying to login the CAS system and I was able to find a diagram of how the system works which I've posted below.

<一个href=\"http://www.middleware.vt.edu/lib/exe/detail.php?id=middleware%3acas%3aprotocol&media=middleware%3acas%3acas_v1_authentication.png\" rel=\"nofollow\">http://www.middleware.vt.edu/lib/exe/detail.php?id=middleware%3Acas%3Aprotocol&media=middleware:cas:cas_v1_authentication.png

我有以下的code迄今:

I have the following code so far:

DefaultHttpClient httpClient = new DefaultHttpClient();

    try {

        HttpGet httpGet = new HttpGet(LOGIN);

        HttpResponse response = httpClient.execute(httpGet);
        HttpEntity entity = response.getEntity();

        Log.i(TAG, "Login form get: " + response.getStatusLine());
        if (entity != null) {

            entity.consumeContent();
        }
        Log.i(TAG, "Initial set of cookies: ");
        List<Cookie> cookies = httpClient.getCookieStore().getCookies();
        if (cookies.isEmpty()) {

            Log.i(TAG, "THere are no cookies");
        }
        else {

            for (int i = 0; i < cookies.size(); i++) {

                Log.i(TAG, " - " + cookies.get(i).toString());
            }
        }

        HttpPost httpPost = new HttpPost(LOGIN);

        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        nvps.add(new BasicNameValuePair("username", "egaebel"));
        nvps.add(new BasicNameValuePair("password", "Under&round11"));

        httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));

        Log.i(TAG, "The last header's value is.... " + response.getAllHeaders().length);

        response = httpClient.execute(httpPost);
        entity = response.getEntity();

        Log.i(TAG, "Login form get: " + response.getStatusLine());
        if (entity != null) {

            entity.consumeContent();
        }

        Log.i(TAG, "Post login cookies: ");
        cookies = httpClient.getCookieStore().getCookies();
        if (cookies.isEmpty()) {

            Log.i(TAG, "No Cookies");
        }
        else {

            for (int i = 0; i < cookies.size(); i++) {

                Log.i(TAG, " - " + cookies.get(i).toString());
            }
        }

        httpClient.getConnectionManager().shutdown();

这code不回我任何错误,但只抓住一个cookie中,当我觉得我需要更多的CASTGC饼干......

This code doesn't return me any errors but it only grabs one cookie, when I think I need one more, the CASTGC cookie......

我希望有人有更多的经验比我可以使图的一些感觉和至少告诉我,如果我在正确的轨道上。

I'm hoping someone with more experience than I can make some sense of the diagram above and at least tell me if I'm on the right track.

感谢您的阅读。

推荐答案

得到它的工作!我只是通过正确的SSL证书,并使用Jsoup为一个逻辑上会。也有一些隐藏的字段我不得不抓住和一些饼干我只好跟着反应得到....

Got it to work! I just had to pass the correct SSL certificate and use Jsoup as one logically would. Also there were some hidden fields I had to grab and some cookies I had to follow responses to get....

这篇关于如何登录到使用Android这个CAS系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆