Forms Authentication Classes


The System.Web.Security namespace contains all the classes that are used to implement ASP.NET security in Web server applications. Table 9-6 shows the significant .NET Framework classes on Forms authentication.

Table 9-6. .NET Framework Classes on Forms Authentication

Class

Description

FormsAuthenticationModule

Allows an ASP.NET application to employ Forms authentication.

FormsAuthentication

Provides static methods that deliver helper utilities for manipulating authentication tickets.

FormsAuthenticationTicket

Provides the information represented in an authentication cookie as used by FormsAuthenticationModule .

FormsIdentity

Provides an IIdentity -derived class to be used by FormsAuthenticationModule and allows an application to access the cookie authentication ticket.

FormsAuthenticationEventArgs

Provides data for the FormsAuthentication_OnAuthenticate event.

The public static (shared) properties defined in the FormsAuthentication class are shown in Table 9-7.

Table 9-7. Public Static (Shared) Properties Defined in the FormsAuthentication Class

Public Property

Description

FormsCookieName

Returns the configured cookie name used for the current application.

FormsCookiePath

Returns the configured cookie path used for the current application.

The public static (shared) methods defined in the FormsAuthentication class are shown in Table 9-8.

Table 9-8. Public Static (Shared) Methods Defined in the FormsAuthentication Class

Public Method

Description

Authenticate

Validates the supplied credentials against those contained in the configured credential store and returns true if the credentials are valid or false otherwise .

Decrypt

Returns a FormsAuthenticationTicket object, given an encrypted authentication ticket acquired from an HTTP cookie.

Encrypt

Returns a string containing an encrypted authentication ticket suitable for use in an HTTP cookie, given a FormsAuthenticationTicket .

GetAuthCookie

Overloaded. Creates an authentication cookie for a given username.

GetRedirectUrl

Returns the redirect URL for the original request that caused the redirect to the logon page. If there is no original URL, default.aspx is used.

HashPasswordForStoring-InConfigFile

Produces a hash password suitable for storing in a configuration file, given a password and a string specifying the hash type. (The hashed password is not salted. You have to add salt value.) Password algorithms supported are SHA-1 and MD5.

Initialize

Initializes FormsAuthentication by reading the configuration and getting the cookie values and encryption keys for the given application.

RedirectFromLoginPage

Overloaded. Redirects an authenticated user back to the originally requested URL.

SetAuthCookie

Overloaded. Does not perform redirect, but creates an authentication ticket for the given UserName and attaches it to the cookie's collection of the outgoing response.

SignOut

Removes the authentication ticket by doing a SetForms with an empty value, given an authenticated user. This removes either durable or session cookies.

The public instance properties defined in the FormsAuthenticationTicket class are shown in Table 9-9.

Table 9-9. Public Instance Properties Defined in the FormsAuthenticationTicket Class

Public Property

Description

CookiePath

Returns the path for which the cookie was issued.

Expiration

Returns the date/time at which the cookie expires .

Expired

Returns true if the cookie expired.

IsPersistent

Returns true if a durable cookie was issued. Otherwise, the authentication cookie is scoped to the browser lifetime.

IssueDate

Returns the date/time at which the cookie was originally issued. This can be used for custom expiration schemes.

Name

Returns the username associated with the authentication cookie. A maximum of 32 bytes are stored in the cookie.

UserData

Returns an application-defined string that might have been stored in the cookie.

Version

Returns a byte version number for future use.

The public instance properties defined in the FormsIdentity class are shown in Table 9-10.

Table 9-10. Public Instance Properties Defined in the FormsIdentity Class

Public Property

Description

AuthenticationType

The type of the identity (in this case, "Forms").

IsAuthenticated

Indicates whether authentication took place.

Name

The name of the identity (in this case, the username).

Ticket

Returns the FormsAuthenticationTicket associated with the current request.



.NET Security and Cryptography
.NET Security and Cryptography
ISBN: 013100851X
EAN: 2147483647
Year: 2003
Pages: 126

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net