Azman Authorisation Manager Store Location Configuration Override

Topics: Security Application Block
Oct 14, 2011 at 3:07 PM

Hello,

I'm looking a for a little help to see if something is possible. I am using the Azman authorisation provider for our application.

We are currently using default behaviour via the application configuration file, which means the location of the Azman xml authorisation file is stored in app.config.

For various reasons we would like to take the file based approach forward into intial production but the problem is the the application will be hosted in a shared environment and we would like to retrieve and set the file location path post application start-up. Is this possible? I can see from the EntLib source that the provider accepts the store location in it's constructor, but I do not know how to infulence this. We are using the Unity block approach to creating the provider, so out code looks like:

            // Initialise the Azman authority provider.           
            SessionSecurity.MCSAzmanAuth = EnterpriseLibraryContainer.Current.GetInstance<IAuthorizationProvider>(Properties.Settings.Default.AuthorityProvider);
Where the AuthorityProvider setting is "AzmanProvider".
Is there a factory setting to change or some way we can influence the unity block? Again this needs to be done programmatically, not via configuration, as the store location will come from a SQL Server store.
Many Thanks any help.
Oct 20, 2011 at 8:15 AM
Edited Oct 20, 2011 at 8:17 AM

You can use a FileConfigurationSource to initialize the container at application startup/initialization.  The code would look something like:

string configLocation = GetConfigLocationFromDB();

FileConfigurationSource config = 
    new FileConfigurationSource(configLocation);

var builder = new ConfigurationSourceBuilder();
builder.UpdateConfigurationWithReplace(config);

EnterpriseLibraryContainer.Current = 
    EnterpriseLibraryContainer.CreateDefaultContainer(config);

Once the container is configured then you should be able to use your existing code as is:

// Initialise the Azman authority provider.           
SessionSecurity.MCSAzmanAuth = 
    EnterpriseLibraryContainer.Current.GetInstance<IAuthorizationProvider>(
         Properties.Settings.Default.AuthorityProvider
    );

-- Randy

Oct 21, 2011 at 10:16 AM

Hello Randy,

Thanks for responding.

Yes, you are correct, I've just been on a journey of discovery, through stepping through the EntLib source, via the EntLib SQLConfiguration Source add-on to arrive at the same point you mention.

I will post up my solution to help others once I'm there.

Thanks Again.

Andy