WW-4121 Improves loop

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1502451 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Lukasz Lenart
2013-07-12 07:16:32 +00:00
parent df7bd8b4eb
commit 589917d4cb
@@ -21,19 +21,17 @@
package org.apache.struts2.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import org.apache.struts2.ServletActionContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import org.apache.struts2.ServletActionContext;
/**
* <!-- START SNIPPET: description --> This interceptor ensures that the action
* will only be executed if the user has the correct role. <!--
@@ -92,7 +90,7 @@ public class RolesInterceptor extends AbstractInterceptor {
public String intercept(ActionInvocation invocation) throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
String result = null;
String result;
if (!isAllowed(request, invocation.getAction())) {
result = handleRejection(invocation, response);
} else {
@@ -109,7 +107,7 @@ public class RolesInterceptor extends AbstractInterceptor {
String[] list = val.split("[ ]*,[ ]*");
return Arrays.asList(list);
} else {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
}
@@ -126,6 +124,7 @@ public class RolesInterceptor extends AbstractInterceptor {
for (String role : allowedRoles) {
if (request.isUserInRole(role)) {
result = true;
break;
}
}
return result;