自定义ServiceAuthorizationManager和WcfCommunicationListener服务结构

时间:2016-08-05 21:21:01

标签: c# wcf azure azure-service-fabric

我正在使用内部wcf端点开发服务结构状态服务,我需要创建一些授权验证,在foruns中搜索我已经看到我可以创建自定义ServiceAuthorizationManager并链接到我的wcf服务行为。

我的问题是,我可以将自定义ServiceAuthorizationManager链接到我的wcf服务结构行为吗?

我正在创建一个Communication Listener Wcf,如下所示:

protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
    {
        return new List<ServiceReplicaListener>
        {
            new ServiceReplicaListener(this.CreateWcfCommunicationListener)
        };


    }


private WcfCommunicationListener<IMainBusService> CreateWcfCommunicationListener(StatefulServiceContext context)
{
    var wcfCommunicationListener = new WcfCommunicationListener<IMainBusService>(
         serviceContext: context,
         wcfServiceObject: this,
         // For this example, we will be using NetTcpBinding.
         listenerBinding: GetNetTcpBinding(),
         endpointResourceName: "WcfServiceEndpoint");
    return wcfCommunicationListener;
}

1 个答案:

答案 0 :(得分:0)

在返回wcfCommunicationListener之前,请执行以下操作:

wcfCommunicationListener.ServiceHost.Authorization.ServiceAuthorizationManager = new CustomServiceAuthorizationManager();