C# Class Cats.Services.Security.UserAccountService

Implementation for user account management. This service allows the creation and management of user accounts, authenticates users through username/password combination, encrypts password(s) and perform user account managment functions (change password, reset password and enable/disable) user accounts.
Inheritance: IUserAccountService
Mostra file Open project: edgecomputing/cats Class Usage Examples

Public Methods

Method Description
Add ( UserProfile entity, Dictionary roles ) : bool
Add ( UserProfile entity, string store, string application ) : bool
AddHubUser ( UserProfile entity, Dictionary roles, int HubId ) : bool
AddRole ( string user, string application, string role ) : bool
AddUserToRoles ( string userName, string Roles, string store, string application ) : void
AssociateRoles ( string username ) : void
Authenticate ( UserInfo info ) : bool
Authenticate ( UserProfile userInfo ) : bool
Authenticate ( string userName, string password ) : bool
ChangePassword ( UserProfile userInfo, string password ) : bool
ChangePassword ( int userId, string password ) : bool
ChangePassword ( string userName, string password ) : bool
Delete ( UserProfile entity ) : bool
DeleteById ( int id ) : bool
DisableAccount ( string userName ) : bool

Flips/Reverts the status of a user account. If an account is active it will disable it but if it is already disabled then it will activiate it by setting its value to 'enabled'.

Dispose ( ) : void
EditUserRole ( string owner, string userName, Dictionary applications ) : void
EnableAccount ( string userName ) : bool
FindBy ( bool>.Expression predicate ) : List
FindById ( int id ) : UserProfile
GenerateString ( Random rng, int length ) : string
GetAll ( ) : List
GetApplications ( string store ) : List
GetRoles ( string application ) : string[]

Get all roles associated with the application provided

GetRolesList ( string application ) : List
GetUserDetail ( int userId ) : UserProfile

Returns the detail of a given user based on supplied UserId

GetUserDetail ( string userName ) : UserProfile

Returns the detail of a given user based on supplied userName

GetUserInfo ( int userId ) : UserInfo
GetUserInfo ( string userName ) : UserInfo

Returns the user info based on supplied username

GetUserPermissions ( string UserName ) : List
GetUserPermissions ( string userName, string store, string application ) : List
GetUserPermissionsNotification ( string UserName ) : List
GetUserPermissionsNotification ( string userName, string store, string application ) : List
GetUserPreferences ( ) : List

Gets list of all user preferences

GetUserRoles ( string username ) : string[]
GetUsers ( ) : List
HashPassword ( string password ) : string

Encrypts a given string (password) using the SHA1 cryptography algorithm

RemoveRole ( string user, string application, string role ) : bool
ResetPassword ( UserInfo userInfo ) : string
ResetPassword ( string userName ) : string
Save ( UserProfile entity ) : bool
UpdateUser ( UserProfile entity ) : bool
UserAccountService ( ) : System
UserAccountService ( IUnitOfWork unitOfWork, IAzManStorage store, NetSqlAzManRoleProvider provider ) : System

Private Methods

Method Description
CheckAccess ( IAzManDBUser dbUser, string app, string role, IAzManStorage storage ) : bool

Retrive a complete Authorization for the current user and populate the string array from .NetSqlAzMan store

ConfigureAuthorizationRoleProvider ( string store, string application ) : System.Collections.Specialized.NameValueCollection
ConfigureRoleProvider ( string store ) : System.Collections.Specialized.NameValueCollection
GenerateChar ( Random rng ) : char

Method Details

Add() public method

public Add ( UserProfile entity, Dictionary roles ) : bool
entity Cats.Models.Security.UserProfile
roles Dictionary
return bool

Add() public method

public Add ( UserProfile entity, string store, string application ) : bool
entity Cats.Models.Security.UserProfile
store string
application string
return bool

AddHubUser() public method

public AddHubUser ( UserProfile entity, Dictionary roles, int HubId ) : bool
entity Cats.Models.Security.UserProfile
roles Dictionary
HubId int
return bool

AddRole() public method

public AddRole ( string user, string application, string role ) : bool
user string
application string
role string
return bool

AddUserToRoles() public method

public AddUserToRoles ( string userName, string Roles, string store, string application ) : void
userName string
Roles string
store string
application string
return void

AssociateRoles() public method

public AssociateRoles ( string username ) : void
username string
return void

Authenticate() public method

public Authenticate ( UserInfo info ) : bool
info UserInfo
return bool

Authenticate() public method

public Authenticate ( UserProfile userInfo ) : bool
userInfo UserProfile
return bool

Authenticate() public method

public Authenticate ( string userName, string password ) : bool
userName string
password string
return bool

ChangePassword() public method

public ChangePassword ( UserProfile userInfo, string password ) : bool
userInfo UserProfile
password string
return bool

ChangePassword() public method

public ChangePassword ( int userId, string password ) : bool
userId int
password string
return bool

ChangePassword() public method

public ChangePassword ( string userName, string password ) : bool
userName string
password string
return bool

Delete() public method

public Delete ( UserProfile entity ) : bool
entity UserProfile
return bool

DeleteById() public method

public DeleteById ( int id ) : bool
id int
return bool

DisableAccount() public method

Flips/Reverts the status of a user account. If an account is active it will disable it but if it is already disabled then it will activiate it by setting its value to 'enabled'.
public DisableAccount ( string userName ) : bool
userName string The account to enable/disable
return bool

Dispose() public method

public Dispose ( ) : void
return void

EditUserRole() public method

public EditUserRole ( string owner, string userName, Dictionary applications ) : void
owner string
userName string
applications Dictionary
return void

EnableAccount() public method

public EnableAccount ( string userName ) : bool
userName string
return bool

FindBy() public method

public FindBy ( bool>.Expression predicate ) : List
predicate bool>.Expression
return List

FindById() public method

public FindById ( int id ) : UserProfile
id int
return UserProfile

GenerateString() public method

public GenerateString ( Random rng, int length ) : string
rng Random
length int
return string

GetAll() public method

public GetAll ( ) : List
return List

GetApplications() public method

public GetApplications ( string store ) : List
store string
return List

GetRoles() public method

Get all roles associated with the application provided
public GetRoles ( string application ) : string[]
application string The application name
return string[]

GetRolesList() public method

public GetRolesList ( string application ) : List
application string
return List

GetUserDetail() public method

Returns the detail of a given user based on supplied UserId
public GetUserDetail ( int userId ) : UserProfile
userId int Unique id identifying the user
return UserProfile

GetUserDetail() public method

Returns the detail of a given user based on supplied userName
public GetUserDetail ( string userName ) : UserProfile
userName string User name identifying the user
return UserProfile

GetUserInfo() public method

public GetUserInfo ( int userId ) : UserInfo
userId int
return UserInfo

GetUserInfo() public method

Returns the user info based on supplied username
public GetUserInfo ( string userName ) : UserInfo
userName string User name identifying the user
return UserInfo

GetUserPermissions() public method

public GetUserPermissions ( string UserName ) : List
UserName string
return List

GetUserPermissions() public method

public GetUserPermissions ( string userName, string store, string application ) : List
userName string
store string
application string
return List

GetUserPermissionsNotification() public method

public GetUserPermissionsNotification ( string UserName ) : List
UserName string
return List

GetUserPermissionsNotification() public method

public GetUserPermissionsNotification ( string userName, string store, string application ) : List
userName string
store string
application string
return List

GetUserPreferences() public method

Gets list of all user preferences
public GetUserPreferences ( ) : List
return List

GetUserRoles() public method

public GetUserRoles ( string username ) : string[]
username string
return string[]

GetUsers() public method

public GetUsers ( ) : List
return List

HashPassword() public method

Encrypts a given string (password) using the SHA1 cryptography algorithm
public HashPassword ( string password ) : string
password string string (passowrd) to encrypt
return string

RemoveRole() public method

public RemoveRole ( string user, string application, string role ) : bool
user string
application string
role string
return bool

ResetPassword() public method

public ResetPassword ( UserInfo userInfo ) : string
userInfo UserInfo
return string

ResetPassword() public method

public ResetPassword ( string userName ) : string
userName string
return string

Save() public method

public Save ( UserProfile entity ) : bool
entity UserProfile
return bool

UpdateUser() public method

public UpdateUser ( UserProfile entity ) : bool
entity UserProfile
return bool

UserAccountService() public method

public UserAccountService ( ) : System
return System

UserAccountService() public method

public UserAccountService ( IUnitOfWork unitOfWork, IAzManStorage store, NetSqlAzManRoleProvider provider ) : System
unitOfWork IUnitOfWork
store IAzManStorage
provider NetSqlAzManRoleProvider
return System