Example #1
0
        public HateoasFilter(
            HateoasService hateoasService,
            IHateoasAuthorizator authorizator)
        {
            this.HateoasService = hateoasService;

            if (authorizator == null)
            {
                // TODO: Loggear que tuvo que usarse el dummy
                this.Authorizator = new DummyAuthorizationService();
            }
            else
            {
                this.Authorizator = authorizator;
            }
        }
Example #2
0
        public IEnumerable <Endpoint> GetCollectionActions(string resourceCode, IHateoasAuthorizator authorizator)
        {
            var actions = this.GetEndpoints(resourceCode, EndpointScope.Collection, EndpointType.Action, authorizator);

            return(actions);
        }
Example #3
0
        public IEnumerable <Endpoint> GetElementActions(IApiResource resource, IHateoasAuthorizator authorizator)
        {
            var actions = this.GetEndpoints(resource, EndpointScope.Element, EndpointType.Action, authorizator);

            return(actions);
        }
Example #4
0
        public IEnumerable <Endpoint> GetElementLinks(IApiResource resource, IHateoasAuthorizator authorizator)
        {
            var links = this.GetEndpoints(resource, EndpointScope.Element, EndpointType.Link, authorizator);

            return(links);
        }
Example #5
0
        public IEnumerable <Endpoint> GetCollectionLinks(string resourceCode, IHateoasAuthorizator authorizator)
        {
            var links = this.GetEndpoints(resourceCode, EndpointScope.Collection, EndpointType.Link, authorizator);

            return(links);
        }
Example #6
0
        private IEnumerable <Endpoint> GetEndpoints(IApiResource resource, EndpointScope scope, EndpointType type, IHateoasAuthorizator authorizator)
        {
            var links =
                Endpoints
                .Where(x => x.Type == type &&
                       x.Scope == scope &&
                       x.ResourceCode == resource.ApiResourceCode &&
                       authorizator.IsAuthorized(resource, x));

            return(links);
        }