use of com.microsoft.identity.common.internal.commands.parameters.GenerateShrCommandParameters in project microsoft-authentication-library-common-for-android by AzureAD.
the class GenerateShrCommand method execute.
@Override
public GenerateShrResult execute() throws Exception {
final String methodName = ":execute";
GenerateShrResult result = null;
final GenerateShrCommandParameters parameters = (GenerateShrCommandParameters) getParameters();
// Iterate over our controllers, to service the request either locally or via the broker...
// if the local (embedded) cache contains tokens for the supplied user, we will sign using
// the embedded PoP keys. If no local user-state exists, the broker will be delegated to
// where the same check is performed.
BaseController controller;
for (int ii = 0; ii < getControllers().size(); ii++) {
controller = getControllers().get(ii);
com.microsoft.identity.common.internal.logging.Logger.verbose(TAG + methodName, "Executing with controller: " + controller.getClass().getSimpleName());
result = controller.generateSignedHttpRequest(parameters);
if (null != result.getErrorCode()) {
final String errorCode = result.getErrorCode();
final String errorMessage = result.getErrorMessage();
// of as thrown Exceptions
if (NO_ACCOUNT_FOUND.equalsIgnoreCase(errorCode)) {
if (getControllers().size() > ii + 1) {
// Try our next controller
continue;
} else {
throw new UiRequiredException(errorCode, errorMessage);
}
} else {
throw new ClientException(errorCode, errorMessage);
}
}
}
return result;
}
Aggregations