Currently, I am using Google Account Verification in my standalone application.
public static boolean isValidAccount(String email, String password) {
if (email == null || password == null) {
return false;
}
try {
// URL of target page script.
final URL url = new URL("https://www.google.com/accounts/ClientLogin");
final URLConnection urlConn = url.openConnection();
urlConn.setDoInput(true);
urlConn.setDoOutput(true);
urlConn.setUseCaches(false);
urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
// Send POST output.
final DataOutputStream cgiInput = new DataOutputStream(urlConn.getOutputStream());
// http://code.google.com/apis/base/faq_gdata.html#clientlogin
String content = "accountType=" + URLEncoder.encode("HOSTED_OR_GOOGLE") + "&Email=" + URLEncoder.encode(email) + "&Passwd=" + URLEncoder.encode(password) + "&service=" + URLEncoder.encode("mail") + "&source=" + URLEncoder.encode("JStock-1.05b");
cgiInput.writeBytes(content);
cgiInput.flush();
cgiInput.close();
if (urlConn instanceof HttpURLConnection) {
// 200 means OK. You OK. I OK. Google OK.
return ((HttpURLConnection) urlConn).getResponseCode() == 200;
}
else {
return false;
}
} catch (MalformedURLException ex) {
Logger.getLogger(UploadServlet.class.getName()).log(Level.SEVERE, null, ex);
}
catch (IOException ex) {
Logger.getLogger(UploadServlet.class.getName()).log(Level.SEVERE, null, ex);
}
return false;
}
May I know is it possible, that I can apply the similar concept on OpenID. I saw there are many web application example using OpenID. However, I haven't seen one in standalone application.
Is it possible to do so?