提交 da4e7849 编写于 作者: I Ing. Pavel Janousek

Modified for being a bit more legible

上级 2a489d3e
......@@ -495,42 +495,46 @@ public abstract class SecurityRealm extends AbstractDescribableImpl<SecurityReal
* @since TODO
*/
public static String getFrom() {
String from = null;
String from = null, returnValue = null;
final StaplerRequest request = Stapler.getCurrentRequest();
if (from == null
&& request != null
// Try to obtain a return point either from the Session
// or from the QueryParameter in this order
if (request != null
&& request.getSession(false) != null) {
from = (String) request.getSession().getAttribute("from");
} else {
if (request != null) {
from = request.getParameter("from");
}
}
// If entry point was not found, try to deduce it from the request URI
// except pages related to login process
if (from == null
&& request != null) {
from = request.getParameter("from");
}
&& request != null
&& request.getRequestURI() != null
&& request.getRequestURI().compareTo("/loginError") != 0
&& request.getRequestURI().compareTo("/login") != 0) {
if (from == null
&& request != null) {
final String requestURI = request.getRequestURI();
if (requestURI != null
&& requestURI.compareTo("/loginError") != 0
&& requestURI.compareTo("/login") != 0) {
from = requestURI;
}
from = request.getRequestURI();
}
// If deduced entry point isn't deduced yet or the content is a blank value
// use the root web point "/" as a fallback
from.trim();
if (StringUtils.isBlank(from)) {
from = "/";
}
from.trim();
// Encode the return value
try {
final String oldFrom = from;
from = null;
from = java.net.URLEncoder.encode(oldFrom, "UTF-8");
returnValue = java.net.URLEncoder.encode(from, "UTF-8");
} catch (UnsupportedEncodingException e) { }
return StringUtils.isBlank(from) ? "/" : from;
// Return encoded value or at least "/" in the case exception occurred during encode()
// or if the encoded content is blank value
return StringUtils.isBlank(returnValue) ? "/" : returnValue;
}
private static class None extends SecurityRealm {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册