public LoginResult login(String appBaseUrl, boolean inDebugMode, String openIdURL) throws FetchException {
LOGGER.info("trying to log in for " + openIdURL);
HttpServletRequest request = getThreadLocalRequest();
LOGGER.info("we have the request. now pass it on to openid servlet");
LoginResult loginResult = new LoginResult();
try {
UserDetails userDetails;
userDetails = OpenIdServlet.getRequestUserInfo(new File(getServletContext().getRealPath("/")), request);
if (userDetails.isLoggedIn()) {
loginResult.setIsLoggedIn(true);
} else {
//not logged in
loginResult.setIsLoggedIn(false);
loginResult.setAuthenticationLink(OpenIdServlet.getAuthenticationURL(openIdURL, appBaseUrl, inDebugMode));
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
throw new FetchException(e.getMessage(), e);
} catch (FileNotFoundException e) {
e.printStackTrace();
throw new FetchException(e.getMessage(), e);
} catch (JSONException e) {
e.printStackTrace();
throw new FetchException(e.getMessage(), e);
} catch (SQLException e) {
e.printStackTrace();
throw new FetchException(e.getMessage(), e);
} catch (IOException e) {
e.printStackTrace();
throw new FetchException(e.getMessage(), e);
} catch (ParseException e) {
e.printStackTrace();
throw new FetchException(e.getMessage(), e);
} catch (OpenIdException e) {
//not logged in
loginResult.setIsLoggedIn(false);
loginResult.setAuthenticationLink(OpenIdServlet.getAuthenticationURL(openIdURL, appBaseUrl, inDebugMode));
}
return loginResult;
}