use of com.microsoft.identity.common.internal.commands.TokenCommand in project microsoft-authentication-library-common-for-android by AzureAD.
the class EstsTelemetry method isTelemetryLoggedByServer.
private boolean isTelemetryLoggedByServer(@SuppressWarnings(WarningType.rawtype_warning) @NonNull final BaseCommand command, @NonNull final CommandResult commandResult) {
// This was a local operation - we didn't reach token endpoint and hence telemetry wasn't sent
if (!(command instanceof TokenCommand)) {
return false;
}
if (commandResult.getStatus() == CommandResult.ResultStatus.ERROR) {
BaseException baseException = (BaseException) commandResult.getResult();
if (!(baseException instanceof ServiceException)) {
// (request did not reach token endpoint)
return false;
} else {
final ServiceException serviceException = (ServiceException) baseException;
final int statusCode = serviceException.getHttpStatusCode();
// for these status codes, headers aren't logged by ests
return !(statusCode == ServiceException.DEFAULT_STATUS_CODE || statusCode == 429 || statusCode >= 500);
}
} else if (commandResult.getStatus() == CommandResult.ResultStatus.CANCEL) {
// we did not go to token endpoint
return false;
} else if (commandResult.getStatus() == CommandResult.ResultStatus.COMPLETED) {
if (commandResult.getResult() instanceof ILocalAuthenticationResult) {
final ILocalAuthenticationResult localAuthenticationResult = (ILocalAuthenticationResult) commandResult.getResult();
if (localAuthenticationResult.isServicedFromCache()) {
// we did not go to token endpoint
return false;
}
} else {
// command probably wasn't a token command - we should never get here in that case
return false;
}
}
// if we get here that means we went to token endpoint and headers were logged by sts
return true;
}
Aggregations