public IAccessToken GetCachedToken(WindowsAzureSubscription subscription, string userId)
{
var key = tokenCache.Keys.FirstOrDefault(k => k.UserId == userId && k.TenantId == subscription.ActiveDirectoryTenantId);
if (key == null)
{
throw new AadAuthenticationFailedException(string.Format(Resources.NoCachedToken,
subscription.SubscriptionName, userId));
}
return new AdalAccessToken(DecodeCachedAuthResult(key), this, new AdalConfiguration(subscription));
}