Skip to content

Commit 86bbb30

Browse files
Updates made based on feedback from code review.
1 parent 07287d3 commit 86bbb30

File tree

1 file changed

+23
-28
lines changed

1 file changed

+23
-28
lines changed

admin/broadleaf-open-admin-platform/src/main/java/org/broadleafcommerce/openadmin/security/BroadleafAdminAuthenticationSuccessHandler.java

+23-28
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@
4141
*/
4242
public class BroadleafAdminAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
4343

44+
protected String loginUri = "/login"; // default login uri but can be overridden in admin security config
4445
private RequestCache requestCache = new HttpSessionRequestCache();
45-
46-
private String loginUri = "/login"; //default login uri but can be overridden in admin security config
47-
4846
private static final String successUrlParameter = "successUrl=";
49-
47+
5048
@Resource(name = "blAdminSecurityRemoteService")
5149
protected SecurityVerifier adminRemoteSecurityService;
5250

@@ -95,35 +93,32 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
9593
// Remove the login URI so we don't continuously redirect to the login page
9694
targetUrl = removeLoginSegment(targetUrl);
9795

98-
if (logger.isDebugEnabled()) {
99-
logger.debug("Redirecting to DefaultSavedRequest Url: " + targetUrl);
100-
}
96+
logger.debug("Redirecting to DefaultSavedRequest Url: " + targetUrl);
10197
getRedirectStrategy().sendRedirect(request, response, targetUrl);
10298
}
103-
99+
104100
/**
105101
* Given the instance attribute loginUri, removes the loginUri from the passed url when present
106102
* @param uri
107103
* @return String
108104
*/
109-
private String removeLoginSegment(String url) {
110-
if ((url == null) || url.equals("")) {
111-
return "/";
112-
}
113-
int lastSlashPos = url.lastIndexOf(loginUri);
114-
if (lastSlashPos >= 0) {
115-
return url.substring(0, lastSlashPos);
116-
}
117-
else {
118-
return url;
119-
}
120-
}
121-
122-
public String getLoginUri() {
123-
return loginUri;
124-
}
125-
126-
public void setLoginUri(String loginUri) {
127-
this.loginUri = loginUri;
128-
}
105+
protected String removeLoginSegment(String url) {
106+
if (StringUtils.isEmpty(url)) {
107+
return "/";
108+
}
109+
int lastSlashPos = url.lastIndexOf(loginUri);
110+
if (lastSlashPos >= 0) {
111+
return url.substring(0, lastSlashPos);
112+
} else {
113+
return url;
114+
}
115+
}
116+
117+
public String getLoginUri() {
118+
return loginUri;
119+
}
120+
121+
public void setLoginUri(String loginUri) {
122+
this.loginUri = loginUri;
123+
}
129124
}

0 commit comments

Comments
 (0)