我正在开发一个能够从Lotus Domino数据库读取数据的android应用程序.
我开始创建一个页面来测试HTTP身份验证,但遇到了很多困难.这是我的代码段:
public void GoAuth(View v){
final String httpsURL = "http://xxx.xxx.xxx.xxx/names.nsf/mypage?openpage";
final DefaultHttpClient client = new DefaultHttpClient();
final HttpPost httppost = new HttpPost(httpsURL);
String userName = "demo";
String password = "demo";
try {
//authentication block:
final List<BasicNameValuePair> nvps = new ArrayList<BasicNameValuePair>();
nvps.add(new BasicNameValuePair("Username", userName));
nvps.add(new BasicNameValuePair("Password", password));
final UrlEncodedFormEntity p_entity = new UrlEncodedFormEntity(nvps, HTTP.UTF_8);
httppost.setEntity(p_entity);
//sending the request and retrieving the response:
HttpResponse response = client.execute(httppost);
HttpEntity responseEntity = response.getEntity();
if (response.getStatusLine().getStatusCode() == HttpURLConnection.HTTP_OK){
//handling the response
final InputSource inputSource = new InputSource(responseEntity.getContent());
TextView res=(TextView)findViewById(R.id.result);
res.setText("Server response: "+inputSource.toString());
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
服务器响应为:
org.xml.sax
InputSource @ 40575700
在浏览器中尝试同样的操作,我看到登录页面,然后看到“ mypage”的内容.
对于在Android上必须遵循的正确方法和机制,我有些困惑.
任何帮助将不胜感激!
解决方法:
正如Richard在评论中提到的那样,您可能会看到“ session based authentication表格”,要处理任何类型的代码都相当麻烦.
为了获得“ HTTP基本身份验证”(可能是任何一种语言都可以轻松处理)(基于浏览器的用户名/密码提示),您可以/应该在服务器端实现Override Session Authentication Rule.
另请参见Domino 7.0.2 allows for overriding of session-based authentication
标签:lotus-domino,android 来源: https://codeday.me/bug/20191101/1983749.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。