Changeset 2172

Show
Ignore:
Timestamp:
05/21/08 13:25:19 (6 months ago)
Author:
dsugar
Message:

support in commands for adding/deleting shapes to also update the NetworkConfig? (.fnet) for the project
some cleanup

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/framework-plugin/resources/dictionary/dictionary.fdic

    r2147 r2172  
    264264} 
    265265 
     266 
     267 
     268rdef otheripsec 
     269[desc: "Another Labeled Networking (ipsec) configured network connection"] 
     270{ 
     271        requires { ipsec } 
     272#       owner { 
     273#               resource { 
     274#               #TODO: I do not think this is correct, but the dictionary parser requires something here 
     275#                       association { polmatch } 
     276#               } 
     277#       } 
     278        read { 
     279                default { read } 
     280                read 
     281                [desc: "Read data over UDP network connection"] 
     282                [backflow: 2] 
     283                { 
     284                        self { 
     285                                association { sendto } 
     286                        } 
     287                        other write { 
     288                                association { recvfrom } 
     289                        } 
     290                } 
     291        } 
     292         
     293        write { 
     294                default { write } 
     295                write 
     296                [desc: "Write data over UDP network connection"] 
     297                [backflow: 2] 
     298                { 
     299                        self { 
     300                                association { recvfrom } 
     301                        } 
     302                        other read { 
     303                                association { sendto } 
     304                        } 
     305                } 
     306        } 
     307         
     308        readwrite { 
     309                default { connrw } 
     310                connrw 
     311                [desc: "read and write over TCP network connection"] 
     312                { 
     313                        resource { 
     314                                association { recvfrom } 
     315                        } 
     316                        self { 
     317                                association { sendto } 
     318                        } 
     319                        other readwrite { 
     320                                association { sendto recvfrom } 
     321                        } 
     322                }  
     323        } 
     324}  
     325 
     326rdef ohtersecmark 
     327[desc: "Another IPTables (secmark) configured network connection"] 
     328{ 
     329        requires { secmark } 
     330#       owner { 
     331#               resource { 
     332#               #TODO: I do not think this is correct, but the dictionary parser requires something here 
     333#                       packet { send recv } 
     334#               } 
     335#       } 
     336        read { 
     337                default { read } 
     338                read 
     339                [desc : "read data over network connection"] 
     340                [backflow: 2] 
     341                { 
     342                        resource { 
     343                                packet { recv } 
     344                        } 
     345                } 
     346        } 
     347         
     348        write { 
     349                default { write } 
     350                write 
     351                [desc : "write data over network connection"] 
     352                [backflow: 1] 
     353                { 
     354                        resource {  
     355                                packet { send } 
     356                        } 
     357                } 
     358        } 
     359         
     360        readwrite { 
     361                default { networkrw } 
     362                networkrw  
     363                [desc : "read and write over network connection"] 
     364                { 
     365                        resource { 
     366                                packet { send recv } 
     367                        }                
     368                } 
     369        } 
     370} 
     371 
    266372rdef namedPipesDir 
    267373[desc: "named pipe and the directory it lives in"] 
  • trunk/framework-plugin/src/com/tresys/framework/compiler/FSysGenerator.java

    r2152 r2172  
    8686                        IPTablesNetworkResource net = (IPTablesNetworkResource) sysRes; 
    8787                        NetworkInfo local_info = net.getLocalInfo (); 
    88                         if (local_info != null) 
    8988                        { 
    9089                                // nic 
    9190                                { 
    9291                                        m_dataBuff.append (" { "); 
    93                                         String device = local_info.getDevice (); 
    94                                         if (device != null && device.length () > 0) 
    95                                         { 
    96                                                 m_dataBuff.append (device); 
     92                                        if (local_info != null) 
     93                                        { 
     94                                                String device = local_info.getDevice (); 
     95                                                if (device != null && device.length () > 0) 
     96                                                { 
     97                                                        m_dataBuff.append (device); 
     98                                                } 
    9799                                        } 
    98100                                        m_dataBuff.append (" } "); 
     
    102104                                { 
    103105                                        m_dataBuff.append ("{"); 
    104                                         String ip_addr = local_info.getIPAddr (); 
    105                                         if (ip_addr != null) 
    106                                         { 
    107                                                 m_dataBuff.append (ip_addr); 
    108                                                 String mask = local_info.getMask (); 
    109                                                 if (mask != null) 
    110                                                 { 
    111                                                         m_dataBuff.append ("/").append (mask); 
     106                                        if (local_info != null) 
     107                                        { 
     108                                                String ip_addr = local_info.getIPAddr (); 
     109                                                if (ip_addr != null) 
     110                                                { 
     111                                                        m_dataBuff.append (ip_addr); 
     112                                                        String mask = local_info.getMask (); 
     113                                                        if (mask != null) 
     114                                                        { 
     115                                                                m_dataBuff.append ("/").append (mask); 
     116                                                        } 
    112117                                                } 
    113118                                        } 
     
    118123                                { 
    119124                                        m_dataBuff.append (" { "); 
    120                                         int[] ports = local_info.getPorts (); 
    121                                         if ( ports != null ) 
    122                                         { 
    123                                                 for (int i = 0; i < ports.length; i++) 
    124                                                 { 
    125                                                         m_dataBuff.append (ports[i]); 
    126                                                         m_dataBuff.append (" "); 
     125                                        if (local_info != null) 
     126                                        { 
     127                                                int[] ports = local_info.getPorts (); 
     128                                                if ( ports != null ) 
     129                                                { 
     130                                                        for (int i = 0; i < ports.length; i++) 
     131                                                        { 
     132                                                                m_dataBuff.append (ports[i]); 
     133                                                                m_dataBuff.append (" "); 
     134                                                        } 
    127135                                                } 
    128136                                        } 
     
    131139                        } 
    132140                        NetworkInfo remote_info = net.getRemoteInfo (); 
    133                         if (remote_info != null) 
    134141                        { 
    135142                                // nic 
    136143                                { 
    137144                                        m_dataBuff.append (" { "); 
    138                                         String device = remote_info.getDevice (); 
    139                                         if (device != null && device.length () > 0) 
    140                                         { 
    141                                                 m_dataBuff.append (device); 
     145                                        if (remote_info != null) 
     146                                        { 
     147                                                String device = remote_info.getDevice (); 
     148                                                if (device != null && device.length () > 0) 
     149                                                { 
     150                                                        m_dataBuff.append (device); 
     151                                                } 
    142152                                        } 
    143153                                        m_dataBuff.append (" } "); 
     
    147157                                { 
    148158                                        m_dataBuff.append ("{"); 
    149                                         String ip_addr = remote_info.getIPAddr (); 
    150                                         if (ip_addr != null) 
    151                                         { 
    152                                                 m_dataBuff.append (ip_addr); 
    153                                                 String mask = local_info.getMask (); 
    154                                                 if (mask != null) 
    155                                                 { 
    156                                                         m_dataBuff.append ("/").append (mask); 
     159                                        if (remote_info != null) 
     160                                        { 
     161                                                String ip_addr = remote_info.getIPAddr (); 
     162                                                if (ip_addr != null) 
     163                                                { 
     164                                                        m_dataBuff.append (ip_addr); 
     165                                                        String mask = remote_info.getMask (); 
     166                                                        if (mask != null) 
     167                                                        { 
     168                                                                m_dataBuff.append ("/").append (mask); 
     169                                                        } 
    157170                                                } 
    158171                                        } 
     
    163176                                { 
    164177                                        m_dataBuff.append (" { "); 
    165                                         int[] ports = local_info.getPorts (); 
    166                                         if ( ports != null ) 
    167                                         { 
    168                                                 for (int i = 0; i < ports.length; i++) 
    169                                                 { 
    170                                                         m_dataBuff.append (ports[i]); 
    171                                                         m_dataBuff.append (" "); 
     178                                        if (remote_info != null) 
     179                                        { 
     180                                                int[] ports = local_info.getPorts (); 
     181                                                if ( ports != null ) 
     182                                                { 
     183                                                        for (int i = 0; i < ports.length; i++) 
     184                                                        { 
     185                                                                m_dataBuff.append (ports[i]); 
     186                                                                m_dataBuff.append (" "); 
     187                                                        } 
    172188                                                } 
    173189                                        } 
     
    177193 
    178194                        String protocol = net.getProtocol (); 
    179                         if (protocol == null) 
    180                         { 
    181                                 /** 
    182                                  * This should not happen we must raise Exception or something 
    183                                  */ 
    184                         } 
    185                         else 
    186                         { 
    187                                 m_dataBuff.append ("{ "); 
     195                        m_dataBuff.append ("{ "); 
     196                        if (protocol != null) 
    188197                                m_dataBuff.append (protocol); 
    189                                 m_dataBuff.append (" }"); 
    190                         } 
     198                        m_dataBuff.append (" }"); 
    191199                } 
    192200                else if (sysRes instanceof LabeledNetworkResource) 
  • trunk/framework-plugin/src/com/tresys/framework/compiler/linkage/net/NetworkConfig.java

    r2171 r2172  
    3333        public void Add (NetItem i_item) 
    3434        { 
     35                if (i_item == null) 
     36                        throw new IllegalArgumentException (); 
     37                 
    3538                String sName = i_item.getName (); 
    3639                m_items.put (sName, i_item); 
    3740        } 
    3841         
    39         public void Remove (String item_name
     42        public void Remove (NetItem i_item
    4043        { 
    41                 m_items.remove (item_name); 
     44                if (i_item != null) 
     45                { 
     46                        String sName = i_item.getName (); 
     47                        Remove (sName); 
     48                } 
     49        } 
     50         
     51        public void Remove (String i_sName) 
     52        { 
     53                if (i_sName == null) 
     54                        throw new IllegalArgumentException (); 
     55                 
     56                m_items.remove (i_sName); 
    4257        } 
    4358 
     
    85100        public void Add (NetConnection i_connection) 
    86101        { 
     102                if (i_connection == null) 
     103                        throw new IllegalArgumentException (); 
     104                 
    87105                String sName = i_connection.toString (); 
    88106                m_connections.put (sName, i_connection); 
     107        } 
     108         
     109        public void Remove (NetConnection i_connection) 
     110        { 
     111                if (i_connection != null) 
     112                { 
     113                        String sName = i_connection.toString (); 
     114                        m_connections.remove (sName); 
     115                } 
    89116        } 
    90117         
  • trunk/framework-plugin/src/com/tresys/framework/compiler/systemResources/SystemResourcesParser.jj

    r2152 r2172  
    212212        |<COLON : ":"> 
    213213        |<SLASH : "/"> 
    214         |<PROTOCOL : "udp" | "tcp"
     214        |<PROTOCOL : "udp" | "tcp" | "any"
    215215        |<DEVICE : <ALPHA>(<ALPHA>|<DIGITS>)+ > 
    216216//      |<IP : (["0"-"9"]){3}"."(["0"-"9"]){3}"."(["0"-"9"]){3}"."(["0"-"9"]){3}  > 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/actions/BuildPRM.java

    r1825 r2172  
    44|*| Author:     David Sugar <dsugar@tresys.com> 
    55|*|   
    6 |*| Version: @version@ 
     6|*| $Rev$ 
     7|*| $Date$ 
    78\*/ 
    89 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/builder/FrameworkBuilder.java

    r2163 r2172  
    1313package com.tresys.framework.plugin.builder; 
    1414 
    15 import java.io.StringReader; 
    1615import java.util.Collection; 
    1716import java.util.HashSet; 
     
    2726import org.eclipse.core.runtime.CoreException; 
    2827import org.eclipse.core.runtime.IProgressMonitor; 
    29 import org.eclipse.jface.text.IDocument; 
    30  
    31 import com.tresys.framework.compiler.dictionary.Dictionary; 
    3228import com.tresys.framework.compiler.linkage.net.NetworkConfig; 
    3329import com.tresys.framework.compiler.linkage.net.NetworkAdder; 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/GraphicPolicyRefresh.java

    r2144 r2172  
    1818import org.eclipse.core.runtime.CoreException; 
    1919 
     20import com.tresys.framework.compiler.linkage.net.NetResource; 
     21import com.tresys.framework.compiler.linkage.net.NetworkConfig; 
    2022import com.tresys.framework.compiler.policy.Ability; 
    2123import com.tresys.framework.compiler.policy.AccessBaseResource; 
     
    126128                } 
    127129                 
    128                 if ( ((NetworkResource)temp.getComponent ()).hasCustomization () ) 
    129                         i_resource.markCustomized (); 
    130                 else 
    131                         i_resource.removeCustomization (); 
     130                NetworkResourceShape netShape = (NetworkResourceShape) temp; 
     131                { 
     132                        NetworkResource netRes = (NetworkResource) netShape.getComponent (); 
     133                        if (netRes.hasCustomization ()) 
     134                                i_resource.markCustomized (); 
     135                        else 
     136                                i_resource.removeCustomization (); 
     137                } 
     138 
     139                { 
     140                        NetworkConfig netconfig = m_system.getNetworkConfig (); 
     141                        NetResource netRes = netconfig.getResource (i_resource.getName ()); 
     142                        netShape.setNetResource (netRes); 
     143                } 
    132144                 
    133145                // set real component - remove from 'extras' list 
    134                 temp.setComponent(i_resource); 
     146                temp.setComponent (i_resource); 
    135147                m_allShapes.remove(temp.getName()); 
    136148                 
     
    166178                } 
    167179                 
    168                 if ( ((Resource)temp.getComponent ()).hasCustomization () ) 
     180                Resource res = (Resource) temp.getComponent (); 
     181                if (res.hasCustomization ()) 
    169182                        i_resource.markCustomized (); 
    170183                else 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/ShapeCreateCommand.java

    r2028 r2172  
    11/*\ 
    2 |*| Copyright (C) 2006 Tresys Technology, LLC 
     2|*| Copyright (C) 2006-2008 Tresys Technology, LLC 
    33|*| License: refer to COPYING file for license information. 
    44|*| Author:     David Sugar <dsugar@tresys.com> 
    55|*|   
    6 |*| Version: @version@ 
     6|*| $Rev$ 
     7|*| $Date$ 
    78\*/ 
    89 
     
    3435import org.eclipse.ui.part.FileEditorInput; 
    3536 
     37import com.tresys.framework.compiler.linkage.net.NetResource; 
     38import com.tresys.framework.compiler.linkage.net.NetworkConfig; 
    3639import com.tresys.framework.plugin.SEFramework_Plugin; 
    3740import com.tresys.framework.plugin.builder.FrameworkNature; 
    3841import com.tresys.framework.plugin.builder.SELinuxSystem; 
    3942import com.tresys.framework.plugin.editor.policy.graphic.GraphicPolicyEditor; 
     43import com.tresys.framework.plugin.editor.policy.graphic.model.NetworkResourceShape; 
    4044import com.tresys.framework.plugin.editor.policy.graphic.model.PolicyDiagram; 
    4145import com.tresys.framework.plugin.editor.policy.graphic.model.Shape; 
     
    107111                        redo(); 
    108112 
    109                         boolean bShowWizard = SEFramework_Plugin.getDefault().getPreferenceStore(). 
    110                                         getBoolean(GraphicEditorPreferences.SHOW_WIZARD);  
     113                        boolean bShowWizard = SEFramework_Plugin.getDefault().getPreferenceStore().getBoolean(GraphicEditorPreferences.SHOW_WIZARD);  
    111114                         
    112115                        if (bShowWizard) 
     
    138141        public void redo()  
    139142        { 
    140                 m_parent.addChild (m_newShape); 
     143                if (m_parent.addChild (m_newShape)) 
     144                { 
     145                        if (m_newShape instanceof NetworkResourceShape) 
     146                        { 
     147                                NetResource netRes = ((NetworkResourceShape) m_newShape).getNetResource (); 
     148                                if (netRes != null) 
     149                                { 
     150                                        NetworkConfig netConfig = m_parent.getSystem ().getNetworkConfig (); 
     151                                        netConfig.Add (netRes); 
     152                                } 
     153                        } 
     154                } 
    141155        } 
    142156         
     
    146160        public void undo()  
    147161        { 
    148                 m_parent.removeChild (m_newShape); 
     162 
     163                if (m_parent.removeChild (m_newShape)) 
     164                { 
     165                        if (m_newShape instanceof NetworkResourceShape) 
     166                        { 
     167                                NetResource netRes = ((NetworkResourceShape) m_newShape).getNetResource (); 
     168                                NetworkConfig netConfig = m_parent.getSystem ().getNetworkConfig (); 
     169                                netConfig.Remove (netRes); 
     170                        } 
     171                } 
    149172        } 
    150173 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/ShapeDeleteCommand.java

    r2028 r2172  
    11/*\ 
    2 |*| Copyright (C) 2006 Tresys Technology, LLC 
     2|*| Copyright (C) 2006-2008 Tresys Technology, LLC 
    33|*| License: refer to COPYING file for license information. 
    44|*| Author:     David Sugar <dsugar@tresys.com> 
    55|*|   
    6 |*| Version: @version@ 
     6|*| $Rev$ 
     7|*| $Date$ 
    78\*/ 
    89 
     
    1920import org.eclipse.ui.PlatformUI; 
    2021 
     22import com.tresys.framework.compiler.linkage.net.NetResource; 
     23import com.tresys.framework.compiler.linkage.net.NetworkConfig; 
    2124import com.tresys.framework.plugin.editor.policy.graphic.model.Connection; 
    2225import com.tresys.framework.plugin.editor.policy.graphic.model.ControlResourceShape; 
     
    2427import com.tresys.framework.plugin.editor.policy.graphic.model.EntryPointShape; 
    2528import com.tresys.framework.plugin.editor.policy.graphic.model.ModelElement; 
     29import com.tresys.framework.plugin.editor.policy.graphic.model.NetworkResourceShape; 
    2630import com.tresys.framework.plugin.editor.policy.graphic.model.PolicyDiagram; 
    2731import com.tresys.framework.plugin.editor.policy.graphic.model.Shape; 
     
    140144                 
    141145                if (wasRemoved)  
     146                { 
    142147                        removeConnections(m_connections); 
     148                        removeNetworkConfig (); 
     149                } 
    143150                else 
    144151                        addControlResources(); 
     
    217224                        addControlResources(); 
    218225                        addConnections(m_connections); 
     226                        addNetworkConfig (); 
     227                } 
     228        } 
     229         
     230        private void addNetworkConfig () 
     231        { 
     232                if (m_child instanceof NetworkResourceShape) 
     233                { 
     234                        NetResource netRes = ((NetworkResourceShape) m_child).getNetResource (); 
     235                        NetworkConfig netConfig = m_parent.getSystem ().getNetworkConfig (); 
     236                        netConfig.Add (netRes); 
     237                } 
     238        } 
     239         
     240        private void removeNetworkConfig () 
     241        { 
     242                if (m_child instanceof NetworkResourceShape) 
     243                { 
     244                        NetResource netRes = ((NetworkResourceShape) m_child).getNetResource (); 
     245                        NetworkConfig netConfig = m_parent.getSystem ().getNetworkConfig (); 
     246                        netConfig.Remove (netRes); 
    219247                } 
    220248        } 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/NetworkResourceShape.java

    r2169 r2172  
    100100 
    101101        private Rdef m_rdef; 
     102        private NetResource m_netResource; 
    102103 
    103104        // private String protocol; 
     
    150151                } 
    151152                return m_rdefs; 
     153        } 
     154         
     155        public NetResource getNetResource () 
     156        { 
     157                return m_netResource; 
     158        } 
     159         
     160        public void setNetResource (NetResource i_netResource) 
     161        { 
     162                m_netResource = i_netResource; 
    152163        } 
    153164 
     
    568579        { 
    569580                HashSet protocols = new HashSet (); 
    570                 protocols.add ("All"); 
     581                protocols.add ("any"); 
    571582                protocols.add ("tcp"); 
    572583                protocols.add ("udp"); 
  • trunk/framework-plugin/src/com/tresys/framework/plugin/wizards/shape/NetworkResourceShapePropertyWizard.java

    r2169 r2172  
    1010package com.tresys.framework.plugin.wizards.shape; 
    1111 
    12 import org.eclipse.core.resources.IProject; 
    1312import org.eclipse.jface.viewers.IStructuredSelection; 
    1413import org.eclipse.ui.IWorkbench; 
     
    2524import com.tresys.framework.compiler.systemResources.NetworkInfo; 
    2625import com.tresys.framework.compiler.systemResources.SystemResourceTypes; 
    27 import com.tresys.framework.plugin.builder.FrameworkNature; 
    2826import com.tresys.framework.plugin.editor.policy.graphic.model.NetworkResourceShape; 
    2927import com.tresys.framework.plugin.editor.policy.graphic.model.Shape; 
     
    5250        public void addPages () 
    5351        { 
    54                 m_page1 = new NetworkResourceShapePropertyPage ((NetworkResourceShape) getShape (), m_bFillInValues); 
     52                m_page1 = new NetworkResourceShapePropertyPage (getCastedShape (), m_bFillInValues); 
    5553                addPage (m_page1); 
    5654        } 
    5755 
     56        private NetworkResourceShape getCastedShape () 
     57        { 
     58                return (NetworkResourceShape) getShape (); 
     59        } 
     60         
    5861        public boolean performFinish () 
    5962        { 
    6063                //m_shape.setComponent (m_page1.getSelection()); 
    61                 Component comp = getShape ().getComponent (); 
     64                NetworkResourceShape netShape = getCastedShape (); 
     65                Component comp = netShape.getComponent (); 
    6266                if (! (comp instanceof ComponentWithDictObjects)) 
    6367                        return false; 
     
    6670                component.ClearAllRdef (); 
    6771 
     72         
    6873                Rdef rdef = m_page1.getNetworkType (); 
    6974                //set the rdef 
     
    7378                getShape ().setName (shape_name); 
    7479 
    75                 IProject project = getShape ().getSystem ().getProject (); 
    76                 FrameworkNature nat = FrameworkNature.getNature (project); 
    77                 NetworkConfig config = nat.getNetworkConfiguration (); 
     80                NetworkConfig config = getShape ().getSystem ().getNetworkConfig (); 
    7881                 
    7982                if (rdef.GetSysResourceState (SystemResourceTypes.ipsec) == SysResourceState.Yes 
     
    9194                        net_resource.generateNewAuth (NetResource.AUTH_KEY_TYPE_MD5); 
    9295                        net_resource.generateNewKey (NetResource.ENC_KEY_TYPE_BLOWFISH); 
     96                 
     97                        netShape.setNetResource (net_resource); 
    9398                        config.Add (net_resource); 
    9499                } 
     
    124129                        net_resource.put (NetResource.KEY_TYPE, rdef.GetName ()); 
    125130                        config.Add (net_resource); 
     131                        netShape.setNetResource (net_resource); 
    126132                } 
    127133