Changeset 1588
- Timestamp:
- 03/28/07 10:12:42
(2 years ago)
- Author:
- msnyder
- Message:
Ticket #131 resolved --- When different policy selected, a recheck is done on the system name (no duplicates), and the default reference policy
directory changes with project selection changes. Work in progress - enter connections with reparenting
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1569 |
r1588 |
|
| 418 | 418 | fileType = getPathType(file.toString()); |
|---|
| 419 | 419 | if(fileType == null) { |
|---|
| 420 | | if(hasFileContext) { |
|---|
| | 420 | if(!hasFileContext) { |
|---|
| 421 | 421 | Utility |
|---|
| 422 | 422 | .ProjectError("Unable to determine file context for " |
|---|
| r1579 |
r1588 |
|
| 254 | 254 | { |
|---|
| 255 | 255 | String sDictionary = m_projPrefs.get (SEFPreferencePage.MAIN_DICTIONARY, PreferenceInitializer.DEFAULT_DICTIONARY).trim (); |
|---|
| | 256 | |
|---|
| 256 | 257 | if (sDictionary.length() > 0) |
|---|
| 257 | 258 | { |
|---|
| … | … | |
| 301 | 302 | Collection systems = getSystems (); |
|---|
| 302 | 303 | |
|---|
| 303 | | |
|---|
| 304 | 304 | for (Iterator itr1 = systems.iterator(); itr1.hasNext(); ) |
|---|
| 305 | 305 | { |
|---|
| r1531 |
r1588 |
|
| 98 | 98 | |
|---|
| 99 | 99 | |
|---|
| 100 | | // loop through all connections and create those we can |
|---|
| | 100 | // loop through all connections and create those that are allowed |
|---|
| 101 | 101 | for (Iterator itr = oldConnections.iterator(); itr.hasNext(); ) |
|---|
| 102 | 102 | { |
|---|
| … | … | |
| 139 | 139 | } |
|---|
| 140 | 140 | } |
|---|
| | 141 | |
|---|
| 141 | 142 | else if (connection instanceof EntryConnection) |
|---|
| 142 | 143 | { |
|---|
| 143 | | //TODO: deal with enter connections |
|---|
| | 144 | EntryConnection oldConnection = (EntryConnection) connection; |
|---|
| | 145 | //Collection entryDefn = oldConnection.getAccessDefn(); |
|---|
| | 146 | |
|---|
| | 147 | // moved shape is source of connection |
|---|
| | 148 | if (oldConnection.getSource () == m_child) |
|---|
| | 149 | { |
|---|
| | 150 | // get all targets |
|---|
| | 151 | Collection targets = oldConnection.getTargetTerminals(); |
|---|
| | 152 | for (Iterator itr2 = targets.iterator(); itr2.hasNext(); ) |
|---|
| | 153 | { |
|---|
| | 154 | // create new connection and execute if valid |
|---|
| | 155 | Shape target = (Shape) itr2.next(); |
|---|
| | 156 | createCommand = new EntryConnectionCreateCommand ((IDomainShape) target, 3); |
|---|
| | 157 | if (createCommand.canExecute()) |
|---|
| | 158 | { |
|---|
| | 159 | m_connAddCommands.add (createCommand); |
|---|
| | 160 | createCommand.execute(); |
|---|
| | 161 | } |
|---|
| | 162 | } |
|---|
| | 163 | } |
|---|
| | 164 | |
|---|
| | 165 | // moved shape is target of connection |
|---|
| | 166 | else if (oldConnection.getTarget () == m_child) |
|---|
| | 167 | { |
|---|
| | 168 | // create new connection and execute if valid |
|---|
| | 169 | Shape source = oldConnection.getSourceTerminal(); |
|---|
| | 170 | createCommand = new EntryConnectionCreateCommand ((IDomainShape) m_child, 3); |
|---|
| | 171 | if (createCommand.canExecute()) |
|---|
| | 172 | { |
|---|
| | 173 | m_connAddCommands.add (createCommand); |
|---|
| | 174 | createCommand.execute(); |
|---|
| | 175 | } |
|---|
| | 176 | } |
|---|
| 144 | 177 | |
|---|
| 145 | 178 | } |
|---|
| r1556 |
r1588 |
|
| 78 | 78 | { |
|---|
| 79 | 79 | super (i_outerSegment == null ? source : (IShape) target.getParent(), target, i_outerSegment); |
|---|
| 80 | | // m_outerSegment = i_outerSegment; |
|---|
| 81 | 80 | m_resourceShape = source; |
|---|
| 82 | 81 | m_domainShape = target; |
|---|
| r1585 |
r1588 |
|
| 150 | 150 | if (systemName.length() > 0) |
|---|
| 151 | 151 | { |
|---|
| 152 | | NewSystemWizard.createSystem (theNewProject, systemName); |
|---|
| | 152 | String srcPath = projPrefs.get (SEFPreferencePage.BASE_POLICY_PATH, ""); |
|---|
| | 153 | NewSystemWizard.createSystem (theNewProject, systemName, srcPath); |
|---|
| 153 | 154 | } |
|---|
| 154 | 155 | } |
|---|
| r1585 |
r1588 |
|
| 54 | 54 | extends WizardPage |
|---|
| 55 | 55 | { |
|---|
| 56 | | private Text txtSystemName = null; |
|---|
| 57 | | private Text refPolFileName; |
|---|
| 58 | | |
|---|
| 59 | | private Button refPolSearchButton; |
|---|
| 60 | | |
|---|
| 61 | | private IProject selected_project; |
|---|
| 62 | | private Vector availableProjects; |
|---|
| 63 | | |
|---|
| 64 | | private Combo comboProject; |
|---|
| | 56 | private Text m_txtSystemName = null; |
|---|
| | 57 | private Text m_refPolFileName; |
|---|
| | 58 | |
|---|
| | 59 | private Button m_refPolSearchButton; |
|---|
| | 60 | |
|---|
| | 61 | private IProject m_previous_selected_project; |
|---|
| | 62 | private IProject m_selected_project; |
|---|
| | 63 | private Vector m_availableProjects; |
|---|
| | 64 | |
|---|
| | 65 | private Combo m_comboProject; |
|---|
| | 66 | |
|---|
| | 67 | //Variable needed to prevent looping when default reference policy directory is given |
|---|
| | 68 | private boolean changed = false; |
|---|
| 65 | 69 | |
|---|
| 66 | 70 | private ModifyListener m_modifyText = new ModifyListener() |
|---|
| … | … | |
| 78 | 82 | setDescription(Messages.new_system_description); |
|---|
| 79 | 83 | |
|---|
| 80 | | selected_project = project; |
|---|
| | 84 | m_selected_project = project; |
|---|
| | 85 | |
|---|
| 81 | 86 | buildProjectList(); |
|---|
| 82 | | |
|---|
| 83 | 87 | } |
|---|
| 84 | 88 | |
|---|
| … | … | |
| 99 | 103 | label.setText(Messages.project_label); |
|---|
| 100 | 104 | |
|---|
| 101 | | comboProject = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY ); |
|---|
| | 105 | m_comboProject = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY ); |
|---|
| 102 | 106 | |
|---|
| 103 | 107 | //List of projects in framework |
|---|
| 104 | | for ( int j = 0; j < availableProjects.size(); j++ ) |
|---|
| 105 | | { |
|---|
| 106 | | comboProject.add(((IProject)availableProjects.elementAt(j)).getName()); |
|---|
| 107 | | if (selected_project != null |
|---|
| 108 | | && selected_project.equals(availableProjects.elementAt(j))) |
|---|
| | 108 | for ( int j = 0; j < m_availableProjects.size(); j++ ) |
|---|
| | 109 | { |
|---|
| | 110 | m_comboProject.add(((IProject)m_availableProjects.elementAt(j)).getName()); |
|---|
| | 111 | if (m_selected_project != null |
|---|
| | 112 | && m_selected_project.equals(m_availableProjects.elementAt(j))) |
|---|
| 109 | 113 | { |
|---|
| 110 | | comboProject.select(j); |
|---|
| | 114 | m_comboProject.select(j); |
|---|
| 111 | 115 | } |
|---|
| 112 | 116 | } |
|---|
| … | … | |
| 118 | 122 | label.setText (Messages.system_name_label); |
|---|
| 119 | 123 | |
|---|
| 120 | | txtSystemName = new Text(composite, SWT.BORDER | SWT.SINGLE); |
|---|
| | 124 | m_txtSystemName = new Text(composite, SWT.BORDER | SWT.SINGLE); |
|---|
| 121 | 125 | GridData sysData = new GridData(GridData.FILL_HORIZONTAL); |
|---|
| 122 | | txtSystemName.setLayoutData(sysData); |
|---|
| | 126 | m_txtSystemName.setLayoutData(sysData); |
|---|
| 123 | 127 | } |
|---|
| 124 | 128 | |
|---|
| … | … | |
| 128 | 132 | data.grabExcessHorizontalSpace = true; |
|---|
| 129 | 133 | data.horizontalSpan = 2; |
|---|
| 130 | | comboProject.setLayoutData(data); |
|---|
| 131 | | txtSystemName.setLayoutData(data); |
|---|
| | 134 | m_comboProject.setLayoutData(data); |
|---|
| | 135 | m_txtSystemName.setLayoutData(data); |
|---|
| 132 | 136 | |
|---|
| 133 | 137 | //GET THE LOCATION FOR THE REFERENCE POLICY----------------------------- |
|---|
| … | … | |
| 139 | 143 | refPolDirLabel.setLayoutData(new GridData()); |
|---|
| 140 | 144 | |
|---|
| 141 | | refPolFileName = new Text (dataArea, SWT.SINGLE | SWT.BORDER); |
|---|
| 142 | | refPolFileName.setLayoutData(new GridData (GridData.FILL_HORIZONTAL)); |
|---|
| 143 | | |
|---|
| 144 | | refPolSearchButton = new Button (dataArea, SWT.PUSH); |
|---|
| 145 | | refPolSearchButton.setText (Messages.browse); |
|---|
| 146 | | refPolSearchButton.setLayoutData(new GridData ()); |
|---|
| 147 | | refPolSearchButton.addSelectionListener (new SelectionAdapter () |
|---|
| | 145 | m_refPolFileName = new Text (dataArea, SWT.SINGLE | SWT.BORDER); |
|---|
| | 146 | m_refPolFileName.setLayoutData(new GridData (GridData.FILL_HORIZONTAL)); |
|---|
| | 147 | |
|---|
| | 148 | m_refPolSearchButton = new Button (dataArea, SWT.PUSH); |
|---|
| | 149 | m_refPolSearchButton.setText (Messages.browse); |
|---|
| | 150 | m_refPolSearchButton.setLayoutData(new GridData ()); |
|---|
| | 151 | m_refPolSearchButton.addSelectionListener (new SelectionAdapter () |
|---|
| 148 | 152 | |
|---|
| 149 | 153 | { |
|---|
| 150 | 154 | public void widgetSelected (SelectionEvent e) |
|---|
| 151 | 155 | { |
|---|
| 152 | | refPolFileName.setText (DialogUtil.DirectorySelector (getShell (),refPolFileName.getText ())); |
|---|
| | 156 | m_refPolFileName.setText (DialogUtil.DirectorySelector (getShell (),m_refPolFileName.getText ())); |
|---|
| 153 | 157 | } |
|---|
| 154 | 158 | }); |
|---|
| … | … | |
| 160 | 164 | theData.minimumWidth = 300; |
|---|
| 161 | 165 | theData.grabExcessHorizontalSpace = true; |
|---|
| 162 | | refPolFileName.setLayoutData(theData); |
|---|
| | 166 | m_refPolFileName.setLayoutData(theData); |
|---|
| 163 | 167 | |
|---|
| 164 | 168 | //Add listeners to the system name, project, and reference policy directory |
|---|
| 165 | | txtSystemName.addModifyListener(m_modifyText); |
|---|
| 166 | | comboProject.addModifyListener(m_modifyText); |
|---|
| 167 | | |
|---|
| 168 | | comboProject.addSelectionListener(new SelectionAdapter () { |
|---|
| | 169 | m_txtSystemName.addModifyListener(m_modifyText); |
|---|
| | 170 | m_comboProject.addModifyListener(m_modifyText); |
|---|
| | 171 | |
|---|
| | 172 | m_comboProject.addSelectionListener(new SelectionAdapter () { |
|---|
| 169 | 173 | public void widgetSelected(SelectionEvent e) { |
|---|
| 170 | 174 | } |
|---|
| 171 | 175 | }); |
|---|
| 172 | 176 | |
|---|
| 173 | | refPolFileName.addModifyListener(m_modifyText); |
|---|
| | 177 | m_refPolFileName.addModifyListener(m_modifyText); |
|---|
| 174 | 178 | PullPrefsFromWorkspace(); |
|---|
| 175 | 179 | |
|---|
| … | … | |
| 205 | 209 | IEclipsePreferences projPrefs = currProjScope.getNode (SEFramework_Plugin.PLUGIN_ID); |
|---|
| 206 | 210 | |
|---|
| 207 | | refPolFileName.setText(projPrefs.get(SEFPreferencePage.BASE_POLICY_PATH, null)); |
|---|
| | 211 | m_refPolFileName.setText(projPrefs.get(SEFPreferencePage.BASE_POLICY_PATH, null)); |
|---|
| 208 | 212 | } |
|---|
| 209 | 213 | } |
|---|
| … | … | |
| 217 | 221 | IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot (); |
|---|
| 218 | 222 | IProject projects[] = root.getProjects(); |
|---|
| 219 | | availableProjects = new Vector(); |
|---|
| | 223 | m_availableProjects = new Vector(); |
|---|
| 220 | 224 | |
|---|
| 221 | 225 | for (int i = 0; i < projects.length; i++) |
|---|
| … | … | |
| 229 | 233 | continue; |
|---|
| 230 | 234 | |
|---|
| 231 | | availableProjects.add(projects[i]); |
|---|
| | 235 | m_availableProjects.add(projects[i]); |
|---|
| 232 | 236 | } |
|---|
| 233 | 237 | catch (CoreException ce) { |
|---|
| … | … | |
| 235 | 239 | } |
|---|
| 236 | 240 | } |
|---|
| 237 | | |
|---|
| | 241 | |
|---|
| 238 | 242 | /** |
|---|
| 239 | 243 | * Verify that a project has been selected, a system name entered(and same name does not exist), and |
|---|
| … | … | |
| 243 | 247 | { |
|---|
| 244 | 248 | IProject selectedProj = getProject(); |
|---|
| | 249 | |
|---|
| | 250 | //Change the default reference policy directory displayed in wizard only if the selected project changes and is not null |
|---|
| | 251 | if ( selectedProj != null && selectedProj != m_previous_selected_project ) |
|---|
| | 252 | { |
|---|
| | 253 | |
|---|
| | 254 | IScopeContext currProjScope = new ProjectScope (selectedProj); |
|---|
| | 255 | IEclipsePreferences projPrefs = currProjScope.getNode (SEFramework_Plugin.PLUGIN_ID); |
|---|
| | 256 | |
|---|
| | 257 | m_previous_selected_project = selectedProj; |
|---|
| | 258 | |
|---|
| | 259 | //Changed is false when a new different project is selected and the Project's default reference policy directory |
|---|
| | 260 | //has not yet been displayed within text of Browsing for reference policy |
|---|
| | 261 | //Needed to prevent the looping that occurs with setText |
|---|
| | 262 | if (changed == false) |
|---|
| | 263 | { |
|---|
| | 264 | changed = true; |
|---|
| | 265 | m_refPolFileName.setText(projPrefs.get(SEFPreferencePage.BASE_POLICY_PATH, "")); |
|---|
| | 266 | } |
|---|
| | 267 | |
|---|
| | 268 | return; |
|---|
| | 269 | } |
|---|
| | 270 | |
|---|
| | 271 | //Change boolean back to false to indicate that reference policy directory has not changed |
|---|
| | 272 | changed = false; |
|---|
| | 273 | |
|---|
| | 274 | //changed = false; |
|---|
| 245 | 275 | String sysName = getSystemName(); |
|---|
| 246 | 276 | String refPolName = getRefPolFileName(); |
|---|
| … | … | |
| 302 | 332 | } |
|---|
| 303 | 333 | |
|---|
| 304 | | |
|---|
| 305 | 334 | //Check reference policy information ----------------------------------- |
|---|
| 306 | 335 | |
|---|
| … | … | |
| 343 | 372 | public String getSystemName() |
|---|
| 344 | 373 | { |
|---|
| 345 | | return txtSystemName.getText().trim(); |
|---|
| | 374 | return m_txtSystemName.getText().trim(); |
|---|
| 346 | 375 | } |
|---|
| 347 | 376 | |
|---|
| … | … | |
| 355 | 384 | { |
|---|
| 356 | 385 | //Get the system folder for the project with the i_systemName |
|---|
| 357 | | IFolder project_systemFolder = selected_project.getFolder("/src/selinux-policy-" + i_systemName); |
|---|
| | 386 | IFolder project_systemFolder = m_selected_project.getFolder("/src/selinux-policy-" + i_systemName); |
|---|
| 358 | 387 | |
|---|
| 359 | 388 | //if the system folder exists for project, return true |
|---|
| … | … | |
| 372 | 401 | public String getRefPolFileName() |
|---|
| 373 | 402 | { |
|---|
| 374 | | return refPolFileName.getText ().trim (); |
|---|
| | 403 | return m_refPolFileName.getText ().trim (); |
|---|
| 375 | 404 | } |
|---|
| 376 | 405 | |
|---|
| … | … | |
| 381 | 410 | public IProject getProject () |
|---|
| 382 | 411 | { |
|---|
| 383 | | int nSelected = comboProject.getSelectionIndex(); |
|---|
| 384 | | |
|---|
| 385 | | if (nSelected < 0 || nSelected > availableProjects.size() - 1) |
|---|
| | 412 | int nSelected = m_comboProject.getSelectionIndex(); |
|---|
| | 413 | |
|---|
| | 414 | if (nSelected < 0 || nSelected > m_availableProjects.size() - 1) |
|---|
| 386 | 415 | { |
|---|
| 387 | 416 | return null; |
|---|
| 388 | 417 | } |
|---|
| 389 | 418 | |
|---|
| 390 | | return (IProject) availableProjects.elementAt(nSelected); |
|---|
| | 419 | //Set the currently selected project and return |
|---|
| | 420 | m_selected_project = (IProject) m_availableProjects.elementAt(nSelected); |
|---|
| | 421 | return m_selected_project; |
|---|
| 391 | 422 | } |
|---|
| 392 | 423 | } |
|---|
| r1585 |
r1588 |
|
| 63 | 63 | |
|---|
| 64 | 64 | private NewSystemPage page1; |
|---|
| | 65 | |
|---|
| 65 | 66 | |
|---|
| 66 | 67 | private IProject m_selectedProject; |
|---|
| … | … | |
| 96 | 97 | } |
|---|
| 97 | 98 | |
|---|
| 98 | | static boolean createSystem (IProject project, String systemName) |
|---|
| | 99 | static boolean createSystem (IProject project, String systemName, final String refPolDir) |
|---|
| 99 | 100 | { |
|---|
| 100 | 101 | try |
|---|
| … | … | |
| 126 | 127 | |
|---|
| 127 | 128 | /* Copy all of reference policy into 'selinux-policy-<system name> */ |
|---|
| 128 | | populateRefPolicyFiles (systemDir); |
|---|
| | 129 | populateRefPolicyFiles (systemDir, refPolDir); |
|---|
| 129 | 130 | |
|---|
| 130 | 131 | /* |
|---|
| … | … | |
| 218 | 219 | final IProject project = page1.getProject (); |
|---|
| 219 | 220 | final String systemName = page1.getSystemName (); |
|---|
| 220 | | |
|---|
| 221 | | return createSystem (project, systemName); |
|---|
| | 221 | final String refPolDir = page1.getRefPolFileName(); |
|---|
| | 222 | return createSystem (project, systemName, refPolDir); |
|---|
| 222 | 223 | } |
|---|
| 223 | 224 | |
|---|
| … | … | |
| 254 | 255 | } |
|---|
| 255 | 256 | |
|---|
| 256 | | private final static void populateRefPolicyFiles (IFolder projectBaseDir) |
|---|
| | 257 | private final static void populateRefPolicyFiles (IFolder projectBaseDir, String refPolDir) |
|---|
| | 258 | //private void populateRefPolicyFiles (IFolder projectBaseDir) |
|---|
| 257 | 259 | // throws CoreException |
|---|
| 258 | 260 | { |
|---|
| … | … | |
| 261 | 263 | IEclipsePreferences projPrefs = currProjScope.getNode (SEFramework_Plugin.PLUGIN_ID); |
|---|
| 262 | 264 | |
|---|
| 263 | | String srcPath = projPrefs.get (SEFPreferencePage.BASE_POLICY_PATH, ""); |
|---|
| | 265 | //String srcPath = projPrefs.get (SEFPreferencePage.BASE_POLICY_PATH, ""); |
|---|
| | 266 | String srcPath = refPolDir; |
|---|
| 264 | 267 | if (srcPath.length() == 0) |
|---|
| 265 | 268 | return; |
|---|
Download in other formats:
* Generating other formats may take time.