Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorafinkbein2008-12-01 16:55:16 +0000
committerafinkbein2008-12-01 16:55:16 +0000
commitd09f61cb89366564eefa78c0f5872b838a45a3d9 (patch)
treea3cdda8cd0714a9170be0acf618b83ea1bc77df9
parentd63b49b85552e7b173ac1716b0782b2e1973767f (diff)
downloadorg.eclipse.osee-d09f61cb89366564eefa78c0f5872b838a45a3d9.tar.gz
org.eclipse.osee-d09f61cb89366564eefa78c0f5872b838a45a3d9.tar.xz
org.eclipse.osee-d09f61cb89366564eefa78c0f5872b838a45a3d9.zip
-rw-r--r--org.eclipse.osee.framework.ui.encrypter/.classpath7
-rw-r--r--org.eclipse.osee.framework.ui.encrypter/.project28
-rw-r--r--org.eclipse.osee.framework.ui.encrypter/META-INF/MANIFEST.MF16
-rw-r--r--org.eclipse.osee.framework.ui.encrypter/build.properties6
-rw-r--r--org.eclipse.osee.framework.ui.encrypter/images/lock.gifbin0 -> 626 bytes
-rw-r--r--org.eclipse.osee.framework.ui.encrypter/images/sample.gifbin0 -> 983 bytes
-rw-r--r--org.eclipse.osee.framework.ui.encrypter/plugin.xml20
-rw-r--r--org.eclipse.osee.framework.ui.encrypter/src/org/eclipse/osee/framework/ui/encrypter/EncrypterAction.java77
-rw-r--r--org.eclipse.osee.framework.ui.encrypter/src/org/eclipse/osee/framework/ui/encrypter/EncrypterPlugin.java34
-rw-r--r--org.eclipse.osee.framework.ui.encrypter/src/org/eclipse/osee/framework/ui/encrypter/EncrypterView.java248
10 files changed, 436 insertions, 0 deletions
diff --git a/org.eclipse.osee.framework.ui.encrypter/.classpath b/org.eclipse.osee.framework.ui.encrypter/.classpath
new file mode 100644
index 00000000000..8a8f1668cdc
--- /dev/null
+++ b/org.eclipse.osee.framework.ui.encrypter/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.osee.framework.ui.encrypter/.project b/org.eclipse.osee.framework.ui.encrypter/.project
new file mode 100644
index 00000000000..62517fafa79
--- /dev/null
+++ b/org.eclipse.osee.framework.ui.encrypter/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.framework.ui.encrypter</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.osee.framework.ui.encrypter/META-INF/MANIFEST.MF b/org.eclipse.osee.framework.ui.encrypter/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..8a146e2c7f6
--- /dev/null
+++ b/org.eclipse.osee.framework.ui.encrypter/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Encrypter Plug-in (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.framework.ui.encrypter;singleton:=true
+Bundle-Version: 0.4.0.qualifier
+Bundle-ClassPath: encrypter.jar
+Bundle-Activator: org.eclipse.osee.framework.ui.encrypter.EncrypterPlugin
+Bundle-Vendor: Eclipse.org
+Export-Package: org.eclipse.osee.framework.ui.encrypter
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.osee.framework.ui.security,
+ org.eclipse.osee.framework.ui.skynet,
+ org.eclipse.osee.framework.ui.plugin,
+ org.eclipse.core.runtime
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/org.eclipse.osee.framework.ui.encrypter/build.properties b/org.eclipse.osee.framework.ui.encrypter/build.properties
new file mode 100644
index 00000000000..3a79aa6ce9a
--- /dev/null
+++ b/org.eclipse.osee.framework.ui.encrypter/build.properties
@@ -0,0 +1,6 @@
+source.encrypter.jar = src/
+output.encrypter.jar = bin/
+bin.includes = plugin.xml,\
+ encrypter.jar,\
+ images/,\
+ META-INF/
diff --git a/org.eclipse.osee.framework.ui.encrypter/images/lock.gif b/org.eclipse.osee.framework.ui.encrypter/images/lock.gif
new file mode 100644
index 00000000000..68fd6cf39ca
--- /dev/null
+++ b/org.eclipse.osee.framework.ui.encrypter/images/lock.gif
Binary files differ
diff --git a/org.eclipse.osee.framework.ui.encrypter/images/sample.gif b/org.eclipse.osee.framework.ui.encrypter/images/sample.gif
new file mode 100644
index 00000000000..34fb3c9d8cb
--- /dev/null
+++ b/org.eclipse.osee.framework.ui.encrypter/images/sample.gif
Binary files differ
diff --git a/org.eclipse.osee.framework.ui.encrypter/plugin.xml b/org.eclipse.osee.framework.ui.encrypter/plugin.xml
new file mode 100644
index 00000000000..49d15d94baf
--- /dev/null
+++ b/org.eclipse.osee.framework.ui.encrypter/plugin.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.views">
+ <category
+ name="Encrypter"
+ id="encrypter">
+ </category>
+ <view
+ name="Encrypter"
+ icon="images/lock.gif"
+ category="osee.jdk.core.category"
+ class="org.eclipse.osee.framework.ui.encrypter.EncrypterView"
+ id="osee.encrypter.EncrypterView">
+ </view>
+ </extension>
+
+</plugin>
diff --git a/org.eclipse.osee.framework.ui.encrypter/src/org/eclipse/osee/framework/ui/encrypter/EncrypterAction.java b/org.eclipse.osee.framework.ui.encrypter/src/org/eclipse/osee/framework/ui/encrypter/EncrypterAction.java
new file mode 100644
index 00000000000..e790efa3709
--- /dev/null
+++ b/org.eclipse.osee.framework.ui.encrypter/src/org/eclipse/osee/framework/ui/encrypter/EncrypterAction.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.ui.encrypter;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Our sample action implements workbench action delegate. The action proxy will be created by the workbench and shown
+ * in the UI. When the user tries to use the action, this delegate will be created and execution will be delegated to
+ * it.
+ *
+ * @see IWorkbenchWindowActionDelegate
+ */
+public class EncrypterAction implements IWorkbenchWindowActionDelegate {
+
+ /**
+ * The constructor.
+ */
+ public EncrypterAction() {
+ }
+
+ /**
+ * The action has been activated. The argument of the method represents the 'real' action sitting in the workbench
+ * UI.
+ *
+ * @see IWorkbenchWindowActionDelegate#run
+ */
+ public void run(IAction action) {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ try {
+ page.showView(EncrypterView.VIEW_ID);
+ } catch (PartInitException e1) {
+ MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Launch Error",
+ "Couldn't Launch OSEE Encrypter View " + e1.getMessage());
+ }
+ }
+
+ /**
+ * Selection in the workbench has been changed. We can change the state of the 'real' action here if we want, but
+ * this can only happen after the delegate has been created.
+ *
+ * @see IWorkbenchWindowActionDelegate#selectionChanged
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+
+ /**
+ * We can use this method to dispose of any system resources we previously allocated.
+ *
+ * @see IWorkbenchWindowActionDelegate#dispose
+ */
+ public void dispose() {
+ }
+
+ /**
+ * We will cache window object in order to be able to provide parent shell for the message dialog.
+ *
+ * @see IWorkbenchWindowActionDelegate#init
+ */
+ public void init(IWorkbenchWindow window) {
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.osee.framework.ui.encrypter/src/org/eclipse/osee/framework/ui/encrypter/EncrypterPlugin.java b/org.eclipse.osee.framework.ui.encrypter/src/org/eclipse/osee/framework/ui/encrypter/EncrypterPlugin.java
new file mode 100644
index 00000000000..3cdf664a4cb
--- /dev/null
+++ b/org.eclipse.osee.framework.ui.encrypter/src/org/eclipse/osee/framework/ui/encrypter/EncrypterPlugin.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.ui.encrypter;
+
+import org.eclipse.osee.framework.ui.plugin.OseeUiActivator;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class EncrypterPlugin extends OseeUiActivator {
+
+ //The shared instance.
+ private static EncrypterPlugin plugin;
+
+ /**
+ * The constructor.
+ */
+ public EncrypterPlugin() {
+ plugin = this;
+ }
+
+ public static EncrypterPlugin getInstance() {
+ return plugin;
+ }
+
+}
diff --git a/org.eclipse.osee.framework.ui.encrypter/src/org/eclipse/osee/framework/ui/encrypter/EncrypterView.java b/org.eclipse.osee.framework.ui.encrypter/src/org/eclipse/osee/framework/ui/encrypter/EncrypterView.java
new file mode 100644
index 00000000000..42ad211343f
--- /dev/null
+++ b/org.eclipse.osee.framework.ui.encrypter/src/org/eclipse/osee/framework/ui/encrypter/EncrypterView.java
@@ -0,0 +1,248 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.ui.encrypter;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osee.framework.ui.security.DESEncrypter;
+import org.eclipse.osee.framework.ui.skynet.ats.IActionable;
+import org.eclipse.osee.framework.ui.skynet.widgets.dialog.EntryDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.program.Program;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * @author Jeff C. Phillips
+ */
+public class EncrypterView extends ViewPart implements IActionable {
+
+ public static final String VIEW_ID = "org.eclipse.osee.framework.ui.encrypter.EncrypterView";
+ private DESEncrypter encrypter;
+ private Text applicationPath;
+ private File input;
+ private File encrypt;
+ private File decrypt;
+ private String pathResults;
+
+ /**
+ * The constructor.
+ */
+ public EncrypterView() {
+ pathResults = "";
+ }
+
+ /**
+ * This is a callback that will allow us to create the viewer and initialize it.
+ */
+ public void createPartControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout(8, false);
+ composite.setLayout(layout);
+
+ Label description = new Label(composite, SWT.NONE);
+ description.setText("Encrypt / Decrypt a file.");
+ GridData gridData = new GridData();
+ gridData.horizontalSpan = 8;
+ description.setLayoutData(gridData);
+
+ applicationPath = new Text(composite, SWT.BORDER);
+ gridData = new GridData();
+ gridData.widthHint = 450;
+ gridData.horizontalSpan = 6;
+ applicationPath.setLayoutData(gridData);
+
+ Button browseButton = new Button(composite, SWT.PUSH);
+ browseButton.setText("Browse");
+
+ Button editButton = new Button(composite, SWT.PUSH);
+ editButton.setText("Edit");
+
+ Button encryptButton = new Button(composite, SWT.PUSH);
+ encryptButton.setText("Encrypt");
+
+ Button decryptButton = new Button(composite, SWT.PUSH);
+ decryptButton.setText("Decrypt");
+
+ browseButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ browseForFile();
+ }
+ });
+
+ editButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ editFile();
+ }
+ });
+
+ encryptButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ encrypt();
+ }
+ });
+
+ decryptButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ decrypt();
+ }
+ });
+ }
+
+ protected void editFile() {
+ if (!pathResults.equals("")) Program.launch(pathResults);
+ }
+
+ /**
+ * Decrypts a file
+ */
+ protected void decrypt() {
+ String password = getPassWord();
+ try {
+
+ if (password.equals("")) {
+ invalidPassPhraseMsg();
+ } else if (password.equals("Canceled")) {
+ return;
+ } else {
+ if (pathResults.length() != 0) {
+ encrypter = new DESEncrypter(password);
+ encrypter.decrypt(new FileInputStream(input), new FileOutputStream(decrypt));
+ cleanUpFiles(decrypt, input);
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Encrypts a file
+ */
+ protected void encrypt() {
+ String password = getPassWord();
+ try {
+
+ if (password.equals("")) {
+ invalidPassPhraseMsg();
+ } else if (password.equals("Canceled")) {
+ return;
+ } else {
+ if (pathResults.length() != 0) {
+ encrypter = new DESEncrypter(password);
+ encrypter.encrypt(new FileInputStream(input), new FileOutputStream(encrypt));
+ cleanUpFiles(encrypt, input);
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private void browseForFile() {
+ FileDialog fileDialog = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ pathResults = fileDialog.open();
+
+ if ((pathResults != null)) {
+ applicationPath.setText(pathResults);
+ input = new File(pathResults);
+ encrypt = new File(input.getPath().substring(0, input.getPath().lastIndexOf("\\") + 1) + "encrpyt");
+ decrypt = new File(input.getPath().substring(0, input.getPath().lastIndexOf("\\") + 1) + "descrypt");
+ } else {
+ pathResults = "";
+ }
+ }
+
+ /**
+ * copies source to destination file and then deletes source file
+ */
+ private void cleanUpFiles(File source, File destination) {
+ try {
+ FileInputStream streamIn = new FileInputStream(source);
+ FileOutputStream streamOut = new FileOutputStream(destination);
+
+ int c;
+ try {
+ while ((c = streamIn.read()) != -1) {
+ streamOut.write(c);
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ } finally {
+ try {
+ streamIn.close();
+ streamOut.close();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ source.delete();
+ } catch (FileNotFoundException ex1) {
+ ex1.printStackTrace();
+ }
+ }
+
+ /**
+ * @return String, pass phrase
+ */
+ private String getPassWord() {
+ String passWord = "";
+ int result = -1;
+ EntryDialog ed =
+ new EntryDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Pass Phrase", null,
+ "Enter pass phrase", MessageDialog.QUESTION, new String[] {"Ok", "Cancel"}, 0);
+ result = ed.open();
+
+ if (result == 0) {
+ if (!ed.getEntry().equals("")) {
+ passWord = ed.getEntry();
+ }
+ } else {
+ passWord = "Canceled";
+ }
+ return passWord;
+ }
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+ }
+
+ /**
+ * displays invalid pass phrase message
+ */
+ private void invalidPassPhraseMsg() {
+ MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Pass phrase Error",
+ "Invalid Pass phrase.");
+ }
+
+ public String getActionDescription() {
+ return "";
+ }
+} \ No newline at end of file

Back to the top