Changeset 1837

Show
Ignore:
Timestamp:
01/17/08 11:55:13 (1 year ago)
Author:
gboyst
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/transwork/framework-plugin/.project

    r1542 r1837  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<projectDescription> 
    3         <name>CDSFramework</name> 
     3        <name>CDSFramework_branch_transwork</name> 
    44        <comment>JavaCC Nature</comment> 
    55        <projects> 
  • branches/transwork/framework-plugin/libselinuxjava/Makefile

    r1010 r1837  
    3535        ln -sf $@ $(TARGET)  
    3636 
    37 %.o:  %.c  
     37%.o:%.c  
    3838        $(CC) $(CFLAGS) -c -o $@ $< 
    3939 
    40 %.lo:  %.c 
     40%.lo:%.c 
     41        $(CC) $(CFLAGS) -fpic -DSHARED -c -o $@ $< 
     42 
     43selinuxswig_wrap.lo: selinuxswig_wrap.c 
    4144        $(CC) $(CFLAGS) -fpic -DSHARED -c -o $@ $< 
    4245 
  • branches/transwork/framework-plugin/src/com/tresys/framework/compiler/ErrorHandler.java

    r1567 r1837  
    3434        static final public int ERROR_RDEF_NOT_DEFINED = 27; 
    3535        static final public int ERROR_ENTRYPOINT_MISSING_FILE = 28; 
     36        static final public int ERROR_DUPLICATE_ACCESS = 29; 
    3637         
    3738         
  • branches/transwork/framework-plugin/src/com/tresys/framework/compiler/dictionary/DictionaryParser.jj

    r1763 r1837  
    569569        { 
    570570                sval = text.image; 
     571                if (sval.charAt(0) == '"' && sval.charAt(sval.length()-1) == '"') 
     572                { 
     573                        sval = sval.substring(1,sval.length()-1); 
     574                } 
     575 
    571576        }) 
    572577        { 
  • branches/transwork/framework-plugin/src/com/tresys/framework/compiler/dictionary/INameValue.java

    r1176 r1837  
    1818 */ 
    1919public interface INameValue { 
     20        public static final String BACKFLOW = "backflow"; 
     21        public static final String DESCRIPTION = "desc"; 
    2022 
    2123        /** 
  • branches/transwork/framework-plugin/src/com/tresys/framework/compiler/linkage/flnkage/FLNKParser.jj

    r1543 r1837  
    803803        { 
    804804                sval = text.image; 
     805                if (sval.charAt(0) == '"' && sval.charAt(sval.length()-1) == '"') 
     806                { 
     807                        sval = sval.substring(1,sval.length()-1); 
     808                } 
    805809        }) 
    806810        { 
  • branches/transwork/framework-plugin/src/com/tresys/framework/compiler/policy/BaseDomain.java

    r1763 r1837  
    4343                super (i_copyMe); 
    4444                entries = new Vector/*<Enter>*/(); 
     45                m_sRole = i_copyMe.m_sRole; 
     46                 
    4547                NameValuePairs = new TreeMap/*<String, NameValuePair<?>>*/(); 
    46                  
    47                 entries.addAll(i_copyMe.entries); 
    4848                NameValuePairs.putAll(i_copyMe.NameValuePairs); 
    4949        } 
  • branches/transwork/framework-plugin/src/com/tresys/framework/compiler/policy/Component.java

    r1763 r1837  
    1818import java.util.Vector; 
    1919 
     20import com.tresys.framework.compiler.ErrorHandler; 
    2021import com.tresys.framework.compiler.IPolicyVisitable; 
    2122import com.tresys.framework.compiler.IPolicyVisitor; 
     
    8485                policy = i_copyMe.policy; 
    8586                parent = i_copyMe.parent; 
     87                m_sType = i_copyMe.m_sType; 
     88                m_sysResToken = i_copyMe.m_sysResToken; 
    8689        } 
    8790         
     
    261264        } 
    262265         
    263         public boolean Add(Access axx) { 
    264                         // Needs to check because it seems that baseresources and basedomains 
    265                         // keep their accesses during policy reload and with out the check 
    266                         // the access is added multiple times.  DJS 8-Mar-2007 
    267                 if (!accesses.contains(axx)) 
    268                         accesses.add(axx); 
     266        public boolean Add(Access axx)  
     267        { 
     268                // Needs to check because it seems that baseresources and basedomains 
     269                // keep their accesses during policy reload and with out the check 
     270                // the access is added multiple times.  DJS 8-Mar-2007 
     271 
     272                // DJS - now we are clearing accesses from BaseDomains and BaseResources 
     273                // during reload.  If there is an existing access it should now be a 
     274                // warning - 9-Jan-2008 
     275                if (accesses.contains(axx)) 
     276                { 
     277                        m_token.Warning ("Component \"" + getName () + "\" already has access\"" + axx.toString (), ErrorHandler.ERROR_DUPLICATE_ACCESS, axx.toString ()); 
     278                        return false; 
     279                } 
     280                         
     281                accesses.add(axx); 
    269282                return true; 
    270283        } 
     
    272285        public boolean Remove(Access i_access) { 
    273286                return accesses.remove(i_access); 
     287        } 
     288         
     289        public void ClearAccesses(){ 
     290                accesses.clear(); 
    274291        } 
    275292 
  • branches/transwork/framework-plugin/src/com/tresys/framework/compiler/policy/IDomain.java

    r1522 r1837  
    4242 
    4343        public boolean Remove(Access axx); 
     44         
     45        public void ClearAccesses (); 
    4446 
    4547        public Policy getPolicy (); 
  • branches/transwork/framework-plugin/src/com/tresys/framework/compiler/policy/Policy.java

    r1765 r1837  
    55 *                      Brian Williams <bwilliams@tresys.com> 
    66 * Policy.java: Contains all objects from a policy file 
    7  * Version: @version@ 
     7 * $Rev$ 
     8 * $Date$ 
    89 */ 
    910 
     
    178179                        topLevelDomains.put(dom.getSubName(), dom); 
    179180                } 
     181                 
     182                dom.ClearAccesses(); 
    180183 
    181184                return true; 
     
    348351                m_baseResources.put(baseResource.getName(), baseResource); 
    349352 
     353                baseResource.ClearAccesses (); 
     354                 
    350355                return true; 
    351356        } 
     
    477482         *  
    478483         * @return map of domains. 
    479          * @deprecated remove this tag once we are sure its only called when really needed 
    480484         */ 
    481485        public Map/*<String, IDomain>*/GetDomains() { 
     
    505509         *  
    506510         * @return map of resources. 
    507          * @deprecated remove this tag once we are sure its only called when really needed 
    508511         */ 
    509512        public Map/*<String, Resource>*/GetResources() { 
     
    538541         *  
    539542         * @return map of entrypoints. 
    540          * @deprecated remove this tag once we are sure its only called when really needed 
    541543         */ 
    542544        public Map/*<EntryPoint>*/GetEntrypoints() { 
  • branches/transwork/framework-plugin/src/com/tresys/framework/compiler/translator/Translator.java

    r1763 r1837  
    55 *              `       Brian Williams <bwilliams@tresys.com> 
    66 * Translator.java: Contains translator class for framework->t.e. conversion 
    7  * Version: @version@ 
     7 * $Rev$ 
     8 * $Date$ 
    89 */ 
    910 
     
    494495                if(strcontext != null) { 
    495496                        String strcon = selinux.char_p_p_value(strcontext); 
    496                         fileType = strcon.substring(strcon.lastIndexOf(":") + 1); 
    497                         fileConMap.put(path, fileType); 
     497                         
     498                        String [] context = strcon.split (":"); 
     499                        if (context.length > 2) 
     500                        { 
     501                                fileType = context[2];  
     502                                fileConMap.put(path, fileType); 
     503                        } 
    498504                } 
    499505 
  • branches/transwork/framework-plugin/src/com/tresys/framework/compiler/translator/TranslatorSELinux.java

    r1794 r1837  
     1/*################################################################################### 
     2# Copyright (C) 2007 Tresys Technology, LLC 
     3# License: refer to COPYING file for license information. 
     4# Authors: Garth Boyst <gboyst@tresys.com> 
     5# 
     6# TranslatorSeLinux.java 
     7# 
     8#    
     9################################################################################## */ 
     10 
     11/** 
     12 * <p>The Translator class is called to convert SEFramework policy to  
     13 * the underlying SELinux policy language.  The Translator walks through 
     14 * the SEFramework policy and queries the Linkage class.  The Linkage class 
     15 * tells the Translator how the translation is performed.</p> 
     16 *  
     17 * <p>The Translator does contain references to underlying policy code.  However, 
     18 * only policy code that is considered version independent should be placed 
     19 * directly in the Translator.  An example of this is the declaration of a domain. 
     20 * This would be policy version dependent.  However, the creation of AccessResource would 
     21 * be a straight forward combination of types and Rdef permissions and this would be 
     22 * handled inside the Translator class.</p> 
     23 *  
     24 * <p>The relationship between the Translator and the Linkage is rigoursly defined.   
     25 * Since both components are writing policy each must understand what the other  
     26 * is doing and how it is doing it.  For example, the naming convention used to  
     27 * derive types must be understood and used by both Translator and Linkage.</p> 
     28 */ 
     29 
    130package com.tresys.framework.compiler.translator; 
    231 
  • branches/transwork/framework-plugin/src/com/tresys/framework/plugin/builder/FrameworkBuilder.java

    r1764 r1837  
    3030import com.tresys.framework.compiler.policy.Policy; 
    3131import com.tresys.framework.plugin.SEFramework_Plugin; 
     32import com.tresys.slide.plugin.nature.SLIDEProjectNature; 
    3233 
    3334public class FrameworkBuilder 
     
    183184                        if (kind == FULL_BUILD) 
    184185                        { 
    185                                 fullBuild (monitor); 
     186                                fullBuild (args, monitor); 
    186187                        } 
    187188                        else 
     
    191192                                if (delta == null) 
    192193                                { 
    193                                         fullBuild (monitor); 
     194                                        fullBuild (args, monitor); 
    194195                                } 
    195196                                else 
     
    217218         *            The monitor for progress of the build 
    218219         */ 
    219         private void fullBuild (final IProgressMonitor monitor) 
    220         { 
     220        private void fullBuild (Map i_args, final IProgressMonitor monitor) 
     221        { 
     222                String sSystemName = null; 
     223                 
     224                if (i_args != null) 
     225                { 
     226                        sSystemName = (String) i_args.get (SLIDEProjectNature.BUILD_CONTAINER_KEY); 
     227                } 
     228                 
    221229                try 
    222230                { 
     
    226234                        { 
    227235                                SELinuxSystem sys = (SELinuxSystem) itr.next(); 
     236                                 
     237                                if (sSystemName != null && !sSystemName.equals (sys.getName ())) 
     238                                        continue; 
     239                                 
    228240                                buildSystem(sys); 
    229241                        } 
  • branches/transwork/framework-plugin/src/com/tresys/framework/plugin/builder/FrameworkNature.java

    r1777 r1837  
    77 * FrameworkNature.java: The nature associated with Framework projects 
    88 * Version: @version@ 
    9  */ 
     9 */  
    1010 
    1111package com.tresys.framework.plugin.builder; 
     
    162162                ICommand[] newCommands = new ICommand[commands.length + 1]; 
    163163 
    164                 System.arraycopy(commands, 0, newCommands, 0, commands.length); 
     164                System.arraycopy(commands, 0, newCommands, 1, commands.length); 
    165165                ICommand command = desc.newCommand(); 
    166  
    167166                command.setBuilderName(FrameworkBuilder.BUILDER_ID); 
    168                 newCommands[newCommands.length - 1] = command; 
     167 
     168                newCommands[0] = command; 
     169                 
    169170                desc.setBuildSpec(newCommands); 
     171 
     172                 
     173                 
    170174                m_project.setDescription(desc, null); 
    171175        } 
     
    183187                IProjectDescription description = getProject().getDescription(); 
    184188                ICommand[] commands = description.getBuildSpec(); 
    185  
    186                 for (int i = 0; i < commands.length; ++i)  
     189                ICommand[] newCommands = new ICommand[commands.length - 1]; 
     190 
     191                for (int i = 0, j = 0; i < commands.length; ++i)  
    187192                { 
    188193                        if (commands[i].getBuilderName().equals(FrameworkBuilder.BUILDER_ID))  
    189                         { 
    190                                 ICommand[] newCommands = new ICommand[commands.length - 1]; 
    191  
    192                                 System.arraycopy(commands, 0, newCommands, 0, i); 
    193                                 System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1); 
    194                                 description.setBuildSpec(newCommands); 
    195                                 return; 
    196                         } 
    197                 } 
     194                                continue; 
     195                         
     196                        newCommands[j++] = commands[i]; 
     197                } 
     198 
     199                description.setBuildSpec(newCommands); 
    198200        } 
    199201 
  • branches/transwork/framework-plugin/src/com/tresys/framework/plugin/builder/SELinuxSystem.java

    r1794 r1837  
    33 * Authors: Brian Williams <bwilliams@tresys.com> 
    44 *                      Spencer Shimko 
    5  * 
     5 *                     Garth Boyst 
    66 * Version: @version@ 
    77 */ 
     
    99package com.tresys.framework.plugin.builder; 
    1010 
    11 import java.io.BufferedOutputStream; 
    1211import java.io.ByteArrayInputStream; 
    1312import java.io.ByteArrayOutputStream; 
     
    1615import java.io.InputStream; 
    1716import java.io.InputStreamReader; 
    18 import java.io.PrintStream; 
    1917import java.util.HashMap; 
    2018import java.util.Map; 
     
    4139import com.tresys.framework.compiler.policy.Policy; 
    4240import com.tresys.framework.compiler.systemResources.SystemResources; 
    43 import com.tresys.framework.compiler.translator.Translator; 
    4441import com.tresys.framework.compiler.translator.TranslatorSELinux; 
    4542import com.tresys.framework.plugin.SEFramework_Plugin; 
  • branches/transwork/framework-plugin/src/com/tresys/framework/plugin/editor/FrameworkActionContributor.java

    r1763 r1837  
    1 /* Copyright (C) 2005-2006 Tresys Technology, LLC 
     1/* Copyright (C) 2005-2008 Tresys Technology, LLC 
    22 * License: refer to COPYING file for license information. 
    33 * Authors: Spencer Shimko <sshimko@tresys.com> 
     
    55 *              Brian Williams <bwilliams@tresys.com> 
    66 * 
    7  * FrameworkActionContributor.java: This controls what actions are availible  
     7 * FrameworkActionContributor.java: This controls what actions are available  
    88 * when a Framework file is open 
    99 * 
    10  * Version: @version@ 
     10 * $Rev: 1834 $ 
     11 * $Date: 2008-01-16 13:57:27 +0000 (Wed, 16 Jan 2008) $ 
    1112 */ 
    1213 
     
    3738import org.eclipse.ui.PlatformUI; 
    3839 
     40import com.tresys.framework.plugin.ErrorConstants; 
    3941import com.tresys.framework.plugin.FRAMEWORKImageRegistry; 
    4042import com.tresys.framework.plugin.SEFramework_Plugin; 
     
    139141                                                                                "Please specify the correct path the base policy directory in SEFramework Preferences",  
    140142                                                                                new Status(IStatus.ERROR, 
    141                                                                                 SEFramework_Plugin.PLUGIN_ID, IStatus.OK
     143                                                                                SEFramework_Plugin.PLUGIN_ID, ErrorConstants.ERROR_NO_BASE_POLICY_FOUND
    142144                                                                                "No base policy path specified", null)); 
    143145                                                        } 
  • branches/transwork/framework-plugin/src/com/tresys/framework/plugin/editor/dictionary/DictionaryHighlightScanner.java

    r1512 r1837  
    7979                        theKeyWords.addWord("rdef"); 
    8080                        theKeyWords.addWord("entrypoint"); 
     81                        theKeyWords.addWord("unrevokable"); 
    8182                                         
    8283                        rules[1] = theKeyWords; 
  • branches/transwork/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/GraphicPolicyEditor.java

    r1763 r1837  
    44|*| Author:     David Sugar <dsugar@tresys.com> 
    55|*|   
    6 |*| Version: @version@ 
     6|*| $Rev: 1825 $ 
     7|*| $Date: 2008-01-15 13:36:57 +0000 (Tue, 15 Jan 2008) $ 
    78\*/ 
    89 
     
    8990import com.tresys.framework.plugin.editor.policy.graphic.model.Shape; 
    9091import com.tresys.framework.plugin.editor.policy.graphic.palette.GraphicPolicyEditorPaletteFactory; 
     92import com.tresys.framework.plugin.editor.policy.graphic.palette.PolicyEditDomain; 
    9193import com.tresys.framework.plugin.editor.policy.graphic.palette.PolicyPalette; 
    9294import com.tresys.framework.plugin.editor.policy.graphic.palette.PolicyPaletteProvider; 
     
    223225        public void commandStackChanged(EventObject event)  
    224226        { 
    225                 firePropertyChange(IEditorPart.PROP_DIRTY); 
     227                firePropertyChange (IEditorPart.PROP_DIRTY); 
    226228                super.commandStackChanged(event); 
    227229        } 
     
    480482                IFile file = (IFile) input.getAdapter(IFile.class); 
    481483 
    482                 m_EditDomain = new DefaultEditDomain (this); 
     484                m_EditDomain = new PolicyEditDomain (this); 
    483485//              m_EditDomain.setDefaultTool() 
    484486                 
  • branches/transwork/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/AccessConnectionCreateCommand.java

    r1556 r1837  
    153153                Set availAccess = m_shapeResource.getAvaiableAccessVerbs(); 
    154154 
    155                 int i = 0; 
    156155                int [] order = { Verb.read, Verb.write, Verb.readwrite, Verb.none }; 
    157                 while (order[i] != m_nVerb.intValue()) 
    158                         i++; 
    159                 while (i < order.length && !availAccess.contains(m_nVerb)) 
    160                 { 
    161                         m_nVerb = new Integer (order[i++]); 
    162                 } 
    163                  
    164                 createSegment(m_shapeDomain, m_shapeResource); 
     156                if (!availAccess.contains (m_nVerb)) 
     157                { 
     158                        for (int j = 0; j < order.length && !availAccess.contains (m_nVerb); j++) 
     159                                m_nVerb = new Integer (order[j]); 
     160                } 
     161 
     162                createSegment (m_shapeDomain, m_shapeResource); 
    165163        } 
    166164         
  • branches/transwork/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/ControlResourceCreateCommand.java

    r1512 r1837  
    3131        PolicyDiagram m_diagram; 
    3232        Rectangle m_bounds; 
    33         boolean m_bWasInserted = false; 
    3433         
    3534        public ControlResourceCreateCommand (ControlResourceShape i_newShape, PolicyDiagram i_parent, Rectangle i_bounds) 
     
    137136                if (bShowWizard) 
    138137                { 
     138                        boolean wasInserted = false; 
     139                         
    139140                        //Dialog block to get the initial information for the shape 
    140141                        if (m_newShape.getWizard() != null) 
     
    143144                                                m_newShape.getWizard()); 
    144145                                dlg.setBlockOnOpen (true); 
    145                                 m_bWasInserted = dlg.open() == Window.OK; 
     146                                wasInserted = dlg.open() == Window.OK; 
     147                        } 
     148                         
     149                        if (! wasInserted) 
     150                        { 
     151                                undo (); 
     152                                throw new UserCanceledException(); 
    146153                        } 
    147154                } 
    148                 else 
    149                         m_bWasInserted = true; 
    150155         
    151                 if (m_bWasInserted) 
    152                 { 
    153                         setLabel (Messages.creation + " " + m_newShape.getName()); 
    154                 } 
    155                 else 
    156                 { 
    157                         undo (); 
    158                 } 
     156                setLabel (Messages.creation + " " + m_newShape.getName()); 
    159157        } 
    160158 
  • branches/transwork/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/commands/ShapeCreateCommand.java

    r1693 r1837  
    5555        private Rectangle m_bounds; 
    5656         
    57         private boolean m_bWasInserted = false; 
    58  
    5957        /** 
    6058         * Create a command that will add a new Shape to a ShapesDiagram. 
     
    109107                        if (bShowWizard) 
    110108                        { 
     109                                boolean bWasInserted = false; 
    111110                                Wizard wiz = m_newShape.getWizard();  
    112111                                //Dialog block to get the initial information for the shape 
     
    115114                                        WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), wiz);  
    116115                                        dlg.setBlockOnOpen (true); 
    117                                         m_bWasInserted = dlg.open() == Window.OK; 
     116                                        bWasInserted = dlg.open() == Window.OK; 
    118117                                } 
    119                         } 
    120                         else 
    121                                 m_bWasInserted = true; 
    122                          
    123                         if (m_bWasInserted) 
    124                         { 
    125                                 setLabel (Messages.creation + " " + m_newShape.getName()); 
    126                         } 
     118                                 
     119                                if (!bWasInserted) 
     120                                { 
     121                                        undo (); 
     122                                        throw new UserCanceledException();  
     123                                } 
     124                        } 
     125                         
     126                        setLabel (Messages.creation + " " + m_newShape.getName()); 
    127127                } 
    128                  
    129                 //If shape properties are not complete then remove from policy 
    130                 if (!m_bWasInserted) 
    131                 { 
    132                         undo(); 
    133                 } 
    134          
    135         } 
    136          
    137         public boolean canUndo () 
    138         { 
    139                 return m_bWasInserted; 
    140         } 
    141          
     128        } 
     129 
    142130        /* (non-Javadoc) 
    143131         * @see org.eclipse.gef.commands.Command#redo() 
  • branches/transwork/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/decorators/BackflowDecoration.java

    r1787 r1837  
    22 
    33 
    4 import org.eclipse.draw2d.FigureUtilities; 
    54import org.eclipse.draw2d.Graphics; 
    65import org.eclipse.draw2d.PolygonDecoration; 
    7 import org.eclipse.draw2d.geometry.Dimension; 
    8 import org.eclipse.draw2d.geometry.Point; 
    9 import org.eclipse.draw2d.geometry.Rectangle; 
    106import org.eclipse.jface.resource.JFaceResources; 
    117import org.eclipse.jface.util.IPropertyChangeListener; 
    128import org.eclipse.jface.util.PropertyChangeEvent; 
     9import org.eclipse.swt.graphics.Color; 
     10import org.eclipse.swt.graphics.Device; 
    1311import org.eclipse.swt.graphics.Font; 
    1412import org.eclipse.swt.graphics.FontData; 
    15 import org.eclipse.swt.graphics.FontMetrics
     13import org.eclipse.swt.graphics.RGB
    1614 
    1715import com.tresys.framework.plugin.editor.policy.graphic.figure.IFigureColors; 
     16 
    1817 
    1918public class BackflowDecoration 
     
    2120        implements IPropertyChangeListener, IFigureColors 
    2221{ 
     22 
     23        private static final double INTENDEDFLOW_SCALED_WIDTH = 10.0; 
     24        private static final double INTENDDEDFLOW_SCALED_HEIGHT = 5.0; 
     25        private static final double BACKFLOW_SCALED_WIDTH = 6.0; 
     26        private static final double BACKFLOW_SCALED_HEIGHT = 2.0; 
     27 
     28        private static int BACKFLOW_MAXIMUM = 10; 
     29        private static int MAXIMUM_COLOR_TUPLE = 255; 
     30        private static Color[] BACKFLOW_ARROWHEAD_COLORS; 
     31        private static Color DEFAULT_START = new Color(null, 128, 0, 128); 
     32        private static Color DEFAULT_END = new Color(null, 255, 0, 255); 
     33         
     34        protected static int selectColorComponentValue(double dValue) 
     35        { 
     36                return (int)Math.max (0.0, Math.min (MAXIMUM_COLOR_TUPLE, dValue)); 
     37        } 
     38         
     39        protected static boolean defineArrowHeadColors() 
     40        { 
     41                boolean retValue = false; 
     42                Device device = JFaceResources.getDefaultFont ().getDevice (); 
     43                Color cRangeStart = JFaceResources.getColorRegistry().get(BACKFLOW_RANGE_START_COLOR); 
     44                Color cRangeEnd = JFaceResources.getColorRegistry ().get (BACKFLOW_RANGE_END_COLOR); 
     45                 
     46