Android 使用 Kerberos 进行身份验证

发布于 2024-09-16 03:49:49 字数 182 浏览 4 评论 0原文

我正在尝试创建一个使用现有 Web 服务的 Android 应用程序。但是,现有的 Web 服务使用 Kerberos 进行身份验证,而我在使用 Android-xmlrpc 库对 Android 进行身份验证时遇到了问题。如果有人有这方面的经验,请回复。

我对这类东西完全陌生,所以任何建议将不胜感激!

谢谢, 戴夫

I am trying to create a Android application that uses an existing web service. However, the existing web service uses Kerberos for authentication and I am having trouble getting Android using the android-xmlrpc library to authenticate with the service. If anyone has any experience with this, please respond.

I am completely new to this kind of stuff, so any advice would be greatly appreciated!

Thanks,
Dave

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深空失忆 2024-09-23 03:49:49

这里的信息帮助我让我的Android应用程序正常工作与 kerberos。这是一个链接 我正在做的一个项目。它进行 kerberos 身份验证。这是相关代码:

UsernamePasswordCredentials creds =
  new UsernamePasswordCredentials(username, password);
DefaultHttpClient client = getHttpClient();
client.getCredentialsProvider().setCredentials(SERVER_AUTH_SCOPE, creds);

boolean authWorked = false;
try{
  HttpGet get = new HttpGet(AUTH_URI);
  HttpResponse resp = client.execute(get);
  authWorked = hasValidCookie();
}
/*catch(AuthenticationException e){
Log.e("TAG", "Auth exceptions");
//TODO maybe do something?
}*/
catch(IOException e){
  Log.e("TAG", "IOException exceptions");
  //TODO maybe do something?
}

这是 getHttpClient() 方法:

  public static DefaultHttpClient getHttpClient(){
    if(httpClient == null){
      httpClient = new DefaultHttpClient();
      final HttpParams params = httpClient.getParams();
      HttpConnectionParams.setConnectionTimeout(params, REGISTRATION_TIMEOUT);
      HttpConnectionParams.setSoTimeout(params, REGISTRATION_TIMEOUT);
      ConnManagerParams.setTimeout(params, REGISTRATION_TIMEOUT);
    }
    return httpClient;
  }

这是 hasValidCookie()

private static final String LOGIN_COOKIE_NAME = "CGISESSID";
private static boolean hasValidCookie(){
  for(Cookie cookie: getHttpClient().getCookieStore().getCookies()){
    if(cookie.getName().equals(LOGIN_COOKIE_NAME))
    {
      return true;
    }
  }
  return false;
}

The information here helped me to get my android app working with kerberos. Here's a link to a project I'm working on. It does kerberos authentication. Here's the pertinent code:

UsernamePasswordCredentials creds =
  new UsernamePasswordCredentials(username, password);
DefaultHttpClient client = getHttpClient();
client.getCredentialsProvider().setCredentials(SERVER_AUTH_SCOPE, creds);

boolean authWorked = false;
try{
  HttpGet get = new HttpGet(AUTH_URI);
  HttpResponse resp = client.execute(get);
  authWorked = hasValidCookie();
}
/*catch(AuthenticationException e){
Log.e("TAG", "Auth exceptions");
//TODO maybe do something?
}*/
catch(IOException e){
  Log.e("TAG", "IOException exceptions");
  //TODO maybe do something?
}

Here's the getHttpClient() method:

  public static DefaultHttpClient getHttpClient(){
    if(httpClient == null){
      httpClient = new DefaultHttpClient();
      final HttpParams params = httpClient.getParams();
      HttpConnectionParams.setConnectionTimeout(params, REGISTRATION_TIMEOUT);
      HttpConnectionParams.setSoTimeout(params, REGISTRATION_TIMEOUT);
      ConnManagerParams.setTimeout(params, REGISTRATION_TIMEOUT);
    }
    return httpClient;
  }

Here's hasValidCookie()

private static final String LOGIN_COOKIE_NAME = "CGISESSID";
private static boolean hasValidCookie(){
  for(Cookie cookie: getHttpClient().getCookieStore().getCookies()){
    if(cookie.getName().equals(LOGIN_COOKIE_NAME))
    {
      return true;
    }
  }
  return false;
}
辞慾 2024-09-23 03:49:49

Hypergate (hypergate.com) 是 Android 的 Kerberos 客户端,允许其他应用程序请求票证。它使用标准的 Android API,这意味着 WebView 和大多数浏览器无需更改任何代码即可工作。有一个 SDK 可以让您轻松集成,它将为您管理门票。

免责声明:我是 Hypergate 的工程师

There is Hypergate (hypergate.com) which is a Kerberos client for Android allowing other apps to request tickets. It's using the standard Android API, which means that WebView's and most Browsers work without any code changes. There is an SDK that allows you to integrate easily, which will manage the tickets for you.

Disclaimer: I'm an engineer at Hypergate

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文