/** * Does the given username and password authenticate for the given DSpace Context? * * @param context * @param un * @param pw * @return true if yes, false if not */ public boolean authenticates(Context context, String un, String pw) { int auth = AuthenticationManager.authenticate(context, un, pw, null, null); if (auth == AuthenticationMethod.SUCCESS) { return true; } return false; }
protected void doDSPost(Context context, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException { // Process the POSTed email and password String netid = request.getParameter("login_netid"); String password = request.getParameter("login_password"); String jsp = null; // Locate the eperson int status = AuthenticationManager.authenticate(context, netid, password, null, request); if (status == AuthenticationMethod.SUCCESS) { // Logged in OK. Authenticate.loggedIn(context, request, context.getCurrentUser()); // Set the Locale according to user preferences Locale epersonLocale = I18nUtil.getEPersonLocale(context.getCurrentUser()); context.setCurrentLocale(epersonLocale); Config.set(request.getSession(), Config.FMT_LOCALE, epersonLocale); log.info(LogManager.getHeader(context, "login", "type=explicit")); // resume previous request Authenticate.resumeInterruptedRequest(request, response); return; } else if (status == AuthenticationMethod.CERT_REQUIRED) { jsp = "/error/require-certificate.jsp"; } else { jsp = "/login/incorrect.jsp"; } // If we reach here, supplied email/password was duff. log.info( LogManager.getHeader( context, "failed_login", "netid=" + netid + ", result=" + String.valueOf(status))); JSPManager.showJSP(request, response, jsp); }