本文整理汇总了Java中com.microsoft.aad.adal.AuthenticationResult类的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationResult类的具体用法?Java AuthenticationResult怎么用?Java AuthenticationResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AuthenticationResult类属于com.microsoft.aad.adal包,在下文中一共展示了AuthenticationResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authenticateSilent
import com.microsoft.aad.adal.AuthenticationResult; //导入依赖的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.AuthenticationResult; //导入依赖的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.AuthenticationResult; //导入依赖的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: getRestAdapter
import com.microsoft.aad.adal.AuthenticationResult; //导入依赖的package包/类
/**
* Returns a retrofit rest adaptor class. The adaptor is created in calling code.
*
* @return A new RestAdapter instance.
*/
public RestAdapter getRestAdapter() {
//This method catches outgoing REST calls and injects the Authorization header before
//sending to REST endpoint
RequestInterceptor requestInterceptor = new RequestInterceptor() {
@Override
public void intercept(final RequestFacade request) {
try {
AuthenticationResult authenticationResult = (AuthenticationResult)mAuthenticationManager.authenticateSilent(null).get();
request.addHeader("Authorization", "Bearer " + authenticationResult.getAccessToken());
// This header has been added to identify this sample in the Microsoft Graph service.
// If you're using this code for your project please remove the following line.
request.addHeader("SampleID", "android-java-meetingfeedback-rest-sample");
} catch (InterruptedException | ExecutionException e) {
Log.e(TAG, e.getMessage());
}
}
};
//Sets required properties in rest adaptor class before it is created.
return new RestAdapter.Builder()
.setEndpoint(Constants.MICROSOFT_GRAPH_ENDPOINT)
.setLogLevel(RestAdapter.LogLevel.BASIC)
.setRequestInterceptor(requestInterceptor)
.build();
}
示例5: login
import com.microsoft.aad.adal.AuthenticationResult; //导入依赖的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();
}
});
}
示例6: callAdal
import com.microsoft.aad.adal.AuthenticationResult; //导入依赖的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());
}
});
}
示例7: onSuccess
import com.microsoft.aad.adal.AuthenticationResult; //导入依赖的package包/类
@Override
public void onSuccess(AuthenticationResult authenticationResult) {
// reset anything that may have gone wrong...
mDiagnosticsLayout.setVisibility(INVISIBLE);
mDiagnosticsTxt.setText("");
// get rid of this Activity so that users can't 'back' into it
finish();
// save our auth token to use later
SharedPrefsUtil.persistAuthToken(authenticationResult);
// get the user display name
final String userDisplayableId =
authenticationResult
.getUserInfo()
.getDisplayableId();
// get the index of their '@' in the name (to determine domain)
final int at = userDisplayableId.indexOf("@");
// parse-out the tenant
final String tenant = userDisplayableId.substring(at + 1);
SharedPrefsUtil.persistUserTenant(tenant);
SharedPrefsUtil.persistUserID(authenticationResult);
// go to our main activity
start();
}
示例8: connect
import com.microsoft.aad.adal.AuthenticationResult; //导入依赖的package包/类
public void connect(AuthenticationCallback<AuthenticationResult> authenticationCallback) {
if (isConnected()) {
authenticateSilent(authenticationCallback);
} else {
authenticatePrompt(authenticationCallback);
}
}
示例9: authenticatePrompt
import com.microsoft.aad.adal.AuthenticationResult; //导入依赖的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);
}
}
);
}
示例10: ADALAccountInfo
import com.microsoft.aad.adal.AuthenticationResult; //导入依赖的package包/类
/**
* Creates an ADALAccountInfo object.
* @param authenticator The authenticator that this account info was created from.
* @param authenticationResult The authentication result for this account.
* @param oneDriveServiceInfo The service info for OneDrive.
* @param logger The logger
*/
public ADALAccountInfo(final ADALAuthenticator authenticator,
final AuthenticationResult authenticationResult,
final ServiceInfo oneDriveServiceInfo,
final ILogger logger) {
mAuthenticator = authenticator;
mAuthenticationResult = authenticationResult;
mOneDriveServiceInfo = oneDriveServiceInfo;
mLogger = logger;
}
示例11: authenticateSilent
import com.microsoft.aad.adal.AuthenticationResult; //导入依赖的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);
}
}
);
}
示例12: onSuccess
import com.microsoft.aad.adal.AuthenticationResult; //导入依赖的package包/类
@Override
public void onSuccess(AuthenticationResult authenticationResult) {
Log.d(TAG, "authentication success!");
finish();
Intent intent = new Intent(ConnectActivity.this, CalendarActivity.class);
startActivity(intent);
}
示例13: authenticate
import com.microsoft.aad.adal.AuthenticationResult; //导入依赖的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
示例14: authenticateSilent
import com.microsoft.aad.adal.AuthenticationResult; //导入依赖的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
示例15: authenticatePrompt
import com.microsoft.aad.adal.AuthenticationResult; //导入依赖的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