Changeset 1974
- Timestamp:
- 03/04/08 13:34:57 (9 months ago)
- Files:
-
- branches/mls/framework-plugin/src/com/tresys/framework/compiler/policy/ComponentWithDictObjects.java (modified) (1 diff)
- branches/mls/framework-plugin/src/com/tresys/framework/plugin/builder/AccessCheckBuilder.java (modified) (4 diffs)
- branches/mls/framework-plugin/src/com/tresys/framework/plugin/builder/FrameworkNature.java (modified) (1 diff)
- branches/mls/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/ResourceShape.java (modified) (1 diff)
- branches/mls/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/UserDomainShape.java (modified) (1 diff)
- branches/mls/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/parts/DomainEditPart.java (modified) (3 diffs)
- branches/mls/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/parts/PolicyEditPart.java (modified) (6 diffs)
- branches/mls/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/parts/ShapeEditPart.java (modified) (6 diffs)
- branches/mls/framework-plugin/src/com/tresys/framework/plugin/preferences/MLSSettingsProjProperties.java (modified) (4 diffs)
- branches/mls/framework-plugin/src/com/tresys/framework/plugin/preferences/SEFPreferencePage.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/mls/framework-plugin/src/com/tresys/framework/compiler/policy/ComponentWithDictObjects.java
r1973 r1974 70 70 sysResources = new TreeMap/*<IDictionaryObject, List<SystemResource>>*/(); 71 71 72 MLSSupport mlsSupport = pol.getLinkage ().getMLSSupport (); 73 if (mlsSupport != null) 74 m_MLSLevel = mlsSupport.getDefaultMLSLevel (); 72 if (getPolicy () != null) 73 { 74 MLSSupport mlsSupport = getPolicy ().getLinkage ().getMLSSupport (); 75 if (mlsSupport != null) 76 m_MLSLevel = mlsSupport.getDefaultMLSLevel (); 77 } 75 78 } 76 79 branches/mls/framework-plugin/src/com/tresys/framework/plugin/builder/AccessCheckBuilder.java
r1973 r1974 22 22 import org.eclipse.core.resources.IFile; 23 23 import org.eclipse.core.resources.IProject; 24 import org.eclipse.core.resources.IResource; 25 import org.eclipse.core.resources.IResourceVisitor; 24 26 import org.eclipse.core.resources.IncrementalProjectBuilder; 25 27 import org.eclipse.core.runtime.CoreException; … … 57 59 import com.tresys.framework.compiler.policy.UserDomain; 58 60 import com.tresys.framework.plugin.SEFramework_Plugin; 61 import com.tresys.slide.plugin.nature.BaseProjectNature; 59 62 60 63 /** 64 * Simple builder to do access check and verify there is not something that will cause them to fail 61 65 * @author dsugar 62 66 * … … 87 91 SELinuxSystem sys = (SELinuxSystem) itr.next(); 88 92 89 IFile buildPolicy = sys.getFolder ().getFile ("policy.19");90 if (!buildPolicy.exists ())91 continue;92 93 93 try 94 94 { 95 // SELinuxSystem sys = getSystem (i_policy); 96 AccessCheckVisitor visitor = null; 97 98 visitor = new AccessCheckVisitor (buildPolicy, sys.getFPOLErrorHandler ()); 95 sys.getFolder ().accept (new PolicyFolderVisitor (), 1, false); 96 } 97 catch (CoreException ce) 98 {} 99 } 100 101 return null; 102 } 103 104 /** 105 * Visit the policy directory looking for the policy.xx and (future) modules 106 * @author dsugar 107 * 108 */ 109 protected class PolicyFolderVisitor 110 implements IResourceVisitor 111 { 112 /* (non-Javadoc) 113 * @see org.eclipse.core.resources.IResourceVisitor#visit(org.eclipse.core.resources.IResource) 114 */ 115 public boolean visit (IResource resource) 116 { 117 try 118 { 119 if (!(resource instanceof IFile)) 120 return true; 121 122 // match policy file 123 String sExtn = resource.getFileExtension (); 124 if (sExtn == null) 125 return false; 126 127 //TODO: need to deal with modular builds!! 128 String sSubName = resource.getName (); 129 sSubName = sSubName.substring (0, sSubName.length () - sExtn.length () -1); 130 if (!BaseProjectNature.FILE_POLICY_BASE.equals (sSubName)) 131 return false; 132 133 if (Integer.valueOf (sExtn) == null) 134 return false; 135 136 FrameworkNature nat = FrameworkNature.getNature (resource.getProject ()); 137 138 // visit the actual policy 139 SELinuxSystem sys = nat.getSystem (resource); 140 AccessCheckVisitor visitor = new AccessCheckVisitor ((IFile) resource, sys.getFPOLErrorHandler ()); 99 141 100 142 if (visitor != null) … … 109 151 e.printStackTrace(); 110 152 } 111 } 112 113 return null; 153 return false; 154 } 114 155 } 115 156 116 157 /** 117 158 * Check all accesses in the policy to verify that they grant the access described branches/mls/framework-plugin/src/com/tresys/framework/plugin/builder/FrameworkNature.java
r1973 r1974 154 154 } 155 155 156 if (event.getKey ().equals (SEFPreferencePage.DEFAULT_MLS_LEVEL_REMOVED))157 {158 IShapeVisitor isv = new DefaultMLSLevelUpdateVisitor(event);159 for (Iterator _iter = getSystems ().iterator (); _iter.hasNext (); )160 {161 SELinuxSystem sels = (SELinuxSystem)_iter.next ();162 sels.getDiagram ().Accept (isv);163 }164 }165 166 156 return; 167 157 } branches/mls/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/ResourceShape.java
r1973 r1974 60 60 61 61 Token tok = new Token (sName, getErrorHandler()); 62 Resource resource = new Resource (tok, null, getPolicy());62 Resource resource = new Resource (tok, null, i_system.getPolicy()); 63 63 64 64 setComponent (resource); branches/mls/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/model/UserDomainShape.java
r1825 r1974 44 44 45 45 Token tok = new Token (sName, getErrorHandler()); 46 UserDomain dom = new UserDomain (tok, getPolicy());46 UserDomain dom = new UserDomain (tok, i_system.getPolicy()); 47 47 48 48 setComponent (dom); branches/mls/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/parts/DomainEditPart.java
r1973 r1974 29 29 import org.eclipse.gef.Request; 30 30 31 import com.tresys.framework.compiler.mls.MLSLevel;32 import com.tresys.framework.compiler.mls.MLSSupport;33 31 import com.tresys.framework.compiler.policy.Access; 34 32 import com.tresys.framework.compiler.policy.Component; 35 33 import com.tresys.framework.compiler.policy.Enter; 36 import com.tresys.framework.compiler.policy.IMLSSetting;37 34 import com.tresys.framework.compiler.policy.IResource; 38 35 import com.tresys.framework.plugin.editor.policy.graphic.figure.ConnectionAnchorFigure; … … 45 42 import com.tresys.framework.plugin.editor.policy.graphic.model.EntryConnection; 46 43 import com.tresys.framework.plugin.editor.policy.graphic.model.IDomainShape; 47 import com.tresys.framework.plugin.editor.policy.graphic.model.IShape;48 44 import com.tresys.framework.plugin.editor.policy.graphic.model.Shape; 49 45 import com.tresys.framework.plugin.editor.policy.graphic.model.UserDomainShape; 50 import com.tresys.framework.plugin.preferences.MLSEclipseLevel;51 46 52 47 public class DomainEditPart … … 129 124 { 130 125 DomainFigure domFig = new DomainFigure(); 131 MLSSupport mlss = MLSSupport.getInstance (); 132 133 if (null != mlss) 134 { 135 IShape is = (IShape)getModel (); 136 IMLSSetting ims = (IMLSSetting)is.getComponent (); 137 MLSLevel level = ims.getMLSLevel (); 138 139 if (level != null) 140 domFig.setBackgroundColor (MLSEclipseLevel.getColorInstance (level)); 141 } 126 142 127 m_connectionAnchor = new ConnectionAnchorFigure (domFig); 143 128 fig = domFig; branches/mls/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/parts/PolicyEditPart.java
r1973 r1974 26 26 import org.eclipse.swt.widgets.Display; 27 27 28 import com.tresys.framework.compiler.linkage.Linkage;29 28 import com.tresys.framework.compiler.mls.MLSLevel; 30 29 import com.tresys.framework.compiler.mls.MLSSupport; … … 50 49 private ConnectionAnchor anchor; 51 50 private static List EMPTY_LIST = new ArrayList (); 52 private String _oldDefaultLevel = null;53 private String _newDefaultLevel = null;54 51 55 52 final static protected boolean DEBUG = SEFramework_Plugin.getDefault ().isDebugging ("/debug/part"); … … 196 193 else if (Shape.MLS_PROP.equals (prop)) 197 194 { 198 String levelName = evt.getNewValue ().toString (); 199 200 MLSSupport mlsSupport = MLSSupport.getInstance (); 201 202 if (null != mlsSupport) 203 { 204 MLSLevel mls = mlsSupport.getLevel (levelName); 205 206 if (null != mls) 207 { 208 this.figure.setBackgroundColor (MLSEclipseLevel.getColorInstance (mls)); 209 refreshVisuals (); 210 } 211 } 195 refreshVisuals (); 212 196 } 213 197 else if (SEFPreferencePage.MLS_UPDATE.equals (prop)) … … 215 199 if (getCastedModel ().getComponent () instanceof IMLSSetting) 216 200 { 217 MLSLevel mls = ((IMLSSetting) getCastedModel ().getComponent ()).getMLSLevel (); 218 if (mls != null) 219 getFigure ().setBackgroundColor (MLSEclipseLevel.getColorInstance (mls)); 220 } 221 } 222 else if (SEFPreferencePage.DEFAULT_MLS_LEVEL.equals (prop)) 223 { 224 Object ov = evt.getOldValue (); 225 if (null != ov) 226 { 227 this._oldDefaultLevel = ov.toString (); 228 this._newDefaultLevel = evt.getNewValue ().toString (); 229 } 230 } 231 else if (SEFPreferencePage.DEFAULT_MLS_LEVEL_REMOVED.equals (prop)) 232 { 233 Object ov = evt.getOldValue (); 234 if (null != ov) 235 { 236 if (Boolean.TRUE.toString ().equals (evt.getNewValue ().toString ())) 201 IMLSSetting mlsComponent = (IMLSSetting) getCastedModel ().getComponent (); 202 MLSLevel mls = mlsComponent.getMLSLevel (); 203 204 MLSSupport mlsSupport = getCastedModel ().getMLSSupport (); 205 if (mls == null || mlsSupport.getLevel (mls.getName ()) == null) 237 206 { 238 Shape s = this.getCastedModel (); 239 240 IMLSSetting ims = (IMLSSetting) s.getComponent (); 241 242 if (_oldDefaultLevel.equals (ims.getMLSLabel ())) 207 mls = mlsSupport.getDefaultMLSLevel (); 208 if (mls != null) 243 209 { 244 Linkage linkage = getCastedModel ().getPolicy ().getLinkage (); 245 MLSSupport mlsSupport = linkage.getMLSSupport (); 246 247 //String levelName = _newDefaultLevel; 248 MLSLevel mlsLevel = mlsSupport.getLevel (_newDefaultLevel); 249 ims.setMLSLabel (mlsLevel); 250 251 /// MLSSupport mlsSupport = MLSSupport.getInstance (); 252 253 if (null != mlsSupport) 254 { 255 // MLSLevel mls = mlsSupport.getLevel (levelName); 256 257 if (null != mlsLevel) 258 { 259 this.figure.setBackgroundColor (MLSEclipseLevel.getColorInstance (mlsLevel)); 260 refreshVisuals (); 261 } 262 } 210 getCastedModel ().setMLS (mls); 211 refreshVisuals (); 263 212 } 264 213 } … … 269 218 Display.getDefault().asyncExec(new Runnable () 270 219 { 271 public void run()272 {273 refreshVisuals();274 };220 public void run() 221 { 222 refreshVisuals(); 223 }; 275 224 }); 276 225 } … … 301 250 ((PolicyComponentFigure) tmpFigure).setSeverity (shape.getProblemSeverity().intValue()); 302 251 252 if (shape.getComponent () instanceof IMLSSetting) 253 { 254 MLSLevel mls = ((IMLSSetting) shape.getComponent ()).getMLSLevel (); 255 if (mls != null) 256 tmpFigure.setBackgroundColor (MLSEclipseLevel.getColorInstance (mls)); 257 } 303 258 } 304 259 branches/mls/framework-plugin/src/com/tresys/framework/plugin/editor/policy/graphic/parts/ShapeEditPart.java
r1973 r1974 22 22 import org.eclipse.gef.EditPolicy; 23 23 24 import com.tresys.framework.compiler.mls.MLSLevel;25 import com.tresys.framework.compiler.mls.MLSSupport;26 import com.tresys.framework.compiler.policy.IMLSSetting;27 24 import com.tresys.framework.plugin.editor.policy.graphic.figure.BaseDomainFigure; 28 25 import com.tresys.framework.plugin.editor.policy.graphic.figure.BaseResourceFigure; … … 36 33 import com.tresys.framework.plugin.editor.policy.graphic.model.ControlResourceShape; 37 34 import com.tresys.framework.plugin.editor.policy.graphic.model.IDomainShape; 38 import com.tresys.framework.plugin.editor.policy.graphic.model.IShape;39 35 import com.tresys.framework.plugin.editor.policy.graphic.model.ResourceShape; 40 36 import com.tresys.framework.plugin.editor.policy.graphic.model.EntryPointShape; 41 37 import com.tresys.framework.plugin.editor.policy.graphic.model.Shape; 42 38 import com.tresys.framework.plugin.editor.policy.graphic.model.UserDomainShape; 43 import com.tresys.framework.plugin.preferences.MLSEclipseLevel;44 39 45 40 /** … … 90 85 { 91 86 IFigure retValue = null; 92 boolean isMLSAware = false;93 87 94 88 if (getModel() instanceof ResourceShape) 95 89 { 96 90 retValue = new ResourceFigure(); 97 isMLSAware = true;98 91 } 99 92 else if (getModel () instanceof BaseResourceShape) … … 112 105 { 113 106 retValue = new EntryPointFigure(); 114 isMLSAware = true;115 107 } 116 108 else if (getModel() instanceof IDomainShape) 117 109 { 118 110 retValue = new DomainFigure(); 119 isMLSAware = true;120 111 } 121 112 else if (getModel () instanceof ControlResourceShape) 122 113 { 123 114 retValue = new ControlResourceFigure (); 124 isMLSAware = true;125 115 } 126 116 else … … 129 119 throw new IllegalArgumentException(); 130 120 } 131 132 // Determine if the Figure's background needs to be set... 133 if (isMLSAware) 134 { 135 MLSSupport mlss = MLSSupport.getInstance (); 136 137 if (null != mlss) 138 { 139 IShape is = (IShape)getModel (); 140 IMLSSetting ims = (IMLSSetting)is.getComponent (); 141 MLSLevel level = ims.getMLSLevel (); 142 if (level != null) 143 retValue.setBackgroundColor (MLSEclipseLevel.getColorInstance (level)); 144 } 145 } 146 121 147 122 return retValue; 148 123 } … … 158 133 return getCastedModel ().getEntryConnections(); 159 134 } 160 161 162 135 163 136 public void refresh() 164 137 { branches/mls/framework-plugin/src/com/tresys/framework/plugin/preferences/MLSSettingsProjProperties.java
r1973 r1974 106 106 protected ComboViewer _levelsDefault = null; 107 107 protected IEclipsePreferences projPrefs = null; 108 protected boolean _defaultWasRemoved = false;109 108 110 109 /** … … 174 173 this.initProjPrefs (); 175 174 176 this._defaultWasRemoved = false;177 178 175 // Define the basics of the page 179 176 setTitle (Messages.mls_settings); … … 410 407 MLSLevel dl = _levels.getLevelOrderedAt (0); 411 408 _levelsDefault.setSelection (new StructuredSelection(dl)); 412 _defaultWasRemoved = true;413 409 } 414 410 … … 535 531 this.projPrefs.put (SEFPreferencePage.MLS_UPDATE, Long.toHexString (System.currentTimeMillis ())); 536 532 537 if (_defaultWasRemoved)538 {539 this.projPrefs.put(SEFPreferencePage.DEFAULT_MLS_LEVEL_REMOVED, Boolean.FALSE.toString ());540 this.projPrefs.put(SEFPreferencePage.DEFAULT_MLS_LEVEL_REMOVED, Boolean.TRUE.toString ());541 }542 533 543 534 projPrefs.flush (); branches/mls/framework-plugin/src/com/tresys/framework/plugin/preferences/SEFPreferencePage.java
r1955 r1974 53 53 */ 54 54 public static final String DEFAULT_MLS_LEVEL = "defaultMLSLevel"; 55 public static final String DEFAULT_MLS_LEVEL_REMOVED = "defaultMLSLevelRemoved";56 55 public static final String MLS_UPDATE = "mlsUpdated"; 57 56
