| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
package net.sourceforge.pebble.web.action; |
| 33 |
|
|
| 34 |
|
import net.sourceforge.pebble.Constants; |
| 35 |
|
import net.sourceforge.pebble.PebbleContext; |
| 36 |
|
import net.sourceforge.pebble.security.PebbleUserDetails; |
| 37 |
|
import net.sourceforge.pebble.security.SecurityRealmException; |
| 38 |
|
import net.sourceforge.pebble.web.view.View; |
| 39 |
|
import net.sourceforge.pebble.web.view.impl.BlogSecurityView; |
| 40 |
|
|
| 41 |
|
import javax.servlet.ServletException; |
| 42 |
|
import javax.servlet.http.HttpServletRequest; |
| 43 |
|
import javax.servlet.http.HttpServletResponse; |
| 44 |
|
import java.util.Collection; |
| 45 |
|
import java.util.LinkedList; |
| 46 |
|
import java.util.List; |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
@author |
| 52 |
|
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0,38 |
|
| 53 |
|
public class ViewBlogSecurityAction extends SecureAction { |
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
@param |
| 59 |
|
@param |
| 60 |
|
@return |
| 61 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0,29 |
|
| 62 |
0
|
public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {... |
| 63 |
0
|
try { |
| 64 |
0
|
getModel().put("blogOwnerUsers", filterUsersByRole(PebbleContext.getInstance().getConfiguration().getSecurityRealm().getUsers(), Constants.BLOG_OWNER_ROLE)); |
| 65 |
0
|
getModel().put("blogPublisherUsers", filterUsersByRole(PebbleContext.getInstance().getConfiguration().getSecurityRealm().getUsers(), Constants.BLOG_PUBLISHER_ROLE)); |
| 66 |
0
|
getModel().put("blogContributorUsers", filterUsersByRole(PebbleContext.getInstance().getConfiguration().getSecurityRealm().getUsers(), Constants.BLOG_CONTRIBUTOR_ROLE)); |
| 67 |
0
|
getModel().put("allUsers", PebbleContext.getInstance().getConfiguration().getSecurityRealm().getUsers()); |
| 68 |
|
} catch (SecurityRealmException sre) { |
| 69 |
0
|
throw new ServletException("Could not get list of users", sre); |
| 70 |
|
} |
| 71 |
|
|
| 72 |
0
|
return new BlogSecurityView(); |
| 73 |
|
} |
| 74 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0,4 |
|
| 75 |
0
|
private List<PebbleUserDetails> filterUsersByRole(Collection<PebbleUserDetails> users, String role) {... |
| 76 |
0
|
List<PebbleUserDetails> list = new LinkedList<PebbleUserDetails>(); |
| 77 |
0
|
for (PebbleUserDetails user : users) { |
| 78 |
0
|
if (user.isUserInRole(role)) { |
| 79 |
0
|
list.add(user); |
| 80 |
|
} |
| 81 |
|
} |
| 82 |
|
|
| 83 |
0
|
return list; |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
@return |
| 90 |
|
@param |
| 91 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 92 |
0
|
public String[] getRoles(HttpServletRequest request) {... |
| 93 |
0
|
return new String[]{ |
| 94 |
|
Constants.BLOG_ADMIN_ROLE, |
| 95 |
|
Constants.BLOG_OWNER_ROLE |
| 96 |
|
}; |
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
} |