1 23 24 28 29 package com.sun.enterprise.config.serverbeans; 30 31 import org.w3c.dom.*; 32 import org.netbeans.modules.schema2beans.*; 33 import java.beans.*; 34 import java.util.*; 35 import java.io.Serializable ; 36 import com.sun.enterprise.config.ConfigBean; 37 import com.sun.enterprise.config.ConfigException; 38 import com.sun.enterprise.config.StaleWriteConfigException; 39 import com.sun.enterprise.util.i18n.StringManager; 40 41 43 public class SecurityMap extends ConfigBean implements Serializable 44 { 45 46 static Vector comparators = new Vector(); 47 private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(4, 2, 0); 48 49 static public final String PRINCIPAL = "Principal"; 50 static public final String USER_GROUP = "UserGroup"; 51 static public final String BACKEND_PRINCIPAL = "BackendPrincipal"; 52 53 public SecurityMap() { 54 this(Common.USE_DEFAULT_VALUES); 55 } 56 57 public SecurityMap(int options) 58 { 59 super(comparators, runtimeVersion); 60 initPropertyTables(3); 62 this.createProperty("principal", PRINCIPAL, Common.SEQUENCE_OR | 63 Common.TYPE_1_N | Common.TYPE_STRING | Common.TYPE_KEY, 64 String .class); 65 this.createProperty("user-group", USER_GROUP, Common.SEQUENCE_OR | 66 Common.TYPE_1_N | Common.TYPE_STRING | Common.TYPE_KEY, 67 String .class); 68 this.createProperty("backend-principal", BACKEND_PRINCIPAL, 69 Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 70 BackendPrincipal.class); 71 this.createAttribute(BACKEND_PRINCIPAL, "user-name", "UserName", 72 AttrProp.CDATA | AttrProp.REQUIRED, 73 null, null); 74 this.createAttribute(BACKEND_PRINCIPAL, "password", "Password", 75 AttrProp.CDATA | AttrProp.IMPLIED, 76 null, null); 77 this.initialize(options); 78 } 79 80 void initialize(int options) { 82 83 } 84 85 public void setPrincipal(String [] value) { 87 this.setValue(PRINCIPAL, value); 88 } 89 90 public String [] getPrincipal() { 92 return (String [])this.getValues(PRINCIPAL); 93 } 94 95 public int sizePrincipal() { 97 return this.size(PRINCIPAL); 98 } 99 100 public int addPrincipal(String value) 102 throws ConfigException{ 103 return addPrincipal(value, true); 104 } 105 106 public int addPrincipal(String value, boolean overwrite) 108 throws ConfigException{ 109 return this.addValue(PRINCIPAL, value, overwrite); 110 } 111 112 public int removePrincipal(String value){ 117 return this.removeValue(PRINCIPAL, value); 118 } 119 120 public int removePrincipal(String value, boolean overwrite) 126 throws StaleWriteConfigException{ 127 return this.removeValue(PRINCIPAL, value, overwrite); 128 } 129 130 public void setUserGroup(String [] value) { 132 this.setValue(USER_GROUP, value); 133 } 134 135 public String [] getUserGroup() { 137 return (String [])this.getValues(USER_GROUP); 138 } 139 140 public int sizeUserGroup() { 142 return this.size(USER_GROUP); 143 } 144 145 public int addUserGroup(String value) 147 throws ConfigException{ 148 return addUserGroup(value, true); 149 } 150 151 public int addUserGroup(String value, boolean overwrite) 153 throws ConfigException{ 154 return this.addValue(USER_GROUP, value, overwrite); 155 } 156 157 public int removeUserGroup(String value){ 162 return this.removeValue(USER_GROUP, value); 163 } 164 165 public int removeUserGroup(String value, boolean overwrite) 171 throws StaleWriteConfigException{ 172 return this.removeValue(USER_GROUP, value, overwrite); 173 } 174 175 public void setBackendPrincipal(BackendPrincipal value) { 177 this.setValue(BACKEND_PRINCIPAL, value); 178 } 179 180 public BackendPrincipal getBackendPrincipal() { 182 return (BackendPrincipal)this.getValue(BACKEND_PRINCIPAL); 183 } 184 185 189 public String getName() { 190 return getAttributeValue(ServerTags.NAME); 191 } 192 197 public void setName(String v, boolean overwrite) throws StaleWriteConfigException { 198 setAttributeValue(ServerTags.NAME, v, overwrite); 199 } 200 204 public void setName(String v) { 205 setAttributeValue(ServerTags.NAME, v); 206 } 207 211 public BackendPrincipal newBackendPrincipal() { 212 return new BackendPrincipal(); 213 } 214 215 220 protected String getRelativeXPath() { 221 String ret = null; 222 ret = "security-map" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ; 223 return (null != ret ? ret.trim() : null); 224 } 225 226 229 public static String getDefaultAttributeValue(String attr) { 230 if(attr == null) return null; 231 attr = attr.trim(); 232 return null; 233 } 234 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 236 comparators.add(c); 237 } 238 239 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 241 comparators.remove(c); 242 } 243 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 244 } 245 246 public void dump(StringBuffer str, String indent){ 248 String s; 249 Object o; 250 org.netbeans.modules.schema2beans.BaseBean n; 251 str.append(indent); 252 str.append("Principal["+this.sizePrincipal()+"]"); for(int i=0; i<this.sizePrincipal(); i++) 254 { 255 str.append(indent+"\t"); 256 str.append("#"+i+":"); 257 str.append(indent+"\t"); str.append("<"); o = this.getValue(PRINCIPAL, i); 260 str.append((o==null?"null":o.toString().trim())); str.append(">\n"); this.dumpAttributes(PRINCIPAL, i, str, indent); 263 } 264 265 str.append(indent); 266 str.append("UserGroup["+this.sizeUserGroup()+"]"); for(int i=0; i<this.sizeUserGroup(); i++) 268 { 269 str.append(indent+"\t"); 270 str.append("#"+i+":"); 271 str.append(indent+"\t"); str.append("<"); o = this.getValue(USER_GROUP, i); 274 str.append((o==null?"null":o.toString().trim())); str.append(">\n"); this.dumpAttributes(USER_GROUP, i, str, indent); 277 } 278 279 str.append(indent); 280 str.append("BackendPrincipal"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getBackendPrincipal(); 282 if (n != null) 283 n.dump(str, indent + "\t"); else 285 str.append(indent+"\tnull"); this.dumpAttributes(BACKEND_PRINCIPAL, 0, str, indent); 287 288 } 289 public String dumpBeanNode(){ 290 StringBuffer str = new StringBuffer (); 291 str.append("SecurityMap\n"); this.dump(str, "\n "); return str.toString(); 294 }} 295 296 298 | Popular Tags |