1 23 24 28 29 package com.sun.enterprise.config.clientbeans; 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.ENUM | AttrProp.REQUIRED, 68 new String [] { 69 "client", 70 "server", 71 "client-server" 72 }, null); 73 this.createAttribute(PROVIDER_CONFIG, "class-name", "ClassName", 74 AttrProp.CDATA | AttrProp.REQUIRED, 75 null, null); 76 this.initialize(options); 77 } 78 79 void initialize(int options) { 81 82 } 83 84 public void setProviderConfig(int index, ProviderConfig value) { 86 this.setValue(PROVIDER_CONFIG, index, value); 87 } 88 89 public ProviderConfig getProviderConfig(int index) { 91 return (ProviderConfig)this.getValue(PROVIDER_CONFIG, index); 92 } 93 94 public void setProviderConfig(ProviderConfig[] value) { 96 this.setValue(PROVIDER_CONFIG, value); 97 } 98 99 public ProviderConfig[] getProviderConfig() { 101 return (ProviderConfig[])this.getValues(PROVIDER_CONFIG); 102 } 103 104 public int sizeProviderConfig() { 106 return this.size(PROVIDER_CONFIG); 107 } 108 109 public int addProviderConfig(ProviderConfig value) 111 throws ConfigException{ 112 return addProviderConfig(value, true); 113 } 114 115 public int addProviderConfig(ProviderConfig value, boolean overwrite) 117 throws ConfigException{ 118 ProviderConfig old = getProviderConfigByProviderId(value.getProviderId()); 119 if(old != null) { 120 throw new ConfigException(StringManager.getManager(MessageSecurityConfig.class).getString("cannotAddDuplicate", "ProviderConfig")); 121 } 122 return this.addValue(PROVIDER_CONFIG, value, overwrite); 123 } 124 125 public int removeProviderConfig(ProviderConfig value){ 130 return this.removeValue(PROVIDER_CONFIG, value); 131 } 132 133 public int removeProviderConfig(ProviderConfig value, boolean overwrite) 139 throws StaleWriteConfigException{ 140 return this.removeValue(PROVIDER_CONFIG, value, overwrite); 141 } 142 143 public ProviderConfig getProviderConfigByProviderId(String id) { 144 if (null != id) { id = id.trim(); } 145 ProviderConfig[] o = getProviderConfig(); 146 if (o == null) return null; 147 148 for (int i=0; i < o.length; i++) { 149 if(o[i].getAttributeValue(Common.convertName(ClientTags.PROVIDER_ID)).equals(id)) { 150 return o[i]; 151 } 152 } 153 154 return null; 155 156 } 157 161 public String getAuthLayer() { 162 return getAttributeValue(ClientTags.AUTH_LAYER); 163 } 164 169 public void setAuthLayer(String v, boolean overwrite) throws StaleWriteConfigException { 170 setAttributeValue(ClientTags.AUTH_LAYER, v, overwrite); 171 } 172 176 public void setAuthLayer(String v) { 177 setAttributeValue(ClientTags.AUTH_LAYER, v); 178 } 179 183 public String getDefaultProvider() { 184 return getAttributeValue(ClientTags.DEFAULT_PROVIDER); 185 } 186 191 public void setDefaultProvider(String v, boolean overwrite) throws StaleWriteConfigException { 192 setAttributeValue(ClientTags.DEFAULT_PROVIDER, v, overwrite); 193 } 194 198 public void setDefaultProvider(String v) { 199 setAttributeValue(ClientTags.DEFAULT_PROVIDER, v); 200 } 201 205 public String getDefaultClientProvider() { 206 return getAttributeValue(ClientTags.DEFAULT_CLIENT_PROVIDER); 207 } 208 213 public void setDefaultClientProvider(String v, boolean overwrite) throws StaleWriteConfigException { 214 setAttributeValue(ClientTags.DEFAULT_CLIENT_PROVIDER, v, overwrite); 215 } 216 220 public void setDefaultClientProvider(String v) { 221 setAttributeValue(ClientTags.DEFAULT_CLIENT_PROVIDER, v); 222 } 223 227 public ProviderConfig newProviderConfig() { 228 return new ProviderConfig(); 229 } 230 231 236 protected String getRelativeXPath() { 237 String ret = null; 238 ret = "message-security-config" + (canHaveSiblings() ? "[@auth-layer='" + getAttributeValue("auth-layer") +"']" : "") ; 239 return (null != ret ? ret.trim() : null); 240 } 241 242 245 public static String getDefaultAttributeValue(String attr) { 246 if(attr == null) return null; 247 attr = attr.trim(); 248 return null; 249 } 250 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 252 comparators.add(c); 253 } 254 255 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 257 comparators.remove(c); 258 } 259 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 260 } 261 262 public void dump(StringBuffer str, String indent){ 264 String s; 265 Object o; 266 org.netbeans.modules.schema2beans.BaseBean n; 267 str.append(indent); 268 str.append("ProviderConfig["+this.sizeProviderConfig()+"]"); for(int i=0; i<this.sizeProviderConfig(); i++) 270 { 271 str.append(indent+"\t"); 272 str.append("#"+i+":"); 273 n = (org.netbeans.modules.schema2beans.BaseBean) this.getProviderConfig(i); 274 if (n != null) 275 n.dump(str, indent + "\t"); else 277 str.append(indent+"\tnull"); this.dumpAttributes(PROVIDER_CONFIG, i, str, indent); 279 } 280 281 } 282 public String dumpBeanNode(){ 283 StringBuffer str = new StringBuffer (); 284 str.append("MessageSecurityConfig\n"); this.dump(str, "\n "); return str.toString(); 287 }} 288 289 291 | Popular Tags |