I think any developer will agree with me that adding security features to an application can be an absolute pain. This is especially true if you don’t have a set template or module that you can slot into your application.
Well with Novalys Visual Guard, the integration of security features is no longer a slog. Visual Guard makes this process very easy to do indeed. In this post we will look at using Visual Guard with a plain simple Windows Forms Application, but Visual Guard can be integrated with .NET 2.0 and above, C#, vb.net, asp.net, Winforms, WCF, WPF, Silverlight, MVC3, MVC4, Windows Azure, PowerBuilder 8 and above, Microsoft Sharepoint and any technologies Supporting HTTP Requests (Java, C++…).
I have to admit that while much of the integration processes should be quite straight forward for most developers, the extensive help files and Developer’s Guide do warrant a read though in order to grasp some of the more advanced features of Visual Guard.
Novalys Visual Guard Features
The product comes in two flavours namely Professional and Enterprise and the features of both are very impressive indeed. Here follows a short list of those features:
User Management – Creation and management of username/passwords and User groups. You can also use Windows accounts to identify users.
User Authentication – Including form-based, Single Sign on, Mixed Mode, Web Single Sign On, Remote Windows Authentication, Off-line Mode and Identity Federation. You can also set a password policy.
Permission and Roles – Application Level Permissions, Support for Static and Dynamic Permissions, Hide/Display controls on the UI or filter data based on permissions, Application and Shared Roles. You can also grant Roles to User Accounts or Groups.
Reporting and Auditing – Generate access control reports, Logging and Auditing End-user/Administrator operations.
Visual Guard Applications – Windows and Web Administration Console, Visual Guard Server, VG Federation Client as well as a deployment utility for security data.
Development Technologies Supported – .NET 2.0 and above, C#, vb.net, asp.net, Winforms, WCF, WPF, Silverlight, MVC3, MVC4, Windows Azure, PowerBuilder 8 and above, Microsoft Sharepoint and Any technologies Supporting HTTP Requests (Java, C++…).
Installing Visual Guard is quite straightforward and takes no time at all.
Start Visual Guard WinConsole and create a Repository
After the installation completes, search for Visual Guard WinConsole from the Windows 8 Search Charm. For easy access, I pinned the app to my taskbar.
Clicking on the icon will launch the Visual Guard WinConsole.
This is where you will create a new repository and manage all your secured features of your application. To add a new repository, select the ‘Add repository’ menu item from the Action menu.
This will start the Repository Creation Wizard.
Select Next and choose the option to create a new empty repository.
The wizard allows you to choose 3 repository types. For the purposes of this post, we will create a File repository but you can choose to create a SQL Server or an Oracle based repository.
The next step is to choose a location for the File Repository.
Visual Guard now allows you to select the Authentication Mode which can be a mix of Windows or Visual Guard authentication.
The next step allows you to name your repository and also to specify a username and password for the Visual Guard authentication mode.
That is all that is needed to create a new repository. Clicking ‘Finish’ will take you back to the main WinConsole screen.
Integrate Visual Guard Runtime with your Application
In order to continue, you now need to Integrate the Visual Guard Runtime into your application. In the solution explorer in Visual Studio (I am using Visual Studio 2012 Ultimate), select to add a reference to your application.
If the required Novalys DLL’s aren’t available in the Add References dialog, browse for them in the Bin folder of the Novalys installation directory. For the WinForms application you need to add the following three DLL’s:
For other platforms, review the support documentation for the required DLL’s to include.
After you have added the references, select each reference and change the Copy Local property to True. This will ensure that the DLL’s are copied to the Bin folder. When you reference the exe in the repository later on,it will require these DLL’s to be present.
The next step you need to perform is to add the required code to the Main section of your application. Before any other code is run, you need to run the Novalys code. In C#, have a look in the Program.cs file and add the following using statements:
Change the static void Main of your application as follows: (Please note that you can specify the Login Text and even which username should be defaulted in the login screen)
Connecting to your Repository / Set up your Application
At this point, you have integrated enough in code in order to connect to the repository you created and configure it correctly. So the next step is to open up the WinConsole again and connect to your newly created repository using the username and password you created previously. To do this, right click on the repository and select ‘Connect’ from the context menu.
Enter the username and password in the Login form.
The next screen allows you to set up your application. Select the application type which in our case would be a WinForm application.
Visual Guard now asks you if you have integrated the runtime with your application. If you select the second option, the Application Creation Wizard will display a warning message and give you the option to review the help documentation. Because we have already integrated the runtime in the application, select the first option and click next.
The next step is to select the main assembly of your application. It is here that the referenced DLL’s need to be output to the Bin folder.
The next screen allows you to configure some advanced options. Select the option to Generate the Visual Guard configuration files and click Finish.
Visual Guard now reminds you to deploy the configuration files that were modified with your application.
Creating a User
The next step you need to do is create a user in the WinConsole. To do this, right click on Users and select ‘New Visual Guard User’ from the context menu.
The ‘Create New User’ form is displayed. Here you can create a user with a default password and require the user to change his or her password at the next logon.
If you head on over to Visual Studio and debug your application, you will now be presented with a Login form.
After logging in, the user will be prompted to change the default password.
After the password has been changed, the user will be logged in to the application. This shows you how easy it was to add a login form to your application. With minimal code we can add a layer of security to our application and modify that easily via the WinConsole.
Edit Password Policy
Let us say that we want to implement a more stringent password policy. This is easily done by clicking on the SalesOrderInterface repository and selecting ‘Edit Password Policy’ from the context menu.
The Edit password policy screen now displays and allows you to modify various settings such as the minimum password length and the number of special characters required in each password.
The next step to take is to modify the user and require that the user must change their password at the next Logon. This kind of granularity in the security settings makes Visual Guard a really easy and secure way to add security features to your application.
In my next post, I will look at more advanced features of securing your application with Visual Guard. My overall experience thus far with Visual Guard has been a very positive one. In a matter of minutes I was able to secure my application with a Login form and have a level of control over the users of my application that normally would take some coding to include, if done as part of the normal development process.
Dirk is a Software Developer and Microsoft MVP from South Africa. He loves all things Technology and is slightly addicted to Twitter and Jimi Hendrix. Apart from writing code, he also enjoys writing human readable articles. "I love sharing knowledge and connecting with people from around the world. It's the diversity that makes life so beautiful." Dirk feels very strongly that pizza is simply not complete without Tabasco, that you can never have too much garlic, and that cooking the perfect steak is an art he has yet to master.