Revert "failing attempt to integrate ADAL authentication (for OneDrive for business)"
This reverts commit 6b69ad20ad.
This commit is contained in:
@@ -9,8 +9,6 @@ import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.onedrive.sdk.authentication.ADALAuthenticator;
|
||||
import com.onedrive.sdk.authentication.MSAAuthenticator;
|
||||
import com.onedrive.sdk.concurrency.ICallback;
|
||||
import com.onedrive.sdk.core.ClientException;
|
||||
import com.onedrive.sdk.core.DefaultClientConfig;
|
||||
@@ -28,7 +26,6 @@ import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
/**
|
||||
* Created by Philipp on 20.11.2016.
|
||||
@@ -36,27 +33,12 @@ import java.util.concurrent.CountDownLatch;
|
||||
public class OneDriveStorage extends JavaFileStorageBase
|
||||
{
|
||||
final IClientConfig oneDriveConfig;
|
||||
final MSAAuthenticator msaAuthenticator;
|
||||
|
||||
|
||||
|
||||
|
||||
final ADALAuthenticator adalAuthenticator = new ADALAuthenticator() {
|
||||
@Override
|
||||
public String getClientId() {
|
||||
return "8374f801-0f55-407d-80cc-9a04fe86d9b2";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRedirectUrl() {
|
||||
return "https://login.microsoftonline.com/common/oauth2/nativeclient";
|
||||
}
|
||||
};
|
||||
final keepass2android.javafilestorage.onedrive.MyMSAAuthenticator msaAuthenticator;
|
||||
|
||||
IOneDriveClient oneDriveClient;
|
||||
|
||||
public OneDriveStorage(final Activity context, final String clientId) {
|
||||
msaAuthenticator = new MSAAuthenticator() {
|
||||
public OneDriveStorage(final Context context, final String clientId) {
|
||||
msaAuthenticator = new keepass2android.javafilestorage.onedrive.MyMSAAuthenticator(context) {
|
||||
@Override
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
@@ -67,8 +49,8 @@ public class OneDriveStorage extends JavaFileStorageBase
|
||||
return new String[] { "offline_access", "onedrive.readwrite" };
|
||||
}
|
||||
};
|
||||
oneDriveConfig = DefaultClientConfig.createWithAuthenticator(adalAuthenticator);
|
||||
initAuthenticator((Activity) context);
|
||||
oneDriveConfig = DefaultClientConfig.createWithAuthenticator(msaAuthenticator);
|
||||
initAuthenticator(null);
|
||||
|
||||
|
||||
}
|
||||
@@ -124,13 +106,11 @@ public class OneDriveStorage extends JavaFileStorageBase
|
||||
}
|
||||
|
||||
private void initAuthenticator(Activity activity) {
|
||||
Log.d("KP2AJ", "initAuth");
|
||||
msaAuthenticator.init(
|
||||
oneDriveConfig.getExecutors(),
|
||||
oneDriveConfig.getHttpProvider(),
|
||||
activity,
|
||||
oneDriveConfig.getLogger());
|
||||
Log.d("KP2AJ", "initAuthDone");
|
||||
}
|
||||
|
||||
|
||||
@@ -179,42 +159,11 @@ public class OneDriveStorage extends JavaFileStorageBase
|
||||
|
||||
}
|
||||
|
||||
public class BuildClientHandler implements ICallback<IOneDriveClient> {
|
||||
private final CountDownLatch loginLatch = new CountDownLatch(1);
|
||||
|
||||
private IOneDriveClient callbackResults;
|
||||
|
||||
private ClientException exception = null;
|
||||
|
||||
public IOneDriveClient buildClient(Activity activity) throws ClientException, InterruptedException {
|
||||
new OneDriveClient.Builder()
|
||||
.fromConfig(oneDriveConfig)
|
||||
.loginAndBuildClient(activity, this);
|
||||
|
||||
loginLatch.await();
|
||||
if (exception != null)
|
||||
throw exception;
|
||||
return callbackResults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void success(IOneDriveClient iOneDriveClient) {
|
||||
callbackResults = iOneDriveClient;
|
||||
exception = null;
|
||||
loginLatch.countDown ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failure(ClientException ex) {
|
||||
this.exception = ex;
|
||||
loginLatch.countDown ();
|
||||
}
|
||||
}
|
||||
|
||||
private IOneDriveClient buildClient(Activity activity) throws InterruptedException {
|
||||
|
||||
return new BuildClientHandler().buildClient(activity);
|
||||
private IOneDriveClient buildClient(Activity activity) {
|
||||
|
||||
return new OneDriveClient.Builder()
|
||||
.fromConfig(oneDriveConfig)
|
||||
.loginAndBuildClient(activity);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user