if (basicAuth.doAuth(req, res))
/** * respond to an HTTP GET request * * @param req * HttpServletRequest object with the client request * @param res * HttpServletResponse object back to the client * @exception ServletException * in case of difficulties * @exception IOException * in case of difficulties */ public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // process any login that might be present basicAuth.doLogin(req); // catch the login helper requests String option = req.getPathInfo(); String[] parts = option.split("/"); if ((parts.length == 2) && ((parts[1].equals("login")))) { doLogin(req, res, null); } else { dispatch(req, res); } }
/** * Emit the basic auth headers and a 401 * @param req * @param res * @return * @throws IOException */ public boolean doAuth(HttpServletRequest req, HttpServletResponse res) throws IOException { if (doBasicAuth(req)) { String uiService = ServerConfigurationService.getString("ui.service", "Sakai"); res.addHeader("WWW-Authenticate", "Basic realm=\"" + uiService + "\""); res.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authorization Required"); return true; } return false; }
/** * Should a basic auth be used * @param req * @return */ protected boolean doBasicAuth(HttpServletRequest req) { boolean allowBasicAuth = ServerConfigurationService.getBoolean( "allow.basic.auth.login", false); if (allowBasicAuth) { if (requestedBasicAuth(req) || !isBrowser(req.getHeader("User-Agent"))) { allowBasicAuth = true; } else { allowBasicAuth = false; } } return allowBasicAuth; }
/** * initialize the AccessServlet servlet * * @param config * the servlet config parameter * @exception ServletException * in case of difficulties */ public void init(ServletConfig config) throws ServletException { super.init(config); startInit(); basicAuth = new BasicAuth(); basicAuth.init(); // Grab our services securityService = ComponentManager.get(SecurityService.class); entityManager = ComponentManager.get(EntityManager.class); activeToolManager = ComponentManager.get(ActiveToolManager.class); sessionManager = ComponentManager.get(SessionManager.class); }
/** * respond to an HTTP POST request; only to handle the login process * * @param req * HttpServletRequest object with the client request * @param res * HttpServletResponse object back to the client * @exception ServletException * in case of difficulties * @exception IOException * in case of difficulties */ public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // process any login that might be present basicAuth.doLogin(req); // catch the login helper posts String option = req.getPathInfo(); String[] parts = option.split("/"); if ((parts.length == 2) && ((parts[1].equals("login")))) { doLogin(req, res, null); } else { sendError(res, HttpServletResponse.SC_NOT_FOUND); } }
if (basicAuth.doAuth(req, res))
if (doBasicAuth(req)) {
try basicAuth.doLogin(req); if (!ToolRenderService.preprocess(this,req, res, getServletContext()))
if ( basicAuth.doAuth(req,res) ) { log.info("BASIC Auth Request Sent to the Browser "); return;
try basicAuth.doLogin(req); if (!ToolRenderService.preprocess(this,req, res, getServletContext()))
try basicAuth.doLogin(req); if (!ToolRenderService.preprocess(this,req, res, getServletContext()))
try basicAuth.doLogin(req); if (!ToolRenderService.preprocess(this,req, res, getServletContext()))