public static Task<bool> CheckAccessAsync(this HttpRequestMessage request, IEnumerable<Claim> scope)
        {
            var authorizationContext = new ScopeAuthorizationContext(
                request.GetOwinContext().Authentication.User ?? new ClaimsPrincipal(new ClaimsIdentity(new List<Claim>(1) { new Claim(ClaimTypes.Name, "") })),
                scope);

            return request.CheckAccessAsync(authorizationContext);
        }
        public static Task<bool> CheckAccessAsync(this HttpRequestMessage request, IEnumerable<Claim> actions, IEnumerable<Claim> resources)
        {
            var authorizationContext = new ResourceAuthorizationContext(
                request.GetOwinContext().Authentication.User ?? Principal.Anonymous,
                actions,
                resources);

            return request.CheckAccessAsync(authorizationContext);
        }
        public static Task<bool> CheckAccessAsync(this HttpRequestMessage request, string action, params string[] resources)
        {
            var authorizationContext = new ResourceAuthorizationContext(
                request.GetOwinContext().Authentication.User ?? Principal.Anonymous,
                action,
                resources);

            return request.CheckAccessAsync(authorizationContext);
        }
        public static Task<bool> CheckAccessAsync(this HttpRequestMessage request, params string[] scope)
        {
            var user = request.GetRequestContext().Principal as ClaimsPrincipal;
            user = user ?? new ClaimsPrincipal(new ClaimsIdentity(new List<Claim>(1) { new Claim(ClaimTypes.Name, "") }));

            var ctx = new ScopeAuthorizationContext(user, scope);

            return request.CheckAccessAsync(ctx);
        }
 public static Task<bool> CheckAccessAsync(this HttpRequestMessage request, string action, params string[] resources)
 {
     var user = request.GetRequestContext().Principal as ClaimsPrincipal;
     user = user ?? Principal.Anonymous;
     
     var ctx = new ResourceAuthorizationContext(user, action, resources);
     
     return request.CheckAccessAsync(ctx);
 }
        public static Task<bool> CheckAccessAsync(this HttpContextBase httpContext, IEnumerable<Claim> actions, IEnumerable<Claim> resources)
        {
            var cp = httpContext.User as ClaimsPrincipal;
            var authorizationContext = new ResourceAuthorizationContext(
                cp ?? Principal.Anonymous,
                actions,
                resources);

            return httpContext.CheckAccessAsync(authorizationContext);
        }
        public static Task<bool> CheckAccessAsync(this HttpContextBase httpContext, string action, params string[] resources)
        {
            var cp = httpContext.User as ClaimsPrincipal;
            var authorizationContext = new ResourceAuthorizationContext(
                cp ?? Principal.Anonymous,
                action,
                resources);

            return httpContext.CheckAccessAsync(authorizationContext);
        }
 public static bool CheckAccess(this HttpContextBase httpContext, string action, params string[] resources)
 {
     return AsyncHelper.RunSync(() => httpContext.CheckAccessAsync(action, resources));
 }
 /// <summary>
 /// Checks if the specified access is available at the given path.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.DataLake.StoreFileSystem.IFileSystemOperations.
 /// </param>
 /// <param name='path'>
 /// Required. The path to the file or folder to check access for.
 /// </param>
 /// <param name='accountName'>
 /// Required. The name of the account to use
 /// </param>
 /// <param name='fsAction'>
 /// Required. File system operation read/write/execute in string form,
 /// matching regex pattern '[rwx-]{3}'
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static Task<AzureOperationResponse> CheckAccessAsync(this IFileSystemOperations operations, string path, string accountName, string fsAction)
 {
     return operations.CheckAccessAsync(path, accountName, fsAction, CancellationToken.None);
 }
 public static bool CheckAccess(this HttpRequestMessage request, params string[] scope)
 {
     return AsyncHelper.RunSync(() => request.CheckAccessAsync(scope));
 }
 public static bool CheckAccess(this HttpRequestMessage request, string action, params string[] resources)
 {
     return AsyncHelper.RunSync(() => request.CheckAccessAsync(action, resources));
 }