企业库系列讲座(1)概述-20050520.ppt_第1页
企业库系列讲座(1)概述-20050520.ppt_第2页
企业库系列讲座(1)概述-20050520.ppt_第3页
企业库系列讲座(1)概述-20050520.ppt_第4页
企业库系列讲座(1)概述-20050520.ppt_第5页
已阅读5页,还剩38页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Enterprise Library 概述,patterns configData.Name = fontDialog.Font.Name; configData.Size = fontDialog.Font.Size; configData.Style = Convert.ToInt32(fontDialog.Font.Style); /write an object info to config file ConfigurationManager.WriteConfiguration(EditorSettings, configData);,Public EditorFontData()

2、Private string fontName; Private Double fontSize; Private Integer fontStyle; ,/ Read an object with multiple properties EditorFontData configData = ConfigurationManager.GetConfiguration(EditorSettings),Security,Crypto,Configuration,Data Access,Logging,Caching,Exceptions,Enterprise Library v1,Legend,

3、Dependency,Plug-in,Config Tool,Data Access Application Block需求与特点,对数据库访问提供了简单、高效的访问方式 减少编写重复累赘代码去执行标准的数据访问任务 易于使用,使用单条语句即可完成Stored Procedure的调用 屏蔽了对常用ADO.NET使用的复杂度,提供了基于最佳实践, 正确快速使用接口 对不同类型的数据库(SQLServer/Oracle/DB2)提供了编程上的透明性 为不同数据库类型提供了统一的编程。 当移植应用程序到不同数据库类型时,减少重写代码的数量 搭起了逻辑数据库与物理数据库间的桥梁,降低改变物理数据目标

4、的难度 增强了数据库联接串的安全性 容易对数据库访问的配置信息进行调整和验证,Data Access Application BlockDesign Overview,Data Access - Example,Public Function GetProductsInCategory(ByRef Category As Integer) As DataSet Create the Database object, using the default database service. The default database service is determined through con

5、figuration. Dim db As Database = DatabaseFactory.CreateDatabase() Invoke the stored procedure with one line of code! return db.ExecuteDataSet(GetProductsByCategory, Category) Note: connection was closed by ExecuteDataSet method call End Function,Security,Crypto,Configuration,Data Access,Logging,Cach

6、ing,Exceptions,Enterprise Library v1,Legend,Dependency,Plug-in,Config Tool,加解密算法的使用场景,使用对称加密算法对敏感信息进行加密保存、或对其进行解密 对单台机器上使用的信息进行加密 (without using keys) 创建密码信息的散列值进行保存,使用时需要对用户提供的密码散列值与保存值进行对比,Cryptography Application Block,简化了开发人员为敏感信息进行加解密工作 加解密任何类型(Stream/Byte)的信息 提高易用性 CreateHash / CompareHash Enc

7、ryptSymmetric / DecryptSymmetric Cryptography Application Block加解密算法 基于.Net Framework已提供的Cryptographic/Hash 算法 对称算法:DES, RC2, Rijndael Managed and TripleDES 散列:SHA1, SHA256, SHA284, SHA512, SHA1Crypto, MD5Crypto, MACTripleDES 允许集成自己开发的加解密算法Provider 提高集成性 Supports all .NET crypto algorithms out of th

8、e box, or implement your own Supports DPAPI for keyless crypto on a single machine Algorithms and keys can be managed through the configuration tool,Cryptography Application BlockDesign Overview,securitycryptography configuration.config,Security,Crypto,Configuration,Data Access,Logging,Caching,Excep

9、tions,Enterprise Library v1,Legend,Dependency,Plug-in,Config Tool,Security Scenarios and Goal,通过一个或多个安全系统或机制,帮助开发人员在应用程序中实现通用的安全相关任务 一致性、可展性、配置驱动的安全机制(不需修改代码) 提供以下功能 认证 Authenticating a User using Credentials Authenticating a User Using a Token Obtaining a Temporary Token for an Authenticated User T

10、erminating a User Session (Expire a Token) 授权 Determining Whether a User Is Authorized to Perform a Task 角色管理 Determining the Roles a User Is In Profile管理 Reading and Writing Profile Information about a User 缓存登陆时的相关安全凭证(认证、授权信息),Security Application Block,封装通用的应用安全相关的任务 最小化应用安全相关的编码 ( 通过少量的方法Authen

11、ticate, Authorize, GetRoles, SetProfile, GetProfile ) 提供标准的安全Provider模型 DbAuthenticationProvider authenticate users against database AzManAuthorizationProvider authorize users against Authorization Manager DbRolesProvider retrieve roles from a database DbProfileProvider retrieve profiles from a data

12、base AdRolesProvider retrieve roles from Active Directory 基于应用安全的最佳实践,Security Application BlockRole-based Security: Principals and Identities,Security Application Block实现了.Net支持的基于角色的安全特性 Identity(身份) Encapsulates information about user Name and Authentication type Principal(主体特征) Represents the se

13、curity context the code is running under Identity and Roles the user belongs to Used in Authorization process 通过Identity与Principal的分离实现了认证和授权两方面的功能,Security,Crypto,Configuration,Data Access,Logging,Caching,Exceptions,Enterprise Library v1,Legend,Dependency,Plug-in,Config Tool,Exception Handling Need

14、s,一致的例外处理策略 需要基于最佳实践例外处理方法 Dont inadvertently disclose security sensitive information to remote callers Add context to exceptions by wrapping or replacing exceptions with more relevant exceptions 便于管理与编码,Exception Handling Application Block,Exception Handling application block 提供了简单的功能强大的例外处理机制,在应用系

15、统的不同层面采用一致的例外处理策略 Exceptions 由配置工具进行定义和维护 不需要通过编码控制例外处理的行为 定义 “Exception Policies”,可指定该策略发生时的行为 Exceptions of type ApplicationException should be logged Exceptions of type SqlClientException should be caught and wrapped with an exception of type DataLayerException and re-thrown Exceptions of type Se

16、curityException should caught and replaced with an AccessDeniedException which will be thrown Exception Handlers提供了附加的处理行为 将例外写入日志 用另外一个例外进行封装 采用不同的例外替代以便隐藏敏感的例外信息 创建自己的Handler,Exception Handling Application Block Scenarios: example,DataSet customersDataSet try customersDataSet = RunQuery(“GetAllCus

17、tomers”); catch(Exception ex) string formattedInfo = FormatException(ex); Logging.Log(formattedInfo) Throw new DataAccessException(“Database access failure for query GetAllCustomers”,e) ,Without Exception Handling App Block,Security,Crypto,Configuration,Data Access,Logging,Caching,Exceptions,Enterpr

18、ise Library v1,Legend,Dependency,Plug-in,Config Tool,Logging Needs,需要对业务及操作数据做日志,希望能通过外部的配置能将日志输出到不同的存储区 需要提供Tracing机制支持Debugging 需要对日益增加的安全性提供审计 能灵活指定哪类信息以何种格式输出、输出到何处 能将日志定向到多个日志存储区,Logging / Log the customer will call / cust.ToString() for the log entry Logger.Write(cust, Category, Priority);,Sec

19、urity,Crypto,Configuration,Data Access,Logging,Caching,Exceptions,Enterprise Library v1,Legend,Dependency,Plug-in,Config Tool,Caching Scenarios,性能:You are creating a Windows Service or Console application which needs a cache to improve performance 智能客户端的离线应用 :You are creating a smart client applicat

20、ion that uses locally cached reference data to create requests and support offline operations,Caching Application Block,提供了灵活可扩展的缓存机制可以用于以下各种类型的应用架构中: Windows Forms Console application NT Service / COM+ Server ASP.NET Web application or Web service if you need features not included in the ASP.NET ca

21、che 支持两类Caching机制: In-memory cache 非永久缓存,但性能很好 Backing store 永久性缓存, 但较慢 Database Isolated Storage 易于使用 - 提供了Cache处理需的所有功能 (retrieve, add、remove cached data) 可配置的expiration和scavenging策略,Caching Application Block Design Overview,Demo-机票定购场景说明,报价与预订,数据访问 应用程序块,DAAB 配置 数据库 定价 EntLib_WYA 预订 EntLib_WYA 连接 EntLi

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论