use of com.biglybt.core.util.http.HTTPAuthHelper in project BiglyBT by BiglySoftware.
the class ExternalLoginWindow method setCaptureMethod.
protected void setCaptureMethod(final BrowserWrapper browser, boolean transparent, boolean show_progress) {
if (sniffer != null) {
sniffer.destroy();
sniffer = null;
}
if (show_progress) {
final ProgressWindow prog_wind = new ProgressWindow(shell, "externalLogin.wait", SWT.DIALOG_TRIM, 500);
browser.addProgressListener(new ProgressListener() {
@Override
public void changed(ProgressEvent arg0) {
}
@Override
public void completed(ProgressEvent arg0) {
if (browser.isDisposed() || browser.getShell().isDisposed()) {
return;
}
browser.removeProgressListener(this);
prog_wind.destroy();
}
});
}
if (transparent) {
browser.setUrl(originalLoginUrl);
} else {
try {
final HTTPAuthHelper this_sniffer = sniffer = new HTTPAuthHelper(new URL(originalLoginUrl));
this_sniffer.addListener(new HTTPAuthHelperListener() {
@Override
public void cookieFound(HTTPAuthHelper helper, String cookie_name, String cookie_value) {
if (helper == this_sniffer) {
foundCookies(cookie_name + "=" + cookie_value, false);
}
}
});
this_sniffer.start();
String str = originalLoginUrl.toString();
int pos = str.indexOf("://");
str = str.substring(pos + 3);
pos = str.indexOf("/");
if (pos != -1) {
str = str.substring(pos);
}
if (!str.startsWith("/")) {
str = "/" + str;
}
browser.setUrl("http://localhost:" + sniffer.getPort() + str);
} catch (Throwable e) {
Debug.printStackTrace(e);
}
}
}
Aggregations