Autenticación de Android con Kerberos
Estoy intentando crear una aplicación de Android que utilice un servicio web existente. Sin embargo, el servicio web existente utiliza Kerberos para la autenticación y tengo problemas para que Android utilice la biblioteca android-xmlrpc para autenticarse con el servicio. Si alguien tiene alguna experiencia con esto, por favor responda.
¡Soy completamente nuevo a este tipo de materia, así que cualquier consejo sería apreciado grandemente!
Gracias Dave
La información aquí me ayudó a conseguir que mi aplicación android funcione con kerberos. Aquí hay un enlace a un proyecto en el que estoy trabajando. Hace autenticación kerberos. Aquí está el código pertinente:
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? }
Aquí está el método 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; }
Aquí 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; }