Changeset 2173
- Timestamp:
- 05/22/08 08:29:18 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/framework-plugin/src/com/tresys/framework/compiler/policy/NetworkResource.java
r2143 r2173 12 12 13 13 import java.util.List; 14 import java.util.Map; 14 15 15 16 import com.tresys.framework.compiler.AbstractToken; 17 import com.tresys.framework.compiler.dictionary.Dictionary; 16 18 import com.tresys.framework.compiler.dictionary.IDictionaryObject; 17 19 import com.tresys.framework.compiler.dictionary.Rdef; 18 20 import com.tresys.framework.compiler.linkage.net.NetResource; 21 import com.tresys.framework.compiler.systemResources.LabeledNetworkResource; 22 import com.tresys.framework.compiler.systemResources.NetworkInfo; 19 23 import com.tresys.framework.compiler.systemResources.SystemResource; 20 24 … … 28 32 super (n, null, policy); 29 33 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 NetworkInfo info = new NetworkInfo (null, null, null, null); 42 LabeledNetworkResource ip_lab = new LabeledNetworkResource (info, rdef); 43 this.AddSystemResource (rdef, ip_lab); 30 44 } 31 45 … … 51 65 { 52 66 if (!GetRdefs ().isEmpty ()) 53 return false;67 this.ClearAllRdef (); 54 68 } 55 69 return super.Add (rdef, i_token); trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/NetworkResourceShape.java
r2172 r2173 11 11 12 12 import java.util.ArrayList; 13 import java.util.Arrays; 13 14 import java.util.List; 14 15 import java.util.HashSet; … … 98 99 private IPropertyDescriptor[] m_descriptors = null; 99 100 private Vector m_rdefs = null; 101 private String[] rdefsArray = null; 100 102 101 103 private Rdef m_rdef; … … 151 153 } 152 154 return m_rdefs; 155 } 156 157 public String[] getRDefsArray() 158 { 159 if (rdefsArray == null) 160 { 161 ArrayList rdefsList = new ArrayList(); 162 163 Dictionary dictionary = getSystem ().getDictionary (); 164 Map rdefs = dictionary.GetRdefs (); 165 Iterator itr = rdefs.values ().iterator (); 166 167 while (itr.hasNext ()) 168 { 169 Rdef item = (Rdef) itr.next (); 170 if (item.isNetworkRdef ()) 171 rdefsList.add (item.GetName ()); 172 } 173 174 rdefsArray = new String[rdefsList.size ()]; 175 176 for (int i = 0; i < rdefsList.size (); i++) 177 rdefsArray[i] = (String)rdefsList.get (i); 178 } 179 180 return rdefsArray; 181 } 182 183 public Integer getRDefsArrayIndex(Rdef rdef) 184 { 185 return new Integer(Arrays.binarySearch (getRDefsArray (), rdef.GetName ())); 153 186 } 154 187 … … 257 290 258 291 { 259 PropertyDescriptor prop_desc = new PropertyDescriptor (NETWORK_TYPE_PROP, DISPLAY_NAME_NETWORK_TYPE);260 prop_desc.setCategory (PROP_ NETWORK_RESOURCE);292 ComboBoxPropertyDescriptor prop_desc = new ComboBoxPropertyDescriptor (NETWORK_TYPE_PROP, DISPLAY_NAME_NETWORK_TYPE, getRDefsArray ()); 293 prop_desc.setCategory (PROP_SECTION_BASE); 261 294 myDescriptors.add (prop_desc); 262 295 } … … 340 373 PropertyDescriptor desc = new ComboBoxPropertyDescriptor (NETWORK_PROTOCOL_INDEX, DISPLAY_NAME_NETWORK_PROTOCOL, 341 374 (String[]) GetNetworkProtcols ().toArray (new String[2])); 342 desc.setCategory (PROP_ NETWORK_RESOURCE);375 desc.setCategory (PROP_SECTION_BASE); 343 376 myDescriptors.add (desc); 344 377 } … … 373 406 374 407 if (NETWORK_TYPE_PROP.equals (propertyId)) 375 return this.m_rdef;408 return getRDefsArrayIndex (this.m_rdef); 376 409 377 410 NetworkResource resource = (NetworkResource) getComponent (); … … 398 431 399 432 if (NETWORK_LOCAL_DEVICE.equals (propertyId)) 400 return localInfo.getDevice (); 401 433 { 434 String retValue = localInfo.getDevice (); 435 if (retValue == null) 436 return ""; 437 438 return retValue; 439 } 440 402 441 if (NETWORK_LOCAL_IP_ADDRESS.equals (propertyId)) 403 return localInfo.getIPAddr (); 404 442 { 443 String retValue = localInfo.getIPAddr (); 444 if (retValue == null) 445 return ""; 446 447 return retValue; 448 } 449 405 450 if (NETWORK_LOCAL_MASK.equals (propertyId)) 406 return localInfo.getMask (); 451 { 452 String retValue = localInfo.getMask (); 453 if (retValue == null) 454 return ""; 455 456 return retValue; 457 } 407 458 408 459 if (NETWORK_LOCAL_IP_PORTS.equals (propertyId)) … … 425 476 426 477 if (NETWORK_REMOTE_DEVICE.equals (propertyId)) 427 return remoteInfo.getDevice (); 478 { 479 String retValue = remoteInfo.getDevice (); 480 if (retValue == null) 481 return ""; 482 483 return retValue; 484 } 428 485 429 486 if (NETWORK_REMOTE_IP_ADDRESS.equals (propertyId)) 430 return remoteInfo.getIPAddr (); 487 { 488 String retValue = remoteInfo.getIPAddr (); 489 if (retValue == null) 490 return ""; 491 492 return retValue; 493 } 431 494 432 495 if (NETWORK_REMOTE_MASK.equals (propertyId)) 433 return remoteInfo.getMask (); 496 { 497 String retValue = remoteInfo.getMask (); 498 if (retValue == null) 499 return ""; 500 501 return retValue; 502 } 434 503 435 504 if (NETWORK_REMOTE_IP_PORTS.equals (propertyId)) … … 455 524 if (NETWORK_TYPE_PROP.equals (propertyId)) 456 525 { 457 this.m_rdef = (Rdef) value; 526 NetworkResource resource = (NetworkResource)getComponent (); 527 List systemResources = resource.GetSystemResources(m_rdef); 528 SystemResource sysResource = (SystemResource) systemResources.get (0); 529 530 NetworkInfo localInfo = null; 531 532 if (sysResource instanceof LabeledNetworkResource) 533 { 534 localInfo = ((LabeledNetworkResource) sysResource).getNetworkInfo (); 535 resource.ClearSystemResources (m_rdef); 536 537 this.m_rdef = (Rdef)getRDefs ().get (((Integer)value).intValue ()); 538 resource.Add(m_rdef, new Token(m_rdef.GetName (), getErrorHandler ())); 539 540 sysResource = new IPTablesNetworkResource(localInfo, new NetworkInfo(null, null, null, null), "tcp", m_rdef); 541 resource.AddSystemResource (m_rdef, sysResource); 542 } 543 544 else if (sysResource instanceof IPTablesNetworkResource) 545 { 546 localInfo = ((IPTablesNetworkResource) sysResource).getLocalInfo (); 547 resource.ClearSystemResources (m_rdef); 548 549 this.m_rdef = (Rdef)getRDefs ().get (((Integer)value).intValue ()); 550 resource.Add(m_rdef, new Token(m_rdef.GetName (), getErrorHandler ())); 551 552 sysResource = new LabeledNetworkResource(localInfo, m_rdef); 553 resource.AddSystemResource (m_rdef, sysResource); 554 } 458 555 } 459 556
