上个月有一个星期的时间都在研究asp.net mvc统一身份验证及单点登录的实现。经过了一番的探索,最终决定使用微软的Windows Identity Foundation。但是这东西用的人貌似不多,而且中文资料甚少,所以在测试的过程中走了不少弯路,所以写下这一系列文章,希望能对以后要使用的朋友带来一点帮助。

首先先说一下什么是WIF(Windows Identity Foundation)。由于各种历史原因,身份验证和标识的管理一般都比较无规律可循。在软件里加入“身份验证”功能意味着要在你的代码里混进处理底层任务(如验证用户名和密码,与X509证书或类似的证书打交道等)的代码。这样一来就得对基础架构相当依赖,程序很难移植,除非大范围重写。要改变这种情况,使用基于声明的标识(claims-based identity)可以很好的解决这个问题。这个“基于声明的标识”是神马东西我们留到以后再讲,现在您只要知道有这么个东西就行了。Windows Identity Foundation(WIF)是微软的基于声明标识的协议栈。它是一个新的基础技术,可以帮助.NET开发人员利用基于声明的方法来处理身份验证,授权,定制化以及任何与标识相关的任务,而无需编写任何底层代码。

下面来说说WIF环境的搭建。在这里我就走了不少冤枉路。我的悲催经历就不跟大家分享了,直接介绍各种环境该如何搭建:

1、如果你已经安装了VS2012,那么WIF已经包含在了.Net Framework当中,而且版本为WIF4.5。但是注意,WIF4.5只能用于.net 4.5的工程,如果你的asp.net或MVC项目是基于.net 4.5以下的话(即使你是在VS2012里创建的工程),请继续参考以下方法。

2、如果你安装的是VS2010/VS2008,那么你首先要先安装WIF,然后安装WIF SDK。

如果你用的是windows 8,那么系统已经集成了Windows Identity Foundation 3.5了,只要打开控制面板->程序和功能->打开或关闭Windows功能,找到 Windows Identity Foundation 3.5 ,将前面的勾勾上,然后点击“确定”,完事儿以后点“关闭”即可,如图:

这样WIF 3.5就启用成功了。

如果是其它操作系统,请点击这里,找到对应操作系统的exe文件,下载安装即可。

3、接下来安装WIF的SDK,如果你用的是VS2012,那就不用装任何SDK了,因为它都已经集成在.Net Framework 4.5里了。但是你可能需要安装一个VS的插件。打开VS2012,点击工具->扩展和更新,在左边列表里点击“联机”,然后在右上角的搜索框里输入"identity",点击搜索结果里的“Identity and Access Tool”,点击下载按钮,等待下载并安装完成就可以了。这个工具可以让你很快捷地为Web Application,MVC程序或者WCF服务增加一个本地开发STS(Local Development STS),来测试WIF的功能。这个工具的使用我们留到以后再讲。

如果你用的不是VS2012,请点击这里进行下载并安装相应的SDK。

至此,WIF所需的环境就已经搭建好了,下一步我们来通过一个小例子来说明WIF的工作原理。

这里我用的环境是win7+vs2012,vs2010+WIF3.5/4.0的情况请参见这篇文章

打开VS2012,新建一个基于.net framework4.5的MVC4的工程,取名为WIFTutorial。如下图:

在弹出的“新ASP.NET MVC 4项目”对话框中直接点“确定”。

项目新建完毕后,在“解决方案资源管理器”中,项目名称上点右键,然后选择“Identity and Accee...”,如图:

在“Providers”页签里选择“Use the Local Development STS to test your application”。此时”Local Development STS"页签由不可用变为可用。切换到该页签,将Test claims to issue表格里的第一行的Value列改为“ojlovecd”,如图:

点击“OK”,这个工具将会更改你的web.config文件,我们在解决方案资源管理器里打开web.config看看:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. 有关如何配置 ASP.NET 应用程序的详细信息,请访问
  4. http://go.microsoft.com/fwlink/?LinkId=169433
  5. -->
  6. <configuration>
  7. <configSections>
  8. <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  9. <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  10. <span style="color: rgb(255, 0, 0);"><section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
  11. <section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /></span>
  12. </configSections>
  13. <connectionStrings>
  14. <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-WIFTutorial-20130220231745;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-WIFTutorial-20130220231745.mdf" providerName="System.Data.SqlClient" />
  15. </connectionStrings>
  16. <appSettings>
  17. <add key="webpages:Version" value="2.0.0.0" />
  18. <add key="webpages:Enabled" value="false" />
  19. <add key="PreserveLoginUrl" value="true" />
  20. <add key="ClientValidationEnabled" value="true" />
  21. <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  22. <span style="color: rgb(255, 0, 0);"><add key="ida:FederationMetadataLocation" value="http://localhost:14419/wsFederationSTS/FederationMetadata/2007-06/FederationMetadata.xml" />
  23. <add key="ida:Issuer" value="http://localhost:14419/wsFederationSTS/Issue" />
  24. <add key="ida:ProviderSelection" value="localSTS" /></span>
  25. </appSettings>
  26. <span style="color: rgb(255, 0, 0);"><location path="FederationMetadata">
  27. <system.web>
  28. <authorization>
  29. <allow users="*" />
  30. </authorization>
  31. </system.web>
  32. </location></span>
  33. <system.web>
  34. <span style="color: rgb(255, 0, 0);"><authorization>
  35. <deny users="?" />
  36. </authorization></span>
  37. <authentication mode="None" />
  38. <compilation debug="true" targetFramework="4.5" />
  39. <httpRuntime targetFramework="4.5" requestValidationMode="4.5" />
  40. <!--Commented by Identity and Access VS Package-->
  41. <!--<authentication mode="Forms"><forms loginUrl="~/Account/Login" timeout="2880" /></authentication>-->
  42. <pages>
  43. <namespaces>
  44. <add namespace="System.Web.Helpers" />
  45. <add namespace="System.Web.Mvc" />
  46. <add namespace="System.Web.Mvc.Ajax" />
  47. <add namespace="System.Web.Mvc.Html" />
  48. <add namespace="System.Web.Optimization" />
  49. <add namespace="System.Web.Routing" />
  50. <add namespace="System.Web.WebPages" />
  51. </namespaces>
  52. </pages>
  53. </system.web>
  54. <system.webServer>
  55. <validation validateIntegratedModeConfiguration="false" />
  56. <handlers>
  57. <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
  58. <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
  59. <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  60. <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
  61. <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
  62. <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
  63. </handlers>
  64. <modules>
  65. <remove name="FormsAuthentication" />
  66. <add name="WSFederationAuthenticationModule" type="System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
  67. <add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
  68. </modules>
  69. </system.webServer>
  70. <runtime>
  71. <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  72. <dependentAssembly>
  73. <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
  74. <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  75. </dependentAssembly>
  76. <dependentAssembly>
  77. <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
  78. <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  79. </dependentAssembly>
  80. <dependentAssembly>
  81. <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
  82. <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  83. </dependentAssembly>
  84. </assemblyBinding>
  85. </runtime>
  86. <entityFramework>
  87. <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
  88. <parameters>
  89. <parameter value="v11.0" />
  90. </parameters>
  91. </defaultConnectionFactory>
  92. </entityFramework>
  93. <system.identityModel>
  94. <identityConfiguration>
  95. <audienceUris>
  96. <add value="http://localhost:8007/" />
  97. </audienceUris>
  98. <issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
  99. <trustedIssuers>
  100. <add thumbprint="9B74CB2F320F7AAFC156E1252270B1DC01EF40D0" name="LocalSTS" />
  101. </trustedIssuers>
  102. </issuerNameRegistry>
  103. <certificateValidation certificateValidationMode="None" />
  104. </identityConfiguration>
  105. </system.identityModel>
  106. <span style="color: rgb(255, 0, 0);"><system.identityModel.services>
  107. <federationConfiguration>
  108. <cookieHandler requireSsl="false" />
  109. <wsFederation passiveRedirectEnabled="true" issuer="http://localhost:14419/wsFederationSTS/Issue" realm="http://localhost:8007/" requireHttps="false" />
  110. </federationConfiguration>
  111. </system.identityModel.services></span>
  112. </configuration>
<?xml version="1.0" encoding="utf-8"?>
<!--
有关如何配置 ASP.NET 应用程序的详细信息,请访问
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-WIFTutorial-20130220231745;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-WIFTutorial-20130220231745.mdf" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="ida:FederationMetadataLocation" value="http://localhost:14419/wsFederationSTS/FederationMetadata/2007-06/FederationMetadata.xml" />
<add key="ida:Issuer" value="http://localhost:14419/wsFederationSTS/Issue" />
<add key="ida:ProviderSelection" value="localSTS" />
</appSettings>
<location path="FederationMetadata">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<system.web>
<authorization>
<deny users="?" />
</authorization>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" requestValidationMode="4.5" />
<!--Commented by Identity and Access VS Package-->
<!--<authentication mode="Forms"><forms loginUrl="~/Account/Login" timeout="2880" /></authentication>-->
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<modules>
<remove name="FormsAuthentication" />
<add name="WSFederationAuthenticationModule" type="System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
<add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
</modules>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<system.identityModel>
<identityConfiguration>
<audienceUris>
<add value="http://localhost:8007/" />
</audienceUris>
<issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<trustedIssuers>
<add thumbprint="9B74CB2F320F7AAFC156E1252270B1DC01EF40D0" name="LocalSTS" />
</trustedIssuers>
</issuerNameRegistry>
<certificateValidation certificateValidationMode="None" />
</identityConfiguration>
</system.identityModel>
<system.identityModel.services>
<federationConfiguration>
<cookieHandler requireSsl="false" />
<wsFederation passiveRedirectEnabled="true" issuer="http://localhost:14419/wsFederationSTS/Issue" realm="http://localhost:8007/" requireHttps="false" />
</federationConfiguration>
</system.identityModel.services>
</configuration>

其中标红色的部分即为工具自动生成的。同时此工具还会在你的程序跟目录下新建了一个名为FederationMetadata的目录,通过在解决方案资源管理器中点击“显示所有文件”按钮就可以看到了。

然后我们按F5,结果报错了,如图:

看提示,是因为要启动LocalSTS必须要用管理员身份来运行。好吧,关掉VS,以管理员身份再次打开,载入项目,再次按F5运行程序,此时看到右下角托盘处LocalSTS已经运行了,而打开的主页中,右上角显示用户ojlovecd已经处于登录状态。

这一连串操作到底都干了什么?

首先,刚才已经说到,Identity and Access Tool先修改了web.config,增加了WIF要用到的一些配置信息,在程序启动的时候,首先一并启动LocalSTS,这个LocalSTS起什么作用?由于web.config中配置了authorization节点,拒绝匿名用户访问,因此在你的程序运行起来以后,对程序的请求信息被重定向到LocalSTS,向LocalSTS请求身份信息,LocalSTS收到请求后,返回身份信息。那么返回的身份信息怎么来的?没错,就是在Identity and Access Tool工具里的第三个页签里配置的。

至此,我们没有编写任何代码,就已经实现了一个很简单的身份验证功能,关于此例子的详细讲解,以及我们要重点介绍的WIF原理及单点登录的实现,我们将留到下面的文章进行讲解。

使用WIF实现单点登录Part I——Windows Identity Foundation介绍及环境搭建 -摘自网络的更多相关文章

  1. 使用WIF实现单点登录Part I——Windows Identity Foundation介绍及环境搭建

    首先先说一下什么是WIF(Windows Identity Foundation).由于各种历史原因,身份验证和标识的管理一般都比较无规律可循.在软件里加入“身份验证”功能意味着要在你的代码里混进处理 ...

  2. 使用WIF实现单点登录Part II —— Windows Identity Foundation基本原理

    在上一篇文章中,我们已经使用WIF构建了一个基于MVC4的简单的身份验证程序,在这篇文章里,我们将探讨一下到底什么是WIF,以及它的工作原理.然后在下一篇文章开始,我们将实际操作,实现单点登录功能. ...

  3. 使用WIF实现单点登录Part II —— Windows Identity Foundation基本原理 -摘自网络

    在上一篇文章中,我们已经使用WIF构建了一个基于MVC4的简单的身份验证程序,在这篇文章里,我们将探讨一下到底什么是WIF,以及它的工作原理.然后在下一篇文章开始,我们将实际操作,实现单点登录功能. ...

  4. 使用WIF实现单点登录Part III —— 正式实战

    我们接下来的demo将包括以下的工程: SiteA —— 基于.net framework 4.5的MVC 4程序,使用WIF 4.5的SDK,第一个RP SiteB —— 基于.net framew ...

  5. 使用WIF实现单点登录Part III —— 正式实战 -摘自网络

    经过前两篇文章,估计大家对WIF已经有比较充分的认识了,估计大家在经过了枯燥的理论以后,肯定是摩拳擦掌赶紧付诸于行动了.没办法,咱们程序员就是这个毛病.那好吧,我也不那么多废话了,直接进入正题吧. 我 ...

  6. ABP集成WIF实现单点登录

    ABP集成WIF实现单点登录 参考 ojlovecd写了三篇关于WIF文章. 使用WIF实现单点登录Part III —— 正式实战 使用WIF的一些开源示例. https://github.com/ ...

  7. Installing Windows Identity Foundation on Windows 8 - The Certificate for the signer of the message is invalid or not found.

    Just a very quick note here, in case you’re struggling to get Windows Identity Foundation installed ...

  8. windows下php+apache+mysql环境搭建

    在Windows 7下进行PHP环境搭建,首先需要下载PHP代码包和Apache与Mysql的安装软件包. PHP版本:php-5.3.2-Win32-VC6-x86,VC9是专门为IIS定制的,VC ...

  9. [转]MonkeyRunner在Windows下的Eclipse开发环境搭建步骤(兼解决网上Jython配置出错的问题)

    MonkeyRunner在Windows下的Eclipse开发环境搭建步骤(兼解决网上Jython配置出错的问题)   网上有一篇shangdong_chu网友写的文章介绍如何在Eclipse上配置M ...

随机推荐

  1. hdu 1251 统计难题 trie入门

    统计难题 Problem Description Ignatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本 ...

  2. Unity3d Shader开发(三)Pass(Color, Material, Lighting )

    材质和灯光参数被用于控制内置顶点光照.顶点光照是Direct3D/OpenGL标准的按每顶点计算的光照模型.光照打开时,光照受材质块,颜色材质和平行高光命令的影响. 每像素光照常被实现为自定义顶点/片 ...

  3. IE9、 Firefox、Safari, Chrome的CSS3圆角属性

    这篇文章主要是记录一下,微软最新发布的 IE9 浏览器CSS 圆角属性,现在CSS3已经 可以轻松实现跨浏览器的圆角效果,包括Firefox高版本,IE9,Safari,Chrome等高端 浏览器. ...

  4. Unity3D中的第三人称镜头的脚本控制

    原地址:http://blog.csdn.net/mobanchengshuang/article/details/27591271 好久没有敲Blog了,谢谢大家的留言.关注.私信等支持,但是我好像 ...

  5. Java中对List集合的排序

    方法一: 第一种方法,就是list中对象实现Comparable接口,代码如下: 实体类: public class Person implements Comparable<Person> ...

  6. SPRING IN ACTION 第4版笔记-第七章Advanced Spring MVC-004- 处理上传文件

    一.用 MultipartFile 1.在html中设置<form enctype="multipart/form-data">及<input type=&quo ...

  7. Javascript实现摩斯码加密解密

    原文地址 作者:liaoyu 摩尔斯电码是一种时通时断的信号代码,通过不同的排列顺序来表达不同的英文字母.数字和标点符号,是由美国人萨缪尔·摩尔斯在1836年发明. 每一个字符(字母或数字)对应不同的 ...

  8. UVA_11468_Substring_(AC自动机+概率动态规划)

    描述 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  9. CH Round #17 舞动的夜晚

    舞动的夜晚 CH Round #17 描述 L公司和H公司举办了一次联谊晚会.晚会上,L公司的N位员工和H公司的M位员工打算进行一场交际舞.在这些领导中,一些L公司的员工和H公司的员工之间是互相认识的 ...

  10. JavaScript里的类和继承

    JavaScript与大部分客户端语言有几点明显的不同: JS是 动态解释性语言,没有编译过程,它在程序运行过程中被逐行解释执行JS是 弱类型语言,它的变量没有严格类型限制JS是面向对象语言,但 没有 ...