if (loginWith != null) {
// If the ui supplies a LoginWithGoogle or LoginWithYahoo link/button,
// this will speed up the openid process by skipping discovery.
// The override is done by adding the OpenIdUser to the request attribute.
if (loginWith.equals("google")) {
OpenIdUser user = OpenIdUser.populate("https://www.google.com/accounts/o8/id",
YadisDiscovery.IDENTIFIER_SELECT,
"https://www.google.com/accounts/o8/ud");
request.setAttribute(OpenIdUser.ATTR_NAME, user);
} else if (loginWith.equals("yahoo")) {
OpenIdUser user = OpenIdUser.populate("http://yahoo.com/",
YadisDiscovery.IDENTIFIER_SELECT,
"https://open.login.yahooapis.com/openid/op/auth");
request.setAttribute(OpenIdUser.ATTR_NAME, user);
}
}
String errorMsg = OpenIdServletFilter.DEFAULT_ERROR_MSG;
try {
OpenIdUser user = _relyingParty.discover(request);
if (user == null) {
if (RelyingParty.isAuthResponse(request)) {
// authentication timeout
response.sendRedirect(request.getRequestURI());
} else {
// set error msg if the openid_identifier is not resolved.
if (request.getParameter(_relyingParty.getIdentifierParameter()) != null) {
request.setAttribute(OpenIdServletFilter.ERROR_MSG_ATTR, errorMsg);//TODO error pages, massage not passed to front end
// request.getRequestDispatcher("/home/error.html").forward(request, response);
response.sendRedirect(request.getContextPath() + "/home/error.html");
} else {
// new user
//request.getRequestDispatcher("/home/login.html").forward(request, response);
response.sendRedirect(request.getContextPath() + "/home/login.html");
}
}
return;
}
if (user.isAuthenticated()) {
// user already authenticated
// request.getRequestDispatcher("/home/home.jsp").forward(request, response);
//added by suho
// the original entry
if (request.getSession().getAttribute(USER_NEED_TO_REGISTER) != null
&& request.getSession().getAttribute(USER_NEED_TO_REGISTER).equals("true")) {
// for registering purposes
// request.getRequestDispatcher("/home/registration.html").forward(request, response);
response.sendRedirect(request.getContextPath() + "/home/registration.html");
} else if (request.getSession().getAttribute(USER_NEED_TO_REGISTER) != null
&& request.getSession().getAttribute(USER_NEED_TO_REGISTER).equals("blocked")) {
// for registering purposes
// request.getRequestDispatcher("/home/registration.html").forward(request, response);
response.sendRedirect(request.getContextPath() + "/logout");
} else {
// if (request.getSession().getAttribute("accessList") != null) {
// AccessList accessList = (AccessList) request.getSession().getAttribute("accessList");
// if (accessList.getUserId().equals("UnRegisteredUser")) {
// response.sendRedirect(request.getContextPath() + "/logout");
// return;
// }
// }
response.sendRedirect(request.getContextPath() + "/admin/upload.html");
}
return;
}
if (user.isAssociated() && RelyingParty.isAuthResponse(request)) {
// verify authentication
if (_relyingParty.verifyAuth(user, request, response)) {
// authenticated
// redirect to home to remove the query params instead of doing:
// request.getRequestDispatcher("/home.jsp").forward(request, response);