Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/AuthenticatedSite.java')
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/AuthenticatedSite.java78
1 files changed, 78 insertions, 0 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/AuthenticatedSite.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/AuthenticatedSite.java
new file mode 100644
index 000000000..e9d3f580a
--- /dev/null
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/AuthenticatedSite.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial implementation
+ ******************************************************************************/
+package org.eclipse.team.internal.core.target;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.core.TeamPlugin;
+
+/**
+ * This is a layer that contains anything which a Target Site implementation that uses authentication would need to have.
+ */
+public abstract class AuthenticatedSite extends Site {
+
+ protected String username;
+ protected String password;
+
+ /**
+ * @see org.eclipse.team.internal.core.target.Site#dispose()
+ */
+ public void dispose() throws TeamException {
+ try {
+ Platform.flushAuthorizationInfo(getURL(), "", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (CoreException e) {
+ throw new TeamException(e.getStatus());
+ }
+ }
+
+ /**
+ * Gets the username.
+ * @return Returns a String
+ */
+ public String getUsername() {
+ return username;
+ }
+
+ /**
+ * Gets the password.
+ * @return Returns a String
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ public void setUsername(String name) throws TeamException {
+ Map authInfo=Platform.getAuthorizationInfo(getURL(), "", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ authInfo.put("name", username); //$NON-NLS-1$
+ try {
+ Platform.flushAuthorizationInfo(getURL(), "", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ Platform.addAuthorizationInfo(getURL(), "", "", authInfo); //$NON-NLS-1$ //$NON-NLS-2$
+ this.username=name;
+ } catch (CoreException e) {
+ throw TeamPlugin.wrapException(e);
+ }
+ }
+
+ public void setPassword(String password) throws TeamException {
+ Map authInfo=Platform.getAuthorizationInfo(getURL(), "", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ authInfo.put("password", password); //$NON-NLS-1$
+ try {
+ Platform.flushAuthorizationInfo(getURL(), "", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ Platform.addAuthorizationInfo(getURL(), "", "", authInfo); //$NON-NLS-1$ //$NON-NLS-2$
+ this.password=password;
+ } catch (CoreException e) {
+ throw TeamPlugin.wrapException(e);
+ }
+ }
+
+}

Back to the top