1 13 package info.magnolia.jaas.principal; 14 15 import info.magnolia.cms.security.auth.GroupList; 16 17 import java.util.ArrayList ; 18 import java.util.Collection ; 19 import java.util.Iterator ; 20 21 import org.apache.commons.lang.StringUtils; 22 import org.apache.commons.lang.builder.ToStringBuilder; 23 import org.apache.commons.lang.builder.ToStringStyle; 24 25 26 29 public class GroupListImpl implements GroupList { 30 31 34 private static final long serialVersionUID = 222L; 35 36 39 protected static final String DEFAULT_NAME = "groups"; 40 41 44 protected String name; 45 46 49 protected Collection list; 50 51 public GroupListImpl() { 52 this.list = new ArrayList (); 53 } 54 55 59 public String getName() { 60 if (StringUtils.isEmpty(this.name)) { 61 return DEFAULT_NAME; 62 } 63 return this.name; 64 } 65 66 70 public void setName(String name) { 71 this.name = name; 72 } 73 74 78 public void add(String name) { 79 this.list.add(name); 80 } 81 82 86 public Collection getList() { 87 return this.list; 88 } 89 90 94 public boolean has(String name) { 95 Iterator listIterator = this.list.iterator(); 96 while (listIterator.hasNext()) { 97 String roleName = (String ) listIterator.next(); 98 if (StringUtils.equalsIgnoreCase(name, roleName)) { 99 return true; 100 } 101 } 102 return false; 103 } 104 105 108 public String toString() { 109 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("name", this.name).append( 110 "list", 111 this.list).toString(); 112 } 113 } 114 | Popular Tags |