use of com.microsoft.identity.common.internal.util.IClockSkewManager in project microsoft-authentication-library-common-for-android by AzureAD.
the class MsalBrokerRequestAdapter method getAuthenticationScheme.
@NonNull
private static AbstractAuthenticationScheme getAuthenticationScheme(@NonNull final Context context, @NonNull final BrokerRequest request) {
final AbstractAuthenticationScheme requestScheme = request.getAuthenticationScheme();
if (null == requestScheme) {
// Default assumes the scheme is Bearer
return new BearerAuthenticationSchemeInternal();
} else {
if (requestScheme instanceof PopAuthenticationSchemeInternal) {
final IClockSkewManager clockSkewManager = new ClockSkewManager(context);
((PopAuthenticationSchemeInternal) requestScheme).setClockSkewManager(clockSkewManager);
}
return requestScheme;
}
}
use of com.microsoft.identity.common.internal.util.IClockSkewManager in project microsoft-authentication-library-common-for-android by AzureAD.
the class LocalMSALController method generateSignedHttpRequest.
@Override
public GenerateShrResult generateSignedHttpRequest(@NonNull final GenerateShrCommandParameters parameters) throws Exception {
final Context context = parameters.getAndroidApplicationContext();
final IClockSkewManager clockSkewManager = new ClockSkewManager(context);
final OAuth2TokenCache cache = parameters.getOAuth2TokenCache();
final String clientId = parameters.getClientId();
final String homeAccountId = parameters.getHomeAccountId();
final IPoPAuthenticationSchemeParams popSchemeParams = parameters.getPopParameters();
final GenerateShrResult result;
if (userHasLocalAccountRecord(cache, clientId, homeAccountId)) {
// Perform the signing locally...
result = DevicePoPUtils.generateSignedHttpRequest(context, clockSkewManager, popSchemeParams);
} else {
// Populate the error on the result and return...
result = new GenerateShrResult();
result.setErrorCode(GenerateShrResult.Errors.NO_ACCOUNT_FOUND);
result.setErrorMessage("Account does not exist.");
}
return result;
}
use of com.microsoft.identity.common.internal.util.IClockSkewManager in project microsoft-authentication-library-common-for-android by AzureAD.
the class AuthenticationSchemeFactory method createScheme.
/**
* Gets the internal scheme equivalent for the provided public api scheme.
*
* @param nameable The nameable public scheme representation.
* @return The internal scheme representation.
*/
public static AbstractAuthenticationScheme createScheme(@NonNull final Context context, @Nullable final INameable nameable) {
if (null == nameable) {
// If null, choose Bearer for backcompat
return new BearerAuthenticationSchemeInternal();
}
switch(nameable.getName()) {
case BearerAuthenticationSchemeInternal.SCHEME_BEARER:
Logger.verbose(TAG, "Constructing Bearer Authentication Scheme.");
return new BearerAuthenticationSchemeInternal();
case PopAuthenticationSchemeInternal.SCHEME_POP:
if (nameable instanceof IPoPAuthenticationSchemeParams) {
Logger.verbose(TAG, "Constructing PoP Authentication Scheme.");
final IPoPAuthenticationSchemeParams params = (IPoPAuthenticationSchemeParams) nameable;
final IClockSkewManager clockSkewManager = new ClockSkewManager(context);
return new PopAuthenticationSchemeInternal(clockSkewManager, params.getHttpMethod(), params.getUrl(), params.getNonce(), params.getClientClaims());
} else {
throw new IllegalStateException("Unrecognized parameter type.");
}
default:
throw new UnsupportedOperationException("Unknown or unsupported scheme: " + nameable.getName());
}
}
Aggregations