当前位置: 首页>>代码示例>>Java>>正文


Java AuthenticationCallback类代码示例

本文整理汇总了Java中com.microsoft.aad.adal.AuthenticationCallback的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationCallback类的具体用法?Java AuthenticationCallback怎么用?Java AuthenticationCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AuthenticationCallback类属于com.microsoft.aad.adal包,在下文中一共展示了AuthenticationCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: authenticateSilent

import com.microsoft.aad.adal.AuthenticationCallback; //导入依赖的package包/类
private void authenticateSilent(
        final AuthenticationCallback<AuthenticationResult> authenticationCallback) {
    mAuthenticationContext.acquireTokenSilentAsync(
            mAuthenticationResourceId,
            mClientId,
            getUserId(),
            new AuthenticationCallback<AuthenticationResult>() {
                @Override
                public void onSuccess(AuthenticationResult authenticationResult) {
                    authenticationCallback.onSuccess(authenticationResult);
                }

                @Override
                public void onError(Exception e) {
                    authenticatePrompt(authenticationCallback);
                }
            });
}
 
开发者ID:microsoftgraph,项目名称:android-java-snippets-sample,代码行数:19,代码来源:AuthenticationManager.java

示例2: authenticateSilent

import com.microsoft.aad.adal.AuthenticationCallback; //导入依赖的package包/类
private void authenticateSilent(
        final AuthenticationCallback<AuthenticationResult> authenticationCallback) {
    mAuthenticationContext.acquireTokenSilent(
            mAuthenticationResourceId,
            mClientId,
            getUserId(),
            new AuthenticationCallback<AuthenticationResult>() {
                @Override
                public void onSuccess(AuthenticationResult authenticationResult) {
                    authenticationCallback.onSuccess(authenticationResult);
                }

                @Override
                public void onError(Exception e) {
                    authenticatePrompt(authenticationCallback);
                }
            });
}
 
开发者ID:OneNoteDev,项目名称:Android-REST-API-Explorer,代码行数:19,代码来源:AuthenticationManager.java

示例3: connect

import com.microsoft.aad.adal.AuthenticationCallback; //导入依赖的package包/类
/**
 * Calls {@link AuthenticationManager#authenticatePrompt(AuthenticationCallback)} if no user id is stored in the shared preferences.
 * Calls {@link AuthenticationManager#authenticateSilent(AuthenticationCallback)} otherwise.
 * @param authenticationCallback The callback to notify when the processing is finished.
 */
public void connect(final AuthenticationCallback<AuthenticationResult> authenticationCallback) {
    // Since we're doing considerable work, let's get out of the main thread
    new Thread(new Runnable() {
        @Override
        public void run() {
            if (verifyAuthenticationContext()) {
                if (isConnected()) {
                    authenticateSilent(authenticationCallback);
                } else {
                    authenticatePrompt(authenticationCallback);
                }
            } else {
                Log.e(TAG, "connect - Auth context verification failed. Did you set a context activity?");
                throw new AuthenticationException(
                        ADALError.ACTIVITY_REQUEST_INTENT_DATA_IS_NULL,
                        "Auth context verification failed. Did you set a context activity?");
            }
        }
    }).start();
}
 
开发者ID:OfficeDev,项目名称:O365-Android-Connect,代码行数:26,代码来源:AuthenticationManager.java

示例4: login

import com.microsoft.aad.adal.AuthenticationCallback; //导入依赖的package包/类
private void login() {

        mAuthContext.acquireToken(LogOutActivity.this, Constants.RESOURCE_ID, Constants.CLIENT_ID,
                Constants.REDIRECT_URL, Constants.USER_HINT,
                new AuthenticationCallback<AuthenticationResult>() {

                    @Override
                    public void onError(Exception exc) {
                        Toast.makeText(LogOutActivity.this, exc.getMessage(), Toast.LENGTH_LONG)
                                .show();

                    }

                    @Override
                    public void onSuccess(AuthenticationResult result) {

                        // Start todo activity
                        Intent intent = new Intent(LogOutActivity.this, ToDoActivity.class);
                        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        startActivity(intent);
                        LogOutActivity.this.finish();
                    }
                });
    }
 
开发者ID:AzureADQuickStarts,项目名称:B2C-NativeClient-Android,代码行数:25,代码来源:LogOutActivity.java

示例5: callAdal

import com.microsoft.aad.adal.AuthenticationCallback; //导入依赖的package包/类
private void callAdal(String user) {
    if(Constants.CORRELATION_ID != null &&
            Constants.CORRELATION_ID.trim().length() !=0){
        mAuthContext.setRequestCorrelationId(UUID.fromString(Constants.CORRELATION_ID));
    }

    mAuthContext.acquireToken(UsersListActivity.this, Constants.RESOURCE_ID, Constants.CLIENT_ID,
            Constants.REDIRECT_URL, user, PromptBehavior.REFRESH_SESSION,
            "nux=1&" + Constants.EXTRA_QP, new AuthenticationCallback<AuthenticationResult>() {

                @Override
                public void onSuccess(AuthenticationResult result) {
                    Constants.CURRENT_RESULT = result;
                    finish();
                }

                @Override
                public void onError(Exception exc) {
                    SimpleAlertDialog.showAlertDialog(UsersListActivity.this, "Exception caught", exc.getMessage());
                }
            });
}
 
开发者ID:AzureADQuickStarts,项目名称:B2C-NativeClient-Android,代码行数:23,代码来源:UsersListActivity.java

示例6: connect

import com.microsoft.aad.adal.AuthenticationCallback; //导入依赖的package包/类
public void connect(AuthenticationCallback<AuthenticationResult> authenticationCallback) {
    if (isConnected()) {
        authenticateSilent(authenticationCallback);
    } else {
        authenticatePrompt(authenticationCallback);
    }
}
 
开发者ID:microsoftgraph,项目名称:android-java-snippets-sample,代码行数:8,代码来源:AuthenticationManager.java

示例7: authenticatePrompt

import com.microsoft.aad.adal.AuthenticationCallback; //导入依赖的package包/类
private void authenticatePrompt(
        final AuthenticationCallback<AuthenticationResult> authenticationCallback) {
    mAuthenticationContext
            .acquireToken(
                    mAuthenticationResourceId,
                    mClientId,
                    mRedirectUri,
                    null,
                    PromptBehavior.Always,
                    null,
                    new AuthenticationCallback<AuthenticationResult>() {
                        @Override
                        public void onSuccess(final AuthenticationResult authenticationResult) {
                            if (Succeeded == authenticationResult.getStatus()) {
                                setUserId(authenticationResult.getUserInfo().getUserId());
                                authenticationCallback.onSuccess(authenticationResult);
                            } else {
                                onError(
                                        new AuthenticationException(ADALError.AUTH_FAILED,
                                                authenticationResult.getErrorCode()));
                            }
                        }

                        @Override
                        public void onError(Exception e) {
                            disconnect();
                            authenticationCallback.onError(e);
                        }
                    }
            );
}
 
开发者ID:microsoftgraph,项目名称:android-java-snippets-sample,代码行数:32,代码来源:AuthenticationManager.java

示例8: authenticateSilent

import com.microsoft.aad.adal.AuthenticationCallback; //导入依赖的package包/类
/**
 * Calls acquireTokenSilent with the user id stored in shared preferences.
 * In case of an error, it falls back to {@link AuthenticationManager#authenticatePrompt(AuthenticationCallback)}.
 * @param authenticationCallback The callback to notify when the processing is finished.
 */
private void authenticateSilent(final AuthenticationCallback<AuthenticationResult> authenticationCallback) {
    getAuthenticationContext().acquireTokenSilent(
            this.mResourceId,
            Constants.CLIENT_ID,
            getUserId(),
            new AuthenticationCallback<AuthenticationResult>() {
                @Override
                public void onSuccess(final AuthenticationResult authenticationResult) {
                    if (authenticationResult != null && authenticationResult.getStatus() == AuthenticationStatus.Succeeded) {
                        mDependencyResolver = new ADALDependencyResolver(
                                getAuthenticationContext(),
                                mResourceId,
                                Constants.CLIENT_ID);
                        authenticationCallback.onSuccess(authenticationResult);
                    } else if (authenticationResult != null) {
                        // I could not authenticate the user silently,
                        // falling back to prompt the user for credentials.
                        authenticatePrompt(authenticationCallback);
                    }
                }

                @Override
                public void onError(Exception e) {
                    // I could not authenticate the user silently,
                    // falling back to prompt the user for credentials.
                    authenticatePrompt(authenticationCallback);
                }
            }
    );
}
 
开发者ID:OfficeDev,项目名称:O365-Android-Connect,代码行数:36,代码来源:AuthenticationManager.java

示例9: authenticate

import com.microsoft.aad.adal.AuthenticationCallback; //导入依赖的package包/类
/**
 * Description: Calls AuthenticationContext.acquireToken(...) once to authenticate with
 * user's credentials and avoid interactive prompt on later calls.
 */
public void authenticate(final AuthenticationCallback<AuthenticationResult> authenticationCallback) {
    // Since we're doing considerable work, let's get out of the main thread
    new Thread(new Runnable() {
        @Override
        public void run() {
            if (mDataStore.isUserLoggedIn()) {
                authenticateSilent(authenticationCallback);
            } else {
                authenticatePrompt(authenticationCallback);
            }
        }
    }).start();
}
 
开发者ID:microsoftgraph,项目名称:android-java-meetingfeedback-rest-sample,代码行数:18,代码来源:AuthenticationManager.java

示例10: authenticateSilent

import com.microsoft.aad.adal.AuthenticationCallback; //导入依赖的package包/类
/**
 * Calls acquireTokenSilent with the user id stored in shared preferences.
 * In case of an error, it falls back to {@link AuthenticationManager#authenticatePrompt(AuthenticationCallback)}.
 * @param authenticationCallback The callback to notify when the processing is finished.
 */
public Future authenticateSilent(final AuthenticationCallback<AuthenticationResult> authenticationCallback) {
    return mAuthenticationContext.acquireTokenSilent(
            mResourceId,
            Constants.CLIENT_ID,
            mDataStore.getUserId(),
            new AuthenticationCallback<AuthenticationResult>() {
                @Override
                public void onSuccess(final AuthenticationResult authenticationResult) {
                    if(null == mDataStore.getUser()) {
                        User user = new User(authenticationResult.getUserInfo());
                        mDataStore.setUser(user);
                    }
                    if(null != authenticationCallback) {
                        authenticationCallback.onSuccess(authenticationResult);
                    }
                }

                @Override
                public void onError(Exception e) {
                    // I could not authenticate the user silently,
                    // falling back to prompt the user for credentials.
                    authenticatePrompt(authenticationCallback);
                }
            }
    );
}
 
开发者ID:microsoftgraph,项目名称:android-java-meetingfeedback-rest-sample,代码行数:32,代码来源:AuthenticationManager.java

示例11: authenticatePrompt

import com.microsoft.aad.adal.AuthenticationCallback; //导入依赖的package包/类
/**
 * Calls acquireToken to prompt the user for credentials.
 * @param authenticationCallback The callback to notify when the processing is finished.
 */
private void authenticatePrompt(final AuthenticationCallback<AuthenticationResult> authenticationCallback) {
    mAuthenticationContext.acquireToken(
            mResourceId,
            Constants.CLIENT_ID,
            Constants.REDIRECT_URI,
            null,
            PromptBehavior.Always,
            null,
            new AuthenticationCallback<AuthenticationResult>() {
                @Override
                public void onSuccess(final AuthenticationResult authenticationResult) {
                    User user = new User(authenticationResult.getUserInfo());
                    mDataStore.setUser(user);
                    if(null != authenticationCallback) {
                        authenticationCallback.onSuccess(authenticationResult);
                    }
                }

                @Override
                public void onError(Exception e) {
                    // We need to make sure that there is no data stored with the failed auth
                    signout();
                    authenticationCallback.onError(e);
                }
            }
    );
}
 
开发者ID:microsoftgraph,项目名称:android-java-meetingfeedback-rest-sample,代码行数:32,代码来源:AuthenticationManager.java

示例12: initialize

import com.microsoft.aad.adal.AuthenticationCallback; //导入依赖的package包/类
/**
 * Description: Calls AuthenticationContext.acquireToken(...) once to initialize with
 * user's credentials and avoid interactive prompt on later calls.
 * If all tokens expire, app must call initialize() again to prompt user interactively and
 * set up authentication context.
 *
 * @return A signal to wait on before continuing execution.
 */
public SettableFuture<AuthenticationResult> initialize() {

    final SettableFuture<AuthenticationResult> result = SettableFuture.create();

    if (verifyAuthenticationContext()) {
        AuthenticationContext authContext = getAuthenticationContext();
        if (authContext != null)
            authContext.acquireToken(
                    this.contextActivity,
                    this.resourceId,
                    Constants.CLIENT_ID,
                    Constants.REDIRECT_URI,
                    PromptBehavior.Auto,
                    new AuthenticationCallback<AuthenticationResult>() {

                        @Override
                        public void onSuccess(final AuthenticationResult authenticationResult) {

                            if (authenticationResult != null && authenticationResult.getStatus() == AuthenticationStatus.Succeeded) {
                                dependencyResolver = new ADALDependencyResolver(
                                        getAuthenticationContext(),
                                        resourceId,
                                        Constants.CLIENT_ID);
                                O365ServicesManager.initialize(authenticationResult.getTenantId());
                                result.set(authenticationResult);
                            }
                        }

                        @Override
                        public void onError(Exception t) {
                            result.setException(t);
                        }
                    }
            );
        else
            result.setException(new Throwable("Auth context verification failed. Did you set a context activity?"));
    } else {
        result.setException(new Throwable("Auth context verification failed. Did you set a context activity?"));
    }
    return result;
}
 
开发者ID:OfficeDev,项目名称:O365-Android-Snippets,代码行数:50,代码来源:AuthenticationController.java

示例13: getToken

import com.microsoft.aad.adal.AuthenticationCallback; //导入依赖的package包/类
private void getToken(final AuthenticationCallback callback) {

        // one of the acquireToken overloads
        mAuthContext.acquireToken(ToDoActivity.this, Constants.RESOURCE_ID, Constants.CLIENT_ID,
                Constants.REDIRECT_URL, Constants.USER_HINT, callback);
        mLastRequestId = callback.hashCode();
    }
 
开发者ID:AzureADQuickStarts,项目名称:B2C-NativeClient-Android,代码行数:8,代码来源:ToDoActivity.java

示例14: getToken

import com.microsoft.aad.adal.AuthenticationCallback; //导入依赖的package包/类
private void getToken(final AuthenticationCallback callback) {

        // one of the acquireToken overloads
        mAuthContext.acquireToken(ToDoActivity.this, Constants.SCOPES, Constants.ADDITIONAL_SCOPES,
                Constants.POLICY, Constants.CLIENT_ID, Constants.REDIRECT_URL, null,
                PromptBehavior.Always, "nux=1&" + Constants.EXTRA_QP, callback);
    }
 
开发者ID:AzureADQuickStarts,项目名称:B2C-NativeClient-Android,代码行数:8,代码来源:ToDoActivity.java

示例15: acquireToken

import com.microsoft.aad.adal.AuthenticationCallback; //导入依赖的package包/类
/**
 * Acquire token from server, callback obj should be passed to get token
 *
 * @param activity activity context
 * @param callback callback of token acquire
 * @return authenticationContext instance you need to use
 */
public static AuthenticationContext acquireToken(Activity activity, AuthenticationCallback callback)
{
	if (getAuthenticationContext(activity) == null)
	{
		return null;
	}
	mAuthContext.acquireToken(activity, RESOURCE_ID, CLIENT_ID,
			REDIRECT_URL, PromptBehavior.Auto, callback);
	return mAuthContext;
}
 
开发者ID:PacteraMobile,项目名称:pacterapulse-android,代码行数:18,代码来源:OfficeAuthenticationHelper.java


注:本文中的com.microsoft.aad.adal.AuthenticationCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。