diff options
author | Siva Velusamy <vsiva@google.com> | 2011-11-14 16:06:50 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-11-14 16:06:50 -0800 |
commit | 87ae4cbb41e27c19364496e52d925acd6a80a0a5 (patch) | |
tree | 774c1f9df394f2a9ef41621a76f2977109c9e377 /sdkmanager | |
parent | 4fa753b2f8e6847755afe4862a64624523de966a (diff) | |
parent | cefde2307aa8737fccc756c3b69c3d7ca3e53e8b (diff) | |
download | sdk-87ae4cbb41e27c19364496e52d925acd6a80a0a5.zip sdk-87ae4cbb41e27c19364496e52d925acd6a80a0a5.tar.gz sdk-87ae4cbb41e27c19364496e52d925acd6a80a0a5.tar.bz2 |
Merge "Add support for NTLM proxy authentication."
Diffstat (limited to 'sdkmanager')
11 files changed, 219 insertions, 85 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ITaskMonitor.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ITaskMonitor.java index 4a1a1e0..dcb1f22 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ITaskMonitor.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ITaskMonitor.java @@ -17,7 +17,6 @@ package com.android.sdklib.internal.repository;
import com.android.sdklib.ISdkLog;
-import com.android.util.Pair;
/**
@@ -134,18 +133,15 @@ public interface ITaskMonitor extends ISdkLog { public boolean displayPrompt(final String title, final String message);
/**
- * Launch an interface which asks for login and password. Implementations
+ * Launch an interface which asks for user credentials. Implementations
* MUST allow this to be called from any thread, e.g. by making sure the
* dialog is opened synchronously in the UI thread.
*
* @param title The title of the dialog box.
* @param message The message to be displayed as an instruction.
- * @return Returns a {@link Pair} holding the entered login and password.
- * The information must always be in the following order:
- * Login,Password. So in order to retrieve the <b>login</b> callers
- * should retrieve the first element, and the second value for the
- * <b>password</b>.
+ * @return Returns the user provided credentials. Some fields may be blank if the user
+ * did not provide any input.
If operation is <b>canceled</b> by user the return value must be <b>null</b>.
*/
- public Pair<String, String> displayLoginPasswordPrompt(String title, String message); + public UserCredentials displayLoginCredentialsPrompt(String title, String message); }
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/NullTaskMonitor.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/NullTaskMonitor.java index 8cd52d6..55049ca 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/NullTaskMonitor.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/NullTaskMonitor.java @@ -18,7 +18,6 @@ package com.android.sdklib.internal.repository; import com.android.sdklib.ISdkLog;
import com.android.sdklib.NullSdkLog;
-import com.android.util.Pair;
/**
@@ -94,7 +93,7 @@ public class NullTaskMonitor implements ITaskMonitor { }
/** Always return null. */
- public Pair<String, String> displayLoginPasswordPrompt(String title, String message) {
+ public UserCredentials displayLoginCredentialsPrompt(String title, String message) {
return null;
}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/UrlOpener.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/UrlOpener.java index 5e1967e..9a20461 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/UrlOpener.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/UrlOpener.java @@ -16,17 +16,17 @@ package com.android.sdklib.internal.repository; -import com.android.util.Pair; - import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.auth.AuthScope; import org.apache.http.auth.AuthState; import org.apache.http.auth.Credentials; -import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.auth.NTCredentials; +import org.apache.http.auth.params.AuthPNames; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.params.AuthPolicy; import org.apache.http.client.protocol.ClientContext; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.conn.ProxySelectorRoutePlanner; @@ -39,7 +39,9 @@ import java.io.IOException; import java.io.InputStream; import java.net.ProxySelector; import java.net.URL; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -56,8 +58,8 @@ public class UrlOpener { } } - private static Map<String, Pair<String, String>> sRealmCache = - new HashMap<String, Pair<String, String>>(); + private static Map<String, UserCredentials> sRealmCache = + new HashMap<String, UserCredentials>(); /** * Opens a URL. It can be a simple URL or one which requires basic @@ -107,7 +109,7 @@ public class UrlOpener { private static InputStream openWithHttpClient(String url, ITaskMonitor monitor) throws IOException, ClientProtocolException, CanceledByUserException { - Pair<String, String> result = null; + UserCredentials result = null; String realm = null; // use the simple one @@ -124,6 +126,19 @@ public class UrlOpener { ProxySelector.getDefault()); httpClient.setRoutePlanner(routePlanner); + // Set preference order for authentication options. + // In particular, we don't add AuthPolicy.SPNEGO, which is given preference over NTLM in + // servers that support both, as it is more secure. However, we don't seem to handle it + // very well, so we leave it off the list. + // See http://hc.apache.org/httpcomponents-client-ga/tutorial/html/authentication.html for + // more info. + List<String> authpref = new ArrayList<String>(); + authpref.add(AuthPolicy.BASIC); + authpref.add(AuthPolicy.DIGEST); + authpref.add(AuthPolicy.NTLM); + httpClient.getParams().setParameter(AuthPNames.PROXY_AUTH_PREF, authpref); + httpClient.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, authpref); + boolean trying = true; // loop while the response is being fetched while (trying) { @@ -171,7 +186,7 @@ public class UrlOpener { result = sRealmCache.get(realm); } else { // since there is no cache, request for login and password - result = monitor.displayLoginPasswordPrompt("Site Authentication", + result = monitor.displayLoginCredentialsPrompt("Site Authentication", "Please login to the following domain: " + realm + "\n\nServer requiring authentication:\n" + authScope.getHost()); if (result == null) { @@ -180,12 +195,15 @@ public class UrlOpener { } // retrieve authentication data - String user = result.getFirst(); - String password = result.getSecond(); + String user = result.getUserName(); + String password = result.getPassword(); + String workstation = result.getWorkstation(); + String domain = result.getDomain(); // proceed in case there is indeed a user if (user != null && user.length() > 0) { - Credentials credentials = new UsernamePasswordCredentials(user, password); + Credentials credentials = new NTCredentials(user, password, + workstation, domain); httpClient.getCredentialsProvider().setCredentials(authScope, credentials); trying = true; } else { diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/UserCredentials.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/UserCredentials.java new file mode 100644 index 0000000..16aed79 --- /dev/null +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/UserCredentials.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.sdklib.internal.repository; + +public class UserCredentials { + private final String mUserName; + private final String mPassword; + private final String mWorkstation; + private final String mDomain; + + public UserCredentials(String userName, String password, String workstation, String domain) { + mUserName = userName; + mPassword = password; + mWorkstation = workstation; + mDomain = domain; + } + + public String getUserName() { + return mUserName; + } + + public String getPassword() { + return mPassword; + } + + public String getWorkstation() { + return mWorkstation; + } + + public String getDomain() { + return mDomain; + } +} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockMonitor.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockMonitor.java index e61184d..30c03bc 100755 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockMonitor.java +++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/MockMonitor.java @@ -16,8 +16,6 @@ package com.android.sdklib.internal.repository;
-import com.android.util.Pair;
-
/**
* Mock implementation of {@link ITaskMonitor} that simply captures
* the output in local strings. Does not provide any UI and has no
@@ -97,7 +95,7 @@ public class MockMonitor implements ITaskMonitor { public void warning(String warningFormat, Object... args) {
}
- public Pair<String, String> displayLoginPasswordPrompt(String title, String message) {
+ public UserCredentials displayLoginCredentialsPrompt(String title, String message) {
return null;
}
}
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SdkUpdaterNoWindow.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SdkUpdaterNoWindow.java index bd4bb01..3fe5bff 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SdkUpdaterNoWindow.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SdkUpdaterNoWindow.java @@ -22,6 +22,7 @@ import com.android.sdklib.internal.repository.ITask; import com.android.sdklib.internal.repository.ITaskFactory; import com.android.sdklib.internal.repository.ITaskMonitor; import com.android.sdklib.internal.repository.NullTaskMonitor; +import com.android.sdklib.internal.repository.UserCredentials; import com.android.sdklib.repository.SdkRepoConstants; import com.android.util.Pair; @@ -360,11 +361,14 @@ public class SdkUpdaterNoWindow { * <b>second element</b> is always the <b>Password</b>. This * method will never return null, in case of error the pair will * be filled with empty strings. - * @see ITaskMonitor#displayLoginPasswordPrompt(String, String) + * @see ITaskMonitor#displayLoginCredentialsPrompt(String, String) */ - public Pair<String, String> displayLoginPasswordPrompt(String title, String message) { + public UserCredentials displayLoginCredentialsPrompt(String title, String message) { String login = ""; //$NON-NLS-1$ String password = ""; //$NON-NLS-1$ + String workstation = ""; //$NON-NLS-1$ + String domain = ""; //$NON-NLS-1$ + mSdkLog.printf("\n%1$s\n%2$s", title, message); byte[] readBuffer = new byte[2048]; try { @@ -372,6 +376,12 @@ public class SdkUpdaterNoWindow { login = readLine(readBuffer); mSdkLog.printf("\nPassword: "); password = readLine(readBuffer); + mSdkLog.printf("\nIf your proxy uses NTLM authentication, provide the following information. Leave blank otherwise."); + mSdkLog.printf("\nWorkstation: "); + workstation = readLine(readBuffer); + mSdkLog.printf("\nDomain: "); + domain = readLine(readBuffer); + /* * TODO: Implement a way to don't echo the typed password On * Java 5 there's no simple way to do this. There's just a @@ -382,11 +392,13 @@ public class SdkUpdaterNoWindow { // Reset login/pass to empty Strings. login = ""; //$NON-NLS-1$ password = ""; //$NON-NLS-1$ + workstation = ""; //$NON-NLS-1$ + domain = ""; //$NON-NLS-1$ //Just print the error to console. mSdkLog.printf("\nError occurred during login/pass query: %s\n", e.getMessage()); } - return Pair.of(login, password); + return new UserCredentials(login, password, workstation, domain); } private String readLine(byte[] buffer) throws IOException { @@ -504,8 +516,8 @@ public class SdkUpdaterNoWindow { return mRoot.displayPrompt(title, message); } - public Pair<String, String> displayLoginPasswordPrompt(String title, String message) { - return mRoot.displayLoginPasswordPrompt(title, message); + public UserCredentials displayLoginCredentialsPrompt(String title, String message) { + return mRoot.displayLoginCredentialsPrompt(title, message); } public ITaskMonitor createSubMonitor(int tickCount) { diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/IProgressUiProvider.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/IProgressUiProvider.java index 1eca704..dc4f3ba 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/IProgressUiProvider.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/IProgressUiProvider.java @@ -17,7 +17,7 @@ package com.android.sdkuilib.internal.tasks; import com.android.sdklib.internal.repository.ITaskMonitor; -import com.android.util.Pair; +import com.android.sdklib.internal.repository.UserCredentials; import org.eclipse.swt.widgets.ProgressBar; @@ -73,19 +73,14 @@ interface IProgressUiProvider extends ILogUiProvider { public abstract boolean displayPrompt(String title, String message); /** - * Launch an interface which asks for login and password. Implementations + * Launch an interface which asks for login credentials. Implementations * MUST allow this to be called from any thread, e.g. by making sure the * dialog is opened synchronously in the UI thread. * * @param title The title of the dialog box. * @param message The message to be displayed as an instruction. - * @return Returns a {@link Pair} holding the entered login and password. - * The information must always be in the following order: - * Login,Password. So in order to retrieve the <b>login</b> callers - * should retrieve the first element, and the second value for the - * <b>password</b>. This method should never return a null pair. - * It's elements however can be empty Strings + * @return Returns user provided credentials */ - public abstract Pair<String, String> displayLoginPasswordPrompt(String title, String message); + public UserCredentials displayLoginCredentialsPrompt(String title, String message); } diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/ProgressTaskDialog.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/ProgressTaskDialog.java index dbc871f..d01466b 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/ProgressTaskDialog.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/ProgressTaskDialog.java @@ -18,6 +18,7 @@ package com.android.sdkuilib.internal.tasks; import com.android.sdklib.SdkConstants;
import com.android.sdklib.internal.repository.ITaskMonitor;
+import com.android.sdklib.internal.repository.UserCredentials;
import com.android.sdkuilib.ui.AuthenticationDialog;
import com.android.sdkuilib.ui.GridDialog;
import com.android.util.Pair;
@@ -408,31 +409,46 @@ final class ProgressTaskDialog extends Dialog implements IProgressUiProvider { * should retrieve the first element, and the second value for the
* <b>password</b>.
* If operation is <b>canceled</b> by user the return value must be <b>null</b>.
- * @see ITaskMonitor#displayLoginPasswordPrompt(String, String)
+ * @see ITaskMonitor#displayLoginCredentialsPrompt(String, String)
*/
- public Pair<String, String> displayLoginPasswordPrompt(
+ public UserCredentials displayLoginCredentialsPrompt(
final String title, final String message) {
- final String[] resultArray = new String[2];
Display display = mDialogShell.getDisplay();
// open dialog and request login and password
- display.syncExec(new Runnable() {
- public void run() {
- AuthenticationDialog authenticationDialog = new AuthenticationDialog(mDialogShell,
- title,
- message);
- int dlgResult= authenticationDialog.open();
- if(dlgResult == GridDialog.OK) {
- resultArray[0] = authenticationDialog.getLogin();
- resultArray[1] = authenticationDialog.getPassword();
- } else {
- resultArray[0] = null;
- resultArray[1] = null;
- }
- }
- });
+ GetUserCredentialsTask task = new GetUserCredentialsTask(mDialogShell, title, message);
+ display.syncExec(task);
+
+ return new UserCredentials(task.userName, task.password, task.workstation, task.domain);
+ }
- return resultArray[0] == null ? null : Pair.of(resultArray[0], resultArray[1]);
+ private static class GetUserCredentialsTask implements Runnable {
+ public String userName = null;
+ public String password = null;
+ public String workstation = null;
+ public String domain = null;
+
+ private Shell mShell;
+ private String mTitle;
+ private String mMessage;
+
+ public GetUserCredentialsTask(Shell shell, String title, String message) {
+ mShell = shell;
+ mTitle = title;
+ mMessage = message;
+ }
+
+ public void run() {
+ AuthenticationDialog authenticationDialog = new AuthenticationDialog(mShell,
+ mTitle, mMessage);
+ int dlgResult= authenticationDialog.open();
+ if(dlgResult == GridDialog.OK) {
+ userName = authenticationDialog.getLogin();
+ password = authenticationDialog.getPassword();
+ workstation = authenticationDialog.getWorkstation();
+ domain = authenticationDialog.getDomain();
+ }
+ }
}
/**
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/ProgressView.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/ProgressView.java index d4eb362..3361a58 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/ProgressView.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/ProgressView.java @@ -18,9 +18,9 @@ package com.android.sdkuilib.internal.tasks; import com.android.sdklib.internal.repository.ITask;
import com.android.sdklib.internal.repository.ITaskMonitor;
+import com.android.sdklib.internal.repository.UserCredentials;
import com.android.sdkuilib.ui.AuthenticationDialog;
import com.android.sdkuilib.ui.GridDialog;
-import com.android.util.Pair;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
@@ -309,22 +309,17 @@ public final class ProgressView implements IProgressUiProvider { } /**
- * This method opens a pop-up window which requests for User Login and
- * password.
+ * This method opens a pop-up window which requests for User Credentials.
*
* @param title The title of the window.
* @param message The message to displayed in the login/password window.
- * @return Returns a {@link Pair} holding the entered login and password.
- * The information must always be in the following order:
- * Login,Password. So in order to retrieve the <b>login</b> callers
- * should retrieve the first element, and the second value for the
- * <b>password</b>.
+ * @return Returns user provided credentials.
* If operation is <b>canceled</b> by user the return value must be <b>null</b>.
- * @see ITaskMonitor#displayLoginPasswordPrompt(String, String)
+ * @see ITaskMonitor#displayLoginCredentialsPrompt(String, String)
*/
- public Pair<String, String>
- displayLoginPasswordPrompt(final String title, final String message) {
- final String[] resultArray = new String[] {"", ""};
+ public UserCredentials
+ displayLoginCredentialsPrompt(final String title, final String message) {
+ final String[] resultArray = new String[] {"", "", "", ""};
// open dialog and request login and password
syncExec(mProgressBar, new Runnable() {
public void run() {
@@ -336,13 +331,16 @@ public final class ProgressView implements IProgressUiProvider { if (dlgResult == GridDialog.OK) {
resultArray[0] = authenticationDialog.getLogin();
resultArray[1] = authenticationDialog.getPassword();
- } else {
- resultArray[0] = null;
- resultArray[1] = null;
+ resultArray[2] = authenticationDialog.getWorkstation();
+ resultArray[3] = authenticationDialog.getDomain();
}
}
});
- return resultArray[0] == null ? null : Pair.of(resultArray[0], resultArray[1]);
- }
+ return new UserCredentials(resultArray[0],
+ resultArray[1],
+ resultArray[2],
+ resultArray[3]);
+ }
}
+
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/TaskMonitorImpl.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/TaskMonitorImpl.java index bb2991c..ff207c5 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/TaskMonitorImpl.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/TaskMonitorImpl.java @@ -17,7 +17,7 @@ package com.android.sdkuilib.internal.tasks;
import com.android.sdklib.internal.repository.ITaskMonitor;
-import com.android.util.Pair;
+import com.android.sdklib.internal.repository.UserCredentials;
/**
* Internal class that implements the logic of an {@link ITaskMonitor}.
@@ -177,8 +177,8 @@ class TaskMonitorImpl implements ITaskMonitor { * element and Password is always the second. If any error occurs a
* pair with empty strings is returned.
*/
- public Pair<String, String> displayLoginPasswordPrompt(String title, String message) {
- return mUi.displayLoginPasswordPrompt(title, message);
+ public UserCredentials displayLoginCredentialsPrompt(String title, String message) {
+ return mUi.displayLoginCredentialsPrompt(title, message);
}
/**
@@ -297,8 +297,8 @@ class TaskMonitorImpl implements ITaskMonitor { return mRoot.displayPrompt(title, message);
}
- public Pair<String, String> displayLoginPasswordPrompt(String title, String message) {
- return mRoot.displayLoginPasswordPrompt(title, message);
+ public UserCredentials displayLoginCredentialsPrompt(String title, String message) {
+ return mRoot.displayLoginCredentialsPrompt(title, message);
}
public ITaskMonitor createSubMonitor(int tickCount) {
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/ui/AuthenticationDialog.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/ui/AuthenticationDialog.java index 497c752..10e2e6e 100644 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/ui/AuthenticationDialog.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/ui/AuthenticationDialog.java @@ -30,18 +30,18 @@ import org.eclipse.swt.widgets.Text; * Dialog which collects from the user his/her login and password. */ public class AuthenticationDialog extends GridDialog { - private Text mTxtLogin; - private Text mTxtPassword; + private Text mTxtWorkstation; + private Text mTxtDomain; private String mTitle; - private String mMessage; - protected String mLogin; - - protected String mPassword; + private String mLogin; + private String mPassword; + private String mWorkstation; + private String mDomain; /** * Constructor which retrieves the parent {@link Shell} and the message to @@ -92,7 +92,7 @@ public class AuthenticationDialog extends GridDialog { mTxtLogin.setFocus(); mTxtLogin.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent arg0) { - mLogin = mTxtLogin.getText(); + mLogin = mTxtLogin.getText().trim(); } }); @@ -110,6 +110,43 @@ public class AuthenticationDialog extends GridDialog { mPassword = mTxtPassword.getText(); } }); + + // add a label indicating that the following two fields are optional + Label lblInfo = new Label(upperComposite, SWT.NONE); + lblInfo.setText("Provide the following info if your proxy uses NTLM authentication. Leave blank otherwise."); + data = new GridData(); + data.horizontalSpan = 2; + lblInfo.setLayoutData(data); + + // add workstation label and text field + Label lblWorkstation = new Label(upperComposite, SWT.NONE); + lblWorkstation.setText("Workstation:"); + data = new GridData(SWT.LEFT, SWT.CENTER, false, false); + lblWorkstation.setLayoutData(data); + + mTxtWorkstation = new Text(upperComposite, SWT.SINGLE | SWT.BORDER); + data = new GridData(SWT.FILL, SWT.CENTER, true, false); + mTxtWorkstation.setLayoutData(data); + mTxtWorkstation.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent arg0) { + mWorkstation = mTxtWorkstation.getText().trim(); + } + }); + + // add domain label and text field + Label lblDomain = new Label(upperComposite, SWT.NONE); + lblDomain.setText("Domain:"); + data = new GridData(SWT.LEFT, SWT.CENTER, false, false); + lblDomain.setLayoutData(data); + + mTxtDomain = new Text(upperComposite, SWT.SINGLE | SWT.BORDER); + data = new GridData(SWT.FILL, SWT.CENTER, true, false); + mTxtDomain.setLayoutData(data); + mTxtDomain.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent arg0) { + mDomain = mTxtDomain.getText().trim(); + } + }); } /** @@ -129,4 +166,22 @@ public class AuthenticationDialog extends GridDialog { public String getPassword() { return mPassword != null ? mPassword : ""; //$NON-NLS-1$ } + + /** + * Retrieves the workstation field information + * + * @return Workstation field value or empty String. Return value is never null + */ + public String getWorkstation() { + return mWorkstation != null ? mWorkstation : ""; + } + + /** + * Retrieves the domain field information + * + * @return Domain field value or empty String. Return value is never null + */ + public String getDomain() { + return mDomain != null ? mDomain : ""; + } } |