OC-1029: add method isIdPRedirection
authormasensio <masensio@solidgear.es>
Wed, 21 Aug 2013 16:31:57 +0000 (18:31 +0200)
committermasensio <masensio@solidgear.es>
Wed, 21 Aug 2013 16:31:57 +0000 (18:31 +0200)
src/com/owncloud/android/authentication/AuthenticatorActivity.java
src/com/owncloud/android/files/services/FileDownloader.java
src/com/owncloud/android/files/services/FileUploader.java
src/com/owncloud/android/operations/RemoteOperation.java
src/com/owncloud/android/operations/RemoteOperationResult.java
src/com/owncloud/android/syncadapter/FileSyncAdapter.java

index 2387ad1..bab98de 100644 (file)
@@ -773,7 +773,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             // NOTHING TO DO ; can't find out what situation that leads to the exception in this code, but user logs signal that it happens\r
         }\r
         \r
             // NOTHING TO DO ; can't find out what situation that leads to the exception in this code, but user logs signal that it happens\r
         }\r
         \r
-        if (result.isTemporalRedirection()) {\r
+        if (result.isTemporalRedirection() || result.isIdPRedirection()) {\r
             String url = result.getRedirectedLocation();\r
             String targetUrl = mHostBaseUrl + AccountUtils.getWebdavPath(mDiscoveredVersion, mCurrentAuthTokenType);\r
             \r
             String url = result.getRedirectedLocation();\r
             String targetUrl = mHostBaseUrl + AccountUtils.getWebdavPath(mDiscoveredVersion, mCurrentAuthTokenType);\r
             \r
index 9410e6d..0afcf6a 100644 (file)
@@ -465,7 +465,8 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
             Notification finalNotification = new Notification(R.drawable.icon, getString(tickerId), System.currentTimeMillis());
             finalNotification.flags |= Notification.FLAG_AUTO_CANCEL;
             boolean needsToUpdateCredentials = (downloadResult.getCode() == ResultCode.UNAUTHORIZED ||
             Notification finalNotification = new Notification(R.drawable.icon, getString(tickerId), System.currentTimeMillis());
             finalNotification.flags |= Notification.FLAG_AUTO_CANCEL;
             boolean needsToUpdateCredentials = (downloadResult.getCode() == ResultCode.UNAUTHORIZED ||
-                                                (downloadResult.isTemporalRedirection() && AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mDownloadClient.getAuthTokenType())));
+                                                ((downloadResult.isTemporalRedirection() || downloadResult.isIdPRedirection())
+                                                        && AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mDownloadClient.getAuthTokenType())));
             if (needsToUpdateCredentials) {
                 // let the user update credentials with one click
                 Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
             if (needsToUpdateCredentials) {
                 // let the user update credentials with one click
                 Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
index 0d0d538..4863840 100644 (file)
@@ -794,7 +794,8 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
             String content = null;
             
             boolean needsToUpdateCredentials = (uploadResult.getCode() == ResultCode.UNAUTHORIZED ||
             String content = null;
             
             boolean needsToUpdateCredentials = (uploadResult.getCode() == ResultCode.UNAUTHORIZED ||
-                    (uploadResult.isTemporalRedirection() && AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mUploadClient.getAuthTokenType())));
+                    ((uploadResult.isTemporalRedirection() || uploadResult.isIdPRedirection())
+                            && AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mUploadClient.getAuthTokenType())));
             if (needsToUpdateCredentials) {
                 // let the user update credentials with one click
                 Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
             if (needsToUpdateCredentials) {
                 // let the user update credentials with one click
                 Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
index 16ecf27..0d7e6ec 100644 (file)
@@ -243,7 +243,7 @@ public abstract class RemoteOperation implements Runnable {
         
             repeat = false;
             if (mCallerActivity != null && mAccount != null && mContext != null && !result.isSuccess() &&
         
             repeat = false;
             if (mCallerActivity != null && mAccount != null && mContext != null && !result.isSuccess() &&
-                    (result.getCode() == ResultCode.UNAUTHORIZED || result.isTemporalRedirection())) {
+                    (result.getCode() == ResultCode.UNAUTHORIZED || result.isTemporalRedirection() || result.isIdPRedirection())) {
                 /// possible fail due to lack of authorization in an operation performed in foreground
                 Credentials cred = mClient.getCredentials();
                 String ssoSessionCookie = mClient.getSsoSessionCookie();
                 /// possible fail due to lack of authorization in an operation performed in foreground
                 Credentials cred = mClient.getCredentials();
                 String ssoSessionCookie = mClient.getSsoSessionCookie();
index 6c5d8b8..7a70744 100644 (file)
@@ -24,7 +24,6 @@ import java.net.MalformedURLException;
 import java.net.SocketException;
 import java.net.SocketTimeoutException;
 import java.net.UnknownHostException;
 import java.net.SocketException;
 import java.net.SocketTimeoutException;
 import java.net.UnknownHostException;
-import java.util.Map;
 
 import javax.net.ssl.SSLException;
 
 
 import javax.net.ssl.SSLException;
 
@@ -313,13 +312,16 @@ public class RemoteOperationResult implements Serializable {
     }
 
     public boolean isTemporalRedirection() {
     }
 
     public boolean isTemporalRedirection() {
-        return (mHttpCode == 302 || mHttpCode == 307 || 
-                mRedirectedLocation.toUpperCase().contains("SAML") || 
-                mRedirectedLocation.toLowerCase().contains("wayf"));
+        return (mHttpCode == 302 || mHttpCode == 307);
     }
 
     public String getRedirectedLocation() {
         return mRedirectedLocation;
     }
 
     }
 
     public String getRedirectedLocation() {
         return mRedirectedLocation;
     }
 
+    public boolean isIdPRedirection() {
+        return (mRedirectedLocation.toUpperCase().contains("SAML") || 
+                mRedirectedLocation.toLowerCase().contains("wayf"));
+    }
+
 }
 }
index 2bf135b..4103dbf 100644 (file)
@@ -225,7 +225,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
             
         } else {
             if (result.getCode() == RemoteOperationResult.ResultCode.UNAUTHORIZED ||
             
         } else {
             if (result.getCode() == RemoteOperationResult.ResultCode.UNAUTHORIZED ||
-                    (result.isTemporalRedirection() && getClient().getSsoSessionCookie() != null)) {
+                    ((result.isTemporalRedirection() || result.isIdPRedirection()) && getClient().getSsoSessionCookie() != null)) {
                 mSyncResult.stats.numAuthExceptions++;
                 
             } else if (result.getException() instanceof DavException) {
                 mSyncResult.stats.numAuthExceptions++;
                 
             } else if (result.getException() instanceof DavException) {
@@ -308,7 +308,8 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
         notification.flags |= Notification.FLAG_AUTO_CANCEL;
         boolean needsToUpdateCredentials = (mLastFailedResult != null && 
                                              (  mLastFailedResult.getCode() == ResultCode.UNAUTHORIZED ||
         notification.flags |= Notification.FLAG_AUTO_CANCEL;
         boolean needsToUpdateCredentials = (mLastFailedResult != null && 
                                              (  mLastFailedResult.getCode() == ResultCode.UNAUTHORIZED ||
-                                                (mLastFailedResult.isTemporalRedirection() && AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(getClient().getAuthTokenType()))
+                                                ((mLastFailedResult.isTemporalRedirection() || mLastFailedResult.isIdPRedirection())
+                                                        && AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(getClient().getAuthTokenType()))
                                              )
                                            );
         // TODO put something smart in the contentIntent below for all the possible errors
                                              )
                                            );
         // TODO put something smart in the contentIntent below for all the possible errors