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

Fixed per Oliver's comments

上级 da4e7849
...@@ -49,6 +49,8 @@ import org.acegisecurity.userdetails.UserDetailsService; ...@@ -49,6 +49,8 @@ import org.acegisecurity.userdetails.UserDetailsService;
import org.acegisecurity.userdetails.UserDetails; import org.acegisecurity.userdetails.UserDetails;
import org.acegisecurity.userdetails.UsernameNotFoundException; import org.acegisecurity.userdetails.UsernameNotFoundException;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.DoNotUse;
import org.kohsuke.stapler.HttpResponse; import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.Stapler; import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerRequest;
...@@ -494,6 +496,7 @@ public abstract class SecurityRealm extends AbstractDescribableImpl<SecurityReal ...@@ -494,6 +496,7 @@ public abstract class SecurityRealm extends AbstractDescribableImpl<SecurityReal
* *
* @since TODO * @since TODO
*/ */
@Restricted(DoNotUse.class)
public static String getFrom() { public static String getFrom() {
String from = null, returnValue = null; String from = null, returnValue = null;
final StaplerRequest request = Stapler.getCurrentRequest(); final StaplerRequest request = Stapler.getCurrentRequest();
...@@ -503,10 +506,8 @@ public abstract class SecurityRealm extends AbstractDescribableImpl<SecurityReal ...@@ -503,10 +506,8 @@ public abstract class SecurityRealm extends AbstractDescribableImpl<SecurityReal
if (request != null if (request != null
&& request.getSession(false) != null) { && request.getSession(false) != null) {
from = (String) request.getSession().getAttribute("from"); from = (String) request.getSession().getAttribute("from");
} else { } else if (request != null) {
if (request != null) { from = request.getParameter("from");
from = request.getParameter("from");
}
} }
// If entry point was not found, try to deduce it from the request URI // If entry point was not found, try to deduce it from the request URI
...@@ -514,18 +515,18 @@ public abstract class SecurityRealm extends AbstractDescribableImpl<SecurityReal ...@@ -514,18 +515,18 @@ public abstract class SecurityRealm extends AbstractDescribableImpl<SecurityReal
if (from == null if (from == null
&& request != null && request != null
&& request.getRequestURI() != null && request.getRequestURI() != null
&& request.getRequestURI().compareTo("/loginError") != 0 && request.getRequestURI().equals("/loginError")
&& request.getRequestURI().compareTo("/login") != 0) { && request.getRequestURI().equals("/login")) {
from = request.getRequestURI(); from = request.getRequestURI();
} }
// If deduced entry point isn't deduced yet or the content is a blank value // If deduced entry point isn't deduced yet or the content is a blank value
// use the root web point "/" as a fallback // use the root web point "/" as a fallback
from.trim();
if (StringUtils.isBlank(from)) { if (StringUtils.isBlank(from)) {
from = "/"; from = "/";
} }
from.trim();
// Encode the return value // Encode the return value
try { try {
......
...@@ -25,5 +25,5 @@ THE SOFTWARE. ...@@ -25,5 +25,5 @@ THE SOFTWARE.
<?jelly escape-by-default='true'?> <?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler"> <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler">
<a href="${rootURL}/${app.securityRealm.loginUrl}?from=${from}"><b>${%login}</b></a> <a href="${rootURL}/${app.securityRealm.loginUrl}?from=${app.securityRealm.from}"><b>${%login}</b></a>
</j:jelly> </j:jelly>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册