using BusinessLogic.Interfaces.Security;
using System;
using System.Linq;
using System.Web.Mvc;
using System.Web.Security;
namespace Admin.Classes.Security
{
///
/// Performs all user and role management
///
public class PaymentsAdminRoleProvider : RoleProvider
{
private readonly IUserStore _userRoleStore;
public PaymentsAdminRoleProvider()
{
_userRoleStore = DependencyResolver.Current.GetService();
}
///
/// Get all the roles for the user specified
///
/// The username to search for
///
public override string[] GetRolesForUser(string username)
{
if (string.IsNullOrWhiteSpace(username))
{
throw new ArgumentException(string.Empty, "username");
}
return _userRoleStore.GetUserRoles(username).ToArray();
}
///
/// Checks whether the specified username is part of the specified role name
///
/// The username to search for
/// The role name to search for
///
public override bool IsUserInRole(string username, string roleName)
{
if (string.IsNullOrWhiteSpace(username)) throw new ArgumentException(string.Empty, "username");
if (string.IsNullOrWhiteSpace(roleName)) throw new ArgumentException(string.Empty, "roleName");
var roles = GetRolesForUser(username);
return roles.Any(o => string.Equals(o, roleName, StringComparison.InvariantCultureIgnoreCase));
}
public override void AddUsersToRoles(string[] usernames, string[] roleNames)
{
throw new NotImplementedException();
}
public override string ApplicationName
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public override void CreateRole(string roleName)
{
throw new NotImplementedException();
}
public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
{
throw new NotImplementedException();
}
public override string[] FindUsersInRole(string roleName, string usernameToMatch)
{
throw new NotImplementedException();
}
public override string[] GetAllRoles()
{
throw new NotImplementedException();
}
public override string[] GetUsersInRole(string roleName)
{
throw new NotImplementedException();
}
public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
{
throw new NotImplementedException();
}
public override bool RoleExists(string roleName)
{
throw new NotImplementedException();
}
}
}