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


Java PromptBehavior类代码示例

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


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

示例1: callAdal

import com.microsoft.aad.adal.PromptBehavior; //导入依赖的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

示例2: authenticatePrompt

import com.microsoft.aad.adal.PromptBehavior; //导入依赖的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

示例3: authenticatePrompt

import com.microsoft.aad.adal.PromptBehavior; //导入依赖的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

示例4: initialize

import com.microsoft.aad.adal.PromptBehavior; //导入依赖的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

示例5: getToken

import com.microsoft.aad.adal.PromptBehavior; //导入依赖的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

示例6: acquireToken

import com.microsoft.aad.adal.PromptBehavior; //导入依赖的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

示例7: getDiscoveryServiceAuthResult

import com.microsoft.aad.adal.PromptBehavior; //导入依赖的package包/类
/**
 * Get the Discovery Service authentication result.
 * @param emailAddressHint The username to populate in the UI.
 * @return The authentication result.
 */
private AuthenticationResult getDiscoveryServiceAuthResult(final String emailAddressHint) {
    final SimpleWaiter discoveryCallbackWaiter = new SimpleWaiter();
    final AtomicReference<ClientException> error = new AtomicReference<>();
    final AtomicReference<AuthenticationResult> discoveryServiceToken =
        new AtomicReference<>();
    final AuthenticationCallback<AuthenticationResult> discoveryCallback =
        new AuthenticationCallback<AuthenticationResult>() {
        @Override
        public void onSuccess(final AuthenticationResult authenticationResult) {
            final String userId;
            if (authenticationResult.getUserInfo() == null) {
                userId = "Invalid User Id";
            } else {
                userId = authenticationResult.getUserInfo().getUserId();
            }
            final String tenantId = authenticationResult.getTenantId();
            mLogger.logDebug(String.format(
                "Successful response from the discover service for user id '%s', tenant id '%s'",
                userId,
                tenantId));
            discoveryServiceToken.set(authenticationResult);
            discoveryCallbackWaiter.signal();
        }

        @Override
        public void onError(final Exception ex) {
            OneDriveErrorCodes code = OneDriveErrorCodes.AuthenticationFailure;
            if (ex instanceof AuthenticationCancelError) {
                code = OneDriveErrorCodes.AuthenticationCancelled;
            }

            String message = "Error while retrieving the discovery service auth token";
            if (ex instanceof AuthenticationException) {
                message = String.format("%s; Code %s",
                        message,
                        ((AuthenticationException)ex).getCode().getDescription());
            }

            error.set(new ClientAuthenticatorException(message, ex, code));
            mLogger.logError("Error while attempting to login interactively", error.get());
            discoveryCallbackWaiter.signal();
        }
        };

    mLogger.logDebug("Starting interactive login for the discover service access token");

    // Initial resource is the Discovery Service.
    mAdalContext.acquireToken(DISCOVER_SERVICE_RESOURCE_ID,
                                getClientId(),
                                getRedirectUrl(),
                                emailAddressHint,
                                PromptBehavior.Auto,
                                null,
                                discoveryCallback);

    mLogger.logDebug("Waiting for interactive login to complete");
    discoveryCallbackWaiter.waitForSignal();
    //noinspection ThrowableResultOfMethodCallIgnored
    if (error.get() != null) {
        throw error.get();
    }
    return discoveryServiceToken.get();
}
 
开发者ID:OneDrive,项目名称:onedrive-sdk-android,代码行数:69,代码来源:ADALAuthenticator.java

示例8: getOneDriveServiceAuthResult

import com.microsoft.aad.adal.PromptBehavior; //导入依赖的package包/类
/**
 * Gets the authentication token for the OneDrive service.
 * @param oneDriveServiceInfo The OneDrive services info.
 * @return The authentication result for this OneDrive service.
 */
private AuthenticationResult getOneDriveServiceAuthResult(final ServiceInfo oneDriveServiceInfo) {
    final SimpleWaiter authorityCallbackWaiter = new SimpleWaiter();
    final AtomicReference<ClientException> error = new AtomicReference<>();
    final AtomicReference<AuthenticationResult> oneDriveServiceAuthToken = new AtomicReference<>();
    final AuthenticationCallback<AuthenticationResult> authorityCallback =
        new AuthenticationCallback<AuthenticationResult>() {
        @Override
        public void onSuccess(final AuthenticationResult authenticationResult) {
            mLogger.logDebug("Successful refreshed the OneDrive service authentication token");
            oneDriveServiceAuthToken.set(authenticationResult);
            authorityCallbackWaiter.signal();
        }

        @Override
        public void onError(final Exception e) {
            String message = "Error while retrieving the service specific auth token";
            OneDriveErrorCodes code = OneDriveErrorCodes.AuthenticationFailure;
            if (e instanceof AuthenticationCancelError) {
                code = OneDriveErrorCodes.AuthenticationCancelled;
            }
            if (e instanceof AuthenticationException) {
                message = String.format("%s; Code %s",
                                        message,
                                        ((AuthenticationException)e).getCode().getDescription());
            }

            error.set(new ClientAuthenticatorException(message,
                                                       e,
                                                       code));
            mLogger.logError("Unable to refresh token into OneDrive service access token", error.get());
            authorityCallbackWaiter.signal();
        }
    };
    mLogger.logDebug("Starting OneDrive resource refresh token request");
    mAdalContext.acquireToken(mActivity,
                              oneDriveServiceInfo.serviceResourceId,
                              getClientId(),
                              getRedirectUrl(),
                              PromptBehavior.Auto,
                              authorityCallback);

    mLogger.logDebug("Waiting for token refresh");
    authorityCallbackWaiter.waitForSignal();
    //noinspection ThrowableResultOfMethodCallIgnored
    if (error.get() != null) {
        throw error.get();
    }
    return oneDriveServiceAuthToken.get();
}
 
开发者ID:OneDrive,项目名称:onedrive-sdk-android,代码行数:55,代码来源:ADALAuthenticator.java

示例9: authenticatePrompt

import com.microsoft.aad.adal.PromptBehavior; //导入依赖的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) {
    getAuthenticationContext().acquireToken(
            this.mContextActivity,
            this.mResourceId,
            Constants.CLIENT_ID,
            Constants.REDIRECT_URI,
            PromptBehavior.Always,
            new AuthenticationCallback<AuthenticationResult>() {
                @Override
                public void onSuccess(final AuthenticationResult authenticationResult) {
                    if (authenticationResult != null && authenticationResult.getStatus() == AuthenticationStatus.Succeeded) {
                        setUserId(authenticationResult.getUserInfo().getUserId());
                        mDependencyResolver = new ADALDependencyResolver(
                                getAuthenticationContext(),
                                mResourceId,
                                Constants.CLIENT_ID);
                        authenticationCallback.onSuccess(authenticationResult);
                    } else if (authenticationResult != null) {
                        // We need to make sure that there is no data stored with the failed auth
                        AuthenticationManager.getInstance().disconnect();
                        // This condition can happen if user signs in with an MSA account
                        // instead of an Office 365 account
                        authenticationCallback.onError(
                                new AuthenticationException(
                                        ADALError.AUTH_FAILED,
                                        authenticationResult.getErrorDescription()
                                )
                        );
                    }
                }

                @Override
                public void onError(Exception e) {
                    // We need to make sure that there is no data stored with the failed auth
                    AuthenticationManager.getInstance().disconnect();
                    authenticationCallback.onError(e);
                }
            }
    );
}
 
开发者ID:OfficeDev,项目名称:O365-Android-Connect,代码行数:45,代码来源:AuthenticationManager.java

示例10: UserTokenCredentials

import com.microsoft.aad.adal.PromptBehavior; //导入依赖的package包/类
/**
 * Initializes a new instance of the UserTokenCredentials.
 *
 * @param activity The caller activity.
 * @param clientId the active directory application client id.
 * @param domain the domain or tenant id containing this application.
 * @param clientRedirectUri the Uri where the user will be redirected after authenticating with AD.
 */
public UserTokenCredentials(
        Activity activity,
        String clientId,
        String domain,
        String clientRedirectUri) {
    this(activity, clientId, domain, clientRedirectUri, PromptBehavior.Auto, AzureEnvironment.AZURE);
}
 
开发者ID:Azure,项目名称:autorest-clientruntime-for-java,代码行数:16,代码来源:UserTokenCredentials.java


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