mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
unencrypted protocol message
This commit is contained in:
parent
1fbd102402
commit
357d3ecd3e
5 changed files with 21 additions and 15 deletions
|
@ -2,7 +2,7 @@
|
|||
DONE persistent cookie storage
|
||||
DONE use expiration cookie info
|
||||
DONE common auth dialog for basic auth & litres
|
||||
* unencrypted protocol warning
|
||||
DONE unencrypted protocol warning
|
||||
* POST processing
|
||||
* SSLCertificate processing
|
||||
|
||||
|
|
|
@ -67,11 +67,11 @@ public class AuthenticationActivity extends Activity {
|
|||
findTextView(R.id.authentication_subtitle).setVisibility(View.GONE);
|
||||
}
|
||||
final TextView warningView = findTextView(R.id.authentication_unencrypted_warning);
|
||||
//if ("https".equalsIgnoreCase(intent.getStringExtra(SCHEME_KEY))) {
|
||||
if ("https".equalsIgnoreCase(intent.getStringExtra(SCHEME_KEY))) {
|
||||
warningView.setVisibility(View.GONE);
|
||||
//} else {
|
||||
// warningView.setText(myResource.getResource("unencryptedWarning").getValue());
|
||||
//}
|
||||
} else {
|
||||
warningView.setText(myResource.getResource("unencryptedWarning").getValue());
|
||||
}
|
||||
findTextView(R.id.authentication_username_label).setText(
|
||||
myResource.getResource("login").getValue()
|
||||
);
|
||||
|
|
|
@ -103,7 +103,7 @@ public class NetworkCatalogActivity extends NetworkBaseActivity implements UserR
|
|||
private volatile String myUsername;
|
||||
private volatile String myPassword;
|
||||
|
||||
public Credentials createCredentials(AuthScope scope) {
|
||||
public Credentials createCredentials(String scheme, AuthScope scope) {
|
||||
if (!"basic".equalsIgnoreCase(scope.getScheme())) {
|
||||
return null;
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ public class NetworkCatalogActivity extends NetworkBaseActivity implements UserR
|
|||
intent.setClass(NetworkCatalogActivity.this, AuthenticationActivity.class);
|
||||
intent.putExtra(AuthenticationActivity.HOST_KEY, host);
|
||||
intent.putExtra(AuthenticationActivity.AREA_KEY, area);
|
||||
intent.putExtra(AuthenticationActivity.SCHEME_KEY, scope.getScheme());
|
||||
intent.putExtra(AuthenticationActivity.SCHEME_KEY, scheme);
|
||||
intent.putExtra(AuthenticationActivity.USERNAME_KEY, option.getValue());
|
||||
startActivityForResult(intent, BASIC_AUTHENTICATION_CODE);
|
||||
synchronized (this) {
|
||||
|
|
|
@ -87,6 +87,7 @@ abstract class Util implements UserRegistrationConstants {
|
|||
if (isRegistrationSupported(activity, link)) {
|
||||
intent.putExtra(AuthenticationActivity.SHOW_SIGNUP_LINK_KEY, true);
|
||||
}
|
||||
intent.putExtra(AuthenticationActivity.SCHEME_KEY, "https");
|
||||
intent.putExtra(AuthenticationActivity.ERROR_KEY, error);
|
||||
if (onSuccess != null) {
|
||||
myAfterRegisrationMap.put(activity, onSuccess);
|
||||
|
|
|
@ -30,8 +30,7 @@ import org.apache.http.auth.AuthScope;
|
|||
import org.apache.http.auth.Credentials;
|
||||
import org.apache.http.client.CookieStore;
|
||||
import org.apache.http.client.CredentialsProvider;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.*;
|
||||
import org.apache.http.client.protocol.ClientContext;
|
||||
import org.apache.http.cookie.Cookie;
|
||||
import org.apache.http.impl.client.*;
|
||||
|
@ -52,20 +51,26 @@ public class ZLNetworkManager {
|
|||
}
|
||||
|
||||
public static interface CredentialsCreator {
|
||||
Credentials createCredentials(AuthScope scope);
|
||||
Credentials createCredentials(String scheme, AuthScope scope);
|
||||
}
|
||||
|
||||
private CredentialsCreator myCredentialsCreator;
|
||||
|
||||
private class MyCredentialsProvider extends BasicCredentialsProvider {
|
||||
private final HttpUriRequest myRequest;
|
||||
|
||||
MyCredentialsProvider(HttpUriRequest request) {
|
||||
myRequest = request;
|
||||
}
|
||||
|
||||
private volatile CredentialsCreator myCredentialsCreator;
|
||||
private final CredentialsProvider myCredentialsProvider = new BasicCredentialsProvider() {
|
||||
@Override
|
||||
public Credentials getCredentials(AuthScope authscope) {
|
||||
System.err.println("getCredentials");
|
||||
final Credentials c = super.getCredentials(authscope);
|
||||
if (c != null) {
|
||||
return c;
|
||||
}
|
||||
if (myCredentialsCreator != null) {
|
||||
return myCredentialsCreator.createCredentials(authscope);
|
||||
return myCredentialsCreator.createCredentials(myRequest.getURI().getScheme(), authscope);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -135,9 +140,9 @@ public class ZLNetworkManager {
|
|||
try {
|
||||
request.doBefore();
|
||||
httpClient = new DefaultHttpClient();
|
||||
httpClient.setCredentialsProvider(myCredentialsProvider);
|
||||
final HttpGet getRequest = new HttpGet(request.URL);
|
||||
setCommonHTTPOptions(getRequest);
|
||||
httpClient.setCredentialsProvider(new MyCredentialsProvider(getRequest));
|
||||
/*
|
||||
if (request.PostData != null) {
|
||||
httpConnection.setRequestMethod("POST");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue