Changeset 2007
- 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
| r2005 |
r2007 |
|
| 21 | 21 | import java.util.Arrays; |
|---|
| 22 | 22 | import java.util.HashMap; |
|---|
| 23 | | import java.util.Iterator; |
|---|
| 24 | 23 | import java.util.Map; |
|---|
| 25 | 24 | |
|---|
| … | … | |
| 55 | 54 | import com.tresys.framework.compiler.linkage.Linkage; |
|---|
| 56 | 55 | import com.tresys.framework.compiler.linkage.libselinuxjava_plugin; |
|---|
| 57 | | import com.tresys.framework.compiler.policy.IPolicyVisitor; |
|---|
| 58 | 56 | import com.tresys.framework.compiler.policy.Policy; |
|---|
| 59 | 57 | import com.tresys.framework.compiler.policy.PolicyValidator; |
|---|
| … | … | |
| 71 | 69 | import com.tresys.setools.analysis.PolicyContainer; |
|---|
| 72 | 70 | import com.tresys.setools.apol.apol_policy_t; |
|---|
| 73 | | import com.tresys.slide.plugin.SLIDEPlugin; |
|---|
| 74 | 71 | import com.tresys.slide.plugin.nature.AnalysisContainer; |
|---|
| 75 | 72 | import com.tresys.slide.plugin.nature.BaseProjectNature; |
|---|
| 76 | | import com.tresys.slide.plugin.nature.Messages; |
|---|
| 77 | 73 | import com.tresys.slide.plugin.nature.PolicyXMLContainer; |
|---|
| 78 | 74 | import com.tresys.slide.plugin.nature.SLIDEProjectNature; |
|---|
| … | … | |
| 144 | 140 | |
|---|
| 145 | 141 | m_mlsSupport = i_mlsSupport; |
|---|
| 146 | | mCustomPolicy = getCustomPoilcyContainer(); |
|---|
| | 142 | // mCustomPolicy = getCustomPoilcyContainer(); |
|---|
| 147 | 143 | AnalysisContainer.getContainer ().addListener (m_folder, this); |
|---|
| 148 | 144 | } |
|---|
| … | … | |
| 539 | 535 | public final IFolder getDefaultLayer() |
|---|
| 540 | 536 | { |
|---|
| 541 | | if( mLayer != null ) |
|---|
| | 537 | if (mLayer != null && mLayer.exists ()) |
|---|
| 542 | 538 | return mLayer; |
|---|
| 543 | 539 | mLayer = m_folder.getFolder (CDS_LAYER); |
|---|
| 544 | | if( mLayer.exists () ) |
|---|
| | 540 | if (mLayer.exists ()) |
|---|
| 545 | 541 | return mLayer; |
|---|
| | 542 | |
|---|
| 546 | 543 | try |
|---|
| 547 | 544 | { |
|---|
| 548 | 545 | 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()); |
|---|
| 554 | 550 | metadataFile.create(stream, true, null); |
|---|
| 555 | | metadataFile.refreshLocal (IResource.DEPTH_ZERO, null); |
|---|
| 556 | | } |
|---|
| 557 | | catch(CoreException ce) |
|---|
| | 551 | } |
|---|
| | 552 | catch (CoreException ce) |
|---|
| 558 | 553 | { |
|---|
| 559 | 554 | mLayer = null; |
|---|
| 560 | 555 | ce.printStackTrace (); |
|---|
| 561 | | return mLayer; |
|---|
| 562 | 556 | } |
|---|
| 563 | 557 | return mLayer; |
|---|
| … | … | |
| 587 | 581 | final String policyPath = "cdsframework-" + m_name; |
|---|
| 588 | 582 | |
|---|
| 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); |
|---|
| 592 | 586 | |
|---|
| 593 | 587 | final IFile dictionaryFile = getFolder ().getFile ("policy/support/cdsdictionary.spt"); |
|---|
| … | … | |
| 767 | 761 | } |
|---|
| 768 | 762 | |
|---|
| 769 | | public class CPolicyContainer implements IResourceChangeListener |
|---|
| | 763 | public class CPolicyContainer |
|---|
| | 764 | implements IResourceChangeListener |
|---|
| 770 | 765 | { |
|---|
| 771 | 766 | public static final int IF_FILE = 0; |
|---|
| … | … | |
| 787 | 782 | { |
|---|
| 788 | 783 | IFolder layer = getDefaultLayer (); |
|---|
| 789 | | if( layer == null ) |
|---|
| | 784 | if (layer == null) |
|---|
| 790 | 785 | 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; |
|---|
| 794 | 790 | |
|---|
| 795 | 791 | final IFile interface_file = layer.getFile (if_file); |
|---|
| … | … | |
| 840 | 836 | { |
|---|
| 841 | 837 | IFolder layer = getDefaultLayer (); |
|---|
| 842 | | if( layer == null ) |
|---|
| | 838 | if (layer == null) |
|---|
| 843 | 839 | return null; |
|---|
| 844 | | if( mModule != null ) |
|---|
| | 840 | if (mModule != null) |
|---|
| 845 | 841 | 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; |
|---|
| 849 | 846 | |
|---|
| 850 | 847 | Object [][]array = |
|---|
| 851 | 848 | { |
|---|
| 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 | }, |
|---|
| 853 | 862 | {layer.getFile (te_file), "policy_module("+ CUSTOM_MODULE_NAME + "," + "1.0.0) \n\n"}, |
|---|
| 854 | 863 | {layer.getFile (fc_file), "\n"}, |
|---|
| … | … | |
| 867 | 876 | { |
|---|
| 868 | 877 | mModule[i].appendContents (stream, IResource.KEEP_HISTORY, null); |
|---|
| 869 | | mModule[i].refreshLocal (IResource.DEPTH_ZERO, null); |
|---|
| 870 | 878 | } |
|---|
| 871 | 879 | else |
|---|
| 872 | 880 | { |
|---|
| 873 | 881 | mModule[i].create (stream, true, null); |
|---|
| 874 | | mModule[i].refreshLocal (IResource.DEPTH_ZERO, null); |
|---|
| 875 | 882 | } |
|---|
| 876 | 883 | } |
|---|
| … | … | |
| 917 | 924 | IResource resource = delta.getResource(); |
|---|
| 918 | 925 | if (resource.getType() == IResource.FILE |
|---|
| 919 | | && resource.getName ().equals(getCustomModuleName ()+".if")) |
|---|
| | 926 | && resource.getName ().equals(getCustomModuleName () + '.' + BaseProjectNature.IF_EXTENSION)) |
|---|
| 920 | 927 | { |
|---|
| 921 | 928 | changed.add(resource); |
|---|
| r2004 |
r2007 |
|
| 39 | 39 | import com.tresys.framework.plugin.editor.policy.graphic.parts.PolicyEditPart; |
|---|
| 40 | 40 | import com.tresys.slide.plugin.editors.module.ModuleEditor; |
|---|
| | 41 | import com.tresys.slide.plugin.editors.module.ModuleEditorInput; |
|---|
| | 42 | |
|---|
| 41 | 43 | |
|---|
| 42 | 44 | public class AddCustomPolicy |
|---|
| … | … | |
| 107 | 109 | * provide input to editor and open up the editor. |
|---|
| 108 | 110 | */ |
|---|
| 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 | |
|---|
| 110 | 116 | } |
|---|
| 111 | 117 | catch(PartInitException pe) |
|---|
| r1884 |
r2007 |
|
| 16 | 16 | import java.io.ByteArrayInputStream; |
|---|
| 17 | 17 | import java.io.File; |
|---|
| | 18 | import java.io.FileWriter; |
|---|
| 18 | 19 | import java.io.IOException; |
|---|
| 19 | 20 | import java.io.InputStream; |
|---|
| … | … | |
| 157 | 158 | frameDir.create (true, false, null); |
|---|
| 158 | 159 | |
|---|
| 159 | | InputStream blank = new ByteArrayInputStream ("".getBytes()); //$NON-NLS-1$ |
|---|
| | 160 | InputStream blank = new ByteArrayInputStream (new String ().getBytes()); |
|---|
| 160 | 161 | |
|---|
| 161 | 162 | |
|---|
| … | … | |
| 179 | 180 | { |
|---|
| 180 | 181 | |
|---|
| 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); |
|---|
| 183 | 184 | |
|---|
| 184 | 185 | if (!supportFile.exists()) |
|---|
| … | … | |
| 186 | 187 | String sPath = FrameworkNature.m_resourcesDir + IPath.SEPARATOR + FrameworkNature.FILE_MACRO_SUPPORT; |
|---|
| 187 | 188 | 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 (); |
|---|
| 190 | 198 | } |
|---|
| | 199 | |
|---|
| 191 | 200 | |
|---|
| 192 | 201 | File buildConfFile = nat.GetBuildConfPath (frameDir); |
|---|
Download in other formats:
* Generating other formats may take time.