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 MessageSecurityConfig 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 PROVIDER_CONFIG = "ProviderConfig"; 50 51 public MessageSecurityConfig() { 52 this(Common.USE_DEFAULT_VALUES); 53 } 54 55 public MessageSecurityConfig(int options) 56 { 57 super(comparators, runtimeVersion); 58 initPropertyTables(1); 60 this.createProperty("provider-config", PROVIDER_CONFIG, 61 Common.TYPE_1_N | Common.TYPE_BEAN | Common.TYPE_KEY, 62 ProviderConfig.class); 63 this.createAttribute(PROVIDER_CONFIG, "provider-id", "ProviderId", 64 AttrProp.CDATA | AttrProp.REQUIRED, 65 null, null); 66 this.createAttribute(PROVIDER_CONFIG, "provider-type", "ProviderType", 67 AttrProp.CDATA | AttrProp.REQUIRED, 68 null, null); 69 this.createAttribute(PROVIDER_CONFIG, "class-name", "ClassName", 70 AttrProp.CDATA | AttrProp.REQUIRED, 71 null, null); 72 this.initialize(options); 73 } 74 75 void initialize(int options) { 77 78 } 79 80 public void setProviderConfig(int index, ProviderConfig value) { 82 this.setValue(PROVIDER_CONFIG, index, value); 83 } 84 85 public ProviderConfig getProviderConfig(int index) { 87 return (ProviderConfig)this.getValue(PROVIDER_CONFIG, index); 88 } 89 90 public void setProviderConfig(ProviderConfig[] value) { 92 this.setValue(PROVIDER_CONFIG, value); 93 } 94 95 public ProviderConfig[] getProviderConfig() { 97 return (ProviderConfig[])this.getValues(PROVIDER_CONFIG); 98 } 99 100 public int sizeProviderConfig() { 102 return this.size(PROVIDER_CONFIG); 103 } 104 105 public int addProviderConfig(ProviderConfig value) 107 throws ConfigException{ 108 return addProviderConfig(value, true); 109 } 110 111 public int addProviderConfig(ProviderConfig value, boolean overwrite) 113 throws ConfigException{ 114 ProviderConfig old = getProviderConfigByProviderId(value.getProviderId()); 115 if(old != null) { 116 throw new ConfigException(StringManager.getManager(MessageSecurityConfig.class).getString("cannotAddDuplicate", "ProviderConfig")); 117 } 118 return this.addValue(PROVIDER_CONFIG, value, overwrite); 119 } 120 121 public int removeProviderConfig(ProviderConfig value){ 126 return this.removeValue(PROVIDER_CONFIG, value); 127 } 128 129 public int removeProviderConfig(ProviderConfig value, boolean overwrite) 135 throws StaleWriteConfigException{ 136 return this.removeValue(PROVIDER_CONFIG, value, overwrite); 137 } 138 139 public ProviderConfig getProviderConfigByProviderId(String id) { 140 if (null != id) { id = id.trim(); } 141 ProviderConfig[] o = getProviderConfig(); 142 if (o == null) return null; 143 144 for (int i=0; i < o.length; i++) { 145 if(o[i].getAttributeValue(Common.convertName(ServerTags.PROVIDER_ID)).equals(id)) { 146 return o[i]; 147 } 148 } 149 150 return null; 151 152 } 153 157 public String getAuthLayer() { 158 return getAttributeValue(ServerTags.AUTH_LAYER); 159 } 160 165 public void setAuthLayer(String v, boolean overwrite) throws StaleWriteConfigException { 166 setAttributeValue(ServerTags.AUTH_LAYER, v, overwrite); 167 } 168 172 public void setAuthLayer(String v) { 173 setAttributeValue(ServerTags.AUTH_LAYER, v); 174 } 175 179 public String getDefaultProvider() { 180 return getAttributeValue(ServerTags.DEFAULT_PROVIDER); 181 } 182 187 public void setDefaultProvider(String v, boolean overwrite) throws StaleWriteConfigException { 188 setAttributeValue(ServerTags.DEFAULT_PROVIDER, v, overwrite); 189 } 190 194 public void setDefaultProvider(String v) { 195 setAttributeValue(ServerTags.DEFAULT_PROVIDER, v); 196 } 197 201 public String getDefaultClientProvider() { 202 return getAttributeValue(ServerTags.DEFAULT_CLIENT_PROVIDER); 203 } 204 209 public void setDefaultClientProvider(String v, boolean overwrite) throws StaleWriteConfigException { 210 setAttributeValue(ServerTags.DEFAULT_CLIENT_PROVIDER, v, overwrite); 211 } 212 216 public void setDefaultClientProvider(String v) { 217 setAttributeValue(ServerTags.DEFAULT_CLIENT_PROVIDER, v); 218 } 219 223 public ProviderConfig newProviderConfig() { 224 return new ProviderConfig(); 225 } 226 227 232 protected String getRelativeXPath() { 233 String ret = null; 234 ret = "message-security-config" + (canHaveSiblings() ? "[@auth-layer='" + getAttributeValue("auth-layer") +"']" : "") ; 235 return (null != ret ? ret.trim() : null); 236 } 237 238 241 public static String getDefaultAttributeValue(String attr) { 242 if(attr == null) return null; 243 attr = attr.trim(); 244 return null; 245 } 246 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 248 comparators.add(c); 249 } 250 251 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 253 comparators.remove(c); 254 } 255 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 256 } 257 258 public void dump(StringBuffer str, String indent){ 260 String s; 261 Object o; 262 org.netbeans.modules.schema2beans.BaseBean n; 263 str.append(indent); 264 str.append("ProviderConfig["+this.sizeProviderConfig()+"]"); for(int i=0; i<this.sizeProviderConfig(); i++) 266 { 267 str.append(indent+"\t"); 268 str.append("#"+i+":"); 269 n = (org.netbeans.modules.schema2beans.BaseBean) this.getProviderConfig(i); 270 if (n != null) 271 n.dump(str, indent + "\t"); else 273 str.append(indent+"\tnull"); this.dumpAttributes(PROVIDER_CONFIG, i, str, indent); 275 } 276 277 } 278 public String dumpBeanNode(){ 279 StringBuffer str = new StringBuffer (); 280 str.append("MessageSecurityConfig\n"); this.dump(str, "\n "); return str.toString(); 283 }} 284 285 287 | Popular Tags |