public class PasswordDigestChannelFactory<TPortTypeClient, TPlugin>
where TPortTypeClient : ClientBase<TPlugin>, TPlugin, new()
where TPlugin : class
{
public PasswordDigestChannelFactory(string endpointConfigurationName)
{
_endpointConfigurationName = endpointConfigurationName;
} private readonly string _endpointConfigurationName; public TPlugin GetClient()
{
var args = new[] {_endpointConfigurationName};
var portInstance = Activator.CreateInstance(typeof (TPortTypeClient), args) as ClientBase<TPlugin>; // replace ClientCredentials with UsernameClientCredentials
var username = "username";
var password = "password"; var credentials = new UsernameClientCredentials(new UsernameInfo(username, password));
portInstance.ChannelFactory.Endpoint.Behaviors.Remove(typeof (ClientCredentials));
portInstance.ChannelFactory.Endpoint.Behaviors.Add(credentials); return portInstance as TPlugin;
}
} // StructureMap injection
For<PortType>()
.Use((new PasswordDigestChannelFactory<PortTypeClient, PortType>("endPoint")).GetClient());

wcf 访问控制的更多相关文章

  1. WCF学习第二篇:WCF 配置架构。这有助于对wcf配置的理解和记忆

    使用 Windows Communication Foundation (WCF) 配置元素,您可以配置 WCF 服务和客户端应用程序. 可以使用配置编辑器工具 (SvcConfigEditor.ex ...

  2. WCF学习系列三--【WCF Interview Questions – Part 3 翻译系列】

    http://www.topwcftutorials.net/2012/10/wcf-faqs-part3.html WCF Interview Questions – Part 3 This WCF ...

  3. WCF

    --http://www.doc88.com/p-699300196010.html ---术语 WCF术语 消息(message) 消息是一个独立的数据单元,它可能由几个部分组成,包括消息正文和消息 ...

  4. WCF、Net remoting、Web service概念及区别

    Windows通信基础(Windows Communication Foundation,WCF)是基于Windows平台下开发和部署服务的软件开发包(Software Development Kit ...

  5. 从开发的角度比较 ASP.NET Web 服务与 WCF

    Windows Communication Foundation (WCF) 具有一个 ASP.NET 兼容模式选项,用户使用此选项可以对 WCF 应用程序进行编程和配置,使其像 ASP.NET We ...

  6. [转]WCF 4 安全性和 WIF 简介

      转自:http://www.cnblogs.com/WizardWu/archive/2010/10/04/1841793.html 本帖简介 .NET 新一代的 Windows Identity ...

  7. WCF学习笔记(一):WCF简介

    转:http://www.cnblogs.com/wengyuli/archive/2009/11/04/1595693.html MSDN上关于WCF给出如下注解: 设计 Windows Commu ...

  8. WCF、.Net Remoting、Web Service概念及区别

    此文章主要参考http://www.cnblogs.com/weiweibtm/archive/2013/06/21/3148583.html 参考书籍<WCF全面解析上册>.<WC ...

  9. (WCF初体验)WCF的认证和消息保护

    最近做WCF开发,有个需求是在服务端做认证,网上查资料了解到可以用UserName和Password 来做认证,只需要写好配置文件和在服务端写好验证类就行了,但是网上普遍的博文都是需要用证书,而我自己 ...

随机推荐

  1. 那些H5用到的技术(3)——屏幕场景滑动

    前言Swiper.js一些需要我们手动设置的参数排版元素需要设置position:absolute绝对元素定位swiperAnimate方法的使用动画播放完成之后的监听上滑提示屏幕适配的问题Anima ...

  2. 再探php

    1. 如何打开一个php文件? 启动本地服务器和MySQL, 然后将php文件放在xampp -> htdocs  目录下(可以是子目录.孙子目录 ......),打开浏览器,在浏览器中输入 l ...

  3. spring、springmvc和mybatis整合(xml方式)

    今天搭建一个基于xml的ssm整合demo.话不多说,直接上代码. 我的开发环境如下: web服务器:tomcat8 开发工具:STS JDK版本:1.8 项目构建工具:maven 1.pom.xml ...

  4. 使用not in的子查询

    operand comparison_operator [NOT] in (subquery) =ANY运算符与IN等效 !=ALL或<>ALL运算符与NOT IN 等效 如果子查询返回任 ...

  5. redis和memcache缓存击穿,缓存失效问题

    我们在用缓存的时候,不管是Redis或者Memcached,基本上会通用遇到以下三个问题: 缓存穿透 缓存并发 缓存失效 一.缓存穿透 Paste_Image.png Paste_Image.png ...

  6. 局域网电脑之间ping不通解决办法

    局域网电脑之间ping不通一般都是防火墙的原因.解决办法有以下两种方法 1 第一种方法 1 找到Windows防火墙 2点击更改通知设置 3 关闭专用网络防火墙 现在就可以ping通这台机器了. 2  ...

  7. iOS设备的屏幕分辨率

    全部列在这里吧.方便自己方便别人.保持更新…… iPhone: iPhone 1G320x480 iPhone 3G320x480 iPhone 3GS320x480 iPhone 4640x960 ...

  8. JSONP原理及简单实现

    在web2.0时代,熟练的使用ajax是每个前端攻城师必备的技能.然而由于受到浏览器的限制,ajax不允许跨域通信. JSONP就是就是目前主流的实现跨域通信的解决方案. 虽然在在jquery中,我们 ...

  9. 游戏反编译工具dnSpy

    dnSpy使用的工具下载地址为: https://github.com/cnxy/dnSpy/archive/v4.0.0.zip 或 dnSpy官方下载地址: https://github.com/ ...

  10. vue打包后运行在本地/非服务器端环境的访问路径

    vue打包前的配置: 项目目录下--> config文件夹---> index.js: build:  { assetsPublickPath:  './',   // 设置成相对路径   ...