Skip to content

Commit

Permalink
Merge pull request #111 from nextcloud/untrustedDomain
Browse files Browse the repository at this point in the history
Show infos on untrusted domains if available
  • Loading branch information
mario authored Jan 23, 2018
2 parents 918f2db + 03d7510 commit 9160514
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ public enum ResultCode {
DELAYED_IN_POWER_SAVE_MODE,
ACCOUNT_USES_STANDARD_PASSWORD,
METADATA_NOT_FOUND,
OLD_ANDROID_API
OLD_ANDROID_API,
UNTRUSTED_DOMAIN
}

private boolean mSuccess = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class GetRemoteStatusOperation extends RemoteOperation {
private static final String NODE_VERSION = "version";
private static final String PROTOCOL_HTTPS = "https://";
private static final String PROTOCOL_HTTP = "http://";
private static final int UNTRUSTED_DOMAIN_ERROR_CODE = 15;

private RemoteOperationResult mLatestResult;
private Context mContext;
Expand Down Expand Up @@ -103,6 +104,7 @@ private boolean tryConnection(OwnCloudClient client) {
}

String response = get.getResponseBodyAsString();

if (status == HttpStatus.SC_OK) {
JSONObject json = new JSONObject(response);
if (!json.getBoolean(NODE_INSTALLED)) {
Expand Down Expand Up @@ -137,13 +139,24 @@ private boolean tryConnection(OwnCloudClient client) {
}
}

} else if (status == HttpStatus.SC_BAD_REQUEST) {
try {
JSONObject json = new JSONObject(response);

if (json.getInt("code") == UNTRUSTED_DOMAIN_ERROR_CODE) {
mLatestResult = new RemoteOperationResult(RemoteOperationResult.ResultCode.UNTRUSTED_DOMAIN);
} else {
mLatestResult = new RemoteOperationResult(false, status, get.getResponseHeaders());
}
} catch (JSONException e) {
mLatestResult = new RemoteOperationResult(false, status, get.getResponseHeaders());
}
} else {
mLatestResult = new RemoteOperationResult(false, status, get.getResponseHeaders());
}

} catch (JSONException e) {
mLatestResult = new RemoteOperationResult(
RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED);
mLatestResult = new RemoteOperationResult(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED);

} catch (Exception e) {
mLatestResult = new RemoteOperationResult(e);
Expand Down

0 comments on commit 9160514

Please sign in to comment.