CLAS comes with several new classes that constitute the core
functionality. We will list those classes and give a brief description of the
use and importance of each one of them.
ClientFormsIdentity: When the user is about to be
authenticated a call to the static Membership.ValidateUser method is issued to
validate the credentials of the user. If Windows Authentication is configured
in the application then this method always returns true. If however, Forms
Authentication is configured, and if the user was successfully authenticated,
an instance of the ClientFormsIdentity can be retrieved by casting the
System.Threading.Thread.CurrentPrincipal.Identity to an instance of
ClientFormsIdentity. Notice though when the application is configured with
Windows Authentication, the System.Threading.Thread.CurrentPrincipal.Identity
refers to an instance of System.Security.Principal.WindowsIdentity with the
AuthenticationType property set to Kerberos. However, when the application is
configured with Forms Authentication, an instance of the ClientFormsIdentity
can be retrieved as mentioned above and the AuthenticationType property is set
to ClientForms.
ClientRolePrincipal: Once the user is authenticated, an
instance of the ClientRolePrincipal can be retrieved by casting the
System.Threading.Thread.CurrentPrincipal object to an instance of
ClientRolePrincipal object. This object provides information about the roles
the currently authenticated user belongs to.
ConnectivityStatus: This class contains a single static
property called IsOffline which allows you to switch the application from online
mode to offline mode and vice versa.
ClientFormsAuthenticationCredentials: This class represents
the credentials of a user. When you want to allow the user to enter his/her
credentials to be authenticated, usually you would create a Login Windows Form
that implements the IClientFormsAuthenticationCredentialsProvider interface.
This interface contains a single method called GetCredentials and returns an
instance of ClientFormsAuthenticationCredentials object containing the user’s
credentials.
ClientFormsAuthenticationMembershipProvider: This class
manages access to the remote authentication service for forms authentication.
It extends the MembershipProvider and adds the Logout method and UserValidated
event. Typically, when Forms Authentication is configured for the application,
you can retrieve an instance of this class by casting the Membership.Provider
property to an instance of ClientFormsAuthenticationMembershipProvider object.
ClientWindowsAuthenticationMembershipProvider: This class
manages Windows Authentication. It extends Membership.Provider and adds a
single method Logout. When the user is logged out, he or she will continue to
be authenticated by Windows but unable to access the remote authentication
services.
ClientRoleProvider: This class manages the access to the
remote roles service. If your applications require accessing roles information
for users, you can simply configure the Roles service the same as you configure
Authentication service. As the other providers, the ClientRoleProvider contains
the ServiceUri property that points to the address of the remote Role service.
When a user is authenticated, you can retrieve an instance of the
ClientRolePrincipal from the System.Threading.Thread.CurrentPrincipal object.
This class contains the IsInRole method that internally calls the
ClientRoleProvider.IsUserInRole method. One final note about the
ClientRoleProvider, it is a Read-Only provider which means you can only use the
ClientRoleProvider to retrieve a user’s roles information.
IClientFormsAuthenticationCredentialsProvider: This
interface has been mentioned above when we discussed the
ClientFormsAuthenticationCredentials class. This interface shall by implemented
by the Windows Forms that will ask the user for credentials, fill up an instance
of the ClientFormsAuthenticationCredentials object and send it back to the
ValidateUser method whether called directly from the Membership class or from
the ClientFormsAuthenticationMembershipProvider. Any class that implements this
class shall provide a method called GetCredentials that returns an object of
ClientFormsAuthenticationCredentials filled up with the entered user
credentials.
At this point, we will be satisfied by only the above
classes. In the next parts of this series we will introduce the other remaining
classes and illustrate more the ones mentioned above.