protected void forwardToErrorPage(Request request, HttpServletResponse response, LoginConfig config) throws IOException { RequestDispatcher disp = context.getServletContext().getRequestDispatcher (config.getErrorPage()); try { disp.forward(request.getRequest(), response); } catch (Throwable t) { String msg = sm.getString("Unexpected error forwarding to error page"); log.warn(msg, t); request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg); } }
private boolean isUserAuthenticated(Request request) { Session sessionInternal = request.getSessionInternal(false); String authMethod = getContext().getLoginConfig().getAuthMethod(); return (authMethod != null && "FORM".equals(authMethod)) && sessionInternal != null && sessionInternal.getNote(Constants.FORM_PRINCIPAL_NOTE) != null; }
protected void forwardToLoginPage(Request request, HttpServletResponse response, LoginConfig config) throws IOException { RequestDispatcher disp = context.getServletContext().getRequestDispatcher (config.getLoginPage()); try { disp.forward(request.getRequest(), response); } catch (Throwable t) { String msg = sm.getString("Unexpected error forwarding to login page"); log.warn(msg, t); request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg); } }
/** * Construct a new LoginConfig with the specified properties. * * @param authMethod The authentication method * @param realmName The realm name * @param loginPage The login page URI * @param errorPage The error page URI */ public LoginConfig(String authMethod, String realmName, String loginPage, String errorPage) { super(); setAuthMethod(authMethod); setRealmName(realmName); setLoginPage(loginPage); setErrorPage(errorPage); }
if (this.context == null || this.context.getRealm() == null) { this.log.warn("missing context/realm"); this.sendError(response, HttpServletResponse.SC_SERVICE_UNAVAILABLE); this.log.debug("{} {}, contentlength: {}", request.getMethod(), request.getRequestURI(), Integer.valueOf(request.getContentLength())); final boolean negotiateCheck = request.getParameter("j_negotiate_check") != null; this.redirectTo(request, response, request.getServletPath()); } else { this.redirectTo(request, response, loginConfig.getErrorPage()); this.redirectTo(request, response, loginConfig.getLoginPage()); return false;
throws IOException { RequestDispatcher disp = context.getServletContext().getRequestDispatcher (config.getErrorPage()); try { if (context.fireRequestInitEvent(request)) { disp.forward(request.getRequest(), response); context.fireRequestDestroyEvent(request); String msg = sm.getString("formAuthenticator.forwardErrorFail"); log.warn(msg, t); request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
throws IOException { if (changeSessionIdOnAuthentication) { Session session = request.getSessionInternal(false); if (session != null) { Manager manager = request.getContext().getManager(); manager.changeSessionId(session, request.getRandom()); request.changeSessionId(session.getId()); context.getServletContext().getRequestDispatcher(config.getLoginPage()); try { disp.forward(request.getRequest(), response);
context.setVersion(metaData.getVersion()); context.setPublicId("/javax/servlet/resources/web-app_3_0.dtd"); else if (metaData.is25()) context.setPublicId("/javax/servlet/resources/web-app_2_5.dtd"); else if (metaData.is24()) context.setPublicId("/javax/servlet/resources/web-app_2_4.dtd"); if (loginConfig != null) org.apache.catalina.deploy.LoginConfig loginConfig2 = new org.apache.catalina.deploy.LoginConfig(); loginConfig2.setAuthMethod(loginConfig.getAuthMethod()); loginConfig2.setRealmName(loginConfig.getRealmName()); if (loginConfig.getFormLoginConfig() != null) loginConfig2.setLoginPage(loginConfig.getFormLoginConfig().getLoginPage()); loginConfig2.setErrorPage(loginConfig.getFormLoginConfig().getErrorPage()); context.setLoginConfig(loginConfig2);
Principal principal = request.getUserPrincipal(); String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE); if (principal != null) { if (log.isDebugEnabled()) associate(ssoId, request.getSessionInternal(true)); return (true); principal = context.getRealm().authenticate(username, password); if (principal != null) { register(request, response, principal, Constants.BASIC_METHOD, if (config.getRealmName() == null) { value.append(REALM_NAME); } else { value.append(config.getRealmName());
throws IOException { RequestDispatcher disp = context.getServletContext().getRequestDispatcher (config.getLoginPage()); try { if (context.fireRequestInitEvent(request)) { disp.forward(request.getRequest(), response); context.fireRequestDestroyEvent(request); String msg = sm.getString("formAuthenticator.forwardLoginFail"); log.warn(msg, t); request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
LoginConfig config = context.getLoginConfig(); if ((config != null) && (org.apache.catalina.realm.Constants.FORM_METHOD.equals(config.getAuthMethod()))) { String requestURI = request.getDecodedRequestURI(); String loginPage = context.getPath() + config.getLoginPage(); if (loginPage.equals(requestURI)) { if (log.isDebugEnabled()) return (true); String errorPage = context.getPath() + config.getErrorPage(); if (errorPage.equals(requestURI)) { if (log.isDebugEnabled()) currentRequestWrapperName.set(request.getWrapper().getName()); Principal principal = request.getUserPrincipal();
Context context = tomcat.addContext(contextPathURIBase == null ? "" : contextPathURIBase, contextPath.getAbsolutePath()); context.addApplicationListener(new ApplicationListener(InitListener.class.getName(), false)); context.setWebappVersion("3.0"); context.addWelcomeFile("index.jspx"); addErrorPages(context); LoginConfig loginConfig = new LoginConfig(); loginConfig.setAuthMethod("DIGEST"); loginConfig.setRealmName(InMemoryRealm.NAME); context.setLoginConfig(loginConfig);
protected void generateContextMappings(Context context, PrintWriter objfile ) String ctxPath = context.getPath(); String nPath=("".equals(ctxPath)) ? "/" : ctxPath; return; objfile.println("<Object name=" + context.getName() + ">"); if(context.getLoginConfig() != null) { String loginPage = context.getLoginConfig().getLoginPage(); if(loginPage != null) { int lpos = loginPage.lastIndexOf("/");
SecurityConstraint constraints[] = context.findConstraints(); if ((constraints == null) || (constraints.length == 0)) return; LoginConfig loginConfig = context.getLoginConfig(); if (loginConfig == null) { loginConfig = DUMMY_LOGIN_CONFIG; context.setLoginConfig(loginConfig); if (customAuthenticators != null) { authenticator = (Valve) customAuthenticators.get(loginConfig.getAuthMethod()); authenticators.getProperty(loginConfig.getAuthMethod()); if (authenticatorName == null) { CatalinaLogger.STARTUP_LOGGER.noAuthenticatorForAuthMethod(loginConfig.getAuthMethod()); ok = false; return; if (pipeline != null) { ((ContainerBase) context).addValve(authenticator); CatalinaLogger.STARTUP_LOGGER.authenticatorConfigured(loginConfig.getAuthMethod());
LoginConfig loginConfig = context.getLoginConfig(); SecurityConstraint constraints[] = context.findConstraints(); if (context.getIgnoreAnnotations() && (constraints == null || constraints.length ==0) && !context.getPreemptiveAuthentication()) { if (customAuthenticators != null) { authenticator = (Valve) customAuthenticators.get(loginConfig.getAuthMethod()); authenticators.getProperty(loginConfig.getAuthMethod()); if (authenticatorName == null) { log.error(sm.getString("contextConfig.authenticatorMissing", loginConfig.getAuthMethod())); ok = false; return; log.debug(sm.getString( "contextConfig.authenticatorConfigured", loginConfig.getAuthMethod()));
context = request.getContext(); LoginConfig config = context.getLoginConfig(); request.getCoyoteRequest().getMimeHeaders() .getValue("authorization"); principal = context.getRealm().authenticate(username, password); if (principal != null) { registerWithCallbackHandler(principal, username, password); if (config.getRealmName() == null) { authenticateCC.append(request.getServerName()); authenticateCC.append(':'); authenticateCC.append(Integer.toString(request.getServerPort())); } else { authenticateCC.append(config.getRealmName());
LoginConfig config = context.getLoginConfig(); if ((config != null) && (Constants.FORM_METHOD.equals(config.getAuthMethod()))) { String requestURI = request.getRequestPathMB().toString(); String loginPage = config.getLoginPage(); if (loginPage.equals(requestURI)) { if (log.isDebugEnabled()) return (true); String errorPage = config.getErrorPage(); if (errorPage.equals(requestURI)) { if (log.isDebugEnabled()) Principal principal = request.getPrincipal(); boolean status = false; boolean denyfromall = false; if (constraint.getAllRoles()) { roles = request.getContext().findSecurityRoles(); } else { roles = constraint.findAuthRoles(); roles = request.getContext().findSecurityRoles(); if (roles.length == 0 && allRolesMode == AllRolesMode.STRICT_AUTH_ONLY_MODE) { if (log.isDebugEnabled()) {
LoginConfig loginConfig = context.getLoginConfig(); if (loginConfig == null) { loginConfig = new LoginConfig("NONE", null, null, null); context.setLoginConfig(loginConfig); Realm rlm = context.getRealm(); if (rlm == null) { rlm.setRealmName(loginConfig.getRealmName(), loginConfig.getAuthMethod()); if (!context.hasConstraints()) { return; String loginMethod = loginConfig.getAuthMethod(); if (loginMethod != null && customAuthenticators.containsKey(loginMethod)) { String authMethod = loginConfig.getAuthMethod(); if (authMethod == null) { authMethod = "NONE"; loginConfig.getAuthMethod()); throw new LifecycleException(msg); ((ContainerBase) context).addValve(authenticator); if (log.isLoggable(Level.FINE)) { log.log(Level.FINE, LogFacade.CONFIGURED_AUTHENTICATOR_FINE, loginConfig.getAuthMethod());
ctx.addServletMapping("/*", "ES Servlet"); ctx.addConstraint(constraint); final LoginConfig lc = new LoginConfig(); lc.setAuthMethod("CLIENT-CERT"); lc.setRealmName("clientcretificate"); ctx.setLoginConfig(lc); ctx.addConstraint(constraint); final LoginConfig lc = new LoginConfig(); lc.setAuthMethod("SPNEGO"); lc.setRealmName("SPNEGO"); ctx.setLoginConfig(lc);
/** * Called to forward to the error page * * @param request Request we are processing * @param response Response we are creating * @param config Login configuration describing how authentication * should be performed */ protected void forwardToErrorPage(Request request, Response response, LoginConfig config) { RequestDispatcher disp = context.getServletContext().getRequestDispatcher (config.getErrorPage()); try { disp.forward(request.getRequest(), response.getResponse()); } catch (Throwable t) { log.warn("Unexpected error forwarding to error page", t); } }