mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Keep removing more SAML stuff
This commit is contained in:
parent
31868dca00
commit
32ecf729c5
@ -11,7 +11,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynamic implementation of {@link OwnCloudClientManager}.
|
* Dynamic implementation of {@link OwnCloudClientManager}.
|
||||||
* <p>
|
*
|
||||||
* Wraps instances of {@link SingleSessionManager} and {@link SimpleFactoryManager} and delegates on one
|
* 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}
|
* or the other depending on the known version of the server corresponding to the {@link OwnCloudAccount}
|
||||||
*
|
*
|
||||||
|
@ -114,7 +114,7 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
status = method.execute();
|
status = method.execute();
|
||||||
checkFirstRedirection(method);
|
checkFirstRedirection(method);
|
||||||
|
|
||||||
if (mFollowRedirects && !isIdPRedirection()) {
|
if (mFollowRedirects) {
|
||||||
status = followRedirection(method).getLastStatus();
|
status = followRedirection(method).getLastStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,7 +422,7 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
*/
|
*/
|
||||||
private boolean shouldInvalidateAccountCredentials(int httpStatusCode) {
|
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
|
should &= (mCredentials != null && // real credentials
|
||||||
!(mCredentials instanceof OwnCloudCredentialsFactory.OwnCloudAnonymousCredentials));
|
!(mCredentials instanceof OwnCloudCredentialsFactory.OwnCloudAnonymousCredentials));
|
||||||
@ -459,17 +459,6 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
mOwnCloudClientManager = 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() {
|
public boolean followRedirects() {
|
||||||
return mFollowRedirects;
|
return mFollowRedirects;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -38,9 +38,6 @@ public class OwnCloudClientManagerFactory {
|
|||||||
case ALWAYS_NEW_CLIENT:
|
case ALWAYS_NEW_CLIENT:
|
||||||
return new SimpleFactoryManager();
|
return new SimpleFactoryManager();
|
||||||
|
|
||||||
case SINGLE_SESSION_PER_ACCOUNT:
|
|
||||||
return new SingleSessionManager();
|
|
||||||
|
|
||||||
case SINGLE_SESSION_PER_ACCOUNT_IF_SERVER_SUPPORTS_SERVER_MONITORING:
|
case SINGLE_SESSION_PER_ACCOUNT_IF_SERVER_SUPPORTS_SERVER_MONITORING:
|
||||||
return new DynamicSessionManager();
|
return new DynamicSessionManager();
|
||||||
|
|
||||||
@ -82,15 +79,11 @@ public class OwnCloudClientManagerFactory {
|
|||||||
if (sDefaultSingleton == null) {
|
if (sDefaultSingleton == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (policy == Policy.ALWAYS_NEW_CLIENT && !(sDefaultSingleton instanceof SimpleFactoryManager)) {
|
return policy == Policy.ALWAYS_NEW_CLIENT && !(sDefaultSingleton instanceof SimpleFactoryManager);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return policy == Policy.SINGLE_SESSION_PER_ACCOUNT && !(sDefaultSingleton instanceof SingleSessionManager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Policy {
|
public enum Policy {
|
||||||
ALWAYS_NEW_CLIENT,
|
ALWAYS_NEW_CLIENT,
|
||||||
SINGLE_SESSION_PER_ACCOUNT,
|
|
||||||
SINGLE_SESSION_PER_ACCOUNT_IF_SERVER_SUPPORTS_SERVER_MONITORING
|
SINGLE_SESSION_PER_ACCOUNT_IF_SERVER_SUPPORTS_SERVER_MONITORING
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -33,7 +33,6 @@ import android.net.Uri;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||||
import com.owncloud.android.lib.common.authentication.OwnCloudSamlSsoCredentials;
|
|
||||||
import com.owncloud.android.lib.common.http.HttpClient;
|
import com.owncloud.android.lib.common.http.HttpClient;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||||
|
|
||||||
@ -116,10 +115,6 @@ public class SingleSessionManager implements OwnCloudClientManager {
|
|||||||
account.loadCredentials(context);
|
account.loadCredentials(context);
|
||||||
client.setCredentials(account.getCredentials());
|
client.setCredentials(account.getCredentials());
|
||||||
|
|
||||||
if (client.getCredentials() instanceof OwnCloudSamlSsoCredentials) {
|
|
||||||
client.disableAutomaticCookiesHandling();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (accountName != null) {
|
if (accountName != null) {
|
||||||
mClientsWithKnownUsername.put(accountName, client);
|
mClientsWithKnownUsername.put(accountName, client);
|
||||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
||||||
|
@ -48,10 +48,6 @@ public class OwnCloudCredentialsFactory {
|
|||||||
return new OwnCloudBearerCredentials(username, authToken);
|
return new OwnCloudBearerCredentials(username, authToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static OwnCloudCredentials newSamlSsoCredentials(String username, String sessionCookie) {
|
|
||||||
return new OwnCloudSamlSsoCredentials(username, sessionCookie);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final OwnCloudCredentials getAnonymousCredentials() {
|
public static final OwnCloudCredentials getAnonymousCredentials() {
|
||||||
if (sAnonymousCredentials == null) {
|
if (sAnonymousCredentials == null) {
|
||||||
sAnonymousCredentials = new OwnCloudAnonymousCredentials();
|
sAnonymousCredentials = new OwnCloudAnonymousCredentials();
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
|
||||||
* 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
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
||||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package com.owncloud.android.lib.common.authentication;
|
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
|
||||||
import com.owncloud.android.lib.common.http.HttpClient;
|
|
||||||
import com.owncloud.android.lib.common.http.HttpConstants;
|
|
||||||
|
|
||||||
public class OwnCloudSamlSsoCredentials implements OwnCloudCredentials {
|
|
||||||
|
|
||||||
private String mUsername;
|
|
||||||
private String mSessionCookie;
|
|
||||||
|
|
||||||
public OwnCloudSamlSsoCredentials(String username, String sessionCookie) {
|
|
||||||
mUsername = username != null ? username : "";
|
|
||||||
mSessionCookie = sessionCookie != null ? sessionCookie : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applyTo(OwnCloudClient client) {
|
|
||||||
// Clear previous credentials
|
|
||||||
HttpClient.deleteHeaderForAllRequests(HttpConstants.AUTHORIZATION_HEADER);
|
|
||||||
HttpClient.deleteHeaderForAllRequests(HttpConstants.COOKIE_HEADER);
|
|
||||||
|
|
||||||
HttpClient.addHeaderForAllRequests(HttpConstants.COOKIE_HEADER, mSessionCookie);
|
|
||||||
client.setFollowRedirects(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUsername() {
|
|
||||||
// not relevant for authentication, but relevant for informational purposes
|
|
||||||
return mUsername;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getAuthToken() {
|
|
||||||
return mSessionCookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean authTokenExpires() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean authTokenCanBeRefreshed() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -254,10 +254,6 @@ public class RemoteOperationResult<T>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isIdPRedirection()) {
|
|
||||||
// overrides default ResultCode.UNKNOWN
|
|
||||||
mCode = ResultCode.UNAUTHORIZED;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -492,12 +488,6 @@ public class RemoteOperationResult<T>
|
|||||||
return mRedirectedLocation;
|
return mRedirectedLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIdPRedirection() {
|
|
||||||
return (mRedirectedLocation != null &&
|
|
||||||
(mRedirectedLocation.toUpperCase().contains("SAML") ||
|
|
||||||
mRedirectedLocation.toLowerCase().contains("wayf")));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is a non https connection
|
* Checks if is a non https connection
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user