public SafeServiceHost(VLogger logger, Type contractType, SafeServicePolicyDecider consumer, string webAddressSuffix, params string[] addresses)
        {
            object instance = consumer;
            this.policyDecider = consumer;
            this.logger = logger;
            List<Uri> addressList = new List<Uri>();
            foreach (String address in addresses)
            {
                addressList.Add(new Uri(address+webAddressSuffix));
            }

            serviceHost = new ServiceHost(instance, addressList.ToArray());
            serviceHost.Authentication.ServiceAuthenticationManager = new SafeServiceAuthenticationManager();
            serviceHost.Authorization.ServiceAuthorizationManager = new SafeServiceAuthorizationManager(consumer, this);
            
            foreach (string address in addresses)
            {
                var contract = ContractDescription.GetContract(contractType);
                var webBinding = new WebHttpBinding();
                var webEndPoint = new ServiceEndpoint(contract, webBinding, new EndpointAddress(address+webAddressSuffix));
                webEndPoint.EndpointBehaviors.Add(new WebHttpBehavior());
                serviceHost.AddServiceEndpoint(webEndPoint);
            }

        }
Пример #2
0
        public SafeServiceHost(VLogger logger, Type contractType, SafeServicePolicyDecider consumer, string webAddressSuffix, params string[] addresses)
        {
            object instance = consumer;

            this.policyDecider = consumer;
            this.logger        = logger;
            List <Uri> addressList = new List <Uri>();

            foreach (String address in addresses)
            {
                addressList.Add(new Uri(address + webAddressSuffix));
            }

            serviceHost = new ServiceHost(instance, addressList.ToArray());
            serviceHost.Authentication.ServiceAuthenticationManager = new SafeServiceAuthenticationManager();
            serviceHost.Authorization.ServiceAuthorizationManager   = new SafeServiceAuthorizationManager(consumer, this);

            foreach (string address in addresses)
            {
                var contract    = ContractDescription.GetContract(contractType);
                var webBinding  = new WebHttpBinding();
                var webEndPoint = new ServiceEndpoint(contract, webBinding, new EndpointAddress(address + webAddressSuffix));
                webEndPoint.EndpointBehaviors.Add(new WebHttpBehavior());
                serviceHost.AddServiceEndpoint(webEndPoint);
            }
        }
        public SafeServiceHost(VLogger logger, SafeServicePolicyDecider consumer, object instance, params string[] addresses)
        {
           
            this.policyDecider = consumer;
            this.logger = logger;
            List<Uri> addressList = new List<Uri>();
            foreach (String address in addresses)
            {
                addressList.Add(new Uri(address));
            }

            serviceHost = new ServiceHost(instance, addressList.ToArray());
            serviceHost.Authentication.ServiceAuthenticationManager = new SafeServiceAuthenticationManager();
            serviceHost.Authorization.ServiceAuthorizationManager = new SafeServiceAuthorizationManager(consumer, this);
        }
Пример #4
0
        public SafeServiceHost(VLogger logger, SafeServicePolicyDecider consumer, object instance, params string[] addresses)
        {
            this.policyDecider = consumer;
            this.logger        = logger;
            List <Uri> addressList = new List <Uri>();

            foreach (String address in addresses)
            {
                addressList.Add(new Uri(address));
            }

            serviceHost = new ServiceHost(instance, addressList.ToArray());
            serviceHost.Authentication.ServiceAuthenticationManager = new SafeServiceAuthenticationManager();
            serviceHost.Authorization.ServiceAuthorizationManager   = new SafeServiceAuthorizationManager(consumer, this);
        }
Пример #5
0
        public SafeServiceAuthorizationManager(SafeServicePolicyDecider consumer, SafeServiceHost safeServiceHost)
            : base()
        {
            hostTokenResultCache = new Dictionary <string, Dictionary <DateTime, bool> >();
            this.consumer        = consumer;
            this.safeServiceHost = safeServiceHost;
            this.enforcePolicies = true;

            // stub to check if policies are not to be enforced
            // Assumption: if the policy is to allow every user from every domain access to every module => EnforcePolicies = false
            string accessedModuleName = safeServiceHost.BaseAddresses()[0].LocalPath.Split('/').ElementAt(2);

            if ((ResultCode)consumer.IsValidAccess(accessedModuleName, "*", "*", "*") == ResultCode.Allow)
            {
                this.enforcePolicies = false;
            }
        }
Пример #6
0
        public SafeServiceAuthorizationManager(SafeServicePolicyDecider consumer, SafeServiceHost safeServiceHost)
            : base()
        {
            hostTokenResultCache = new Dictionary<string, Dictionary<DateTime,bool>>();
             this.consumer = consumer;
             this.safeServiceHost = safeServiceHost;
             this.enforcePolicies = true;

             // stub to check if policies are not to be enforced
            // Assumption: if the policy is to allow every user from every domain access to every module => EnforcePolicies = false
             string accessedModuleName = safeServiceHost.BaseAddresses()[0].LocalPath.Split('/').ElementAt(2);
             if ((ResultCode)consumer.IsValidAccess(accessedModuleName, "*", "*", "*") == ResultCode.Allow)
                 this.enforcePolicies = false;
        }