@@ -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