Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of HawkActionFilter using a type for
        /// instanciating a IHawkCredentialRepository
        /// </summary>
        /// <param name="hawkCredentialRepositoryType">IHawkCredentialRepository type</param>
        public HawkAuthentication(Type hawkCredentialRepositoryType,
                                  int timeskewInSeconds           = 60,
                                  bool includeServerAuthorization = false)
            : base()
        {
            if (hawkCredentialRepositoryType == null)
            {
                throw new ArgumentNullException("hawkCredentialRepositoryType");
            }

            if (!hawkCredentialRepositoryType.GetInterfaces()
                .Contains(typeof(IHawkCredentialRepository)))
            {
                throw new ArgumentException(
                          "Must derive from IHawkCredentialRepository",
                          "hawkCredentialRepositoryType");
            }

            var instance = (IHawkCredentialRepository)Activator
                           .CreateInstance(hawkCredentialRepositoryType);

            this.repository                 = instance;
            this.timeskewInSeconds          = timeskewInSeconds;
            this.includeServerAuthorization = includeServerAuthorization;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of HawkActionFilter using a IHawkCredentialRepository 
        /// implementation
        /// </summary>
        /// <param name="repository">IHawkCredentialRepository implementation</param>
        public RequiresHawkAttribute(IHawkCredentialRepository repository)
            : base()
        {
            if (repository == null)
                throw new ArgumentNullException("repository");

            this.credentials = (id) => repository.Get(id);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new instance of HawkActionFilter using a IHawkCredentialRepository
        /// implementation
        /// </summary>
        /// <param name="repository">IHawkCredentialRepository implementation</param>
        public RequiresHawkAttribute(IHawkCredentialRepository repository)
            : base()
        {
            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }

            this.credentials = (id) => repository.Get(id);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new instance of HawkActionFilter using a IHawkCredentialRepository
        /// implementation
        /// </summary>
        /// <param name="repository">IHawkCredentialRepository implementation</param>
        public HawkRequestFilter(IHawkCredentialRepository repository)
            : base()
        {
            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }

            this.credentials = (id) => repository.Get(id);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a new instance of HawkActionFilter using a type for
        /// instanciating a IHawkCredentialRepository
        /// </summary>
        /// <param name="hawkCredentialRepositoryType">IHawkCredentialRepository type</param>
        public HawkAuthentication(Type hawkCredentialRepositoryType,
            int timeskewInSeconds = 60,
            bool includeServerAuthorization = false)
            : base()
        {
            if (hawkCredentialRepositoryType == null)
                throw new ArgumentNullException("hawkCredentialRepositoryType");

            if (!hawkCredentialRepositoryType.GetInterfaces()
                .Contains(typeof(IHawkCredentialRepository)))
            {
                throw new ArgumentException(
                    "Must derive from IHawkCredentialRepository",
                    "hawkCredentialRepositoryType");
            }

            var instance = (IHawkCredentialRepository)Activator
                .CreateInstance(hawkCredentialRepositoryType);

            this.repository = instance;
            this.timeskewInSeconds = timeskewInSeconds;
            this.includeServerAuthorization = includeServerAuthorization;
        }