void commence()

in plugin-core/plugin/src/main/groovy/grails/plugin/springsecurity/web/authentication/AjaxAwareAuthenticationEntryPoint.groovy [49:78]


	void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException {

		if ('true'.equalsIgnoreCase(request.getHeader('nopage'))) {
			response.sendError HttpServletResponse.SC_UNAUTHORIZED
			return
		}

		String redirectUrl

		if (useForward) {
			if (forceHttps && 'http' == request.scheme) {
				// First redirect the current request to HTTPS.
				// When that request is received, the forward to the login page will be used.
				redirectUrl = buildHttpsRedirectUrlForRequest(request)
			}

			if (redirectUrl == null) {
				String loginForm = determineUrlToUseForThisRequest(request, response, e)
				log.debug 'Server side forward to: {}', loginForm
				request.getRequestDispatcher(loginForm).forward request, response
				return
			}
		}
		else {
			// redirect to login page. Use https if forceHttps true
			redirectUrl = buildRedirectUrlToLoginPage(request, response, e)
		}

		redirectStrategy.sendRedirect request, response, redirectUrl
	}