本文整理汇总了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);
}
});
}
示例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);
}
});
}
示例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();
}
示例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();
}
});
}
示例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());
}
});
}
示例6: connect
import com.microsoft.aad.adal.AuthenticationCallback; //导入依赖的package包/类
public void connect(AuthenticationCallback<AuthenticationResult> authenticationCallback) {
if (isConnected()) {
authenticateSilent(authenticationCallback);
} else {
authenticatePrompt(authenticationCallback);
}
}
示例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);
}
}
);
}
示例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);
}
}
);
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}