提交 92ccc8df 编写于 作者: M mindless

[FIXED HUDSON-2408] On a failed permission check for anonymous, it seems

rsp.getOutputStream() has already been called before reaching this class.
So use getOutputStream() instead of getWriter() to send html for login
redirect (and catch exception/use getWriter, just in case).


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@14049 71c3de6d-444a-0410-be80-ed276b4c234a
上级 5ac33c57
......@@ -4,12 +4,15 @@ import org.acegisecurity.AuthenticationException;
import org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.URLEncoder;
import java.text.MessageFormat;
......@@ -49,7 +52,14 @@ public class HudsonAuthenticationEntryPoint extends AuthenticationProcessingFilt
rsp.setStatus(SC_FORBIDDEN);
rsp.setContentType("text/html;charset=UTF-8");
rsp.getWriter().printf(
PrintWriter out;
try {
ServletOutputStream sout = rsp.getOutputStream();
out = new PrintWriter(new OutputStreamWriter(sout));
} catch (IllegalStateException e) {
out = rsp.getWriter();
}
out.printf(
"<html><head>" +
"<meta http-equiv='refresh' content='1;url=%1$s'/>" +
"<script>window.location.replace('%1$s');</script>" +
......@@ -57,6 +67,7 @@ public class HudsonAuthenticationEntryPoint extends AuthenticationProcessingFilt
"<body style='background-color:white; color:white;'>" +
"Authentication required</body></html>", loginForm
);
out.flush();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册