Skip to content

Commit 9160514

Browse files
authored
Merge pull request #111 from nextcloud/untrustedDomain
Show infos on untrusted domains if available
2 parents 918f2db + 03d7510 commit 9160514

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ public enum ResultCode {
125125
DELAYED_IN_POWER_SAVE_MODE,
126126
ACCOUNT_USES_STANDARD_PASSWORD,
127127
METADATA_NOT_FOUND,
128-
OLD_ANDROID_API
128+
OLD_ANDROID_API,
129+
UNTRUSTED_DOMAIN
129130
}
130131

131132
private boolean mSuccess = false;

src/com/owncloud/android/lib/resources/status/GetRemoteStatusOperation.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public class GetRemoteStatusOperation extends RemoteOperation {
6363
private static final String NODE_VERSION = "version";
6464
private static final String PROTOCOL_HTTPS = "https://";
6565
private static final String PROTOCOL_HTTP = "http://";
66+
private static final int UNTRUSTED_DOMAIN_ERROR_CODE = 15;
6667

6768
private RemoteOperationResult mLatestResult;
6869
private Context mContext;
@@ -103,6 +104,7 @@ private boolean tryConnection(OwnCloudClient client) {
103104
}
104105

105106
String response = get.getResponseBodyAsString();
107+
106108
if (status == HttpStatus.SC_OK) {
107109
JSONObject json = new JSONObject(response);
108110
if (!json.getBoolean(NODE_INSTALLED)) {
@@ -137,13 +139,24 @@ private boolean tryConnection(OwnCloudClient client) {
137139
}
138140
}
139141

142+
} else if (status == HttpStatus.SC_BAD_REQUEST) {
143+
try {
144+
JSONObject json = new JSONObject(response);
145+
146+
if (json.getInt("code") == UNTRUSTED_DOMAIN_ERROR_CODE) {
147+
mLatestResult = new RemoteOperationResult(RemoteOperationResult.ResultCode.UNTRUSTED_DOMAIN);
148+
} else {
149+
mLatestResult = new RemoteOperationResult(false, status, get.getResponseHeaders());
150+
}
151+
} catch (JSONException e) {
152+
mLatestResult = new RemoteOperationResult(false, status, get.getResponseHeaders());
153+
}
140154
} else {
141155
mLatestResult = new RemoteOperationResult(false, status, get.getResponseHeaders());
142156
}
143157

144158
} catch (JSONException e) {
145-
mLatestResult = new RemoteOperationResult(
146-
RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED);
159+
mLatestResult = new RemoteOperationResult(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED);
147160

148161
} catch (Exception e) {
149162
mLatestResult = new RemoteOperationResult(e);

0 commit comments

Comments
 (0)