本文整理汇总了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());
}
});
}
示例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);
}
}
);
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
示例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();
}
示例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);
}
}
);
}
示例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);
}