Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

[New arch] Remove SAML #263

Merged
merged 2 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* Dynamic implementation of {@link OwnCloudClientManager}.
* <p>
*
* Wraps instances of {@link SingleSessionManager} and {@link SimpleFactoryManager} and delegates on one
* or the other depending on the known version of the server corresponding to the {@link OwnCloudAccount}
*
Expand Down Expand Up @@ -60,4 +60,4 @@ public void saveAllClients(Context context, String accountType) {
mSimpleFactoryManager.saveAllClients(context, accountType);
mSingleSessionManager.saveAllClients(context, accountType);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public int executeHttpMethod(HttpBaseMethod method) throws Exception {
status = method.execute();
checkFirstRedirection(method);

if (mFollowRedirects && !isIdPRedirection()) {
if (mFollowRedirects) {
status = followRedirection(method).getLastStatus();
}

Expand Down Expand Up @@ -422,7 +422,7 @@ private boolean checkUnauthorizedAccess(int status, int repeatCounter) {
*/
private boolean shouldInvalidateAccountCredentials(int httpStatusCode) {

boolean should = (httpStatusCode == HttpConstants.HTTP_UNAUTHORIZED || isIdPRedirection()); // invalid credentials
boolean should = (httpStatusCode == HttpConstants.HTTP_UNAUTHORIZED); // invalid credentials

should &= (mCredentials != null && // real credentials
!(mCredentials instanceof OwnCloudCredentialsFactory.OwnCloudAnonymousCredentials));
Expand Down Expand Up @@ -459,17 +459,6 @@ void setOwnCloudClientManager(OwnCloudClientManager clientManager) {
mOwnCloudClientManager = clientManager;
}

/**
* Check if the redirection is to an identity provider such as SAML or wayf
*
* @return true if the redirection location includes SAML or wayf, false otherwise
*/
private boolean isIdPRedirection() {
return (mRedirectedLocation != null &&
(mRedirectedLocation.toUpperCase().contains("SAML") ||
mRedirectedLocation.toLowerCase().contains("wayf")));
}

public boolean followRedirects() {
return mFollowRedirects;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ownCloud Android Library is available under MIT license
* Copyright (C) 2016 ownCloud GmbH.
* Copyright (C) 2019 ownCloud GmbH.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -38,9 +38,6 @@ public static OwnCloudClientManager newOwnCloudClientManager(Policy policy) {
case ALWAYS_NEW_CLIENT:
return new SimpleFactoryManager();

case SINGLE_SESSION_PER_ACCOUNT:
return new SingleSessionManager();

case SINGLE_SESSION_PER_ACCOUNT_IF_SERVER_SUPPORTS_SERVER_MONITORING:
return new DynamicSessionManager();

Expand Down Expand Up @@ -86,16 +83,11 @@ private static boolean defaultSingletonMustBeUpdated(Policy policy) {
!(sDefaultSingleton instanceof SimpleFactoryManager)) {
return true;
}
if (policy == Policy.SINGLE_SESSION_PER_ACCOUNT &&
!(sDefaultSingleton instanceof SingleSessionManager)) {
return true;
}
return false;
}

public static enum Policy {
public enum Policy {
ALWAYS_NEW_CLIENT,
SINGLE_SESSION_PER_ACCOUNT,
SINGLE_SESSION_PER_ACCOUNT_IF_SERVER_SUPPORTS_SERVER_MONITORING
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import android.util.Log;

import com.owncloud.android.lib.common.accounts.AccountUtils;
import com.owncloud.android.lib.common.authentication.OwnCloudSamlSsoCredentials;
import com.owncloud.android.lib.common.utils.Log_OC;

import java.io.IOException;
Expand Down Expand Up @@ -119,10 +118,6 @@ public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) thr
account.loadCredentials(context);
client.setCredentials(account.getCredentials());

if (client.getCredentials() instanceof OwnCloudSamlSsoCredentials) {
client.disableAutomaticCookiesHandling();
}

if (accountName != null) {
mClientsWithKnownUsername.put(accountName, client);
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Expand Down Expand Up @@ -232,4 +227,4 @@ private void keepUriUpdated(OwnCloudAccount account, OwnCloudClient reusedClient
reusedClient.setBaseUri(recentUri);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ownCloud Android Library is available under MIT license
* Copyright (C) 2016 ownCloud GmbH.
* Copyright (C) 2019 ownCloud GmbH.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -41,9 +41,4 @@ public static String getAuthTokenTypeAccessToken(String accountType) {
public static String getAuthTokenTypeRefreshToken(String accountType) {
return accountType + ".oauth2.refresh_token";
}

public static String getAuthTokenTypeSamlSessionCookie(String accountType) {
return accountType + ".saml.web_sso.session_cookie";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ public static String getWebDavUrlForAccount(Context context, Account account)
OwnCloudCredentials ownCloudCredentials = getCredentialsForAccount(context, account);
webDavUrlForAccount = getBaseUrlForAccount(context, account) + OwnCloudClient.WEBDAV_FILES_PATH_4_0
+ ownCloudCredentials.getUsername();
} catch (OperationCanceledException e) {
e.printStackTrace();
} catch (AuthenticatorException e) {
e.printStackTrace();
} catch (IOException e) {
} catch (OperationCanceledException | AuthenticatorException | IOException e) {
e.printStackTrace();
}

Expand Down Expand Up @@ -148,11 +144,6 @@ public static OwnCloudCredentials getCredentialsForAccount(Context context, Acco
String supportsOAuth2 = am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_OAUTH2);
boolean isOauth2 = supportsOAuth2 != null && supportsOAuth2.equals("TRUE");

String supportsSamlSSo = am.getUserData(account,
AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO);

boolean isSamlSso = supportsSamlSSo != null && supportsSamlSSo.equals("TRUE");

String username = AccountUtils.getUsernameForAccount(account);
OwnCloudVersion version = new OwnCloudVersion(am.getUserData(account, Constants.KEY_OC_VERSION));

Expand All @@ -164,14 +155,6 @@ public static OwnCloudCredentials getCredentialsForAccount(Context context, Acco

credentials = OwnCloudCredentialsFactory.newBearerCredentials(username, accessToken);

} else if (isSamlSso) {
String accessToken = am.blockingGetAuthToken(
account,
AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(account.type),
false);

credentials = OwnCloudCredentialsFactory.newSamlSsoCredentials(username, accessToken);

} else {
String password = am.blockingGetAuthToken(
account,
Expand Down Expand Up @@ -317,10 +300,7 @@ public static class Constants {
* Flag signaling if the ownCloud server can be accessed with OAuth2 access tokens.
*/
public static final String KEY_SUPPORTS_OAUTH2 = "oc_supports_oauth2";
/**
* Flag signaling if the ownCloud server can be accessed with session cookies from SAML-based web single-sign-on.
*/
public static final String KEY_SUPPORTS_SAML_WEB_SSO = "oc_supports_saml_web_sso";

/**
* OC account cookies
*/
Expand All @@ -345,6 +325,5 @@ public static class Constants {
* OAuth2 refresh token
**/
public static final String KEY_OAUTH2_REFRESH_TOKEN = "oc_oauth2_refresh_token";

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ public static OwnCloudCredentials newBearerCredentials(String username, String a
return new OwnCloudBearerCredentials(username, authToken);
}

public static OwnCloudCredentials newSamlSsoCredentials(String username, String sessionCookie) {
return new OwnCloudSamlSsoCredentials(username, sessionCookie);
}

public static final OwnCloudCredentials getAnonymousCredentials() {
if (sAnonymousCredentials == null) {
sAnonymousCredentials = new OwnCloudAnonymousCredentials();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,6 @@ public RemoteOperationResult(int httpCode, String httpPhrase, Headers headers) {
}
}
}
if (isIdPRedirection()) {
// overrides default ResultCode.UNKNOWN
mCode = ResultCode.UNAUTHORIZED;
}
}

/**
Expand Down Expand Up @@ -492,12 +488,6 @@ public String getRedirectedLocation() {
return mRedirectedLocation;
}

public boolean isIdPRedirection() {
return (mRedirectedLocation != null &&
(mRedirectedLocation.toUpperCase().contains("SAML") ||
mRedirectedLocation.toLowerCase().contains("wayf")));
}

/**
* Checks if is a non https connection
*
Expand Down