1 16 package org.apache.cocoon.portal.tools.helper; 17 18 import java.util.StringTokenizer ; 19 20 import org.apache.cocoon.portal.profile.PortalUser; 21 22 27 public class MultipleRoleMatcher 28 implements RoleMatcher { 29 30 33 public static final String ROLE_SEPARATOR = "+"; 34 35 38 private String [] roles; 39 40 43 public MultipleRoleMatcher(String roles) { 44 StringTokenizer tokenizer = new StringTokenizer ( 45 roles, 46 ROLE_SEPARATOR, 47 false); 48 49 this.roles = new String [tokenizer.countTokens()]; 50 51 String token; 52 int i = 0; 53 while (tokenizer.hasMoreTokens()) { 54 token = tokenizer.nextToken(); 55 this.roles[i] = token; 56 i++; 57 } 58 } 59 60 65 public boolean matches(PortalUser user) { 66 int length = this.roles.length; 68 for (int i = 0; i < length; i++) { 69 if (!user.isUserInRole(this.roles[i])) { 70 return false; 71 } 72 } 73 return true; 74 } 75 } | Popular Tags |