Ejemplo n.º 1
0
        /// <summary>
        /// Get the authentication provider.
        /// </summary>
        /// <returns>The authorisation provider.</returns>
        public static Nequeo.Security.IAuthorisationProvider Authenticate()
        {
            Nequeo.Security.IAuthorisationProvider authenticate = null;

            switch (AuthenticationProvider.ToLower())
            {
            case "sqlauthenticationtypeprovider":
                // Get the provider type and create the provider instance.
                string providerType = new Nequeo.Configuration.Reader().GetReflectionProvider(Common.Helper.SQLAuthenticationTypeProvider);
                Type   type         = Type.GetType(providerType);
                authenticate = (Nequeo.Security.IAuthorisationProvider)Nequeo.Reflection.TypeAccessor.CreateInstance(type);
                break;

            case "sqlcompositeservice":
                Nequeo.Composite.Composition <Nequeo.Security.IAuthorisationProvider, Nequeo.ComponentModel.Composition.IContentMetadata> compose = null;

                try
                {
                    // Create the composition instance.
                    compose = new Nequeo.Composite.Composition <Nequeo.Security.IAuthorisationProvider, Nequeo.ComponentModel.Composition.IContentMetadata>();

                    // Get the specified composite element.
                    Composite.Configuration.CompositeServiceDirectoryCatalogElement element =
                        new Nequeo.Composite.Configuration.Reader().GetServiceDirectory(Common.Helper.SQLCompositeService);

                    // Add the directory catalog items.
                    compose.AddCatalogItem(new string[] { element.Path }, element.SearchPattern);

                    // Compose the service.
                    compose.Compose();

                    // Get the composite service.
                    bool found = false;
                    authenticate = compose.FindCompositeContext(Common.Helper.SQLCompositeService, out found);
                }
                catch { throw; }
                finally
                {
                    try
                    {
                        // Release the services
                        // and release resources.
                        if (compose != null)
                        {
                            compose.Release();
                            compose.Dispose();
                        }
                    }
                    catch { }
                }
                break;

            default:
                break;
            }

            // Return the authentication provider.
            return(authenticate);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Authentication.
 /// </summary>
 /// <param name="provider">The authorisation provider use to authorisation the user.</param>
 public Authentication(Nequeo.Security.IAuthorisationProvider provider)
 {
     _provider = provider;
 }