This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
|The latest Enterprise Library information can be found at the Enterprise Library site.|
The Security QuickStart application demonstrates some of the key features of the Security Application Block. It demonstrates these features by using a set of walkthroughs, which are implementations of the situations discussed in Key Scenarios. The QuickStart includes the following walkthroughs:
- Walkthrough: Obtain a Temporary Token for an Authenticated User
- Walkthrough: Authenticate a User Using a Token
- Walkthrough: Terminate a User Session
- Walkthrough: Determine Whether a User Is Authorized to Perform a Task
The QuickStart is provided in two versions. The first uses the factory approach to create Enterprise Library objects and the static methods. For example, it uses the static GetAuthorizationProvider method of the AuthorizationFactory class to get an instance of the required rule provider and the GetSecurityCacheProvider method of the SecurityCacheFactory class to get an instance of the required caching store provider. This version of the QuickStart also creates instances of the child forms it requires using the new operator.
The second version demonstrates integration with the Unity Application Block. It creates and populates a UnityContainer instance with the data from the <unity> section of the configuration file. This loads the Enterprise Library Core and Security Application Block extensions. This QuickStart also uses the RegisterInstance method of the UnityContainer to register the existing MembershipProvider and RoleProvider objects. Then it generates the main form instance using the Resolve method of the UnityContainer, which causes Unity to create and inject instances of the AuthorizationProvider, SecurityCacheProvider, and MembershipProvider classes in the form constructor. In addition, the constructor of the QuickStart main form contains a parameter of the type QuickstartChildForms; a class that exposes a property for each required child form and specifies the Dependency attribute on each property. This causes Unity to create and inject instances of each form when it creates the main form.
For information about integration with the Unity Application Block and how you can create instances of Enterprise Library objects using Unity, see Creating Objects Using the Unity Application Block.
Building and Running the QuickStart
The QuickStart ships as source code, which means you must compile it before running it. You use Visual Studio to build the QuickStart.
To build the Security QuickStart
- Ensure the Enterprise Library Source Code is installed.
- Open the Enterprise Library Source Code folder in Windows Explorer or from the Start menu. To open it from the Start menu, click Start on the taskbar, point to All Programs, point to Microsoft patterns & practices, point to Enterprise Library 4.0 — May 2008, and then click Enterprise Library 4.0 Source Folder.
- To run the factory version of the QuickStart, open the QuickStarts folder, open the Security folder, and then open the CS folder (for C#) or the VB folder (for Visual Basic .NET).
- To run the version of the QuickStart that demonstrates integration with the Unity Application Block, open the QuickStarts folder, open the Security folder, and then open the CS-UnityIntegration folder (for C#) or the VB-UnityIntegration folder (for Visual Basic .NET).
- Double-click the SecurityQuickStart.sln icon.
- Visual Studio opens, displaying the solution file. Open the Build menu and click Rebuild Solution. By default, this is a debug build.
- Press F5 to run the QuickStart.
The walkthroughs in the Security QuickStart are shipped with a defined configuration, which is included in the App.config file. This file is located in the same folder as the QuickStart project file and has the following settings.
Authorization is configured as follows:
Type: Authorization Rule Provider
- Print Document: NOT I:?
- Hire Employee: R:Manager OR R:HumanResources
- Submit New Order: (R:Employee AND (NOT I:Bob))
Security Cache Configuration
The cache is configured as follows:
- Name: Caching Store Provider
- AbsoluteExpiration: 60
- CacheManager: Default Cache Manager
- SlidingExpiration: 10
Caching Application Block Configuration
The Caching Application Block is configured as follows:
- Name: Default Cache Manager
- ExpirationPollFrequencyInSeconds: 60
- MaximumElementsInCacheBeforeScavenging: 1000
- NumberToRemoveWhenScavenging: 10
To change or view these settings, use the Enterprise Library configuration tools to open the App.config file in the directory containing the QuickStart project file. The App.config file contains the configuration data.
You can also change the application configuration when you do not plan to recompile the application by opening the SecurityQuickStart.exe.config file with the Enterprise Library configuration tools. However, these changes will be overwritten during the next successful build.