Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-01-08 16:40:37 +0000
committerMichael Valenta2002-01-08 16:40:37 +0000
commit1592826e89e518ecb20175bee7d0253a251b846e (patch)
tree7177fb74aae6471aa00eebd23b2cc43c8a626bb3
parent4aff5b7f8ccdac6eb39b8396342d25adb477a21e (diff)
downloadeclipse.platform.team-1592826e89e518ecb20175bee7d0253a251b846e.tar.gz
eclipse.platform.team-1592826e89e518ecb20175bee7d0253a251b846e.tar.xz
eclipse.platform.team-1592826e89e518ecb20175bee7d0253a251b846e.zip
Made validateConnection part of ICVSRepositoryLocation API
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java186
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java3
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java327
3 files changed, 261 insertions, 255 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java
index 7a7609cc7..9c44a7a18 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java
@@ -1,90 +1,96 @@
-package org.eclipse.team.ccvs.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-
-/**
- * This interface provides access to the specific portions of
- * the repository location string for use by connection methods
- * and the user authenticator.
- *
- * It is not intended to implemented by clients.
- *
- * @see IUserAuthenticator
- * @see IConnectionMethod
- */
-public interface ICVSRepositoryLocation extends IAdaptable {
-
- /**
- * port value which indicates to a connection method to use the default port
- */
- public static int USE_DEFAULT_PORT = 0;
-
- /**
- * Return the connection method for making the connection
- */
- public IConnectionMethod getMethod();
-
- /**
- * Returns the host where the repository is located
- */
- public String getHost();
-
- /**
- * Returns the port to connect to or USE_DEFAULT_PORT if
- * the connection method is to use its default port.
- */
- public int getPort();
-
- /**
- * Returns the root directory of the repository.
- */
- public String getRootDirectory();
-
- /**
- * Returns the string representing the receiver. This string
- * should contain enough information to recreate the receiver.
- */
- public String getLocation();
-
- /**
- * Returns the immediate children of this location. If tag is <code>null</code> the
- * HEAD branch is assumed.
- *
- * @param tag the context in which to return the members (e.g. branch or version).
- */
- public ICVSRemoteResource[] members(CVSTag tag, IProgressMonitor progress) throws CVSException;
-
- /**
- * Returns a handle to a remote folder at this repository location using the given tag as the
- * context. The corresponding remote folder may not exist.
- */
- public ICVSRemoteFolder getRemoteFolder(String remotePath, CVSTag tag);
-
- /**
- * Return the conection timeout value in milliseconds.
- * A value of 0 means there is no timeout value.
- */
- public int getTimeout();
-
- /**
- * Return the information about the user as an IUserInfo.
- *
- * This allows the querying of the user name and the setting
- * of the username and password.
- */
- public IUserInfo getUserInfo();
-
- /**
- * Return the username
- */
- public String getUsername();
-}
-
+package org.eclipse.team.ccvs.core;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.sync.IRemoteResource;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+
+/**
+ * This interface provides access to the specific portions of
+ * the repository location string for use by connection methods
+ * and the user authenticator.
+ *
+ * It is not intended to implemented by clients.
+ *
+ * @see IUserAuthenticator
+ * @see IConnectionMethod
+ */
+public interface ICVSRepositoryLocation extends IAdaptable {
+
+ /**
+ * port value which indicates to a connection method to use the default port
+ */
+ public static int USE_DEFAULT_PORT = 0;
+
+ /**
+ * Return the connection method for making the connection
+ */
+ public IConnectionMethod getMethod();
+
+ /**
+ * Returns the host where the repository is located
+ */
+ public String getHost();
+
+ /**
+ * Returns the port to connect to or USE_DEFAULT_PORT if
+ * the connection method is to use its default port.
+ */
+ public int getPort();
+
+ /**
+ * Returns the root directory of the repository.
+ */
+ public String getRootDirectory();
+
+ /**
+ * Returns the string representing the receiver. This string
+ * should contain enough information to recreate the receiver.
+ */
+ public String getLocation();
+
+ /**
+ * Returns the immediate children of this location. If tag is <code>null</code> the
+ * HEAD branch is assumed.
+ *
+ * @param tag the context in which to return the members (e.g. branch or version).
+ */
+ public ICVSRemoteResource[] members(CVSTag tag, IProgressMonitor progress) throws CVSException;
+
+ /**
+ * Returns a handle to a remote folder at this repository location using the given tag as the
+ * context. The corresponding remote folder may not exist.
+ */
+ public ICVSRemoteFolder getRemoteFolder(String remotePath, CVSTag tag);
+
+ /**
+ * Return the conection timeout value in milliseconds.
+ * A value of 0 means there is no timeout value.
+ */
+ public int getTimeout();
+
+ /**
+ * Return the information about the user as an IUserInfo.
+ *
+ * This allows the querying of the user name and the setting
+ * of the username and password.
+ */
+ public IUserInfo getUserInfo();
+
+ /**
+ * Return the username
+ */
+ public String getUsername();
+
+ /**
+ * Validate that the receiver can be used to connect to a repository.
+ * An exception is thrown if connection fails
+ */
+ public void validateConnection() throws CVSException;
+}
+
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java
index 31bcfc353..cf829fd7f 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java
@@ -332,10 +332,9 @@ public class CVSRepositoryLocation extends PlatformObject implements ICVSReposit
* information, the method returns. Otherwise, an exception
* indicating the problem is throw.
*/
- public boolean validateConnection() throws CVSException {
+ public void validateConnection() throws CVSException {
try {
openConnection().close();
- return true;
} catch (CVSException e) {
// If the validation failed, dispose of any cached info
dispose();
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java
index 70cae403c..5ed6d2b4c 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java
@@ -1,163 +1,164 @@
-package org.eclipse.team.internal.ccvs.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.ccvs.core.IUserAuthenticator;
-import org.eclipse.team.ccvs.core.IUserInfo;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-
-/**
- * An authenticator that prompts the user for authentication info,
- * and stores the results in the Platform's authentication keyring.
- */
-public class WorkbenchUserAuthenticator implements IUserAuthenticator {
-
- public static final String INFO_PASSWORD = "org.eclipse.team.ccvs.ui.password";
- public static final String INFO_USERNAME = "org.eclipse.team.ccvs.ui.username";
- public static final String AUTH_SCHEME = "";
- public static final URL FAKE_URL;
-
- static {
- URL temp = null;
- try {
- temp = new URL("http://org.eclipse.team.ccvs.ui");
- } catch (MalformedURLException e) {
- }
- FAKE_URL = temp;
- }
- /**
- * WorkbenchUserAuthenticator constructor.
- */
- public WorkbenchUserAuthenticator() {
- super();
- }
- /**
- * @see IUserAuthenticator#authenticateUser
- */
- public boolean authenticateUser(final ICVSRepositoryLocation location, final IUserInfo userinfo, final boolean retry, final String message) throws CVSException {
-
- // first check to see if there is a cached username and password
- if ((!retry) && (retrievePassword(location, userinfo))) {
- return true;
- }
-
- // ask the user for a password
- final String[] result = new String[2];
- Display display = Display.getCurrent();
- if (display != null) {
- promptForPassword(location, userinfo.getUsername(), message, userinfo.isUsernameMutable(), result);
- } else {
- // sync exec in default thread
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- promptForPassword(location, userinfo.getUsername(), message, userinfo.isUsernameMutable(), result);
- }
- });
- }
-
- if (result[0] == null) {
- throw new CVSOperationCancelledException(Policy.bind("WorkbenchUserAuthenticator.cancelled"));
- }
-
- updateAndCache(location, userinfo, result[0], result[1]);
- return true;
- }
- /**
- * Asks the user to enter a password. Places the
- * results in the supplied string[]. result[0] must
- * contain the username, result[1] must contain the password.
- * If the user canceled, both values must be zero.
- *
- * @param location the location to obtain the password for
- * @param username the username
- * @param message a message to display to the user
- * @param userMutable whether the user can be changed in the dialog
- * @param result a String array of length two in which to put the result
- */
- private void promptForPassword(ICVSRepositoryLocation location, String username, String message, boolean userMutable, String[] result) {
- Shell shell = new Shell();
- UserValidationDialog dialog = new UserValidationDialog(shell, location.getLocation(), (username==null)?"":username, message);
- dialog.setUsernameMutable(userMutable);
- dialog.open();
-
- shell.dispose();
- result[0] = dialog.getUsername();
- result[1] = dialog.getPassword();
- }
- /**
- * @see IUserAuthenticator#cachePassword
- */
- public void cachePassword(ICVSRepositoryLocation location, IUserInfo userinfo, String password) throws CVSException {
- updateAndCache(location, userinfo, userinfo.getUsername(), password);
- }
- /**
- * @see IUserAuthenticator#retrievePassword
- */
- public boolean retrievePassword(ICVSRepositoryLocation location, IUserInfo userinfo) throws CVSException {
- Map map = Platform.getAuthorizationInfo(FAKE_URL, location.getLocation(), AUTH_SCHEME);
- if (map != null) {
- String username = (String) map.get(INFO_USERNAME);
- String password = (String) map.get(INFO_PASSWORD);
- if (password != null) {
- if (userinfo.isUsernameMutable())
- userinfo.setUsername(username);
- userinfo.setPassword(password);
- return true;
- }
- }
- return false;
- }
- /**
- * @see IUserAuthenticator#dispose(IRepositoryLocation)
- */
- public void dispose(ICVSRepositoryLocation location) throws CVSException {
- try {
- Platform.flushAuthorizationInfo(FAKE_URL, location.getLocation(), AUTH_SCHEME);
- } catch (CoreException e) {
- // We should probably wrap the CoreException here!
- CVSUIPlugin.log(e.getStatus());
- throw new CVSException(e.getStatus());
- }
- }
- /**
- * Updates the pasword in the platform keyring.
- *
- * @param location the repository location
- * @param userinfo the user information
- * @param username the name of the user
- * @param password the password
- * @throws CVSException if a CVS error occurs
- */
- public void updateAndCache(ICVSRepositoryLocation location, IUserInfo userinfo, String username, String password) throws CVSException {
- // put the password into the Platform map
- Map map = Platform.getAuthorizationInfo(FAKE_URL, location.getLocation(), AUTH_SCHEME);
- if (map == null) {
- map = new java.util.HashMap(10);
- }
- map.put(INFO_USERNAME, username);
- map.put(INFO_PASSWORD, password);
- try {
- Platform.addAuthorizationInfo(FAKE_URL, location.getLocation(), AUTH_SCHEME, map);
- } catch (CoreException e) {
- // We should probably wrap the CoreException here!
- CVSUIPlugin.log(e.getStatus());
- throw new CVSException(e.getStatus());
- }
- if (userinfo.isUsernameMutable()) {
- userinfo.setUsername(username);
- }
- userinfo.setPassword(password);;
- }
-}
+package org.eclipse.team.internal.ccvs.ui;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.ccvs.core.IUserAuthenticator;
+import org.eclipse.team.ccvs.core.IUserInfo;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+
+/**
+ * An authenticator that prompts the user for authentication info,
+ * and stores the results in the Platform's authentication keyring.
+ */
+public class WorkbenchUserAuthenticator implements IUserAuthenticator {
+
+ public static final String INFO_PASSWORD = "org.eclipse.team.ccvs.ui.password";
+ public static final String INFO_USERNAME = "org.eclipse.team.ccvs.ui.username";
+ public static final String AUTH_SCHEME = "";
+ public static final URL FAKE_URL;
+
+ static {
+ URL temp = null;
+ try {
+ temp = new URL("http://org.eclipse.team.ccvs.ui");
+ } catch (MalformedURLException e) {
+ }
+ FAKE_URL = temp;
+ }
+ /**
+ * WorkbenchUserAuthenticator constructor.
+ */
+ public WorkbenchUserAuthenticator() {
+ super();
+ }
+ /**
+ * @see IUserAuthenticator#authenticateUser
+ */
+ public boolean authenticateUser(final ICVSRepositoryLocation location, final IUserInfo userinfo, final boolean retry, final String message) throws CVSException {
+
+ // first check to see if there is a cached username and password
+ if ((!retry) && (retrievePassword(location, userinfo))) {
+ return true;
+ }
+
+ // ask the user for a password
+ final String[] result = new String[2];
+ Display display = Display.getCurrent();
+ if (display != null) {
+ promptForPassword(location, userinfo.getUsername(), message, userinfo.isUsernameMutable(), result);
+ } else {
+ // sync exec in default thread
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ promptForPassword(location, userinfo.getUsername(), message, userinfo.isUsernameMutable(), result);
+ }
+ });
+ }
+
+ if (result[0] == null) {
+ throw new OperationCanceledException(Policy.bind("WorkbenchUserAuthenticator.cancelled"));
+ }
+
+ updateAndCache(location, userinfo, result[0], result[1]);
+ return true;
+ }
+ /**
+ * Asks the user to enter a password. Places the
+ * results in the supplied string[]. result[0] must
+ * contain the username, result[1] must contain the password.
+ * If the user canceled, both values must be zero.
+ *
+ * @param location the location to obtain the password for
+ * @param username the username
+ * @param message a message to display to the user
+ * @param userMutable whether the user can be changed in the dialog
+ * @param result a String array of length two in which to put the result
+ */
+ private void promptForPassword(ICVSRepositoryLocation location, String username, String message, boolean userMutable, String[] result) {
+ Shell shell = new Shell();
+ UserValidationDialog dialog = new UserValidationDialog(shell, location.getLocation(), (username==null)?"":username, message);
+ dialog.setUsernameMutable(userMutable);
+ dialog.open();
+
+ shell.dispose();
+ result[0] = dialog.getUsername();
+ result[1] = dialog.getPassword();
+ }
+ /**
+ * @see IUserAuthenticator#cachePassword
+ */
+ public void cachePassword(ICVSRepositoryLocation location, IUserInfo userinfo, String password) throws CVSException {
+ updateAndCache(location, userinfo, userinfo.getUsername(), password);
+ }
+ /**
+ * @see IUserAuthenticator#retrievePassword
+ */
+ public boolean retrievePassword(ICVSRepositoryLocation location, IUserInfo userinfo) throws CVSException {
+ Map map = Platform.getAuthorizationInfo(FAKE_URL, location.getLocation(), AUTH_SCHEME);
+ if (map != null) {
+ String username = (String) map.get(INFO_USERNAME);
+ String password = (String) map.get(INFO_PASSWORD);
+ if (password != null) {
+ if (userinfo.isUsernameMutable())
+ userinfo.setUsername(username);
+ userinfo.setPassword(password);
+ return true;
+ }
+ }
+ return false;
+ }
+ /**
+ * @see IUserAuthenticator#dispose(IRepositoryLocation)
+ */
+ public void dispose(ICVSRepositoryLocation location) throws CVSException {
+ try {
+ Platform.flushAuthorizationInfo(FAKE_URL, location.getLocation(), AUTH_SCHEME);
+ } catch (CoreException e) {
+ // We should probably wrap the CoreException here!
+ CVSUIPlugin.log(e.getStatus());
+ throw new CVSException(e.getStatus());
+ }
+ }
+ /**
+ * Updates the pasword in the platform keyring.
+ *
+ * @param location the repository location
+ * @param userinfo the user information
+ * @param username the name of the user
+ * @param password the password
+ * @throws CVSException if a CVS error occurs
+ */
+ public void updateAndCache(ICVSRepositoryLocation location, IUserInfo userinfo, String username, String password) throws CVSException {
+ // put the password into the Platform map
+ Map map = Platform.getAuthorizationInfo(FAKE_URL, location.getLocation(), AUTH_SCHEME);
+ if (map == null) {
+ map = new java.util.HashMap(10);
+ }
+ map.put(INFO_USERNAME, username);
+ map.put(INFO_PASSWORD, password);
+ try {
+ Platform.addAuthorizationInfo(FAKE_URL, location.getLocation(), AUTH_SCHEME, map);
+ } catch (CoreException e) {
+ // We should probably wrap the CoreException here!
+ CVSUIPlugin.log(e.getStatus());
+ throw new CVSException(e.getStatus());
+ }
+ if (userinfo.isUsernameMutable()) {
+ userinfo.setUsername(username);
+ }
+ userinfo.setPassword(password);;
+ }
+}

Back to the top