Changeset 2199
- Timestamp:
- 05/30/08 10:54:19 (6 months ago)
- Files:
-
- trunk/framework-plugin/src/com/tresys/framework/compiler/FNetGenerator.java (modified) (1 diff)
- trunk/framework-plugin/src/com/tresys/framework/compiler/FSysGenerator.java (modified) (2 diffs)
- trunk/framework-plugin/src/com/tresys/framework/compiler/linkage/net/NetResource.java (modified) (2 diffs)
- trunk/framework-plugin/src/com/tresys/framework/compiler/linkage/net/NetworkAdder.java (modified) (1 diff)
- trunk/framework-plugin/src/com/tresys/framework/compiler/linkage/net/NetworkConfig.java (modified) (12 diffs)
- trunk/framework-plugin/src/com/tresys/framework/compiler/policy/NetworkResource.java (modified) (4 diffs)
- trunk/framework-plugin/src/com/tresys/framework/compiler/systemResources/IPTablesNetworkResource.java (modified) (1 diff)
- trunk/framework-plugin/src/com/tresys/framework/compiler/systemResources/LabeledNetworkResource.java (modified) (1 diff)
- trunk/framework-plugin/src/com/tresys/framework/plugin/builder/ENetworkConfig.java (modified) (4 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/builder/FrameworkNature.java (modified) (3 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/ShapeDeleteCommand.java (modified) (1 diff)
- trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/NetworkResourceShape.java (modified) (15 diffs)
- trunk/framework-plugin/src/com/tresys/framework/plugin/wizards/shape/NetworkResourceShapePropertyWizard.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/framework-plugin/src/com/tresys/framework/compiler/FNetGenerator.java
r2183 r2199 106 106 { 107 107 String name = i_net_resource.getName (); 108 109 Object type = i_net_resource.get (NetResource.KEY_TYPE); 110 if (type == null) 111 return; 112 108 113 mData.append ("networkresource "); 109 114 mData.append (name).append (" {"); 110 115 111 Object type = i_net_resource.get (NetResource.KEY_TYPE);112 116 if (type != null) 113 117 { trunk/framework-plugin/src/com/tresys/framework/compiler/FSysGenerator.java
r2188 r2199 70 70 { 71 71 Rdef rdef = i_resource.GetRdef (); 72 72 if (rdef == null) 73 return; 74 73 75 m_dataBuff.append (i_resource.getName ()); 74 76 … … 78 80 m_dataBuff.append (" { "); 79 81 80 SystemResource sysRes = i_resource. getSystemResource (rdef);82 SystemResource sysRes = i_resource.GetSystemResource (rdef); 81 83 if (sysRes instanceof IPTablesNetworkResource) 82 84 { trunk/framework-plugin/src/com/tresys/framework/compiler/linkage/net/NetResource.java
r2164 r2199 52 52 public final static String ENC_KEY_TYPE_BLOWFISH = "3des-blowfish"; 53 53 54 public final static String ENC_KEY_TYPE_DEFAULT = ENC_KEY_TYPE_CBC; 55 54 56 public final static String AUTH_KEY_TYPE_MD5 = "hmac-md5"; 57 58 public final static String AUTH_KEY_TYPE_DEFAULT = AUTH_KEY_TYPE_MD5; 55 59 56 60 … … 88 92 } 89 93 94 public void remove (String i_sKey) 95 { 96 m_resInfo.remove (i_sKey); 97 } 98 90 99 public Map getResources() 91 100 { trunk/framework-plugin/src/com/tresys/framework/compiler/linkage/net/NetworkAdder.java
r2194 r2199 11 11 12 12 import java.util.ArrayList; 13 import java.util.Collection;14 13 import java.util.Iterator; 15 14 trunk/framework-plugin/src/com/tresys/framework/compiler/linkage/net/NetworkConfig.java
r2192 r2199 46 46 * full list of full connections (source domain to target domain through ipsec net resource) 47 47 */ 48 pr ivate final Map /* < NetResource, Collection <NetConnection> > */ m_connections = new HashMap ();48 protected final Map /* < String, Collection <NetConnection> > */ m_connections = new HashMap (); 49 49 50 50 /** 51 51 * list of accesses (half connections) used to generate connections as found 52 52 */ 53 pr ivate final Map /* < NetResource, Collection < Endpoint > > */ m_endpoints = new HashMap ();53 protected final Map /* < String, Collection < Endpoint > > */ m_endpoints = new HashMap (); 54 54 55 55 public NetworkConfig () … … 67 67 { 68 68 m_netresources.put (sName, i_item); 69 m_endpoints.put ( i_item, new HashSet ());70 m_connections.put ( i_item, new HashSet ());69 m_endpoints.put (sName, new HashSet ()); 70 m_connections.put (sName, new HashSet ()); 71 71 } 72 72 } … … 90 90 public void RemoveNetResource (String i_sNetResourceName) 91 91 { 92 Object res = m_netresources.remove (i_sNetResourceName); 93 if (res != null) 94 { 95 m_endpoints.remove (res); 96 m_connections.remove (res); 97 } 92 m_netresources.remove (i_sNetResourceName); 93 m_endpoints.remove (i_sNetResourceName); 94 m_connections.remove (i_sNetResourceName); 98 95 } 99 96 … … 113 110 { 114 111 Collection connections = (Collection) itr.next (); 112 if (connections == null) 113 continue; 115 114 for (Iterator itr2 = connections.iterator (); itr2.hasNext (); ) 116 115 { … … 143 142 144 143 NetResource res = i_connection.getResource (); 145 Collection cons = (Collection) m_connections.get (res );144 Collection cons = (Collection) m_connections.get (res.getName ()); 146 145 cons.add (i_connection); 147 146 148 Collection entrypoints = (Collection) m_endpoints.get (res );147 Collection entrypoints = (Collection) m_endpoints.get (res.getName ()); 149 148 entrypoints.add (i_connection.getSource ()); 150 149 entrypoints.add (i_connection.getTarget ()); … … 156 155 { 157 156 NetResource res = i_connection.getResource (); 158 Collection cons = (Collection) m_connections.get (res );157 Collection cons = (Collection) m_connections.get (res.getName ()); 159 158 160 159 cons.remove (i_connection); … … 164 163 public Collection getConnections (NetResource i_res) 165 164 { 166 return (Collection) m_connections.get (i_res );165 return (Collection) m_connections.get (i_res.getName ()); 167 166 } 168 167 … … 247 246 248 247 Rdef rdef = netResource.GetRdef (); 249 SystemResource sysRes = netResource. getSystemResource (rdef);248 SystemResource sysRes = netResource.GetSystemResource (rdef); 250 249 if (!(sysRes instanceof LabeledNetworkResource)) 251 250 return; … … 262 261 return; 263 262 264 Collection endpoints = (Collection) m_endpoints.get (netRes );263 Collection endpoints = (Collection) m_endpoints.get (netResource.getName ()); 265 264 if (endpoints == null) 266 265 return; … … 324 323 325 324 // update connection list 326 m_connections.put (netRes , newConnection);325 m_connections.put (netRes.getName (), newConnection); 327 326 328 327 } … … 336 335 337 336 Rdef rdef = netResource.GetRdef (); 338 SystemResource sysRes = netResource. getSystemResource (rdef);337 SystemResource sysRes = netResource.GetSystemResource (rdef); 339 338 if (!(sysRes instanceof LabeledNetworkResource)) 340 339 return; … … 351 350 return; 352 351 353 Collection endpoints = (Collection) m_endpoints.get (netRes );352 Collection endpoints = (Collection) m_endpoints.get (netResource.getName ()); 354 353 if (endpoints == null) 355 354 return; trunk/framework-plugin/src/com/tresys/framework/compiler/policy/NetworkResource.java
r2190 r2199 12 12 13 13 import java.util.List; 14 import java.util.Map;15 14 16 15 import com.tresys.framework.compiler.AbstractToken; 17 import com.tresys.framework.compiler.dictionary.Dictionary;18 16 import com.tresys.framework.compiler.dictionary.IDictionaryObject; 19 17 import com.tresys.framework.compiler.dictionary.Rdef; 20 18 import com.tresys.framework.compiler.linkage.net.NetResource; 21 import com.tresys.framework.compiler.systemResources.LabeledNetworkResource;22 import com.tresys.framework.compiler.systemResources.NetworkInfo;23 19 import com.tresys.framework.compiler.systemResources.SystemResource; 24 20 … … 32 28 super (n, null, policy); 33 29 m_netInfo = i_netRes; 34 35 Dictionary dictionary = policy.getDictionary ();36 Map rdefs = dictionary.GetRdefs ();37 Rdef rdef = (Rdef)rdefs.get ("ipsec");38 39 this.Add (rdef, new Token(rdef.GetName (), n.getErrorHandler ()));40 41 m_netInfo.put (NetResource.KEY_TYPE, rdef.GetName ());42 m_netInfo.generateNewAuth (NetResource.AUTH_KEY_TYPE_MD5);43 m_netInfo.generateNewKey (NetResource.ENC_KEY_TYPE_BLOWFISH);44 45 NetworkInfo info = new NetworkInfo ("", "", "", new int[0]);46 LabeledNetworkResource ip_lab = new LabeledNetworkResource (info, rdef);47 this.AddSystemResource (rdef, ip_lab);48 30 } 49 31 50 32 /** 51 * Conv inient method to get the SystemResource out of the super. Network33 * Convenient method to get the SystemResource out of the super. Network 52 34 * contains one and only one NetworkResource. 53 35 * … … 80 62 81 63 /** 82 * Conv inient method to get the SystemResource out of the super. Network64 * Convenient method to get the SystemResource out of the super. Network 83 65 * contains one and only one NetworkResource. 84 66 * … … 87 69 * @see #GetSystemResources(IDictionaryObject) 88 70 */ 89 public SystemResource getSystemResource (IDictionaryObject dobj)71 public SystemResource GetSystemResource (IDictionaryObject dobj) 90 72 { 91 73 List list = super.GetSystemResources (dobj); trunk/framework-plugin/src/com/tresys/framework/compiler/systemResources/IPTablesNetworkResource.java
r2135 r2199 39 39 m_sProtocol = i_sProtocol; 40 40 } 41 42 public IPTablesNetworkResource (IPTablesNetworkResource i_copy, IDictionaryObject i_do) 43 { 44 this (i_copy.m_netLocal, i_copy.m_netRemote, i_copy.m_sProtocol, i_do); 45 } 41 46 42 47 public NetworkInfo getLocalInfo () trunk/framework-plugin/src/com/tresys/framework/compiler/systemResources/LabeledNetworkResource.java
r2113 r2199 30 30 } 31 31 32 public LabeledNetworkResource (LabeledNetworkResource i_copy, IDictionaryObject i_do) 33 { 34 this (i_copy.m_netInfo, i_do); 35 } 36 32 37 public NetworkInfo getNetworkInfo () 33 38 { trunk/framework-plugin/src/com/tresys/framework/plugin/builder/ENetworkConfig.java
r2192 r2199 17 17 import java.util.Iterator; 18 18 19 import com.tresys.framework.compiler.dictionary.Rdef; 20 import com.tresys.framework.compiler.dictionary.SysResourceState; 19 21 import com.tresys.framework.compiler.linkage.net.Endpoint; 20 22 import com.tresys.framework.compiler.linkage.net.NetResource; … … 24 26 import com.tresys.framework.compiler.policy.Access; 25 27 import com.tresys.framework.compiler.policy.AccessNetwork; 28 import com.tresys.framework.compiler.policy.NetworkResource; 29 import com.tresys.framework.compiler.systemResources.SystemResourceTypes; 26 30 import com.tresys.framework.plugin.editor.policy.graphic.model.AccessConnection; 27 31 import com.tresys.framework.plugin.editor.policy.graphic.model.IDomainShape; … … 97 101 public void propertyChange (PropertyChangeEvent e) 98 102 { 99 S ystem.out.println ("Property change: " + e.toString ());103 String sProperty = e.getPropertyName (); 100 104 101 String sProperty = e.getPropertyName ();102 105 if (Shape.NAME_PROP.equals (sProperty)) 103 106 { … … 123 126 netRes.setName (e.getNewValue ().toString ()); 124 127 m_netresources.put (e.getNewValue ().toString (), m_netresources.remove (e.getOldValue ().toString ())); 128 m_endpoints.put (e.getNewValue ().toString (), m_endpoints.remove (e.getOldValue ().toString ())); 129 m_connections.put (e.getNewValue ().toString (), m_connections.remove (e.getOldValue ().toString ())); 125 130 } 126 131 } 127 132 } 128 133 else if (NetworkResourceShape.NETWORK_TYPE_PROP.equals (sProperty)) 134 { 135 Shape source = (Shape) e.getSource (); 136 Rdef rdef = ((NetworkResource) source.getComponent ()).GetRdef (); 137 //NetworkResourceShape.getRDefsArrayIndex (rdef); 138 139 NetResource netRes = getResource (source.getName ()); 140 netRes.put (NetResource.KEY_TYPE, rdef.GetName ()); 141 142 if (rdef.GetSysResourceState (SystemResourceTypes.ipsec) != SysResourceState.No) 143 { 144 netRes.generateNewAuth (NetResource.AUTH_KEY_TYPE_DEFAULT); 145 netRes.generateNewKey (NetResource.ENC_KEY_TYPE_DEFAULT); 146 } 147 148 else if (rdef.GetSysResourceState (SystemResourceTypes.secmark) != SysResourceState.No) 149 { 150 netRes.remove (NetResource.KEY_AUTH_TYPE); 151 netRes.remove (NetResource.KEY_ENC_TYPE); 152 } 153 154 } 129 155 } 130 156 } trunk/framework-plugin/src/com/tresys/framework/plugin/builder/FrameworkNature.java
r2192 r2199 87 87 */ 88 88 protected ENetworkConfig m_networkConfiguration; 89 protected boolean m_bLoadNetconfig = true; 90 protected long m_netModificationStamp = IResource.NULL_STAMP; 91 89 92 private ErrorHandler m_fnetErrorHandler; 90 93 private GUIProjectErrorHandler m_errorHandler; … … 334 337 public ENetworkConfig getNetworkConfiguration () 335 338 { 336 if (m_networkConfiguration == null) 337 { 338 m_networkConfiguration = new ENetworkConfig (); 339 if (m_networkConfiguration == null || m_bLoadNetconfig == true) 340 { 341 if (m_networkConfiguration == null) 342 m_networkConfiguration = new ENetworkConfig (); 343 339 344 IFile fnet = getFNetFile (); 340 341 FrameworkNature.deleteMarkers (fnet);342 //InputStream fnetStream = fnet.getContents (true);343 if( fnet.exists () )344 {345 try345 long modStamp = fnet.getModificationStamp (); 346 347 if (modStamp != m_netModificationStamp) 348 { 349 FrameworkNature.deleteMarkers (fnet); 350 if (fnet.exists ()) 346 351 { 347 FNETParser parser = new FNETParser (m_networkConfiguration); 348 parser.Parse (new FileReader (fnet.getLocation ().toFile ()), getFNETErrorHandler ()); 352 try 353 { 354 FNETParser parser = new FNETParser (m_networkConfiguration); 355 parser.Parse (new FileReader (fnet.getLocation ().toFile ()), getFNETErrorHandler ()); 356 m_bLoadNetconfig = false; 357 } 358 catch (FileNotFoundException e) 359 { 360 e.printStackTrace(); 361 } 349 362 } 350 catch (FileNotFoundException e) 351 { 352 e.printStackTrace(); 353 } 354 } 355 } 363 } 364 365 m_netModificationStamp = modStamp; 366 } 367 356 368 return m_networkConfiguration; 357 369 } … … 359 371 public void forceNetworkReload () 360 372 { 361 m_networkConfiguration = null; 373 // m_networkConfiguration = null; 374 m_bLoadNetconfig = true; 362 375 System.out.println ("FrameworkNature.forceNetworkReload()"); 363 376 } trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/ShapeDeleteCommand.java
r2192 r2199 135 135 { 136 136 NetworkResource res = (NetworkResource)((NetworkResourceShape)m_child).getComponent (); 137 SystemResource sysres = res. getSystemResource (res.GetRdef ());137 SystemResource sysres = res.GetSystemResource (res.GetRdef ()); 138 138 if( sysres instanceof LabeledNetworkResource ) 139 139 { trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/NetworkResourceShape.java
r2192 r2199 12 12 import java.util.ArrayList; 13 13 import java.util.Arrays; 14 import java.util.List;15 14 import java.util.HashSet; 16 15 import java.util.Iterator; … … 104 103 private static final String EMPTY_STRING = new String (); 105 104 106 private Rdef m_rdef;107 105 private NetResource m_netResource; 108 106 … … 119 117 m_netResource = new NetResource(tok, null); 120 118 NetworkResource resource = new NetworkResource (tok, m_netResource, i_system.getPolicy ()); 121 119 122 120 SELinuxSystem sys = getSystem (); 123 121 ENetworkConfig config = sys.getNetworkConfig (); … … 130 128 { 131 129 super (i_system, i_Resource); 132 133 m_rdef = i_Resource.GetRdef ();134 130 } 135 131 … … 152 148 Dictionary dictionary = getSystem ().getDictionary (); 153 149 Map rdefs = dictionary.GetRdefs (); 154 Iterator itr = rdefs.values ().iterator (); 155 156 while (itr.hasNext ()) 150 151 for (Iterator itr = rdefs.values ().iterator (); itr.hasNext (); ) 157 152 { 158 153 Rdef item = (Rdef) itr.next (); … … 164 159 } 165 160 166 p ublicString[] getRDefsArray()161 private String[] getRDefsArray() 167 162 { 168 163 if (rdefsArray == null) 169 164 { 170 ArrayList rdefsList = new ArrayList(); 171 172 Dictionary dictionary = getSystem ().getDictionary (); 173 Map rdefs = dictionary.GetRdefs (); 174 Iterator itr = rdefs.values ().iterator (); 175 176 while (itr.hasNext ()) 177 { 178 Rdef item = (Rdef) itr.next (); 179 if (item.isNetworkRdef ()) 180 rdefsList.add (item.GetName ()); 181 } 182 183 rdefsArray = new String[rdefsList.size ()]; 184 165 Vector rdefsList = getRDefs (); 166 rdefsArray = new String[rdefsList.size () + 1]; 167 185 168 for (int i = 0; i < rdefsList.size (); i++) 186 rdefsArray[i] = (String)rdefsList.get (i); 169 rdefsArray[i] = ((Rdef)rdefsList.get (i)).GetName (); 170 rdefsArray[rdefsArray.length -1] = new String (); 187 171 } 188 172 … … 190 174 } 191 175 192 public Integer getRDefsArrayIndex(Rdef rdef) 193 { 176 private Integer getRDefsArrayIndex(Rdef rdef) 177 { 178 if (rdef == null) 179 return new Integer (getRDefsArray ().length -1); 180 194 181 return new Integer(Arrays.binarySearch (getRDefsArray (), rdef.GetName ())); 195 182 } … … 244 231 } 245 232 233 protected Rdef GetRdef () 234 { 235 return ((NetworkResource) getComponent ()).GetRdef (); 236 } 237 246 238 /* 247 239 * (non-Javadoc) … … 256 248 public IPropertyDescriptor[] getPropertyDescriptors () 257 249 { 258 int nStatPropCount = 1; 259 260 if (m_rdef == null) 261 { 262 m_rdef = ((NetworkResource) getComponent ()).GetRdef (); 263 if (m_rdef == null) 264 return new IPropertyDescriptor[] {}; 265 } 266 267 { 268 IPropertyDescriptor[] parentDescriptors = super.getPropertyDescriptors (); 269 270 //Vector rdefs = getRDefs (); 271 272 //int nRdefCount = rdefs.size (); 273 274 MLSSupport mlsSupport = getMLSSupport (); 275 if (mlsSupport != null) 276 { 277 nStatPropCount++; 278 } 279 280 ArrayList myDescriptors = new ArrayList (); 281 282 // Set validator to be used by cell editor. When value not valid, 283 // message will be returned 284 TextPropertyDescriptor text_desc = new TextPropertyDescriptor (NAME_PROP, DISPLAY_NAME_NAME); 285 text_desc.setValidator (new NameValidator ()); 286 text_desc.setAlwaysIncompatible (true); 287 text_desc.setCategory (PROP_SECTION_BASE); 288 myDescriptors.add (text_desc); 289 290 // Fetch project to get the current MLS Level configuration 291 // definitions 292 if (mlsSupport != null) 293 { 294 ComboBoxPropertyDescriptor combo_desc = new ComboBoxPropertyDescriptor (MLS_PROP, DISPLAY_NAME_MLS, mlsSupport 295 .getLevelNames ()); 296 combo_desc.setCategory (PROP_SECTION_BASE); 297 myDescriptors.add (combo_desc); 298 } 299 300 { 301 ComboBoxPropertyDescriptor prop_desc = new ComboBoxPropertyDescriptor (NETWORK_TYPE_PROP, DISPLAY_NAME_NETWORK_TYPE, getRDefsArray ()); 302 prop_desc.setCategory (PROP_SECTION_BASE); 303 myDescriptors.add (prop_desc); 304 } 305 306 if (m_rdef.GetSysResourceState (SystemResourceTypes.ipsec) == SysResourceState.Yes 307 || m_rdef.GetSysResourceState (SystemResourceTypes.ipsec) == SysResourceState.Optional) 250 IPropertyDescriptor[] parentDescriptors = super.getPropertyDescriptors (); 251 252 MLSSupport mlsSupport = getMLSSupport (); 253 ArrayList myDescriptors = new ArrayList (); 254 255 // Set validator to be used by cell editor. When value not valid, 256 // message will be returned 257 TextPropertyDescriptor text_desc = new TextPropertyDescriptor (NAME_PROP, DISPLAY_NAME_NAME); 258 text_desc.setValidator (new NameValidator ()); 259 text_desc.setAlwaysIncompatible (true); 260 text_desc.setCategory (PROP_SECTION_BASE); 261 myDescriptors.add (text_desc); 262 263 // Fetch project to get the current MLS Level configuration 264 // definitions 265 if (mlsSupport != null) 266 { 267 ComboBoxPropertyDescriptor combo_desc = new ComboBoxPropertyDescriptor (MLS_PROP, DISPLAY_NAME_MLS, mlsSupport 268 .getLevelNames ()); 269 combo_desc.setCategory (PROP_SECTION_BASE); 270 myDescriptors.add (combo_desc); 271 } 272 273 { 274 ComboBoxPropertyDescriptor prop_desc = new ComboBoxPropertyDescriptor (NETWORK_TYPE_PROP, DISPLAY_NAME_NETWORK_TYPE, getRDefsArray ()); 275 prop_desc.setCategory (PROP_SECTION_BASE); 276 myDescriptors.add (prop_desc); 277 } 278 279 Rdef rdef = GetRdef (); 280 if (rdef != null) 281 { 282 if (rdef.GetSysResourceState (SystemResourceTypes.ipsec) == SysResourceState.Yes 283 || rdef.GetSysResourceState (SystemResourceTypes.ipsec) == SysResourceState.Optional) 308 284 { 309 285 { … … 328 304 } 329 305 330 else if ( m_rdef.GetSysResourceState (SystemResourceTypes.secmark) == SysResourceState.Yes331 || m_rdef.GetSysResourceState (SystemResourceTypes.secmark) == SysResourceState.Optional)306 else if (rdef.GetSysResourceState (SystemResourceTypes.secmark) == SysResourceState.Yes 307 || rdef.GetSysResourceState (SystemResourceTypes.secmark) == SysResourceState.Optional) 332 308 { 333 309 { … … 386 362 } 387 363 } 388 389 m_descriptors = new IPropertyDescriptor[parentDescriptors.length + myDescriptors.size ()]; 390 391 System.arraycopy (parentDescriptors, 0, m_descriptors, 0, parentDescriptors.length); 392 393 System.arraycopy (myDescriptors.toArray (), 0, m_descriptors, parentDescriptors.length, myDescriptors.size ()); 394 395 // System.arraycopy (pathDescriptors, 0, m_descriptors, 396 // parentDescriptors.length 397 // + myDescriptors.length, pathDescriptors.length); 398 } 364 } 365 366 m_descriptors = new IPropertyDescriptor[parentDescriptors.length + myDescriptors.size ()]; 367 368 System.arraycopy (parentDescriptors, 0, m_descriptors, 0, parentDescriptors.length); 369 System.arraycopy (myDescriptors.toArray (), 0, m_descriptors, parentDescriptors.length, myDescriptors.size ()); 370 399 371 400 372 return m_descriptors; 401 373 } 402 374 375 376 public void setNetworkRdef (Rdef i_rdef) 377 { 378 if (i_rdef == null) 379 throw new IllegalArgumentException (); 380 381 Rdef rdef = GetRdef (); 382 NetworkResource resource = (NetworkResource)getComponent (); 383 SystemResource sysResource = null; 384 if (rdef != null) 385 sysResource = resource.GetSystemResource(rdef); 386 387 Rdef oldRdef = rdef; 388 NetworkInfo localInfo = null; 389 390 if (sysResource instanceof IPTablesNetworkResource) 391 localInfo = ((IPTablesNetworkResource) sysResource).getLocalInfo (); 392 else if (sysResource instanceof LabeledNetworkResource) 393 localInfo = ((LabeledNetworkResource) sysResource).getNetworkInfo (); 394 395 if (rdef != null) 396 resource.ClearSystemResources (rdef); 397 resource.Add(i_rdef, new Token(i_rdef.GetName (), getErrorHandler ())); 398 399 if (localInfo == null) 400 localInfo = new NetworkInfo (null, null, null, null); 401 402 if (i_rdef.GetSysResourceState (SystemResourceTypes.ipsec) != SysResourceState.No) 403 { 404 if (sysResource instanceof LabeledNetworkResource) 405 sysResource = new LabeledNetworkResource ((LabeledNetworkResource) sysResource, i_rdef); 406 else 407 sysResource = new LabeledNetworkResource (localInfo, i_rdef); 408 } 409 410 if (i_rdef.GetSysResourceState (SystemResourceTypes.secmark) != SysResourceState.No) 411 { 412 if (sysResource instanceof IPTablesNetworkResource) 413 sysResource = new IPTablesNetworkResource ((IPTablesNetworkResource) sysResource, i_rdef); 414 else 415 sysResource = new IPTablesNetworkResource (localInfo, new NetworkInfo (null, null, null, null), "tcp", i_rdef); 416 } 417 418 resource.AddSystemResource (i_rdef, sysResource); 419 420 firePropertyChange (NETWORK_TYPE_PROP, oldRdef, i_rdef); 421 } 422 403 423 public Object getPropertyValue (Object propertyId) 404 424 { … … 415 435 416 436 if (NETWORK_TYPE_PROP.equals (propertyId)) 417 return getRDefsArrayIndex ( this.m_rdef);437 return getRDefsArrayIndex (GetRdef ()); 418 438 419 439 NetworkResource resource = (NetworkResource) getComponent (); 420 SystemResource sysResource = resource.getSystemResource (m_rdef); 440 Rdef rdef = GetRdef (); 441 SystemResource sysResource = null; 442 if (rdef != null) 443 sysResource = resource.GetSystemResource (rdef); 421 444 422 445 if (NETWORK_PROTOCOL_INDEX.equals (propertyId)) 423 446 { 424 return GetNetworkProtocolIndex ( ((IPTablesNetworkResource) sysResource).getProtocol ()); 447 Integer nIndex = new Integer (0); 448 if (sysResource instanceof IPTablesNetworkResource) 449 nIndex = GetNetworkProtocolIndex (((IPTablesNetworkResource) sysResource).getProtocol ()); 450 return (nIndex); 425 451 } 426 452 … … 561 587 if (NETWORK_TYPE_PROP.equals (propertyId)) 562 588 { 563 NetworkResource resource = (NetworkResource)getComponent (); 564 List systemResources = resource.GetSystemResources(m_rdef); 565 SystemResource sysResource = (SystemResource) systemResources.get (0); 566 567 NetworkInfo localInfo = null; 568 569 if (sysResource instanceof LabeledNetworkResource) 570 { 571 localInfo = ((LabeledNetworkResource) sysResource).getNetworkInfo (); 572 resource.ClearSystemResources (m_rdef); 573 574 this.m_rdef = (Rdef)getRDefs ().get (((Integer)value).intValue ()); 575 resource.Add(m_rdef, new Token(m_rdef.GetName (), getErrorHandler ())); 589 try 590 { 591 Rdef newRdef = (Rdef)getRDefs ().get (((Integer)value).intValue ()); 592 setNetworkRdef (newRdef); 593 } 594 catch (ArrayIndexOutOfBoundsException aie) 595 { 576 596 577 sysResource = new IPTablesNetworkResource(localInfo, new NetworkInfo(null, null, null, null), "tcp", m_rdef); 578 resource.AddSystemResource (m_rdef, sysResource); 579 } 580 581 else if (sysResource instanceof IPTablesNetworkResource) 582 { 583 localInfo = ((IPTablesNetworkResource) sysResource).getLocalInfo (); 584 &nbs
