SmartCardAuthenticationEventArgs Implementation

9:01 PM j. montgomery 0 Comments

Page 5 of 9

Previous Page: Implementing IHttpModule | Next Page: SmartCardIdentity Implementation

The SmartCardAuthenticationEventArgs is a class used to pass references around of the HttpContext, User (Principal), and Identity objects to events that are subscribed to the Authenticate event of the SmartCardAuthenticationModule.

C#

1 using System;
2 using System.Web;
3 using System.Security.Principal;
4 using System.Security.Permissions;
5 using System.Security.Cryptography.X509Certificates;
6
7 namespace SmartCardAuthentication
8 {
9 public sealed class SmartCardAuthenticationEventArgs : EventArgs
10 {
11 private HttpContext _context;
12 private SmartCardIdentity _identity;
13 private IPrincipal _user;
14
15 public SmartCardAuthenticationEventArgs(SmartCardIdentity identity,
16 HttpContext context)
17 {
18 this._identity = identity;
19 this._context = context;
20 }
21
22 public HttpContext Context
23 {
24 get { return this._context; }
25 }
26
27 public SmartCardIdentity Identity
28 {
29 get { return this._identity; }
30 }
31
32
33
34
35
36 public IPrincipal User
37 {
38 get { return this._user; }
39 set
40 {
41 // Make sure up-stack callers have permission to change the principal.
42 SecurityPermission controlPrincipalPermission =
43 new SecurityPermission(SecurityPermissionFlag.ControlPrincipal);
44 controlPrincipalPermission.Demand();
45
46 this._user = value;
47 }
48 }
49 }
50 }

VB.Net

1 Imports System.Web
2 Imports System.Security.Principal
3 Imports System.Security.Permissions
4 Imports System.Security.Cryptography.X509Certificates
5
6 Public NotInheritable Class SmartCardAuthenticationEventArgs
7 Inherits EventArgs
8
9 Private _context As HttpContext
10 Private _identity As SmartCardIdentity
11 Private _user As IPrincipal
12
13 Public ReadOnly Property Context() As HttpContext
14 Get
15 Return Me._context
16 End Get
17 End Property
18
19 Public ReadOnly Property Identity() As SmartCardIdentity
20 Get
21 Return Me._identity
22 End Get
23 End Property
24
25 Public Property User() As IPrincipal
26 Get
27 Return Me._user
28 End Get
29 Set(ByVal Value As IPrincipal)
30 ' Make sure upstream callers have permission to change the principal.
31 Dim controlPrincipalPermission As _
32 New SecurityPermission(SecurityPermissionFlag.ControlPrincipal)
33 controlPrincipalPermission.Demand()
34
35 Me._user = Value
36 End Set
37 End Property
38
39 Public Sub New(ByVal identity As SmartCardIdentity, ByVal context As HttpContext)
40 Me._identity = identity
41 Me._context = context
42 End Sub
43 End Class
44

Previous Page: Implementing IHttpModule | Next Page: SmartCardIdentity Implementation

Page 5 of 9

0 comments: