| 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.domain.AbstractBlog; |
| 37 |
|
import net.sourceforge.pebble.security.SecurityRealm; |
| 38 |
|
import net.sourceforge.pebble.security.SecurityRealmException; |
| 39 |
|
import net.sourceforge.pebble.web.controller.RequireSecurityToken; |
| 40 |
|
import net.sourceforge.pebble.web.view.RedirectView; |
| 41 |
|
import net.sourceforge.pebble.web.view.View; |
| 42 |
|
import org.apache.commons.logging.Log; |
| 43 |
|
import org.apache.commons.logging.LogFactory; |
| 44 |
|
|
| 45 |
|
import javax.servlet.ServletException; |
| 46 |
|
import javax.servlet.http.HttpServletRequest; |
| 47 |
|
import javax.servlet.http.HttpServletResponse; |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
@author |
| 53 |
|
|
| 54 |
|
@RequireSecurityToken |
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 6 |
Complexity Density: 0,43 |
|
| 55 |
|
public class ManageUsersAction extends SecureAction { |
| 56 |
|
|
| 57 |
|
|
| 58 |
|
private static final Log log = LogFactory.getLog(ManageUsersAction.class); |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
|
@param |
| 64 |
|
@param |
| 65 |
|
@return |
| 66 |
|
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 5 |
Complexity Density: 0,38 |
|
| 67 |
0
|
public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {... |
| 68 |
0
|
try { |
| 69 |
0
|
AbstractBlog blog = (AbstractBlog)getModel().get(Constants.BLOG_KEY); |
| 70 |
0
|
String usernames[] = request.getParameterValues("user"); |
| 71 |
0
|
String submit = request.getParameter("submit"); |
| 72 |
|
|
| 73 |
0
|
SecurityRealm realm = PebbleContext.getInstance().getConfiguration().getSecurityRealm(); |
| 74 |
0
|
if (usernames != null) { |
| 75 |
0
|
for (String username : usernames) { |
| 76 |
0
|
if (submit.equalsIgnoreCase("Remove")) { |
| 77 |
0
|
realm.removeUser(username); |
| 78 |
0
|
} else if (submit.equalsIgnoreCase("Reset Password")) { |
| 79 |
0
|
realm.changePassword(username, "password"); |
| 80 |
|
} |
| 81 |
|
} |
| 82 |
|
} |
| 83 |
|
|
| 84 |
0
|
return new RedirectView(blog.getUrl() + "viewUsers.secureaction"); |
| 85 |
|
} catch (SecurityRealmException e) { |
| 86 |
0
|
throw new ServletException(e); |
| 87 |
|
} |
| 88 |
|
} |
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
@return |
| 94 |
|
@param |
| 95 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 96 |
0
|
public String[] getRoles(HttpServletRequest request) {... |
| 97 |
0
|
return new String[]{Constants.BLOG_ADMIN_ROLE}; |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
} |