Changeset 2199

Show
Ignore:
Timestamp:
05/30/08 10:54:19 (6 months ago)
Author:
dsugar
Message:

bunch of cleanup and fix some null pointer problems.
Things seem to be working ok - needs some good testing to verify that I didn't break anything else.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/framework-plugin/src/com/tresys/framework/compiler/FNetGenerator.java

    r2183 r2199  
    106106        { 
    107107                String name = i_net_resource.getName (); 
     108 
     109                Object type = i_net_resource.get (NetResource.KEY_TYPE); 
     110                if (type == null) 
     111                        return; 
     112                 
    108113                mData.append ("networkresource "); 
    109114                mData.append (name).append (" {"); 
    110115 
    111                 Object type = i_net_resource.get (NetResource.KEY_TYPE); 
    112116                if (type != null) 
    113117                { 
  • trunk/framework-plugin/src/com/tresys/framework/compiler/FSysGenerator.java

    r2188 r2199  
    7070        { 
    7171                Rdef rdef = i_resource.GetRdef (); 
    72  
     72                if (rdef == null) 
     73                        return; 
     74                 
    7375                m_dataBuff.append (i_resource.getName ()); 
    7476 
     
    7880                m_dataBuff.append (" { "); 
    7981 
    80                 SystemResource sysRes = i_resource.getSystemResource (rdef); 
     82                SystemResource sysRes = i_resource.GetSystemResource (rdef); 
    8183                if (sysRes instanceof IPTablesNetworkResource) 
    8284                { 
  • trunk/framework-plugin/src/com/tresys/framework/compiler/linkage/net/NetResource.java

    r2164 r2199  
    5252        public final static String ENC_KEY_TYPE_BLOWFISH = "3des-blowfish"; 
    5353         
     54        public final static String ENC_KEY_TYPE_DEFAULT = ENC_KEY_TYPE_CBC; 
     55         
    5456        public final static String AUTH_KEY_TYPE_MD5 = "hmac-md5"; 
     57         
     58        public final static String AUTH_KEY_TYPE_DEFAULT = AUTH_KEY_TYPE_MD5; 
    5559         
    5660 
     
    8892        } 
    8993         
     94        public void remove (String i_sKey) 
     95        { 
     96                m_resInfo.remove (i_sKey); 
     97        } 
     98         
    9099        public Map getResources() 
    91100        { 
  • trunk/framework-plugin/src/com/tresys/framework/compiler/linkage/net/NetworkAdder.java

    r2194 r2199  
    1111 
    1212import java.util.ArrayList; 
    13 import java.util.Collection; 
    1413import java.util.Iterator; 
    1514 
  • trunk/framework-plugin/src/com/tresys/framework/compiler/linkage/net/NetworkConfig.java

    r2192 r2199  
    4646         * full list of full connections (source domain to target domain through ipsec net resource) 
    4747         */ 
    48         private final Map /* < NetResource, Collection <NetConnection> > */ m_connections = new HashMap (); 
     48        protected final Map /* < String, Collection <NetConnection> > */ m_connections = new HashMap (); 
    4949         
    5050        /** 
    5151         * list of accesses (half connections) used to generate connections as found 
    5252         */ 
    53         private final Map /* < NetResource, Collection < Endpoint > > */ m_endpoints = new HashMap (); 
     53        protected final Map /* < String, Collection < Endpoint > > */ m_endpoints = new HashMap (); 
    5454 
    5555        public NetworkConfig () 
     
    6767                { 
    6868                        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 ()); 
    7171                } 
    7272        } 
     
    9090        public void RemoveNetResource (String i_sNetResourceName) 
    9191        { 
    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); 
    9895        } 
    9996 
     
    113110                { 
    114111                        Collection connections = (Collection) itr.next (); 
     112                        if (connections == null) 
     113                                        continue; 
    115114                        for (Iterator itr2 = connections.iterator (); itr2.hasNext (); ) 
    116115                        { 
     
    143142 
    144143                NetResource res = i_connection.getResource (); 
    145                 Collection cons = (Collection) m_connections.get (res); 
     144                Collection cons = (Collection) m_connections.get (res.getName ()); 
    146145                cons.add (i_connection); 
    147146                 
    148                 Collection entrypoints = (Collection) m_endpoints.get (res); 
     147                Collection entrypoints = (Collection) m_endpoints.get (res.getName ()); 
    149148                entrypoints.add (i_connection.getSource ()); 
    150149                entrypoints.add (i_connection.getTarget ()); 
     
    156155                { 
    157156                        NetResource res = i_connection.getResource (); 
    158                         Collection cons = (Collection) m_connections.get (res); 
     157                        Collection cons = (Collection) m_connections.get (res.getName ()); 
    159158                         
    160159                        cons.remove (i_connection); 
     
    164163        public Collection getConnections (NetResource i_res) 
    165164        { 
    166                 return (Collection) m_connections.get (i_res); 
     165                return (Collection) m_connections.get (i_res.getName ()); 
    167166        } 
    168167         
     
    247246 
    248247                Rdef rdef = netResource.GetRdef (); 
    249                 SystemResource sysRes = netResource.getSystemResource (rdef); 
     248                SystemResource sysRes = netResource.GetSystemResource (rdef); 
    250249                if (!(sysRes instanceof LabeledNetworkResource)) 
    251250                        return; 
     
    262261                        return; 
    263262                 
    264                 Collection endpoints = (Collection) m_endpoints.get (netRes); 
     263                Collection endpoints = (Collection) m_endpoints.get (netResource.getName ()); 
    265264                if (endpoints == null) 
    266265                        return; 
     
    324323                         
    325324                        // update connection list 
    326                         m_connections.put (netRes, newConnection); 
     325                        m_connections.put (netRes.getName (), newConnection); 
    327326                         
    328327                } 
     
    336335 
    337336                Rdef rdef = netResource.GetRdef (); 
    338                 SystemResource sysRes = netResource.getSystemResource (rdef); 
     337                SystemResource sysRes = netResource.GetSystemResource (rdef); 
    339338                if (!(sysRes instanceof LabeledNetworkResource)) 
    340339                        return; 
     
    351350                        return; 
    352351                 
    353                 Collection endpoints = (Collection) m_endpoints.get (netRes); 
     352                Collection endpoints = (Collection) m_endpoints.get (netResource.getName ()); 
    354353                if (endpoints == null) 
    355354                        return; 
  • trunk/framework-plugin/src/com/tresys/framework/compiler/policy/NetworkResource.java

    r2190 r2199  
    1212 
    1313import java.util.List; 
    14 import java.util.Map; 
    1514 
    1615import com.tresys.framework.compiler.AbstractToken; 
    17 import com.tresys.framework.compiler.dictionary.Dictionary; 
    1816import com.tresys.framework.compiler.dictionary.IDictionaryObject; 
    1917import com.tresys.framework.compiler.dictionary.Rdef; 
    2018import com.tresys.framework.compiler.linkage.net.NetResource; 
    21 import com.tresys.framework.compiler.systemResources.LabeledNetworkResource; 
    22 import com.tresys.framework.compiler.systemResources.NetworkInfo; 
    2319import com.tresys.framework.compiler.systemResources.SystemResource; 
    2420 
     
    3228                super (n, null, policy); 
    3329                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); 
    4830        } 
    4931 
    5032        /** 
    51          * Convinient method to get the SystemResource out of the super. Network 
     33         * Convenient method to get the SystemResource out of the super. Network 
    5234         * contains one and only one NetworkResource. 
    5335         *  
     
    8062 
    8163        /** 
    82          * Convinient method to get the SystemResource out of the super. Network 
     64         * Convenient method to get the SystemResource out of the super. Network 
    8365         * contains one and only one NetworkResource. 
    8466         *  
     
    8769         * @see #GetSystemResources(IDictionaryObject) 
    8870         */ 
    89         public SystemResource getSystemResource (IDictionaryObject dobj) 
     71        public SystemResource GetSystemResource (IDictionaryObject dobj) 
    9072        { 
    9173                List list = super.GetSystemResources (dobj); 
  • trunk/framework-plugin/src/com/tresys/framework/compiler/systemResources/IPTablesNetworkResource.java

    r2135 r2199  
    3939                m_sProtocol = i_sProtocol; 
    4040        } 
     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        } 
    4146 
    4247        public NetworkInfo getLocalInfo () 
  • trunk/framework-plugin/src/com/tresys/framework/compiler/systemResources/LabeledNetworkResource.java

    r2113 r2199  
    3030        } 
    3131         
     32        public LabeledNetworkResource (LabeledNetworkResource i_copy, IDictionaryObject i_do) 
     33        { 
     34                this (i_copy.m_netInfo, i_do); 
     35        } 
     36         
    3237        public NetworkInfo getNetworkInfo () 
    3338        { 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/builder/ENetworkConfig.java

    r2192 r2199  
    1717import java.util.Iterator; 
    1818 
     19import com.tresys.framework.compiler.dictionary.Rdef; 
     20import com.tresys.framework.compiler.dictionary.SysResourceState; 
    1921import com.tresys.framework.compiler.linkage.net.Endpoint; 
    2022import com.tresys.framework.compiler.linkage.net.NetResource; 
     
    2426import com.tresys.framework.compiler.policy.Access; 
    2527import com.tresys.framework.compiler.policy.AccessNetwork; 
     28import com.tresys.framework.compiler.policy.NetworkResource; 
     29import com.tresys.framework.compiler.systemResources.SystemResourceTypes; 
    2630import com.tresys.framework.plugin.editor.policy.graphic.model.AccessConnection; 
    2731import com.tresys.framework.plugin.editor.policy.graphic.model.IDomainShape; 
     
    97101        public void propertyChange (PropertyChangeEvent e) 
    98102        { 
    99                 System.out.println ("Property change: " + e.toString ()); 
     103                String sProperty = e.getPropertyName (); 
    100104 
    101                 String sProperty = e.getPropertyName (); 
    102105                if (Shape.NAME_PROP.equals (sProperty)) 
    103106                { 
     
    123126                                        netRes.setName (e.getNewValue ().toString ()); 
    124127                                        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 ())); 
    125130                                } 
    126131                        } 
    127132                } 
    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                } 
    129155        } 
    130156} 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/builder/FrameworkNature.java

    r2192 r2199  
    8787         */ 
    8888        protected ENetworkConfig m_networkConfiguration; 
     89        protected boolean m_bLoadNetconfig = true; 
     90        protected long m_netModificationStamp = IResource.NULL_STAMP; 
     91         
    8992        private ErrorHandler m_fnetErrorHandler; 
    9093        private GUIProjectErrorHandler m_errorHandler; 
     
    334337        public ENetworkConfig getNetworkConfiguration () 
    335338        { 
    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 
    339344                        IFile fnet = getFNetFile (); 
    340                          
    341                         FrameworkNature.deleteMarkers (fnet); 
    342                         //InputStream fnetStream = fnet.getContents (true); 
    343                         if( fnet.exists () ) 
    344                         { 
    345                                 try 
     345                        long modStamp = fnet.getModificationStamp (); 
     346                         
     347                        if (modStamp != m_netModificationStamp) 
     348                        { 
     349                               FrameworkNature.deleteMarkers (fnet); 
     350                                if (fnet.exists ()) 
    346351                                { 
    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                                        } 
    349362                                } 
    350                                 catch (FileNotFoundException e) 
    351                                 { 
    352                                         e.printStackTrace(); 
    353                                 } 
    354                         } 
    355                 } 
     363                        } 
     364                         
     365                        m_netModificationStamp = modStamp; 
     366                } 
     367 
    356368                return m_networkConfiguration; 
    357369        } 
     
    359371        public void forceNetworkReload () 
    360372        { 
    361                 m_networkConfiguration = null; 
     373//              m_networkConfiguration = null; 
     374                m_bLoadNetconfig = true; 
    362375                System.out.println ("FrameworkNature.forceNetworkReload()"); 
    363376        } 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/ShapeDeleteCommand.java

    r2192 r2199  
    135135                { 
    136136                        NetworkResource res = (NetworkResource)((NetworkResourceShape)m_child).getComponent (); 
    137                         SystemResource sysres = res.getSystemResource (res.GetRdef ()); 
     137                        SystemResource sysres = res.GetSystemResource (res.GetRdef ()); 
    138138                        if( sysres instanceof LabeledNetworkResource ) 
    139139                        { 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/NetworkResourceShape.java

    r2192 r2199  
    1212import java.util.ArrayList; 
    1313import java.util.Arrays; 
    14 import java.util.List; 
    1514import java.util.HashSet; 
    1615import java.util.Iterator; 
     
    104103        private static final String EMPTY_STRING = new String (); 
    105104         
    106         private Rdef m_rdef; 
    107105        private NetResource m_netResource; 
    108106 
     
    119117                m_netResource = new NetResource(tok, null);              
    120118                NetworkResource resource = new NetworkResource (tok, m_netResource, i_system.getPolicy ()); 
    121          
     119                
    122120                SELinuxSystem sys = getSystem (); 
    123121                ENetworkConfig config = sys.getNetworkConfig (); 
     
    130128        { 
    131129                super (i_system, i_Resource); 
    132  
    133                 m_rdef = i_Resource.GetRdef (); 
    134130        } 
    135131 
     
    152148                        Dictionary dictionary = getSystem ().getDictionary (); 
    153149                        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 (); ) 
    157152                        { 
    158153                                Rdef item = (Rdef) itr.next (); 
     
    164159        } 
    165160         
    166         public String[] getRDefsArray() 
     161        private String[] getRDefsArray() 
    167162        { 
    168163                if (rdefsArray == null) 
    169164                { 
    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 
    185168                        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 (); 
    187171                } 
    188172                 
     
    190174        } 
    191175         
    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                 
    194181                return new Integer(Arrays.binarySearch (getRDefsArray (), rdef.GetName ())); 
    195182        } 
     
    244231        } 
    245232 
     233        protected Rdef GetRdef () 
     234        { 
     235                return ((NetworkResource) getComponent ()).GetRdef (); 
     236        } 
     237         
    246238        /* 
    247239         * (non-Javadoc) 
     
    256248        public IPropertyDescriptor[] getPropertyDescriptors () 
    257249        { 
    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) 
    308284                        { 
    309285                                { 
     
    328304                        } 
    329305 
    330                         else if (m_rdef.GetSysResourceState (SystemResourceTypes.secmark) == SysResourceState.Yes 
    331                                 || m_rdef.GetSysResourceState (SystemResourceTypes.secmark) == SysResourceState.Optional) 
     306                        else if (rdef.GetSysResourceState (SystemResourceTypes.secmark) == SysResourceState.Yes 
     307                                || rdef.GetSysResourceState (SystemResourceTypes.secmark) == SysResourceState.Optional) 
    332308                        {                                
    333309                                { 
     
    386362                                } 
    387363                        } 
    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 
    399371 
    400372                return m_descriptors; 
    401373        } 
    402374 
     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         
    403423        public Object getPropertyValue (Object propertyId) 
    404424        { 
     
    415435 
    416436                if (NETWORK_TYPE_PROP.equals (propertyId)) 
    417                         return getRDefsArrayIndex (this.m_rdef); 
     437                        return getRDefsArrayIndex (GetRdef ()); 
    418438 
    419439                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); 
    421444 
    422445                if (NETWORK_PROTOCOL_INDEX.equals (propertyId)) 
    423446                { 
    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); 
    425451                } 
    426452 
     
    561587                if (NETWORK_TYPE_PROP.equals (propertyId)) 
    562588                { 
    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                        { 
    576596                                 
    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