1 16 package org.apache.webapp.balancer.rules; 17 18 import javax.servlet.http.HttpServletRequest ; 19 20 21 27 public class UserRoleRule extends BaseRule { 28 33 private String role; 34 35 40 public void setRole(String theRole) { 41 if (theRole == null) { 42 throw new IllegalArgumentException ("The role cannot be null."); 43 } else { 44 role = theRole; 45 } 46 } 47 48 53 protected String getRole() { 54 return role; 55 } 56 57 60 public boolean matches(HttpServletRequest request) { 61 return request.isUserInRole(getRole()); 62 } 63 64 69 public String toString() { 70 StringBuffer buffer = new StringBuffer (); 71 72 buffer.append("["); 73 buffer.append(getClass().getName()); 74 buffer.append(": "); 75 76 buffer.append("Target role: "); 77 buffer.append(getRole()); 78 buffer.append(" / "); 79 80 buffer.append("Redirect URL: "); 81 buffer.append(getRedirectUrl()); 82 83 buffer.append("]"); 84 85 return buffer.toString(); 86 } 87 } 88 89 90 | Popular Tags |