Exemplo n.º 1
0
        public ContentResult RoleProvider(string baseUrl, string token)
        {
            var serviceUrl = string.IsNullOrWhiteSpace(baseUrl) ? GetAbsoluteUrl("~/Public/Role.svc") : baseUrl + "/Public/Role.svc";

            var binding = new BasicHttpBinding();

            if (serviceUrl.StartsWith("https://"))
            {
                binding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential;
            }

            if (string.IsNullOrWhiteSpace(token))
            {
                token =
                    Repository.OfType <AccessToken>().Queryable.Where(x => x.Application.Name == "Catbert" && x.Active).
                    Select(x => x.Token).FirstOrDefault();
            }

            Check.Require(token != null, "No access tokens for catbert found");

            var provider = new CatbertServiceRoleProvider();

            provider.InitWithoutConfig("Catbert", serviceUrl, token);

            string[] users = provider.GetUsersInRole("Admin");

            return(Content("User count: " + users.Length));
        }
Exemplo n.º 2
0
        public ActionResult ServiceTests()
        {
            var messageService = new ChannelFactory <IMessageService>(new BasicHttpBinding(), GetAbsoluteUrl("~/Public/Message.svc"));
            var roleService    = new ChannelFactory <IRoleService>(new BasicHttpBinding(), GetAbsoluteUrl("~/Public/Role.svc"));

            var messageProxy = messageService.CreateChannel();

            var message = messageProxy.GetMessages("AD419");

            messageService.Close();


            var provider = new CatbertServiceRoleProvider();

            provider.InitWithoutConfig("Catbert", GetAbsoluteUrl("~/Public/Role.svc"), "fake");

            var roles = provider.GetAllRoles();

            var q  = Roles.GetAllRoles();
            var q2 = Roles.GetUsersInRole("Admin");

            return(Content(""));
        }