C# Класс BlogEngine.Core.Security

Class to provide a unified area of authentication/authorization checking.
Наследование: IHttpModule
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
AuthenticateUser ( string username, string password, bool rememberMe ) : bool
CurrentUserRights ( ) : IEnumerable

Returns an IEnumerable of Rights that belong to the ecurrent user.

DemandUserHasRight ( AuthorizationCheck authCheck, bool redirectIfUnauthorized ) : void

If the current user does not have the requested rights, either redirects to the login page, or throws a SecurityException.

DemandUserHasRight ( Rights right, bool redirectToLoginPage ) : void

If the current user does not have the requested right, either redirects to the login page, or throws a SecurityException.

Dispose ( ) : void

Disposes of the resources (other than memory) used by the module that implements T:System.Web.IHttpModule.

GetCurrentUserRoles ( ) : string[]

Helper method that returns the correct roles based on authentication.

ImpersonateUser ( string username, string password ) : bool

Impersonates a user for the duration of the HTTP request.

Init ( System.Web.HttpApplication context ) : void

Initializes a module and prepares it to handle requests.

IsAuthorizedTo ( AuthorizationCheck authCheck ) : bool

Returns whether the current user passes authorization on the rights based on the given AuthorizationCheck.

IsAuthorizedTo ( AuthorizationCheck authCheck, IEnumerable rights ) : bool

Returns whether the current user passes authorization on the rights based on the given AuthorizationCheck.

IsAuthorizedTo ( Rights right ) : bool

Returns whether or not the current user has the passed in Right.

IsSystemRole ( string roleName ) : bool

Returns whether a role is a System role.

RedirectForUnauthorizedRequest ( ) : void
SignOut ( ) : void

Приватные методы

Метод Описание
ContextAuthenticateRequest ( object sender, EventArgs e ) : void

Handles the AuthenticateRequest event of the context control.

Security ( ) : System

Описание методов

AuthenticateUser() публичный статический Метод

public static AuthenticateUser ( string username, string password, bool rememberMe ) : bool
username string
password string
rememberMe bool
Результат bool

CurrentUserRights() публичный статический Метод

Returns an IEnumerable of Rights that belong to the ecurrent user.
public static CurrentUserRights ( ) : IEnumerable
Результат IEnumerable

DemandUserHasRight() публичный статический Метод

If the current user does not have the requested rights, either redirects to the login page, or throws a SecurityException.
public static DemandUserHasRight ( AuthorizationCheck authCheck, bool redirectIfUnauthorized ) : void
authCheck AuthorizationCheck
redirectIfUnauthorized bool /// If true and user does not have rights, redirects to the login page or homepage. /// If false and user does not have rights, throws a security exception. ///
Результат void

DemandUserHasRight() публичный статический Метод

If the current user does not have the requested right, either redirects to the login page, or throws a SecurityException.
public static DemandUserHasRight ( Rights right, bool redirectToLoginPage ) : void
right Rights
redirectToLoginPage bool /// If true and user does not have rights, redirects to the login page. /// If false and user does not have rights, throws a security exception. ///
Результат void

Dispose() публичный Метод

Disposes of the resources (other than memory) used by the module that implements T:System.Web.IHttpModule.
public Dispose ( ) : void
Результат void

GetCurrentUserRoles() публичный статический Метод

Helper method that returns the correct roles based on authentication.
public static GetCurrentUserRoles ( ) : string[]
Результат string[]

ImpersonateUser() публичный статический Метод

Impersonates a user for the duration of the HTTP request.
public static ImpersonateUser ( string username, string password ) : bool
username string The username
password string The password
Результат bool

Init() публичный Метод

Initializes a module and prepares it to handle requests.
public Init ( System.Web.HttpApplication context ) : void
context System.Web.HttpApplication An that provides access to the methods, properties, and events common to all application objects within an ASP.NET application
Результат void

IsAuthorizedTo() публичный статический Метод

Returns whether the current user passes authorization on the rights based on the given AuthorizationCheck.
public static IsAuthorizedTo ( AuthorizationCheck authCheck ) : bool
authCheck AuthorizationCheck
Результат bool

IsAuthorizedTo() публичный статический Метод

Returns whether the current user passes authorization on the rights based on the given AuthorizationCheck.
public static IsAuthorizedTo ( AuthorizationCheck authCheck, IEnumerable rights ) : bool
authCheck AuthorizationCheck
rights IEnumerable
Результат bool

IsAuthorizedTo() публичный статический Метод

Returns whether or not the current user has the passed in Right.
public static IsAuthorizedTo ( Rights right ) : bool
right Rights
Результат bool

IsSystemRole() публичный статический Метод

Returns whether a role is a System role.
public static IsSystemRole ( string roleName ) : bool
roleName string The name of the role.
Результат bool

RedirectForUnauthorizedRequest() публичный статический Метод

public static RedirectForUnauthorizedRequest ( ) : void
Результат void

SignOut() публичный статический Метод

public static SignOut ( ) : void
Результат void