Пример #1
0
        protected override bool CheckAccessCore(OperationContext operationContext)
        {
            string clientAppIdHash = WCFAApMessageInspector.GetReceivedClientAppIdHash(WebOperationContext.Current.IncomingRequest.Headers);

            if (clientAppIdHash != null && allowedAppIdHashStrings != null && !allowedAppIdHashStrings.Contains(clientAppIdHash))
            {
                return(true);
            }
            else
            {
                WebOperationContext.Current.OutgoingResponse.Headers.Add("WWW-Authenticate: Basic realm=\"WCFCustomAuthorizationManager\"");
                throw new WebFaultException(HttpStatusCode.Unauthorized);
            }
        }
        public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
        {
            WCFAApMessageInspector inspector = new WCFAApMessageInspector(allowedAppIds);

            endpointDispatcher.DispatchRuntime.MessageInspectors.Add(inspector);
        }
        public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
        {
            WCFAApMessageInspector inspector = new WCFAApMessageInspector(clientAppId);

            clientRuntime.MessageInspectors.Add(inspector);
        }