diff options
author | afinkbein | 2009-01-14 23:35:01 +0000 |
---|---|---|
committer | afinkbein | 2009-01-14 23:35:01 +0000 |
commit | b9455e6425f408dbbd7c1491d48e0210179f7ad7 (patch) | |
tree | ca922e6ef542e21a4ba2dbd05e71a83db49727be | |
parent | 92a3ddf8a7337b74ea6e35c4f652015b4f79944f (diff) | |
download | org.eclipse.osee-b9455e6425f408dbbd7c1491d48e0210179f7ad7.tar.gz org.eclipse.osee-b9455e6425f408dbbd7c1491d48e0210179f7ad7.tar.xz org.eclipse.osee-b9455e6425f408dbbd7c1491d48e0210179f7ad7.zip |
7 files changed, 233 insertions, 0 deletions
diff --git a/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/.classpath b/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/.classpath new file mode 100644 index 00000000000..02159672985 --- /dev/null +++ b/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/.project b/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/.project new file mode 100644 index 00000000000..480fea62c6e --- /dev/null +++ b/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.osee.framework.ui.security</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/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/.settings/org.eclipse.jdt.core.prefs b/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..a8020f2dc2e --- /dev/null +++ b/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +#Fri Mar 28 14:00:57 GMT 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/META-INF/MANIFEST.MF b/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..a91d95b6313 --- /dev/null +++ b/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/META-INF/MANIFEST.MF @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Security Plug-in (Incubation) +Bundle-SymbolicName: org.eclipse.osee.framework.ui.security;singleton:=true +Bundle-Version: 0.4.0.qualifier +Require-Bundle: org.eclipse.osee.framework.jdk.core, + org.eclipse.osee.framework.plugin.core +Bundle-ActivationPolicy: lazy +Export-Package: org.eclipse.osee.framework.ui.security +Bundle-Vendor: Eclipse.org +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-Activator: org.eclipse.osee.framework.ui.security.internal.Activator +Import-Package: org.eclipse.core.runtime;version="3.4.0", + org.eclipse.osee.framework.logging, + org.osgi.framework;version="1.4.0" diff --git a/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/build.properties b/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/build.properties new file mode 100644 index 00000000000..aed1551c5ed --- /dev/null +++ b/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/build.properties @@ -0,0 +1,5 @@ +source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ src/
diff --git a/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/src/org/eclipse/osee/framework/ui/security/DESEncrypter.java b/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/src/org/eclipse/osee/framework/ui/security/DESEncrypter.java new file mode 100644 index 00000000000..4c86db54a86 --- /dev/null +++ b/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/src/org/eclipse/osee/framework/ui/security/DESEncrypter.java @@ -0,0 +1,150 @@ +/*******************************************************************************
+ * 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.security;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.NoSuchAlgorithmException;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.InvalidKeySpecException;
+import java.util.logging.Level;
+import javax.crypto.Cipher;
+import javax.crypto.CipherInputStream;
+import javax.crypto.CipherOutputStream;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+import javax.crypto.spec.PBEParameterSpec;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.security.internal.Activator;
+
+/**
+ * Encrypts and Decrypts inputStreams using DES and MD5 hashing.
+ *
+ * @author Jeff C. Phillips
+ */
+
+public class DESEncrypter {
+ private static final String KEY_FORMAT = "PBEWithMD5AndDES";
+ private static int iterationCount = 15;
+ private Cipher encryptCipher;
+ private Cipher decryptCipher;
+ private SecretKey key;
+
+ private static byte[] salt =
+ {(byte) 0x8E, (byte) 0x45, (byte) 0x77, (byte) 0x94, (byte) 0x21, (byte) 0x32, (byte) 0x90, (byte) 0x22};
+
+ /**
+ * This constructor will auto generate a secret key. Therefore, the getKey() method should be used to save off the
+ * key to decrypt.
+ *
+ * @throws InvalidKeySpecException
+ * @throws NoSuchAlgorithmException
+ */
+ public DESEncrypter() throws InvalidKeySpecException, NoSuchAlgorithmException {
+ this(GUID.generateGuidStr());
+ }
+
+ /**
+ * @param passPhrase
+ * @throws NoSuchAlgorithmException
+ * @throws InvalidKeySpecException
+ */
+ public DESEncrypter(String passPhrase) throws InvalidKeySpecException, NoSuchAlgorithmException {
+ this(SecretKeyFactory.getInstance(KEY_FORMAT).generateSecret(
+ new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount)));
+ }
+
+ /**
+ * @param key
+ */
+ public DESEncrypter(SecretKey key) {
+ this.key = key;
+
+ configureCipher(key);
+ }
+
+ /**
+ * @return
+ */
+ public SecretKey getKey() {
+ return key;
+ }
+
+ private void configureCipher(SecretKey key) {
+ try {
+ encryptCipher = Cipher.getInstance(key.getAlgorithm());
+ decryptCipher = Cipher.getInstance(key.getAlgorithm());
+
+ AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);
+
+ encryptCipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
+ decryptCipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, "", ex);
+ }
+ }
+
+ /**
+ * Encrypts inputStream and write data out to outputStream
+ *
+ * @param in in , InputStream
+ * @param out out, OutputStream
+ */
+ public void encrypt(InputStream in, OutputStream out) {
+ byte[] buffer = new byte[1024];
+ int index = 0;
+
+ try {
+ out = new CipherOutputStream(out, encryptCipher);
+
+ while ((index = in.read(buffer)) >= 0) {
+ out.write(buffer, 0, index);
+ }
+ in.close();
+ out.close();
+ } catch (java.io.IOException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, "", ex);
+ }
+ }
+
+ /**
+ * decrypts inputStream
+ *
+ * @param in , InputStream
+ * @return decrypted inputStream
+ */
+ public InputStream decrypt(InputStream in) {
+ in = new CipherInputStream(in, decryptCipher);
+ return in;
+ }
+
+ /**
+ * @param in - inputStream
+ * @param out - outputStream
+ */
+ public void decrypt(InputStream in, OutputStream out) {
+ byte[] buffer = new byte[1024];
+ int index = 0;
+
+ try {
+ in = new CipherInputStream(in, decryptCipher);
+
+ while ((index = in.read(buffer)) >= 0) {
+ out.write(buffer, 0, index);
+ }
+ out.close();
+ } catch (java.io.IOException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, "", ex);
+ }
+ }
+}
diff --git a/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/src/org/eclipse/osee/framework/ui/security/internal/Activator.java b/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/src/org/eclipse/osee/framework/ui/security/internal/Activator.java new file mode 100644 index 00000000000..bf4e3216871 --- /dev/null +++ b/MS_0.6.0_20090114/org.eclipse.osee.framework.ui.security/src/org/eclipse/osee/framework/ui/security/internal/Activator.java @@ -0,0 +1,16 @@ +/*
+ * Created on Nov 15, 2008
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.ui.security.internal;
+
+import org.eclipse.core.runtime.Plugin;
+
+/**
+ * @author Ryan D. Brooks
+ *
+ */
+public class Activator extends Plugin {
+
+}
|