1 17 18 package org.apache.lenya.cms.ac.cocoon; 19 20 import org.apache.lenya.ac.Accreditable; 21 import org.apache.lenya.ac.Group; 22 import org.apache.lenya.ac.IPRange; 23 import org.apache.lenya.ac.Item; 24 import org.apache.lenya.ac.Role; 25 import org.apache.lenya.ac.User; 26 27 31 public class CredentialWrapper { 32 33 37 public String getAccreditableId() { 38 return accreditableId; 39 } 40 41 45 public String getAccreditableName() { 46 return accreditableName; 47 } 48 49 53 public String getRoleId() { 54 return roleId; 55 } 56 57 61 public String getRoleName() { 62 return roleName; 63 } 64 65 69 public String getType() { 70 return type; 71 } 72 73 78 public CredentialWrapper(Accreditable accreditable, Role role) { 79 if (accreditable instanceof Item) { 80 Item item = (Item) accreditable; 81 accreditableId = item.getId(); 82 accreditableName = item.getName(); 83 84 if (item instanceof User) { 85 type = USER; 86 } 87 else if (item instanceof Group) { 88 type = GROUP; 89 } 90 else if (item instanceof IPRange) { 91 type = IPRANGE; 92 } 93 } 94 else { 95 accreditableId = "world"; 96 accreditableName = "the world"; 97 type = "world"; 98 } 99 roleId = role.getId(); 100 roleName = role.getName(); 101 102 } 103 104 public static final String USER = "user"; 105 public static final String GROUP = "group"; 106 public static final String IPRANGE = "iprange"; 107 108 private String type; 109 private String accreditableId; 110 private String accreditableName; 111 private String roleId; 112 private String roleName; 113 114 } 115 | Popular Tags |