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