Changeset 2007

Show
Ignore:
Timestamp:
03/21/08 11:29:01 (8 months ago)
Author:
dsugar
Message:

some cleanup
fix problem opening multiple editors when customizing policy.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/custome_policy/framework-plugin/src/com/tresys/framework/plugin/builder/SELinuxSystem.java

    r2005 r2007  
    2121import java.util.Arrays; 
    2222import java.util.HashMap; 
    23 import java.util.Iterator; 
    2423import java.util.Map; 
    2524 
     
    5554import com.tresys.framework.compiler.linkage.Linkage; 
    5655import com.tresys.framework.compiler.linkage.libselinuxjava_plugin; 
    57 import com.tresys.framework.compiler.policy.IPolicyVisitor; 
    5856import com.tresys.framework.compiler.policy.Policy; 
    5957import com.tresys.framework.compiler.policy.PolicyValidator; 
     
    7169import com.tresys.setools.analysis.PolicyContainer; 
    7270import com.tresys.setools.apol.apol_policy_t; 
    73 import com.tresys.slide.plugin.SLIDEPlugin; 
    7471import com.tresys.slide.plugin.nature.AnalysisContainer; 
    7572import com.tresys.slide.plugin.nature.BaseProjectNature; 
    76 import com.tresys.slide.plugin.nature.Messages; 
    7773import com.tresys.slide.plugin.nature.PolicyXMLContainer; 
    7874import com.tresys.slide.plugin.nature.SLIDEProjectNature; 
     
    144140 
    145141                m_mlsSupport = i_mlsSupport; 
    146               mCustomPolicy = getCustomPoilcyContainer(); 
     142//            mCustomPolicy = getCustomPoilcyContainer(); 
    147143                AnalysisContainer.getContainer ().addListener (m_folder, this); 
    148144        } 
     
    539535        public final IFolder getDefaultLayer() 
    540536        { 
    541                 if( mLayer != null
     537                if (mLayer != null && mLayer.exists ()
    542538                        return mLayer; 
    543539                mLayer = m_folder.getFolder (CDS_LAYER); 
    544                 if( mLayer.exists ()
     540                if (mLayer.exists ()
    545541                        return mLayer; 
     542 
    546543                try 
    547544                { 
    548545                        mLayer.create (true, true, null); 
    549                         mLayer.getProjectRelativePath().append("metadata.xml"); //$NON-NLS-1$ 
    550                         IFile metadataFile = getProject ().getFile(mLayer.getProjectRelativePath().append("metadata.xml")); //$NON-NLS-1$ 
    551                          
    552                         String summary = "<summary>CDSFramework Policy Layer</summary>\n"; 
    553                         InputStream stream = new ByteArrayInputStream (summary.getBytes()); //$NON-NLS-1$ 
     546                        IFile metadataFile = mLayer.getFile (BaseProjectNature.FILE_METADATA_XML); 
     547                         
     548                        String summary = "<summary>CDSFramework Policy Layer</summary>\n"; //$NON-NLS-1$ 
     549                        InputStream stream = new ByteArrayInputStream (summary.getBytes());  
    554550                        metadataFile.create(stream, true, null); 
    555                         metadataFile.refreshLocal (IResource.DEPTH_ZERO, null); 
    556                 } 
    557                 catch(CoreException ce) 
     551                } 
     552                catch (CoreException ce) 
    558553                { 
    559554                        mLayer = null; 
    560555                        ce.printStackTrace (); 
    561                         return mLayer; 
    562556                } 
    563557                return mLayer; 
     
    587581                final String policyPath = "cdsframework-" + m_name; 
    588582 
    589                 final IFile teFile = getDefaultLayer ().getFile(policyPath + ".te"); 
    590                 final IFile ifFile = getDefaultLayer ().getFile(policyPath + ".if");           
    591                 final IFile fcFile = getDefaultLayer ().getFile(policyPath + ".fc"); 
     583                final IFile teFile = getDefaultLayer ().getFile(policyPath + '.' + BaseProjectNature.TE_EXTENSION); 
     584                final IFile ifFile = getDefaultLayer ().getFile(policyPath + '.' + BaseProjectNature.IF_EXTENSION);            
     585                final IFile fcFile = getDefaultLayer ().getFile(policyPath + '.' + BaseProjectNature.FC_EXTENSION); 
    592586 
    593587                final IFile dictionaryFile = getFolder ().getFile ("policy/support/cdsdictionary.spt"); 
     
    767761        } 
    768762         
    769         public class CPolicyContainer implements IResourceChangeListener 
     763        public class CPolicyContainer  
     764                implements IResourceChangeListener 
    770765        { 
    771766                public static final int IF_FILE = 0; 
     
    787782                { 
    788783                        IFolder layer = getDefaultLayer (); 
    789                         if( layer == null
     784                        if (layer == null
    790785                                return; 
    791                         String if_file = CUSTOM_MODULE_NAME + ".if"; 
    792                         String te_file = CUSTOM_MODULE_NAME + ".te"; 
    793                         String fc_file = CUSTOM_MODULE_NAME + ".fc"; 
     786 
     787                        String if_file = CUSTOM_MODULE_NAME + '.' + BaseProjectNature.IF_EXTENSION; 
     788                        String te_file = CUSTOM_MODULE_NAME + '.' + BaseProjectNature.TE_EXTENSION; 
     789                        String fc_file = CUSTOM_MODULE_NAME + '.' + BaseProjectNature.FC_EXTENSION; 
    794790                         
    795791                        final IFile interface_file = layer.getFile (if_file); 
     
    840836                { 
    841837                        IFolder layer = getDefaultLayer (); 
    842                         if( layer == null
     838                        if (layer == null
    843839                                return null; 
    844                         if( mModule != null
     840                        if (mModule != null
    845841                                return mModule; 
    846                         String if_file = CUSTOM_MODULE_NAME + ".if"; 
    847                         String te_file = CUSTOM_MODULE_NAME + ".te"; 
    848                         String fc_file = CUSTOM_MODULE_NAME + ".fc"; 
     842                         
     843                        String if_file = CUSTOM_MODULE_NAME + '.' + BaseProjectNature.IF_EXTENSION; 
     844                        String te_file = CUSTOM_MODULE_NAME + '.' + BaseProjectNature.TE_EXTENSION; 
     845                        String fc_file = CUSTOM_MODULE_NAME + '.' + BaseProjectNature.FC_EXTENSION; 
    849846                         
    850847                        Object [][]array =  
    851848                        { 
    852                                 {layer.getFile (if_file), "## <summary> </summary>\n"}, 
     849                                {layer.getFile (if_file),  
     850                                        "## <summary>\n" + 
     851                                        "## Customizations for CDS Framework generated policy for " + getName () + "\n" + 
     852                                        "## </summary>\n" + 
     853                                        "## <desc>\n" + 
     854                                        "## <p>\n" + 
     855                                        "## Please only use these customizations when no other means of \n" + 
     856                                        "## customizing your policy is working.  Please use this as a \n" + 
     857                                        "## last resort efort try to use custom dictionary entry, ability,\n" + 
     858                                        "## base resource or base domain first.\n" + 
     859                                        "## </p>\n" + 
     860                                        "## </desc>\n" 
     861                                }, 
    853862                                {layer.getFile (te_file), "policy_module("+ CUSTOM_MODULE_NAME + "," + "1.0.0) \n\n"}, 
    854863                                {layer.getFile (fc_file), "\n"}, 
     
    867876                                        { 
    868877                                                mModule[i].appendContents (stream, IResource.KEEP_HISTORY, null); 
    869                                                 mModule[i].refreshLocal (IResource.DEPTH_ZERO, null); 
    870878                                        } 
    871879                                        else 
    872880                                        { 
    873881                                                mModule[i].create (stream, true, null); 
    874                                                 mModule[i].refreshLocal (IResource.DEPTH_ZERO, null); 
    875882                                        } 
    876883                                } 
     
    917924                                        IResource resource = delta.getResource(); 
    918925                                        if (resource.getType() == IResource.FILE  
    919                                                 && resource.getName ().equals(getCustomModuleName ()+".if")) 
     926                                                && resource.getName ().equals(getCustomModuleName () + '.' + BaseProjectNature.IF_EXTENSION)) 
    920927                                        { 
    921928                                                changed.add(resource); 
  • branches/custome_policy/framework-plugin/src/com/tresys/framework/plugin/editor/action/AddCustomPolicy.java

    r2004 r2007  
    3939import com.tresys.framework.plugin.editor.policy.graphic.parts.PolicyEditPart; 
    4040import com.tresys.slide.plugin.editors.module.ModuleEditor; 
     41import com.tresys.slide.plugin.editors.module.ModuleEditorInput; 
     42 
    4143 
    4244public class AddCustomPolicy 
     
    107109                         * provide input to editor and open up the editor. 
    108110                         */ 
    109                                 IDE.openEditor (mEditor.getSite ().getPage (), files[0], ModuleEditor.ID, true); 
     111 
     112                        ModuleEditorInput fileInput = new ModuleEditorInput (files[0]);                  
     113 
     114                        IDE.openEditor (mEditor.getSite ().getPage (), fileInput, ModuleEditor.ID, true); 
     115 
    110116                } 
    111117                catch(PartInitException pe) 
  • branches/custome_policy/framework-plugin/src/com/tresys/framework/plugin/wizards/NewSystemWizard.java

    r1884 r2007  
    1616import java.io.ByteArrayInputStream; 
    1717import java.io.File; 
     18import java.io.FileWriter; 
    1819import java.io.IOException; 
    1920import java.io.InputStream; 
     
    157158                                                        frameDir.create (true, false, null); 
    158159                                                 
    159                                                 InputStream blank = new ByteArrayInputStream ("".getBytes()); //$NON-NLS-1$ 
     160                                                InputStream blank = new ByteArrayInputStream (new String ().getBytes()); 
    160161                                                 
    161162                                                 
     
    179180                        { 
    180181                                 
    181 //                              IContainer policyDir = nat.getSupportMacroIFolder(frameDir);  //TODO: future!! added in 1.1.11  of SLIDE 
    182                                 IFile supportFile = systemDir.getFile("policy/support/" + FrameworkNature.FILE_MACRO_SUPPORT); //$NON-NLS-1$ 
     182                                File supportDir = nat.getSupportMacroFolder (frameDir); 
     183                                File supportFile = new File (supportDir.getPath () + File.separator + FrameworkNature.FILE_MACRO_SUPPORT); 
    183184 
    184185                                if (!supportFile.exists()) 
     
    186187                                        String sPath = FrameworkNature.m_resourcesDir + IPath.SEPARATOR + FrameworkNature.FILE_MACRO_SUPPORT; 
    187188                                        URL basePathURL = SEFramework_Plugin.getDefault().getBundle().getEntry(sPath); 
    188                                         InputStream supportFileStream = basePathURL.openStream(); 
    189                                         supportFile.create(supportFileStream, true, null); 
     189                                        InputStream supportFileStream = basePathURL.openStream (); 
     190                                         
     191                                        byte [] supportMacros = new byte [supportFileStream.available ()]; 
     192                                        supportFileStream.read (supportMacros); 
     193                                         
     194                                        FileWriter writer = new FileWriter (supportFile); 
     195                                        writer.write (new String (supportMacros)); 
     196                                        writer.flush (); 
     197                                        writer.close (); 
    190198                                } 
     199                                 
    191200                                 
    192201                                File buildConfFile = nat.GetBuildConfPath (frameDir);