Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2012-01-10 16:26:16 +0000
committerJohn Arthorne2012-01-10 16:26:16 +0000
commit141a5960077ceb94e56327de6dc5e16ff59e7a3b (patch)
tree5037e6e6b72f9ac1a0a90688fee57c852e3b6240
parent203bebb52f006138064c1f7333245ab0ebaf185c (diff)
downloadeclipse.platform.runtime-141a5960077ceb94e56327de6dc5e16ff59e7a3b.tar.gz
eclipse.platform.runtime-141a5960077ceb94e56327de6dc5e16ff59e7a3b.tar.xz
eclipse.platform.runtime-141a5960077ceb94e56327de6dc5e16ff59e7a3b.zip
Bug 368253 - remove org.eclipse.core.runtime.compatibility.auth dependency from org.eclipse.core.runtimev20120110-1626v20120110v20110112I20120110-2200
-rw-r--r--bundles/org.eclipse.core.runtime.compatibility.auth/src/org/eclipse/core/internal/runtime/auth/Messages.java3
-rw-r--r--bundles/org.eclipse.core.runtime.compatibility.auth/src/org/eclipse/core/internal/runtime/auth/messages.properties3
-rw-r--r--bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/AuthorizationHandler.java (renamed from bundles/org.eclipse.core.runtime.compatibility.auth/src/org/eclipse/core/internal/runtime/auth/AuthorizationHandler.java)158
-rw-r--r--bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java3
-rw-r--r--bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Messages.java3
-rw-r--r--bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/messages.properties3
-rw-r--r--bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java48
-rw-r--r--tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF1
-rw-r--r--tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/AllTests.java5
-rw-r--r--tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/AuthorizationDatabaseTest.java178
-rw-r--r--tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/CipherStreamsTest.java95
-rw-r--r--tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/CipherTest.java118
12 files changed, 139 insertions, 479 deletions
diff --git a/bundles/org.eclipse.core.runtime.compatibility.auth/src/org/eclipse/core/internal/runtime/auth/Messages.java b/bundles/org.eclipse.core.runtime.compatibility.auth/src/org/eclipse/core/internal/runtime/auth/Messages.java
index d3bae1e6a..732bb8d15 100644
--- a/bundles/org.eclipse.core.runtime.compatibility.auth/src/org/eclipse/core/internal/runtime/auth/Messages.java
+++ b/bundles/org.eclipse.core.runtime.compatibility.auth/src/org/eclipse/core/internal/runtime/auth/Messages.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others. All rights reserved. This
+ * Copyright (c) 2005, 2012 IBM Corporation and others. 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
@@ -16,7 +16,6 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.core.internal.runtime.auth.messages"; //$NON-NLS-1$
public static String meta_authFormatChanged;
- public static String meta_keyringFileAlreadySpecified;
public static String meta_unableToReadAuthorization;
public static String meta_unableToWriteAuthorization;
diff --git a/bundles/org.eclipse.core.runtime.compatibility.auth/src/org/eclipse/core/internal/runtime/auth/messages.properties b/bundles/org.eclipse.core.runtime.compatibility.auth/src/org/eclipse/core/internal/runtime/auth/messages.properties
index da5d3dad4..ba0a7368c 100644
--- a/bundles/org.eclipse.core.runtime.compatibility.auth/src/org/eclipse/core/internal/runtime/auth/messages.properties
+++ b/bundles/org.eclipse.core.runtime.compatibility.auth/src/org/eclipse/core/internal/runtime/auth/messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2006 IBM Corporation and others.
+# Copyright (c) 2006, 2012 IBM Corporation and others.
# 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
@@ -11,6 +11,5 @@
auth_notAvailable = Authorization infrastructure (org.eclipse.core.runtime.compatibility.auth) not installed.
meta_authFormatChanged = The platform authorization database file format has changed. Cached authorization information will be lost.
-meta_keyringFileAlreadySpecified = The keyring file location has already been specified {0}.
meta_unableToReadAuthorization = Unable to read authorization database: {0}.
meta_unableToWriteAuthorization = Unable to write to authorization database: {0}.
diff --git a/bundles/org.eclipse.core.runtime.compatibility.auth/src/org/eclipse/core/internal/runtime/auth/AuthorizationHandler.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/AuthorizationHandler.java
index e4629da78..35c6efd66 100644
--- a/bundles/org.eclipse.core.runtime.compatibility.auth/src/org/eclipse/core/internal/runtime/auth/AuthorizationHandler.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/AuthorizationHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2012 IBM Corporation and others.
* 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
@@ -8,72 +8,134 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.core.internal.runtime.auth;
+package org.eclipse.core.internal.runtime;
+
+import java.lang.reflect.InvocationTargetException;
import java.io.File;
+import java.lang.reflect.*;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
-import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.*;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
-// This class factors out the management of the .keyring location
+/**
+ * This class factors out the management of the .keyring location, and manages
+ * the case where the legacy keyring implementation is not present (i.,e 4.0 and beyond).
+ * @since 3.2
+ */
public class AuthorizationHandler {
/* package */static final String F_KEYRING = ".keyring"; //$NON-NLS-1$
//Authorization related informations
- private static AuthorizationDatabase keyring = null;
private static long keyringTimeStamp;
- private static String keyringFile = null;
private static String password = ""; //$NON-NLS-1$
+ private static String keyringFile = null;
+
+ private static Object keyring = null;
+ //reflective access to legacy authentication implementation
+ private static Class authClass;
+ private static boolean authNotAvailableLogged = false;
+
+ /**
+ * Get the legacy class that implemented the authorization API. Return <code>null</code>
+ * if the legacy implementation is not present.
+ */
+ private static Class getAuthClass() {
+ if (authClass == null) {
+ try {
+ authClass = Class.forName("org.eclipse.core.internal.runtime.auth.AuthorizationDatabase"); //$NON-NLS-1$
+ } catch (ClassNotFoundException e) {
+ logAuthNotAvailable(e);
+ }
+ }
+ return authClass;
+ }
+
+ private static void logAuthNotAvailable(Throwable e) {
+ if (authNotAvailableLogged)
+ return;
+ authNotAvailableLogged = true;
+ RuntimeLog.log(new Status(IStatus.WARNING, Platform.PI_RUNTIME, 0, Messages.auth_notAvailable, e));
+ }
/**
* Opens the password database (if any) initially provided to the platform at startup.
+ * Returns <code>true</code> if the authentication implementation was successfully initialized, and
+ * <code>false</code> if no authentication implementation is available.
*/
- private static void loadKeyring() throws CoreException {
+ private static boolean loadKeyring() throws CoreException {
+ if (getAuthClass() == null)
+ return false;
if (keyring != null && new File(keyringFile).lastModified() == keyringTimeStamp)
- return;
+ return true;
if (keyringFile == null) {
ServiceReference[] refs = null;
try {
- refs = Activator.getContext().getServiceReferences(Location.class.getName(), Location.CONFIGURATION_FILTER);
+ refs = PlatformActivator.getContext().getServiceReferences(Location.class.getName(), Location.CONFIGURATION_FILTER);
if (refs == null || refs.length == 0)
- return;
+ return true;
} catch (InvalidSyntaxException e) {
// ignore this. It should never happen as we have tested the above format.
- return;
+ return true;
}
- Location configurationLocation = (Location) Activator.getContext().getService(refs[0]);
+ Location configurationLocation = (Location) PlatformActivator.getContext().getService(refs[0]);
if (configurationLocation == null)
- return;
+ return true;
File file = new File(configurationLocation.getURL().getPath() + "/org.eclipse.core.runtime"); //$NON-NLS-1$
- Activator.getContext().ungetService(refs[0]);
+ PlatformActivator.getContext().ungetService(refs[0]);
file = new File(file, F_KEYRING);
keyringFile = file.getAbsolutePath();
}
try {
- keyring = new AuthorizationDatabase(keyringFile, password);
- } catch (CoreException e) {
- Activator.log(e.getStatus());
+ Constructor constructor = authClass.getConstructor(new Class[] {String.class, String.class});
+ keyring = constructor.newInstance(new Object[] {keyringFile, password});
+ } catch (Exception e) {
+ log(e);
}
if (keyring == null) {
//try deleting the file and loading again - format may have changed
new java.io.File(keyringFile).delete();
- keyring = new AuthorizationDatabase(keyringFile, password);
- //don't bother logging a second failure and let it flows to the callers
+ try {
+ Constructor constructor = authClass.getConstructor(new Class[] {String.class, String.class});
+ keyring = constructor.newInstance(new Object[] {keyringFile, password});
+ } catch (Exception e) {
+ //don't bother logging a second failure and let it flows to the callers
+ }
}
keyringTimeStamp = new File(keyringFile).lastModified();
+ return true;
+ }
+
+ /**
+ * Propagate invocation target exceptions but log anything else
+ */
+ private static void log(Exception e) throws CoreException {
+ if (e instanceof InvocationTargetException) {
+ Throwable cause = ((InvocationTargetException) e).getTargetException();
+ if (cause instanceof CoreException) {
+ throw (CoreException) cause;
+ }
+ }
+ //otherwise it is a reflective error
+ logAuthNotAvailable(e);
}
-
+
/**
* Saves the keyring file to disk.
* @exception CoreException
*/
private static void saveKeyring() throws CoreException {
- keyring.save();
+ try {
+ Method method = authClass.getMethod("save", new Class[0]); //$NON-NLS-1$
+ method.invoke(keyring, null);
+ } catch (Exception e) {
+ log(e);
+ }
keyringTimeStamp = new File(keyringFile).lastModified();
}
@@ -105,8 +167,14 @@ public class AuthorizationHandler {
* XXX Move to a plug-in to be defined (JAAS plugin).
*/
public static synchronized void addAuthorizationInfo(URL serverUrl, String realm, String authScheme, Map info) throws CoreException {
- loadKeyring();
- keyring.addAuthorizationInfo(serverUrl, realm, authScheme, new HashMap(info));
+ if (!loadKeyring())
+ return;
+ try {
+ Method method = authClass.getMethod("addAuthorizationInfo", new Class[] {URL.class, String.class, String.class, Map.class}); //$NON-NLS-1$
+ method.invoke(keyring, new Object[] {serverUrl, realm, authScheme, new HashMap(info)});
+ } catch (Exception e) {
+ log(e);
+ }
saveKeyring();
}
@@ -129,8 +197,14 @@ public class AuthorizationHandler {
* XXX Move to a plug-in to be defined (JAAS plugin).
*/
public static synchronized void addProtectionSpace(URL resourceUrl, String realm) throws CoreException {
- loadKeyring();
- keyring.addProtectionSpace(resourceUrl, realm);
+ if (!loadKeyring())
+ return;
+ try {
+ Method method = authClass.getMethod("addProtectionSpace", new Class[] {URL.class, String.class}); //$NON-NLS-1$
+ method.invoke(keyring, new Object[] {resourceUrl, realm});
+ } catch (Exception e) {
+ log(e);
+ }
saveKeyring();
}
@@ -156,8 +230,14 @@ public class AuthorizationHandler {
* XXX Move to a plug-in to be defined (JAAS plugin).
*/
public static synchronized void flushAuthorizationInfo(URL serverUrl, String realm, String authScheme) throws CoreException {
- loadKeyring();
- keyring.flushAuthorizationInfo(serverUrl, realm, authScheme);
+ if (!loadKeyring())
+ return;
+ try {
+ Method method = authClass.getMethod("flushAuthorizationInfo", new Class[] {URL.class, String.class, String.class}); //$NON-NLS-1$
+ method.invoke(keyring, new Object[] {serverUrl, realm, authScheme});
+ } catch (Exception e) {
+ log(e);
+ }
saveKeyring();
}
@@ -182,8 +262,14 @@ public class AuthorizationHandler {
public static synchronized Map getAuthorizationInfo(URL serverUrl, String realm, String authScheme) {
Map info = null;
try {
- loadKeyring();
- info = keyring.getAuthorizationInfo(serverUrl, realm, authScheme);
+ if (!loadKeyring())
+ return null;
+ try {
+ Method method = authClass.getMethod("getAuthorizationInfo", new Class[] {URL.class, String.class, String.class}); //$NON-NLS-1$
+ info = (Map) method.invoke(keyring, new Object[] {serverUrl, realm, authScheme});
+ } catch (Exception e) {
+ log(e);
+ }
} catch (CoreException e) {
// The error has already been logged in loadKeyring()
}
@@ -202,17 +288,23 @@ public class AuthorizationHandler {
*/
public static synchronized String getProtectionSpace(URL resourceUrl) {
try {
- loadKeyring();
+ if (!loadKeyring())
+ return null;
+ try {
+ Method method = authClass.getMethod("getProtectionSpace", new Class[] {URL.class}); //$NON-NLS-1$
+ return (String)method.invoke(keyring, new Object[] {resourceUrl});
+ } catch (Exception e) {
+ log(e);
+ }
} catch (CoreException e) {
// The error has already been logged in loadKeyring()
- return null;
}
- return keyring.getProtectionSpace(resourceUrl);
+ return null;
}
public static void setKeyringFile(String file) {
if (keyringFile != null)
- throw new IllegalStateException(NLS.bind(Messages.meta_keyringFileAlreadySpecified, keyringFile));
+ throw new IllegalStateException(NLS.bind(Messages.auth_alreadySpecified, keyringFile));
keyringFile = file;
}
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
index e347eb702..8ace8e8a6 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* 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
@@ -20,7 +20,6 @@ import org.eclipse.core.internal.preferences.exchange.ILegacyPreferences;
import org.eclipse.core.internal.preferences.exchange.IProductPreferencesService;
import org.eclipse.core.internal.preferences.legacy.InitLegacyPreferences;
import org.eclipse.core.internal.preferences.legacy.ProductPreferencesService;
-import org.eclipse.core.internal.runtime.auth.AuthorizationHandler;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.core.runtime.preferences.IPreferencesService;
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Messages.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Messages.java
index 28e178512..88ffac9c1 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Messages.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2012 IBM Corporation and others.
* 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
@@ -17,6 +17,7 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.core.internal.runtime.messages"; //$NON-NLS-1$
// authorization
+ public static String auth_alreadySpecified;
public static String auth_notAvailable;
// line separator platforms
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/messages.properties b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/messages.properties
index af73a713c..199c21a5e 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/messages.properties
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2009 IBM Corporation and others.
+# Copyright (c) 2000, 2012 IBM Corporation and others.
# 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
@@ -11,6 +11,7 @@
### Runtime plugin messages
### Authorization
+auth_alreadySpecified=The keyring file location has already been specified {0}.
auth_notAvailable = Authorization infrastructure (org.eclipse.core.runtime.compatibility.auth) not installed.
### metadata
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java
index dcbc2a7b4..ddad65d67 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* 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
@@ -17,7 +17,6 @@ import java.lang.reflect.Method;
import java.net.URL;
import java.util.*;
import org.eclipse.core.internal.runtime.*;
-import org.eclipse.core.internal.runtime.auth.AuthorizationHandler;
import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.Job;
@@ -439,7 +438,6 @@ public final class Platform {
private static final String LINE_SEPARATOR_VALUE_LF = "\n"; //$NON-NLS-1$
private static final String LINE_SEPARATOR_VALUE_CRLF = "\r\n"; //$NON-NLS-1$
- private static boolean authNotAvailableLogged = false;
/**
* Private constructor to block instance creation.
@@ -480,12 +478,7 @@ public final class Platform {
* Consider using <code>ISecurePreferences#put(String, String, boolean)</code> as a replacement of this method.
*/
public static void addAuthorizationInfo(URL serverUrl, String realm, String authScheme, Map info) throws CoreException {
- try {
- AuthorizationHandler.addAuthorizationInfo(serverUrl, realm, authScheme, info);
- } catch (NoClassDefFoundError e) {
- // The authorization code is not available so just log and continue
- logAuthNotAvailable(e);
- }
+ AuthorizationHandler.addAuthorizationInfo(serverUrl, realm, authScheme, info);
}
/**
@@ -526,12 +519,7 @@ public final class Platform {
* for data access and modifications.
*/
public static void addProtectionSpace(URL resourceUrl, String realm) throws CoreException {
- try {
- AuthorizationHandler.addProtectionSpace(resourceUrl, realm);
- } catch (NoClassDefFoundError e) {
- // The authorization code is not available so just log and continue
- logAuthNotAvailable(e);
- }
+ AuthorizationHandler.addProtectionSpace(resourceUrl, realm);
}
/**
@@ -593,19 +581,7 @@ public final class Platform {
* Consider using <code>ISecurePreferences#clear()</code> as a replacement of this method.
*/
public static void flushAuthorizationInfo(URL serverUrl, String realm, String authScheme) throws CoreException {
- try {
- AuthorizationHandler.flushAuthorizationInfo(serverUrl, realm, authScheme);
- } catch (NoClassDefFoundError e) {
- // The authorization code is not available so just log and continue
- logAuthNotAvailable(e);
- }
- }
-
- private static void logAuthNotAvailable(Throwable e) {
- if(authNotAvailableLogged)
- return;
- authNotAvailableLogged = true;
- InternalPlatform.getDefault().log(new Status(IStatus.WARNING, Platform.PI_RUNTIME, 0, Messages.auth_notAvailable, e));
+ AuthorizationHandler.flushAuthorizationInfo(serverUrl, realm, authScheme);
}
/**
@@ -642,13 +618,7 @@ public final class Platform {
* Consider using <code>ISecurePreferences#get(String, String)</code> as a replacement of this method.
*/
public static Map getAuthorizationInfo(URL serverUrl, String realm, String authScheme) {
- try {
- return AuthorizationHandler.getAuthorizationInfo(serverUrl, realm, authScheme);
- } catch (NoClassDefFoundError e) {
- // The authorization code is not available so just log and continue
- logAuthNotAvailable(e);
- }
- return null;
+ return AuthorizationHandler.getAuthorizationInfo(serverUrl, realm, authScheme);
}
/**
@@ -828,13 +798,7 @@ public final class Platform {
* for data access and modifications.
*/
public static String getProtectionSpace(URL resourceUrl) {
- try {
- return AuthorizationHandler.getProtectionSpace(resourceUrl);
- } catch (NoClassDefFoundError e) {
- // The authorization code is not available so just log and continue
- logAuthNotAvailable(e);
- }
- return null;
+ return AuthorizationHandler.getProtectionSpace(resourceUrl);
}
/**
diff --git a/tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF b/tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF
index 6a3216bf3..dd974f86d 100644
--- a/tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF
@@ -18,7 +18,6 @@ Export-Package: org.eclipse.core.tests.internal.preferences,
Require-Bundle: org.eclipse.core.tests.harness;bundle-version="3.4.0",
org.junit,
org.eclipse.test.performance;resolution:=optional,
- org.eclipse.core.runtime.compatibility.auth,
org.eclipse.core.runtime.compatibility
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/AllTests.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/AllTests.java
index daeaac28c..ae466e6cd 100644
--- a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/AllTests.java
+++ b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* 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
@@ -31,9 +31,6 @@ public class AllTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(AllTests.class.getName());
- suite.addTest(AuthorizationDatabaseTest.suite());
- suite.addTest(CipherStreamsTest.suite());
- suite.addTest(CipherTest.suite());
suite.addTest(LogSerializationTest.suite());
suite.addTest(PlatformURLLocalTest.suite());
suite.addTest(PlatformURLSessionTest.suite());
diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/AuthorizationDatabaseTest.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/AuthorizationDatabaseTest.java
deleted file mode 100644
index 957cc10f2..000000000
--- a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/AuthorizationDatabaseTest.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.tests.internal.runtime;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Hashtable;
-import java.util.Map;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.internal.runtime.auth.AuthorizationDatabase;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.tests.runtime.RuntimeTest;
-
-public class AuthorizationDatabaseTest extends RuntimeTest {
- public AuthorizationDatabaseTest() {
- super(null);
- }
-
- public AuthorizationDatabaseTest(String name) {
- super(name);
- }
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(AuthorizationDatabaseTest.class.getName());
- suite.addTest(new AuthorizationDatabaseTest("test1"));
- suite.addTest(new AuthorizationDatabaseTest("test2"));
- suite.addTest(new AuthorizationDatabaseTest("test3"));
- suite.addTest(new AuthorizationDatabaseTest("test4"));
- return suite;
- }
-
- public void test1() {
- File file = new File(Platform.getLocation().toFile(), Long.toString(System.currentTimeMillis()) + ".auth");
- try {
- String filename = file.getAbsolutePath();
- String password = "testing";
- if (file.exists()) {
- file.delete();
- }
-
- AuthorizationDatabase db = new AuthorizationDatabase(filename, password);
-
- URL serverUrl = new URL("http://www.oti.com/");
- URL resourceUrl = new URL("http://www.oti.com/folder/");
- String realm = "WallyWorld";
- String authScheme = "Basic";
- Map info = new Hashtable(2);
- info.put("username", "jonathan");
- info.put("password", "testing");
-
- db.addAuthorizationInfo(serverUrl, realm, authScheme, info);
- db.addProtectionSpace(resourceUrl, realm);
-
- db.save();
-
- db = new AuthorizationDatabase(filename, password);
-
- info = db.getAuthorizationInfo(serverUrl, realm, authScheme);
- assertEquals("00", "jonathan", info.get("username"));
- assertEquals("01", "testing", info.get("password"));
-
- assertEquals("02", realm, db.getProtectionSpace(resourceUrl));
- assertEquals("03", realm, db.getProtectionSpace(new URL(resourceUrl.toString() + "file")));
- } catch (Exception e) {
- assertTrue("04", false);
- } finally {
- file.delete();
- }
-
- }
-
- public void test2() {
- AuthorizationDatabase db = new AuthorizationDatabase();
-
- URL url1 = null;
- URL url2 = null;
- try {
- url1 = new URL("http://www.oti.com/file1");
- url2 = new URL("http://www.oti.com/folder1/");
- } catch (MalformedURLException e) {
- assertTrue("00", false);
- }
-
- String realm1 = "realm1";
- String realm2 = "realm2";
-
- db.addProtectionSpace(url1, realm1);
-
- assertEquals("00", realm1, db.getProtectionSpace(url1));
- assertEquals("01", realm1, db.getProtectionSpace(url2));
-
- db.addProtectionSpace(url2, realm1);
-
- assertEquals("02", realm1, db.getProtectionSpace(url1));
- assertEquals("03", realm1, db.getProtectionSpace(url2));
-
- db.addProtectionSpace(url2, realm2);
-
- assertTrue("04", db.getProtectionSpace(url1) == null);
- assertEquals("05", realm2, db.getProtectionSpace(url2));
-
- db.addProtectionSpace(url1, realm1);
-
- assertEquals("05", realm1, db.getProtectionSpace(url1));
- assertEquals("06", realm1, db.getProtectionSpace(url2));
- }
-
- public void test3() {
- AuthorizationDatabase db = new AuthorizationDatabase();
-
- URL url1 = null;
- try {
- url1 = new URL("http://www.oti.com");
- } catch (MalformedURLException e) {
- assertTrue("00", false);
- }
-
- Hashtable info = new Hashtable(2);
- db.addAuthorizationInfo(url1, "realm1", "Basic", info);
-
- assertTrue("01", db.getAuthorizationInfo(url1, "realm1", "Basic") != null);
- db.flushAuthorizationInfo(url1, "realm1", "Basic");
- assertTrue("02", db.getAuthorizationInfo(url1, "realm1", "Basic") == null);
- }
-
- public void test4() {
- File file = new File("relative.test");
- try {
- String filename = file.getPath();
- String password = "testing";
- if (file.exists()) {
- file.delete();
- }
-
- AuthorizationDatabase db = new AuthorizationDatabase(filename, password);
-
- URL serverUrl = new URL("http://www.oti.com/");
- URL resourceUrl = new URL("http://www.oti.com/folder/");
- String realm = "WallyWorld";
- String authScheme = "Basic";
- Map info = new Hashtable(2);
- info.put("username", "jonathan");
- info.put("password", "testing");
-
- db.addAuthorizationInfo(serverUrl, realm, authScheme, info);
- db.addProtectionSpace(resourceUrl, realm);
-
- db.save();
-
- db = new AuthorizationDatabase(filename, password);
-
- info = db.getAuthorizationInfo(serverUrl, realm, authScheme);
- assertEquals("00", "jonathan", info.get("username"));
- assertEquals("01", "testing", info.get("password"));
-
- assertEquals("02", realm, db.getProtectionSpace(resourceUrl));
- assertEquals("03", realm, db.getProtectionSpace(new URL(resourceUrl.toString() + "file")));
- } catch (Exception e) {
- assertTrue("04", false);
- } finally {
- file.delete();
- }
- }
-}
diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/CipherStreamsTest.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/CipherStreamsTest.java
deleted file mode 100644
index 066d2ca3d..000000000
--- a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/CipherStreamsTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.tests.internal.runtime;
-
-import java.io.*;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.internal.runtime.auth.CipherInputStream;
-import org.eclipse.core.internal.runtime.auth.CipherOutputStream;
-import org.eclipse.core.tests.runtime.RuntimeTest;
-
-public class CipherStreamsTest extends RuntimeTest {
- public CipherStreamsTest() {
- super(null);
- }
-
- public CipherStreamsTest(String name) {
- super(name);
- }
-
- protected void doCipherTest(String password, byte[] data) {
- try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- CipherOutputStream cos = new CipherOutputStream(baos, password);
- cos.write(data);
- cos.close();
-
- byte[] encryptedData = baos.toByteArray();
- ByteArrayInputStream bais = new ByteArrayInputStream(encryptedData);
- CipherInputStream cis = new CipherInputStream(bais, password);
- byte[] decryptedData = new byte[data.length];
- cis.read(decryptedData);
- assertTrue("01", cis.read() == -1);
- cis.close();
-
- assertEquals("02", data.length, decryptedData.length);
- for (int i = 0; i < data.length; ++i) {
- assertEquals("03." + i, data[i], decryptedData[i]);
- }
- } catch (IOException e) {
- fail("99", e);
- }
- }
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(CipherStreamsTest.class.getName());
- suite.addTest(new CipherStreamsTest("test1"));
- return suite;
- }
-
- protected String getLongMessage() {
- return "This is a test!This is a test!This is a test!This is a test!This is a test!" + "este e' o meu conteudo (portuguese)there is no imagination for more sentences" + "este e' o meu conteudo (portuguese)there is no imagination for more sentences" + "este e' o meu conteudo (portuguese)there is no imagination for more sentences" + "este e' o meu conteudo (portuguese)there is no imagination for more sentences" + "This is a very long message that contains quite a lot of bytes and thus" + "may prove to make for a more interesting test case than the far simpler" + "(and admittedly mundane) messages that are also included in this test" + "este e' o meu conteudo (portuguese)there is no imagination for more sentences"
- + "este e' o meu conteudo (portuguese)there is no imagination for more sentences" + "este e' o meu conteudo (portuguese)there is no imagination for more sentences";
- }
-
- protected String[] getMessages() {
- return new String[] {"This is a test!", "", "a", getLongMessage(), getVeryLongMessage(),};
- }
-
- protected String[] getPasswords() {
- return new String[] {"", "pasord", " ", "This is a very long password that contains quite a lot of bytes and thus" + "may prove to make for a more interesting test case than the far simpler" + "(and admittedly mundane) passwords that are also included in this array",};
- }
-
- protected String getVeryLongMessage() {
- StringBuffer message = new StringBuffer(1000);
- while (message.length() < 5300) {
- message.append(getLongMessage());
- }
- return message.toString();
- }
-
- public void test1() {
- String[] passwords = getPasswords();
- String[] messages = getMessages();
- for (int i = 0; i < messages.length; i++) {
- byte[] data = messages[i].getBytes();
- for (int j = 0; j < passwords.length; j++) {
- doCipherTest(passwords[j], data);
- }
- }
- }
-
-}
diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/CipherTest.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/CipherTest.java
deleted file mode 100644
index e00c39a7a..000000000
--- a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/CipherTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.tests.internal.runtime;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.internal.runtime.auth.Cipher;
-import org.eclipse.core.tests.runtime.RuntimeTest;
-
-public class CipherTest extends RuntimeTest {
- public CipherTest() {
- super(null);
- }
-
- public CipherTest(String name) {
- super(name);
- }
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite() {
- return new TestSuite(CipherTest.class);
- // TestSuite suite = new TestSuite();
- // suite.addTest(new CipherTest("test1"));
- // return suite;
- }
-
- public void test1() {
- try {
- String[] passwords = getPasswords();
- String[] messages = getMessages();
- for (int i = 0; i < messages.length; i++) {
- byte[] data = messages[i].getBytes();
- for (int j = 0; j < passwords.length; j++) {
- doCipherTest(passwords[j], data);
- }
- }
- } catch (Exception e) {
- fail("04", e);
- }
- }
-
- public void testDifferentChunkSizes() {
- //read and write different chunk sizes at once. Should still decrypt to
- //be the same bytes
- byte[] inputBytes = "This is the message that will be encrypted.".getBytes();
- String password = "music";
-
- //encrypt first ten bytes, then remaining bytes
- try {
- Cipher cipher = new Cipher(Cipher.ENCRYPT_MODE, password);
- byte[] encrypted1 = cipher.cipher(inputBytes, 0, 10);
- //introduce some noise by encrypting an empty array
- cipher.cipher(new byte[0]);
- byte[] encrypted2 = cipher.cipher(inputBytes, 10, inputBytes.length - 10);
- byte[] fullEncrypted = new byte[encrypted1.length + encrypted2.length];
- System.arraycopy(encrypted1, 0, fullEncrypted, 0, encrypted1.length);
- System.arraycopy(encrypted2, 0, fullEncrypted, encrypted1.length, encrypted2.length);
-
- cipher = new Cipher(Cipher.DECRYPT_MODE, password);
- //introduce some noise by decrypting an empty array
- cipher.cipher(new byte[0]);
- //now decrypt all at once
- byte[] result = cipher.cipher(fullEncrypted);
-
- assertEquals("1.0", inputBytes.length, result.length);
- for (int i = 0; i < inputBytes.length; i++) {
- assertEquals("2." + i, inputBytes[i], result[i]);
- }
- } catch (Exception e) {
- fail("1.99", e);
- }
- }
-
- protected String[] getMessages() {
- return new String[] {"This is a test a test!", "", "a", getLongMessage(), getVeryLongMessage(),};
- }
-
- protected String getLongMessage() {
- return "This is a test!This is a test!This is a test!This is a test!This is a test!" + "este e' o meu conteudo (portuguese)there is no imagination for more sentences" + "este e' o meu conteudo (portuguese)there is no imagination for more sentences" + "este e' o meu conteudo (portuguese)there is no imagination for more sentences" + "este e' o meu conteudo (portuguese)there is no imagination for more sentences" + "This is a very long message that contains quite a lot of bytes and thus" + "may prove to make for a more interesting test case than the far simpler" + "(and admittedly mundane) messages that are also included in this test" + "este e' o meu conteudo (portuguese)there is no imagination for more sentences"
- + "este e' o meu conteudo (portuguese)there is no imagination for more sentences" + "este e' o meu conteudo (portuguese)there is no imagination for more sentences" + "este e' o meu conteudo (portuguese)there is no imagination for more sentences" + "este e' o meu conteudo (portuguese)there is no imagination for more sentences";
- }
-
- protected String[] getPasswords() {
- return new String[] {"", "password", "a", "This is a very long password that contains quite a lot of bytes and thus" + "may prove to make for a more interesting test case than the far simpler" + "(and admittedly mundane) passwords that are also included in this array",};
- }
-
- protected String getVeryLongMessage() {
- StringBuffer message = new StringBuffer(1000);
- while (message.length() < 5000) {
- message.append(getLongMessage());
- }
- return message.toString();
- }
-
- protected void doCipherTest(String password, byte[] data) throws Exception {
- Cipher cipher = new Cipher(Cipher.ENCRYPT_MODE, password);
- byte[] encryptedData = cipher.cipher(data);
- assertEquals("00", data.length, encryptedData.length);
-
- cipher = new Cipher(Cipher.DECRYPT_MODE, password);
- byte[] decryptedData = cipher.cipher(encryptedData);
- assertEquals("02", data.length, decryptedData.length);
- for (int i = 0; i < data.length; ++i) {
- assertEquals("03." + i, data[i], decryptedData[i]);
- }
- }
-}

Back to the top