|
Lines 148-157
Link Here
|
| 148 |
|
148 |
|
| 149 |
protected Proxy proxy = Proxy.NO_PROXY; |
149 |
protected Proxy proxy = Proxy.NO_PROXY; |
| 150 |
|
150 |
|
| 151 |
protected String username; |
|
|
| 152 |
|
| 153 |
protected String password; |
| 154 |
|
| 155 |
protected URL repositoryUrl; |
151 |
protected URL repositoryUrl; |
| 156 |
|
152 |
|
| 157 |
protected String characterEncoding; |
153 |
protected String characterEncoding; |
|
Lines 174-184
Link Here
|
| 174 |
|
170 |
|
| 175 |
public BugzillaClient(AbstractWebLocation location, String characterEncoding, Map<String, String> configParameters, |
171 |
public BugzillaClient(AbstractWebLocation location, String characterEncoding, Map<String, String> configParameters, |
| 176 |
BugzillaLanguageSettings languageSettings) throws MalformedURLException { |
172 |
BugzillaLanguageSettings languageSettings) throws MalformedURLException { |
| 177 |
AuthenticationCredentials credentials = location.getCredentials(AuthenticationType.REPOSITORY); |
|
|
| 178 |
if (credentials != null) { |
| 179 |
this.username = credentials.getUserName(); |
| 180 |
this.password = credentials.getPassword(); |
| 181 |
} |
| 182 |
this.repositoryUrl = new URL(location.getUrl()); |
173 |
this.repositoryUrl = new URL(location.getUrl()); |
| 183 |
this.location = location; |
174 |
this.location = location; |
| 184 |
this.characterEncoding = characterEncoding; |
175 |
this.characterEncoding = characterEncoding; |
|
Lines 202-208
Link Here
|
| 202 |
} |
193 |
} |
| 203 |
|
194 |
|
| 204 |
protected boolean hasAuthenticationCredentials() { |
195 |
protected boolean hasAuthenticationCredentials() { |
| 205 |
return username != null && username.length() > 0; |
196 |
AuthenticationCredentials credentials = location.getCredentials(AuthenticationType.REPOSITORY); |
|
|
197 |
return (credentials != null && credentials.getUserName().length() > 0); |
| 206 |
} |
198 |
} |
| 207 |
|
199 |
|
| 208 |
private GzipGetMethod getConnect(String serverURL, IProgressMonitor monitor) throws IOException, CoreException { |
200 |
private GzipGetMethod getConnect(String serverURL, IProgressMonitor monitor) throws IOException, CoreException { |
|
Lines 349-356
Link Here
|
| 349 |
hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor); |
341 |
hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor); |
| 350 |
|
342 |
|
| 351 |
NameValuePair[] formData = new NameValuePair[2]; |
343 |
NameValuePair[] formData = new NameValuePair[2]; |
| 352 |
formData[0] = new NameValuePair(IBugzillaConstants.POST_INPUT_BUGZILLA_LOGIN, username); |
344 |
AuthenticationCredentials credentials = location.getCredentials(AuthenticationType.REPOSITORY); |
| 353 |
formData[1] = new NameValuePair(IBugzillaConstants.POST_INPUT_BUGZILLA_PASSWORD, password); |
345 |
if (credentials == null) { |
|
|
346 |
authenticated = false; |
| 347 |
throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, |
| 348 |
RepositoryStatus.ERROR_REPOSITORY_LOGIN, repositoryUrl.toString(), |
| 349 |
"Authentication credentials from location missing.")); //$NON-NLS-1$ |
| 350 |
} |
| 351 |
formData[0] = new NameValuePair(IBugzillaConstants.POST_INPUT_BUGZILLA_LOGIN, credentials.getUserName()); |
| 352 |
formData[1] = new NameValuePair(IBugzillaConstants.POST_INPUT_BUGZILLA_PASSWORD, credentials.getPassword()); |
| 354 |
|
353 |
|
| 355 |
postMethod = new GzipPostMethod(WebUtil.getRequestPath(repositoryUrl.toString() |
354 |
postMethod = new GzipPostMethod(WebUtil.getRequestPath(repositoryUrl.toString() |
| 356 |
+ IBugzillaConstants.URL_POST_LOGIN), true); |
355 |
+ IBugzillaConstants.URL_POST_LOGIN), true); |
|
Lines 665-670
Link Here
|
| 665 |
postMethod.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, true); |
664 |
postMethod.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, true); |
| 666 |
List<PartBase> parts = new ArrayList<PartBase>(); |
665 |
List<PartBase> parts = new ArrayList<PartBase>(); |
| 667 |
parts.add(new StringPart(IBugzillaConstants.POST_INPUT_ACTION, VALUE_ACTION_INSERT, characterEncoding)); |
666 |
parts.add(new StringPart(IBugzillaConstants.POST_INPUT_ACTION, VALUE_ACTION_INSERT, characterEncoding)); |
|
|
667 |
AuthenticationCredentials credentials = location.getCredentials(AuthenticationType.REPOSITORY); |
| 668 |
String username; |
| 669 |
String password; |
| 670 |
if (credentials != null) { |
| 671 |
username = credentials.getUserName(); |
| 672 |
password = credentials.getPassword(); |
| 673 |
} else { |
| 674 |
username = null; |
| 675 |
password = null; |
| 676 |
|
| 677 |
} |
| 668 |
if (username != null && password != null) { |
678 |
if (username != null && password != null) { |
| 669 |
parts.add(new StringPart(IBugzillaConstants.POST_INPUT_BUGZILLA_LOGIN, username, characterEncoding)); |
679 |
parts.add(new StringPart(IBugzillaConstants.POST_INPUT_BUGZILLA_LOGIN, username, characterEncoding)); |
| 670 |
parts.add(new StringPart(IBugzillaConstants.POST_INPUT_BUGZILLA_PASSWORD, password, characterEncoding)); |
680 |
parts.add(new StringPart(IBugzillaConstants.POST_INPUT_BUGZILLA_PASSWORD, password, characterEncoding)); |