Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Jsoup身份验证失败_Java_Android_Authentication_Cookies_Jsoup - Fatal编程技术网

Java Jsoup身份验证失败

Java Jsoup身份验证失败,java,android,authentication,cookies,jsoup,Java,Android,Authentication,Cookies,Jsoup,我正在尝试使用以下代码连接此网站: Connection.Response response = Jsoup.connect("https://ent.enteduc.fr/CookieAuth.dll?GetLogon?curl=Z2F&flags=0&forcedownlevel=0&formdir=1&username=XXX&password=XXX&trusted=4&SubmitCreds.x=36&SubmitCred

我正在尝试使用以下代码连接此网站:

Connection.Response response = Jsoup.connect("https://ent.enteduc.fr/CookieAuth.dll?GetLogon?curl=Z2F&flags=0&forcedownlevel=0&formdir=1&username=XXX&password=XXX&trusted=4&SubmitCreds.x=36&SubmitCreds.y=7&SubmitCreds=Ouvrir+une+session")
                        .method(Connection.Method.GET)
                        .execute();

                Document Doc = Jsoup.connect("https://ent.enteduc.fr/CookieAuth.dll?GetLogon?curl=Z2F&reason=0&formdir=1")
                        .data("username","myusername")
                        .data("password","mypassword")
                        .data("curl","Z2F")
                        .data("flags","0")
                        .data("forcedownlevel","0")
                        .data("formdir","1")
                        .data("trusted","4")
                        .data("SubmitCreds.x","40") //Seems to send the coordinates of the cursor
                        .data("SubmitCreds.y","12") //Seems to send the coordinates of the cursor
                        .data("SubmitCreds","Ouvrir une session")
                        .cookies(response.cookies())
                        .post();
                Log.e("Body", Doc.body().toString());
但是显示的“Body”仍然是身份验证页面(Logcat中没有错误) 怎么了

下面是连接的详细信息,请使用Chromes的控制台获取

Remote Address:85.90.60.205:443
Request URL:https://ent.enteduc.fr/CookieAuth.dll?Logon
Request Method:POST
Status Code:302 Moved Temporarily
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:165
Content-Type:application/x-www-form-urlencoded
Cookie:ISAWPLB{FE9B5C07-18E7-4D86-BC7C-2F0AFE4F36BF}={8A3F320B-C8EB-40F9-A11E-D036A91F953F}; __utma=136247269.742318163.1408441429.1408445338.1408450626.3; __utmb=136247269.5.10.1408450626; __utmc=136247269; __utmz=136247269.1408441429.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); WSS_KeepSessionAuthenticated=; logondata=acc=0&lgn=*********
Host:ent.enteduc.fr
Origin:https://ent.enteduc.fr
Referer:https://ent.enteduc.fr/CookieAuth.dll?GetLogon?curl=Z2F&reason=0&formdir=1
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36
Query String Parametersview sourceview URL encoded
Logon:
Form Dataview sourceview URL encoded
curl:Z2F
flags:0
forcedownlevel:0
formdir:1
username:myusername
password:mypass
trusted:4
SubmitCreds.x:53
SubmitCreds.y:12
SubmitCreds:Ouvrir une session
Response Headersview source
Connection:close
Content-Length:0
Location:https://ent.enteduc.fr/
Set-Cookie:cadata6A45CD714D774496A399F96AC521E21E....

你的代码没有问题。它起作用了。我尝试了您提供的默认用户名和密码。这就是网站所做的

  • 您成功登录,它向路径/发送HTTP 302,并提供一个标识您的cookie

HTTP/1.1 302临时移动
地点:https://ent.enteduc.fr/
设置Cookie:XXX

  • 浏览器请求
    /
    ,服务器用另一个HTTP 302响应

找到HTTP/1.1 302
连接:保持活力
位置:/etabs/0680001F/Pages/Accueil.aspx

  • 请求
    /etabs/0680001F/Pages/accureil.aspx
    会导致200 OK,HTML内容用法语编写。原谅我!我是法国人
更改代码以遵循重定向,并在每个步骤上设置cookies,您应该会没事

[编辑]


完成后,请删除您在此帖子中提供的身份验证信息。

我已冒昧地屏蔽了您帖子中的用户名和密码。公开发布时请小心。我不确定它为什么会失败。是否存在未绑定到真实帐户的测试用户名和密码?我们可以尝试登录并帮助您。感谢您的耐心等待。我已经删除了身份验证信息。但是没有成功获取经过身份验证的页面的html。我在第一个代码中没有找到要更改的内容。请不要阅读正文。而是获取响应HTTP状态代码并检查它是否为302。如果是,则遵循
位置
标题并提出另一个请求。执行此操作直到您登录到
/etabs/0680001F/Pages/Accueil.aspx
因为我得到了一个200代码,而对于一个IOException:“未找到身份验证挑战”事实上,似乎没有cookie集,根据这一点:response=Jsoup.connect(“).method(Connection.method.get).execute();Log.e(“Status1”),String.valueOf(response.statusCode())//返回200 Log.e(“Cookies”,String.valueOf(response.Cookies())//返回{}确实很奇怪。你能截获你的程序和站点之间的流量并确认没有
Set Cookie
头吗?