use of com.microsoft.identity.common.internal.util.ClockSkewManager in project microsoft-authentication-library-common-for-android by AzureAD.
the class ClockSkewManagerTest method testOnTimestampReceived2.
@Test
public void testOnTimestampReceived2() {
clockSkewManager = new ClockSkewManager(context) {
@Override
public Date getCurrentClientTime() {
return new Date(67890);
}
};
final Date serverTime = new Date(12345);
clockSkewManager.onTimestampReceived(serverTime.getTime());
assertEquals(55545, clockSkewManager.getSkewMillis());
}
use of com.microsoft.identity.common.internal.util.ClockSkewManager 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.ClockSkewManager 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