Sunday, November 7, 2010

Building Secure ASP.NET Applications












Contents
About This Book xxi
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Applies To . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
What This Guide is About . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Who Should Read This Guide? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
What You Must Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
Feedback and Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
The Team That Brought You This Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
Contributors and Reviewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiv
At a Glance xxvii
Chapter 1 – Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
Chapter 2 – Security Model for ASP.NET Applications . . . . . . . . . . . . . . . . . . . . . . . . xxvii
Chapter 3 – Authentication and Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
Chapter 4 – Secure Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
Chapter 5 – Intranet Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxx
Chapter 6 – Extranet Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxii
Chapter 7 – Internet Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxiii
Chapter 8 – ASP.NET Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxiv
Chapter 9 – Enterprise Services Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxv
Chapter 10 – Web Services Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxvii
Chapter 11 – .NET Remoting Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxviii
Chapter 12 – Data Access Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxix
Chapter 13 – Troubleshooting Security Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xl
Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xl
Chapter 1
Introduction 1
The Connected Landscape . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
What Are the Goals of This Guide? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
How You Should Read This Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Organization of the Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Part I, Security Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Part II, Application Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Part III, Securing the Tiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Part IV, Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Key Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Chapter 2
Security Model for ASP.NET Applications 9
.NET Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Logical Tiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Physical Deployment Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Implementation Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Enterprise Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
.NET Remoting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
ADO.NET and SQL Server 2000 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Internet Protocol Security (IPSec) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Secure Sockets Layer (SSL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Security Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Security Across the Tiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Gatekeepers and Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Identities and Principals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
WindowsPrincipal and WindowsIdentity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
GenericPrincipal and Associated Identity Objects . . . . . . . . . . . . . . . . . . . . . . . . . . 24
ASP.NET and HttpContext.User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Remoting and Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Chapter 3
Authentication and Authorization 29
Designing an Authentication and Authorization Strategy . . . . . . . . . . . . . . . . . . . . . . . 30
Identify Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Choose an Authorization Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Choose the Identities Used for Resource Access . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Consider Identity Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Choose an Authentication Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Decide How to Flow Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Authorization Approaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Role Based . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Resource Based . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Resource Access Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
The Trusted Subsystem Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
The Impersonation / Delegation Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Choosing a Resource Access Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Flowing Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Application vs. Operating System Identity Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Impersonation and Delegation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Role-Based Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
.NET Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Enterprise Services (COM+) Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
SQL Server User Defined Database Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
SQL Server Application Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
.NET Roles versus Enterprise Services (COM+) Roles . . . . . . . . . . . . . . . . . . . . . . . 45
Using .NET Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Choosing an Authentication Mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Internet Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Intranet / Extranet Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Authentication Mechanism Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Chapter 4
Secure Communication 55
Know What to Secure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
SSL/TLS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Using SSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
IPSec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Using IPSec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
RPC Encryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Using RPC Encryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Point to Point Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Browser to Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Web Server to Remote Application Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Application Server to Database Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Choosing Between IPSec and SSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Farming and Load Balancing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Chapter 5
Intranet Security 65
ASP.NET to SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Secure the Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
The Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Security Configuration Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Q&A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Related Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
ASP.NET to Enterprise Services to SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Secure the Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
The Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Security Configuration Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Pitfalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
ASP.NET to Web Services to SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Secure the Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
The Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Security Configuration Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Pitfalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Q&A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
ASP.NET to Remoting to SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Secure the Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
The Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Security Configuration Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Pitfalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Flowing the Original Caller to the Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
ASP.NET to SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
ASP.NET to Enterprise Services to SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
The Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Pitfalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Chapter 6
Extranet Security 103
Exposing a Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Secure the Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
The Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Security Configuration Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Pitfalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Q&A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Exposing a Web Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Scenario Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Secure the Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
The Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Pitfalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Chapter 7
Internet Security 119
ASP.NET to SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Secure the Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
The Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Security Configuration Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Pitfalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Related Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
ASP.NET to Remote Enterprise Services to SQL Server . . . . . . . . . . . . . . . . . . . . . . . 127
Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Secure the Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
The Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Security Configuration Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Pitfalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Related Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Chapter 8
ASP.NET Security 137
ASP.NET Security Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Gatekeepers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Authentication and Authorization Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Available Authorization Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Windows Authentication with Impersonation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Windows Authentication without Impersonation . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Windows Authentication Using a Fixed Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Forms Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Passport Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Configuring Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Configure IIS Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Configure ASP.NET Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Secure Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Secure Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Programming Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
An Authorization Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Creating a Custom IPrincipal class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Windows Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Forms Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Development Steps for Forms Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Forms Implementation Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Hosting Multiple Applications Using Forms Authentication . . . . . . . . . . . . . . . . . . 168
Cookieless Forms Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Passport Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Custom Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Process Identity for ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Use a Least Privileged Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Avoid Running as SYSTEM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Using the Default ASPNET Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Impersonation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Impersonation and Local Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Impersonation and Remote Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Impersonation and Threading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Accessing System Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Accessing the Event Log. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Accessing the Registry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
Accessing COM Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
Apartment Model Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Accessing Network Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Using the ASP.NET Process Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Using a Serviced Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Using the Anonymous Internet User Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Using LogonUser and Impersonating a Specific Windows Identity . . . . . . . . . . . . . 182
Using the Original Caller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Accessing Files on a UNC File Share . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Accessing Non-Windows Network Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Secure Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Storing Secrets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Options for Storing Secrets in ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Consider Storing Secrets in Files on Separate Logical Volumes . . . . . . . . . . . . . . . 186
Securing Session and View State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Securing View State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Securing Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Securing SQL Session State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Web Farm Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Session State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
DPAPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Using Forms Authentication in a Web Farm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
The Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Chapter 9
Enterprise Services Security 195
Security Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Gatekeepers and Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
Use Server Applications for Increased Security . . . . . . . . . . . . . . . . . . . . . . . . . . 198
Security for Server and Library Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Code Access Security Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Configuring Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Configuring a Server Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Configuring an ASP.NET Client Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Configuring Impersonation Levels for an Enterprise Services Application . . . . . . . . 208
Programming Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Programmatic Role-Based Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Identifying Callers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Choosing a Process Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Never Run as the Interactive User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Use a Least-Privileged Custom Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Accessing Network Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Using the Original Caller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
Using the Current Process Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
Using a Specific Service Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Flowing the Original Caller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Calling CoImpersonateClient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
RPC Encryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Building Serviced Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
DLL Locking Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Versioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
QueryInterface Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
DCOM and Firewalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Calling Serviced Components from ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Caller’s Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Use Windows Authentication and Impersonation Within
the Web-based Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Configure Authentication and Impersonation within Machine.config . . . . . . . . . . . . 218
Configuring Interface Proxies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Security Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
Enterprise Services (COM+) Roles and .NET Roles . . . . . . . . . . . . . . . . . . . . . . . . 222
Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Impersonation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Chapter 10
Web Services Security 227
Web Service Security Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
Platform/Transport Level (Point-to-Point) Security . . . . . . . . . . . . . . . . . . . . . . . . . 228
Application Level Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Message Level (End-to-End) Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Platform/Transport Security Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Gatekeepers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Authentication and Authorization Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Windows Authentication with Impersonation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Windows Authentication without Impersonation . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Windows Authentication Using a Fixed Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
Configuring Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
Configure IIS Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
Configure ASP .NET Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Secure Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Disable HTTP-GET, HTTP-POST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Secure Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
Passing Credentials for Authentication to Web Services . . . . . . . . . . . . . . . . . . . . . . 240
Specifying Client Credentials for Windows Authentication . . . . . . . . . . . . . . . . . . . 241
Calling Web Services from Non-Windows Clients . . . . . . . . . . . . . . . . . . . . . . . . . 243
Proxy Server Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
Flowing the Original Caller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
Default Credentials with Kerberos Delegation . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Explicit Credentials with Basic or Forms Authentication . . . . . . . . . . . . . . . . . . . . 247
Trusted Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
Flowing the Caller’s Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
Configuration Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
Accessing System Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Accessing Network Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Accessing COM Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Using Client Certificates with Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Authenticating Web Browser Clients with Certificates . . . . . . . . . . . . . . . . . . . . . . 254
Using the Trusted Subsystem Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Secure Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Transport Level Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
Message Level Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
Chapter 11
.NET Remoting Security 261
.NET Remoting Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
Remoting Sinks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
Anatomy of a Request When Hosting in ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . 264
ASP.NET and the HTTP Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
.NET Remoting Gatekeepers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
Hosting in ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
Hosting in a Windows Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Using File Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Authentication and Authorization Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Accessing System Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Accessing Network Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Passing Credentials for Authentication to Remote Objects . . . . . . . . . . . . . . . . . . . . 272
Specifying Client Credentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Flowing the Original Caller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Default Credentials with Kerberos Delegation . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
Explicit Credentials with Basic or Forms Authentication . . . . . . . . . . . . . . . . . . . . 278
Trusted Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
Flowing the Caller’s Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
Choosing a Host . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
Configuration Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
Secure Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
Platform Level Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
Choosing a Host Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Recommendation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Hosting in ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Hosting in a Windows Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
Hosting in a Console Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Remoting vs. Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Chapter 12
Data Access Security 293
Introducing Data Access Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
SQL Server Gatekeepers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
Trusted Subsystem vs. Impersonation/Delegation . . . . . . . . . . . . . . . . . . . . . . . . 295
Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Windows Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
SQL Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
Authenticating Against Non-SQL Server Databases. . . . . . . . . . . . . . . . . . . . . . . . 305
Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
Using Multiple Database Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
Secure Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
The Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
Choosing an Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
Connecting with Least Privilege . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
The Database Trusts the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
The Database Trusts Different Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
The Database Trusts the Original Caller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
Creating a Least Privilege Database Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
Storing Database Connection Strings Securely . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
The Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Using DPAPI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Using Web.config and Machine.config . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
Using UDL Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
Using Custom Text Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
Using the Registry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
Using the COM+ Catalog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
Authenticating Users Against a Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
Store One-way Password Hashes (with Salt) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
SQL Injection Attacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Anatomy of a SQL Script Injection Attack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Protecting Pattern Matching Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Auditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Process Identity for SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Chapter 13
Troubleshooting Security Issues 331
Process for Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Searching for Implementation Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
Troubleshooting Authentication Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
IIS Authentication Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
Using Windows Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
Using Forms Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
Kerberos Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
Troubleshooting Authorization Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
Check Windows ACLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
Check Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
Check the Element. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Enable Tracing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Configuration Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
Determining Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
Determining Identity in a Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
Determining Identity in a Web service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
Determining Identity in a Visual Basic 6 COM Object . . . . . . . . . . . . . . . . . . . . . . 340
.NET Remoting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
SSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
IPSec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
Auditing and Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
Windows Security Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
SQL Server Auditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
IIS Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
Troubleshooting Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
File Monitor (FileMon.exe) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
Fusion Log Viewer (Fuslogvw.exe) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
ISQL.exe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Windows Task Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Network Monitor (NetMon.exe) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Registry Monitor (regmon.exe) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
WFetch.exe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Visual Studio .NET Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
WebServiceStudio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Windows 2000 Resource Kit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
How To:
Index 349
ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Authentication and Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Cryptography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Enterprise Services Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Web Services Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
Remoting Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
Secure Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
How To:
Create a Custom Account to Run ASP.NET 351
ASP.NET Worker Process Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
Impersonating Fixed Identities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
1. Create a New Local Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
2. Assign Minimum Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
3. Assign NTFS Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
4. Configure ASP.NET to Run Using the New Account . . . . . . . . . . . . . . . . . . . . . . . . . 356
How To:
Use Forms Authentication with Active Directory 357
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
1. Create a Web Application with a Logon Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
2. Configure the Web Application for Forms Authentication . . . . . . . . . . . . . . . . . . . . 359
3. Develop LDAP Authentication Code to Look Up the User in Active Directory . . . . . . 360
4. Develop LDAP Group Retrieval Code to Look Up the User’s Group Membership . . . 361
5. Authenticate the User and Create a Forms Authentication Ticket . . . . . . . . . . . . . . 362
6. Implement an Authentication Request Handler to Construct
a GenericPrincipal Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364
7. Test the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366
How To:
Use Forms Authentication with SQL Server 2000 367
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
1. Create a Web Application with a Logon Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
2. Configure the Web Application for Forms Authentication . . . . . . . . . . . . . . . . . . . . 369
3. Develop Functions to Generate a Hash and Salt value . . . . . . . . . . . . . . . . . . . . . 370
4. Create a User Account Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
5. Use ADO.NET to Store Account Details in the Database . . . . . . . . . . . . . . . . . . . . 372
6. Authenticate User Credentials Against the Database . . . . . . . . . . . . . . . . . . . . . . 373
7. Test the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
Additional Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
How To:
Create GenericPrincipal Objects with Forms Authentication 377
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
1. Create a Web Application with a Logon Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
2. Configure the Web Application for Forms Authentication . . . . . . . . . . . . . . . . . . . . 379
3. Generate an Authentication Ticket for Authenticated Users . . . . . . . . . . . . . . . . . . 379
4. Construct GenericPrincipal and FormsIdentity Objects . . . . . . . . . . . . . . . . . . . . . 382
5. Test the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
Additional Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
How To:
Implement Kerberos Delegation for Windows 2000 385
Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386
1. Confirm that the Client Account is Configured for Delegation . . . . . . . . . . . . . . . . 386
2. Confirm that the Server Process Account is Trusted for Delegation . . . . . . . . . . . . 386
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
How To:
Implement IPrincipal 389
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
1. Create a Simple Web Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
2. Configure the Web Application for Forms Authentication . . . . . . . . . . . . . . . . . . . . 391
3. Generate an Authentication Ticket for Authenticated Users . . . . . . . . . . . . . . . . . . 392
4. Create a Class that Implements and Extends IPrincipal . . . . . . . . . . . . . . . . . . . . 394
5. Create the CustomPrincipal Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
5. Test the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
Additional Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
How To:
Create a DPAPI Library 399
Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
1. Create a C# Class Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
2. Strong Name the Assembly (Optional) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
How To:
Use DPAPI (Machine Store) from ASP.NET 409
Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
1. Create an ASP.NET Client Web Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
2. Test the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
3. Modify the Web Application to Read an Encrypted Connection String
from Web.Config . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
How To:
Use DPAPI (User Store) from ASP.NET with Enterprise Services 415
Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
Why Use Enterprise Services? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
Why Use a Windows Service? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
1. Create a Serviced Component that Provides Encrypt and Decrypt Methods . . . . . . 418
2. Call the Managed DPAPI Class Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
3. Create a Dummy Class that will Launch the Serviced Component . . . . . . . . . . . . . 420
4. Create a Windows Account to Run the Enterprise Services Application and
Windows Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
5. Configure, Strong Name, and Register the Serviced Component . . . . . . . . . . . . . . 421
6. Create a Windows Service Application that will Launch the Serviced
Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
7. Install and Start the Windows Service Application . . . . . . . . . . . . . . . . . . . . . . . . 424
8. Write a Web Application to Test the Encryption and Decryption Routines . . . . . . . . 424
9. Modify the Web Application to Read an Encrypted Connection String from
an Application Configuration File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
How To:
Create an Encryption Library 429
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
1. Create a C# Class Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430
2. Create a Console Test Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
How To:
Store an Encrypted Connection String in the Registry 439
Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
1. Store the Encrypted Data in the Registry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
2. Create an ASP.NET Web Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
How To:
Use Role-based Security with Enterprise Services 445
Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
1. Create a C# Class Library Application to Host the Serviced Component . . . . . . . . . 446
2. Create the Serviced Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
3. Configure the Serviced Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
4. Generate a Strong Name for the Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
5. Build the Assembly and Add it to the Global Assembly Cache . . . . . . . . . . . . . . . . 449
6. Manually Register the Serviced Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
7. Examine the Configured Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
8. Create a Test Client Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
How To:
Call a Web Service Using Client Certificates from ASP.NET 453
Why Use a Serviced Component? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
Why is a User Profile Required? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
1. Create a Simple Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
2. Configure the Web Service Virtual Directory to Require Client Certificates . . . . . . . 456
3. Create a Custom Account for Running the Serviced Component . . . . . . . . . . . . . . 457
4. Request a Client Certificate for the Custom Account . . . . . . . . . . . . . . . . . . . . . . 457
6. Export the Client Certificate to a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
7. Develop the Serviced Component Used to Call the Web Service . . . . . . . . . . . . . . 460
8. Configure and Install the Serviced Component . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
9. Develop a Web Application to Call the Serviced Component . . . . . . . . . . . . . . . . . 464
Additional Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
How To:
Call a Web Service Using SSL 467
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
1. Create a Simple Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
2. Configure the Web Service Virtual Directory to Require SSL . . . . . . . . . . . . . . . . . 468
3. Test the Web Service Using a Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
4. Install the Certificate Authority’s Certificate on the Client Computer . . . . . . . . . . . 470
5. Develop a Web Application to Call the Web Service . . . . . . . . . . . . . . . . . . . . . . . 471
Additional Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
How To:
Host a Remote Object in a Windows Service 473
Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
1. Create the Remote Object Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
2. Create a Windows Service Host Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
3. Create a Windows Account to Run the Service . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
4. Install the Windows Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
5. Create a Test Client Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
How To:
Set Up SSL on a Web Server 479
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
1. Generate a Certificate Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
2. Submit a Certificate Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
3. Issue the Certificate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
4. Install the Certificate on the Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
5. Configure Resources to Require SSL Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
How To:
Set Up Client Certificates 485
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485
1. Create a Simple Web Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486
2. Configure the Web Application to Require Client Certificates . . . . . . . . . . . . . . . . . 486
3. Request and Install a Client Certificate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
4. Verify Client Certificate Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488
Additional Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488
How To:
Use IPSec to Provide Secure Communication Between Two Servers 489
Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
1. Create an IP Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
2. Create Filter Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493
3. Create Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494
4. Export the IPSec Policy to the Remote Computer . . . . . . . . . . . . . . . . . . . . . . . . . 495
5. Assign Policies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495
6. Verify that it Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496
Additional Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498
How To:
Use SSL to Secure Communication with SQL Server 2000 499
Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500
1. Install a Server Authentication Certificate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500
2. Verify that the Certificate Has Been Installed . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501
3. Install the Issuing CA’s Certificate on the Client . . . . . . . . . . . . . . . . . . . . . . . . . . 502
4. Force All Clients to Use SSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502
5. Allow Clients to Determine Whether to Use SSL . . . . . . . . . . . . . . . . . . . . . . . . . . 503
6. Verify that Communication is Encrypted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504
Additional Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507
Base Configuration 509
Configuration Stores and Tools 511
Reference Hub 517
Searching the Knowledge Base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517
Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518
.NET Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518
Hubs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518
Active Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518
Hubs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518
Key Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
Articles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
ADO.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
Roadmaps and Overviews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
Seminars and WebCasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
Hubs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
Roadmaps and Overviews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520
Knowledge Base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520
Articles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520
How Tos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520
Seminars and WebCasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
Enterprise Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
Knowledge Base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
Roadmaps and Overviews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
How Tos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
FAQs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
Seminars and WebCasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
IIS (Internet Information Server) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
Hubs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
Remoting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
Roadmaps and Overviews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
How Tos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
Seminars and WebCasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
Hubs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
Seminars and WebCasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
Visual Studio .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
Hubs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
Roadmaps and Overviews: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
Hubs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
Roadmaps and Overviews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
How Tos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
Seminars and WebCasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
Windows 2000 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525
Hubs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525
How Does It Work? 527
IIS and ASP.NET Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
Application Isolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
The ASP.NET ISAPI Extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
IIS 6.0 and Windows .NET Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
ASP.NET Pipeline Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
The Anatomy of a Web Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
Event Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
Implementing a Custom HTTP Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
Implementing a Custom HTTP Handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
ASP.NET Identity Matrix 537
Cryptography and Certificates 541
Keys and Certificates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541
X.509 Digital Certificates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
Certificate Stores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
Cryptography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
Technical Choices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
Cryptography in .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
.NET Web Application Security 549
Glossary 551

Download
Another Web Programming Books
Another .NET Books
Continue Reading ...

Mastering UML with Rational Rose 2002












Table of Contents
Mastering UML with Rational Rose 2002........................................................................................................1
Chapter 1: Introduction to UML.......................................................................................................................4
Introduction to the Object−Oriented Paradigm.......................................................................................4
Encapsulation.............................................................................................................................5
Inheritance.................................................................................................................................6
Polymorphism............................................................................................................................8
What Is Visual Modeling?......................................................................................................................8
Systems of Graphical Notation................................................................................................................9
Booch Notation........................................................................................................................10
Object Management Technology (OMT).................................................................................10
Unified Modeling Language (UML)........................................................................................11
Understanding UML Diagrams..............................................................................................................12
Business Use Case Diagrams....................................................................................................13
Use Case Diagrams...................................................................................................................14
Activity Diagrams.....................................................................................................................14
Sequence Diagrams...................................................................................................................16
Collaboration Diagrams............................................................................................................17
Class Diagrams........................................................................................................................17
Statechart Diagrams..................................................................................................................18
Component Diagrams...............................................................................................................19
Deployment Diagrams..............................................................................................................21
Visual Modeling and the Software Development Process.....................................................................22
Inception..................................................................................................................................24
Elaboration...............................................................................................................................24
Construction.............................................................................................................................25
Transition.................................................................................................................................26
Summary...............................................................................................................................................26
Chapter 2: A Tour of Rose..............................................................................................................................27
What Is Rose?.......................................................................................................................................27
Getting Around in Rose.........................................................................................................................30
Parts of the Screen....................................................................................................................31
Exploring Four Views in a Rose Model................................................................................................38
Use Case View..........................................................................................................................38
Logical View............................................................................................................................40
Component View......................................................................................................................42
Deployment View.....................................................................................................................43
Working with Rose...............................................................................................................................45
Creating Models........................................................................................................................45
Saving Models.........................................................................................................................46
Exporting and Impoting Models..............................................................................................47
Publishing Models to the Web..................................................................................................48
Working with Controlled Units................................................................................................50
Using the Model Integrator.......................................................................................................52
Working with Notes..................................................................................................................53
Working with Packages............................................................................................................54
Adding Files and URLs to Rose Model Elements....................................................................56
Adding and Deleting Diagrams................................................................................................56
Setting Global Options..........................................................................................................................57
Working with Fonts..................................................................................................................58
Working with Colors................................................................................................................58
Chapter 2: A Tour of Rose
Summary...............................................................................................................................................59
Chapter 3: Business Modeling........................................................................................................................61
Introduction to Business Modeling........................................................................................................61
Why Model the Business?........................................................................................................61
Do I Need to Do Business Modeling?......................................................................................62
Business Modeling in an Iterative Process...............................................................................63
Business−Modeling Concepts................................................................................................................66
Business Actors.........................................................................................................................66
Business Workers.....................................................................................................................67
Business Use Cases...................................................................................................................68
Business Use Case Diagrams....................................................................................................69
Activity Diagrams.....................................................................................................................70
Business Entities.......................................................................................................................72
Organization Unit.....................................................................................................................73
Where Do I Start?.................................................................................................................................74
Identifying the Business Actors................................................................................................74
Identifying the Business Workers.............................................................................................75
Identifying the Business Use Cases..........................................................................................76
Showing the Interactions..........................................................................................................76
Documenting the Details..........................................................................................................77
Creating Business Use Case Diagrams..................................................................................................78
Deleting Business Use Case Diagrams.....................................................................................79
The Use Case Diagram Toolbar................................................................................................80
Adding Business Use Cases......................................................................................................80
Business Use Case Specifications.............................................................................................81
Assigning a Priority to a Business Use Case............................................................................83
Viewing Diagrams for a Business Use Case............................................................................83
Viewing Relationships for a Business Use Case......................................................................86
Working with Business Actors..............................................................................................................87
Adding Business Actors............................................................................................................87
Adding Actor Specifications.....................................................................................................88
Assigning an Actor Stereotype.................................................................................................89
Setting Business Actor Multiplicity..........................................................................................89
Viewing Relationships for a Business Actor............................................................................90
Working with Relationships..................................................................................................................91
Association Relationship..........................................................................................................91
Generalization Relationship......................................................................................................92
Working with Organization Units..........................................................................................................94
Adding Organization Units.......................................................................................................94
Deleting Organization Units.....................................................................................................95
Activity Diagrams.................................................................................................................................95
Adding an Activity Diagram.....................................................................................................96
Adding Details to an Activity Diagram....................................................................................97
Summary.............................................................................................................................................102
Chapter 4: Use Cases and Actors..................................................................................................................104
Use Case Modeling Concepts..............................................................................................................104
Actors.....................................................................................................................................104
Use Cases...............................................................................................................................105
Traceability............................................................................................................................107
Flow of Events........................................................................................................................108
Relationships..........................................................................................................................114
Use Case Diagrams.............................................................................................................................118
Activity Diagrams...............................................................................................................................119
Activity..................................................................................................................................120
Start and End States................................................................................................................121
Objects and Object Flows.......................................................................................................121
Transitions.............................................................................................................................122
Synchronization.....................................................................................................................122
Working with Use Cases in Rational Rose..........................................................................................123
The Use Case Diagram Toolbar..............................................................................................123
Creating Use Case Diagrams..................................................................................................124
Deleting Use Case Diagrams..................................................................................................126
Adding Use Cases...................................................................................................................127
Deleting Use Cases.................................................................................................................129
Use Case Specifications..........................................................................................................130
Naming a Use Case.................................................................................................................131
Viewing Participants of a Use Case........................................................................................132
Assigning a Use Case Stereotype...........................................................................................132
Assigning a Priority to a Use Case.........................................................................................133
Creating an Abstract Use Case...............................................................................................133
Viewing Diagrams for a Use Case..........................................................................................134
Viewing Relationships for a Use Case...................................................................................136
Working with Actors...........................................................................................................................137
Adding Actors.........................................................................................................................137
Deleting Actors.......................................................................................................................139
Actor Specifications................................................................................................................139
Naming Actors........................................................................................................................141
Assigning an Actor Stereotype...............................................................................................142
Setting Actor Multiplicity.......................................................................................................142
Creating an Abstract Actor.....................................................................................................143
Viewing Relationships for an Actor.......................................................................................144
Viewing an Actor's Instances..................................................................................................145
Working with Relationships................................................................................................................145
Association Relationship........................................................................................................145
Includes Relationship..............................................................................................................146
Extends Relationship..............................................................................................................148
Generalization Relationship....................................................................................................148
Working with Activity Diagrams.........................................................................................................149
The Activity Diagram Toolbar...............................................................................................149
Creating Activity Diagrams....................................................................................................150
Deleting Activity Diagrams....................................................................................................154
Exercise...............................................................................................................................................154
Problem Statement..................................................................................................................154
Create a Use Case Diagram....................................................................................................154
Summary.............................................................................................................................................157
Chapter 5: Object Interaction......................................................................................................................159
Interaction Diagrams...........................................................................................................................159
What Is an Object?..................................................................................................................161
What Is a Class?......................................................................................................................161
Where Do I Start?...................................................................................................................162
Finding Objects.......................................................................................................................162
Finding the Actor....................................................................................................................163
Using Interaction Diagrams....................................................................................................164
Sequence Diagrams.............................................................................................................................164
The Sequence Diagram Toolbar.............................................................................................165
Collaboration Diagrams.......................................................................................................................166
The Collaboration Diagram Toolbar.......................................................................................167
Working with Actors on an Interaction Diagram................................................................................167
Working with Objects.........................................................................................................................168
Adding Objects to an Interaction Diagram.............................................................................168
Deleting Objects from an Interaction Diagram.......................................................................169
Setting Object Specifications..................................................................................................169
Naming an Object...................................................................................................................170
Mapping an Object to a Class.................................................................................................171
Setting Object Persistence......................................................................................................173
Using Multiple Instances of an Object...................................................................................174
Working with Messages.......................................................................................................................175
Adding Messages to an Interaction Diagram..........................................................................175
Adding Messages to a Sequence Diagram..............................................................................175
Deleting Messages from a Sequence Diagram.......................................................................176
Reordering Messages in a Sequence Diagram........................................................................176
Message Numbering in a Sequence Diagram.........................................................................177
Viewing the Focus of Control in a Sequence Diagram..........................................................178
Adding Messages to a Collaboration Diagram.......................................................................179
Deleting Messages from a Collaboration Diagram.................................................................180
Message Numbering in a Collaboration Diagram..................................................................181
Adding Data Flows to a Collaboration Diagram....................................................................181
Setting Message Specifications..............................................................................................182
Naming a Message..................................................................................................................182
Mapping a Message to an Operation......................................................................................183
Setting Message Synchronization Options.............................................................................185
Setting Message Frequency....................................................................................................188
End of a Lifeline.................................................................................................................................189
Working with Scripts..........................................................................................................................189
Switching Between Sequence and Collaboration Diagrams................................................................191
Two−Pass Approach to Interaction Diagrams.....................................................................................192
Exercise...............................................................................................................................................195
Problem Statement..................................................................................................................195
Create Interaction Diagrams...................................................................................................195
Summary.............................................................................................................................................200
Chapter 6: Classes and Packages..................................................................................................................201
Logical View of a Rose Model............................................................................................................201
Class Diagrams...................................................................................................................................201
What Is a Class?......................................................................................................................202
Finding Classes.......................................................................................................................203
Creating Class Diagrams........................................................................................................205
Deleting Class Diagrams........................................................................................................207
Organizing Items on a Class Diagram....................................................................................207
Using the Class Diagram Toolbar...........................................................................................208
Working with Classes.........................................................................................................................209
Adding Classes.......................................................................................................................209
Class Stereotypes................................................................................................................................212
Analysis Stereotypes...............................................................................................................212
Class Types............................................................................................................................217
Interfaces................................................................................................................................224
Web Modeling Stereotypes.....................................................................................................225
Other Language Stereotypes...................................................................................................228
Class Specifications............................................................................................................................230
Naming a Class.......................................................................................................................231
Setting Class Visibility...........................................................................................................232
Setting Class Multiplicity.......................................................................................................233
Setting Storage Requirements for a Class...............................................................................234
Setting Class Persistence........................................................................................................234
Setting Class Concurrency......................................................................................................235
Creating an Abstract Class......................................................................................................235
Viewing Class Attributes........................................................................................................236
Viewing Class Operations......................................................................................................236
Viewing Class Relationships..................................................................................................237
Using Nested Classes..............................................................................................................237
Viewing the Interaction Diagrams That Contain a Class.......................................................238
Setting Java Class Specifications............................................................................................239
Setting CORBA Class Specifications.....................................................................................241
Working with Packages.......................................................................................................................242
Adding Packages.....................................................................................................................242
Deleting Packages...................................................................................................................243
Exercise...............................................................................................................................................244
Problem Statement..................................................................................................................244
Creating a Class Diagram.......................................................................................................244
Summary.............................................................................................................................................250
Chapter 7: Attributes and Operations..........................................................................................................251
Working with Attributes.....................................................................................................................251
Finding Attributes...................................................................................................................251
Adding Attributes...................................................................................................................252
Deleting Attributes..................................................................................................................255
Setting Attribute Specifications..............................................................................................256
Setting the Attribute Containment..........................................................................................264
Making an Attribute Static......................................................................................................265
Specifying a Derived Attribute...............................................................................................265
Working with Operations.....................................................................................................................266
Finding Operations.................................................................................................................267
Adding Operations..................................................................................................................268
Deleting Operations................................................................................................................271
Setting Operation Specifications............................................................................................272
Adding Arguments to an Operation........................................................................................278
Specifying the Operation Protocol..........................................................................................279
Specifying the Operation Qualifications.................................................................................280
Specifying the Operation Exceptions.....................................................................................281
Specifying the Operation Size................................................................................................281
Specifying the Operation Time...............................................................................................281
Specifying the Operation Concurrency...................................................................................282
Specifying the Operation Preconditions.................................................................................282
Specifying the Operation Postconditions................................................................................283
Specifying the Operation Semantics.......................................................................................284
Displaying Attributes and Operations on Class Diagrams..................................................................285
Showing Attributes.................................................................................................................286
Showing Operations................................................................................................................288
Showing Visibility..................................................................................................................290
Showing Stereotypes...............................................................................................................291
Mapping Operations to Messages........................................................................................................292
Mapping an Operation to a Message on an Interaction Diagram...........................................294
Exercise...............................................................................................................................................295
Problem Statement..................................................................................................................295
Add Attributes and Operations...............................................................................................296
Summary.............................................................................................................................................300
Chapter 8: Relationships...............................................................................................................................301
Relationships.......................................................................................................................................301
Types of Relationships............................................................................................................301
Finding Relationships.............................................................................................................303
Associations........................................................................................................................................304
Using Web Association Stereotypes.......................................................................................306
Creating Associations.............................................................................................................307
Deleting Associations.............................................................................................................310
Dependencies......................................................................................................................................311
Creating Dependencies...........................................................................................................313
Deleting Dependencies...........................................................................................................314
Package Dependencies........................................................................................................................315
Creating Package Dependencies.............................................................................................316
Deleting Package Dependencies.............................................................................................317
Aggregations.......................................................................................................................................317
Creating Aggregations............................................................................................................318
Deleting Aggregations............................................................................................................320
Generalizations...................................................................................................................................321
Creating Generalizations.........................................................................................................322
Deleting Generalizations.........................................................................................................323
Working with Relationships................................................................................................................324
Setting Multiplicity.................................................................................................................324
Using Relationship Names......................................................................................................326
Using Stereotypes...................................................................................................................327
Using Roles............................................................................................................................328
Setting Export Control............................................................................................................330
Using Static Relationships......................................................................................................331
Using Friend Relationships.....................................................................................................332
Setting Containment...............................................................................................................333
Using Qualifiers.....................................................................................................................334
Using Link Elements..............................................................................................................335
Using Constraints....................................................................................................................336
Exercise...............................................................................................................................................338
Problem Statement..................................................................................................................338
Adding Relationships..............................................................................................................338
Summary.............................................................................................................................................340
Chapter 9: Object Behavior..........................................................................................................................341
Statechart Diagrams............................................................................................................................341
Creating a Statechart Diagram................................................................................................342
Adding States.........................................................................................................................343
Adding State Details...............................................................................................................344
Adding Transitions.................................................................................................................349
Adding Transition Details.......................................................................................................350
Adding Special States.............................................................................................................352
Using Nested States and State History...................................................................................353
Exercise...............................................................................................................................................355
Problem Statement..................................................................................................................355
Create a Statechart Diagram...................................................................................................356
Summary.............................................................................................................................................359
Chapter 10: Component View.......................................................................................................................360
What Is a Component?........................................................................................................................360
Types of Components.............................................................................................................360
Component Diagrams.........................................................................................................................362
Creating Component Diagrams..............................................................................................363
Adding Components...............................................................................................................364
Adding Component Details....................................................................................................367
Adding Component Dependencies.........................................................................................372
Exercise...............................................................................................................................................373
Problem Statement..................................................................................................................373
Summary.............................................................................................................................................380
Chapter 11: Deployment View.......................................................................................................................381
Deployment Diagrams........................................................................................................................381
Opening the Deployment Diagram.........................................................................................381
Adding Processors..................................................................................................................382
Adding Processor Details........................................................................................................384
Adding Devices.......................................................................................................................387
Adding Device Details............................................................................................................389
Adding Connections...............................................................................................................391
Adding Connection Details.....................................................................................................392
Adding Processes....................................................................................................................394
Exercise...............................................................................................................................................397
Problem Statement..................................................................................................................397
Create Deployment Diagram..................................................................................................397
Summary.............................................................................................................................................400
Chapter 12: Introduction to Code Generation and Reverse Engineering Using Rational Rose.............401
Preparing for Code Generation............................................................................................................401
Step One: Check the Model....................................................................................................402
Step Two: Create Components...............................................................................................404
Step Three: Map Classes to Components...............................................................................405
Step Four: Set the Code−Generation Properties.....................................................................406
Step Five: Select a Class, Component, or Package.................................................................409
Step Six: Generate Code.........................................................................................................409
What Gets Generated?........................................................................................................................410
Introduction to Reverse Engineering Using Rational Rose.................................................................411
Model Elements Created During Reverse Engineering.......................................................................412
Round−Trip Engineering....................................................................................................................415
Summary.............................................................................................................................................415
Chapter 13: ANSI C++ and Visual C++ Code Generation and Reverse Engineering.............................417
Generating Code in ANSI C++ and Visual C++.................................................................................417
Converting a C++ Model to an ANSI C++ Model..............................................................................418
ANSI C++ Code−Generation Properties.............................................................................................419
Class Properties......................................................................................................................420
Attribute Properties.................................................................................................................421
Operation Properties...............................................................................................................422
Package (Class Category) Properties......................................................................................424
Component (Module Specification) Properties......................................................................424
Role Properties.......................................................................................................................427
Generalization Properties........................................................................................................428
Visual C++ Code−Generation Properties............................................................................................428
Class Model Assistant.............................................................................................................428
Component Properties.............................................................................................................431
Project Properties....................................................................................................................433
Visual C++ and ATL Objects.................................................................................................434
Generated Code...................................................................................................................................435
Code Generated for Classes....................................................................................................435
Code Generated for Attributes................................................................................................439
Code Generated for Operations..............................................................................................441
Visual C++ Code Generation...............................................................................................................443
Reverse Engineering ANSI C++..........................................................................................................443
Reverse Engineering Visual C++........................................................................................................445
Summary.............................................................................................................................................445
Chapter 14: Java Code Generation and Reverse Engineering...................................................................447
Overview.............................................................................................................................................447
Introduction to Rose J..........................................................................................................................448
Beginning a Java Project......................................................................................................................449
Selecting a Java Framework...................................................................................................449
Linking to IBM VisualAge for Java.......................................................................................450
Linking to Microsoft Visual J++............................................................................................451
Java Code−Generation Properties........................................................................................................451
Project Properties....................................................................................................................452
Class Properties......................................................................................................................456
Attribute Properties.................................................................................................................458
Operation Properties...............................................................................................................459
Module Properties...................................................................................................................460
Role Properties.......................................................................................................................461
Generating Code.................................................................................................................................462
Generated Code...................................................................................................................................462
Classes...................................................................................................................................463
Attributes...............................................................................................................................465
Operations..............................................................................................................................466
Bidirectional Associations......................................................................................................468
Unidirectional Associations....................................................................................................471
Associations with a Multiplicity of One to Many...................................................................472
Associations with a Multiplicity of Many to Many................................................................474
Reflexive Associations...........................................................................................................476
Aggregations..........................................................................................................................476
Dependency Relationships......................................................................................................478
Generalization Relationships..................................................................................................479
Interfaces................................................................................................................................480
Java Beans..............................................................................................................................481
Support for J2EE.................................................................................................................................484
EJBs.......................................................................................................................................484
Servlets...................................................................................................................................487
JAR and WAR Files...............................................................................................................488
Automated J2EE Deployment................................................................................................489
Reverse Engineering...........................................................................................................................490
Summary.............................................................................................................................................491
Chapter 15: Visual Basic Code Generation and Reverse Engineering......................................................493
Starting a Visual Basic Project............................................................................................................494
Visual Basic Code−Generation Properties..........................................................................................494
Class Properties......................................................................................................................495
Attribute Properties.................................................................................................................498
Operation Properties...............................................................................................................499
Module Specification Properties.............................................................................................502
Role Properties.......................................................................................................................503
Generalization Properties........................................................................................................504
Using the Code−Generation Wizard....................................................................................................505
Generated Code...................................................................................................................................509
Classes...................................................................................................................................509
Attributes...............................................................................................................................530
Operations..............................................................................................................................531
Bidirectional Associations......................................................................................................531
Unidirectional Associations....................................................................................................533
Associations with a Multiplicity of One to Many...................................................................534
Associations with a Multiplicity of Many to Many................................................................534
Reflexive Associations...........................................................................................................535
Aggregations..........................................................................................................................535
Dependency Relationships......................................................................................................536
Generalization Relationships..................................................................................................536
Reverse Engineering...........................................................................................................................537
Summary.............................................................................................................................................539
Chapter 16: XML DTD Code Generation and Reverse Engineering........................................................541
Overview.............................................................................................................................................541
Introduction to XML DTD...................................................................................................................542
Elements.................................................................................................................................542
Attributes...............................................................................................................................543
Entities and Notations.............................................................................................................543
DTD−to−UML Mapping.....................................................................................................................545
DTD Code−Generation Properties.......................................................................................................546
Project Properties....................................................................................................................546
Class Properties......................................................................................................................547
Attribute Properties.................................................................................................................551
Role Properties.......................................................................................................................552
Component Properties.............................................................................................................553
Generating Code.................................................................................................................................554
Generated Code...................................................................................................................................554
Classes...................................................................................................................................555
Attributes...............................................................................................................................562
Reverse Engineering DTD...................................................................................................................564
Summary.............................................................................................................................................565
Chapter 17: CORBA/IDL Code Generation and Reverse Engineering....................................................567
CORBA/IDL Code−Generation Properties.........................................................................................567
Project Properties....................................................................................................................568
Class Properties......................................................................................................................570
Attribute Properties.................................................................................................................575
Operation Properties...............................................................................................................576
Module Properties...................................................................................................................578
Association (Role) Properties.................................................................................................579
Dependency Properties...........................................................................................................580
Generated Code...................................................................................................................................581
Classes...................................................................................................................................581
Attributes...............................................................................................................................588
Operations..............................................................................................................................591
Bidirectional Associations......................................................................................................591
Unidirectional Associations....................................................................................................595
Associations with a Multiplicity of One to Many...................................................................595
Associations with a Multiplicity of Many to Many................................................................599
Associations with Bounded Multiplicity................................................................................600
Reflexive Associations...........................................................................................................602
Aggregations..........................................................................................................................604
Dependency Relationships......................................................................................................604
Generalization Relationships..................................................................................................605
Reverse Engineering CORBA Source Code...........................................................................608
Summary.............................................................................................................................................609
Chapter 18: Rose Data Modeler....................................................................................................................610
Object Models and Data Models..........................................................................................................610
Creating a Data Model.........................................................................................................................612
Logic in a Data Model.........................................................................................................................613
Adding a Database..............................................................................................................................614
Adding Tablespaces................................................................................................................615
Adding a Schema................................................................................................................................621
Creating a Data Model Diagram.............................................................................................622
Creating Domain Packages and Domains............................................................................................623
Adding Tables.....................................................................................................................................626
Adding Columns.....................................................................................................................628
Setting a Primary Key.............................................................................................................631
Adding Constraints.................................................................................................................631
Adding Triggers......................................................................................................................633
Adding Indexes.......................................................................................................................635
Adding Stored Procedures...................................................................................................................636
Adding Relationships..........................................................................................................................639
Adding Referential Integrity Rules.........................................................................................642
Working with Views...........................................................................................................................644
Generating an Object Model from a Data Model................................................................................648
Generating a Data Model from an Object Model................................................................................649
Generating a Database from a Data Model..........................................................................................651
Updating an Existing Database............................................................................................................653
Reverse Engineering a Database..........................................................................................................655
Summary.............................................................................................................................................656
Chapter 19: Web Modeling...........................................................................................................................657
Modeling a Web Application...............................................................................................................657
Web Class Stereotypes............................................................................................................659
Relationships..........................................................................................................................666
Reverse Engineering a Web Application.............................................................................................668
Generating Code for a Web Application.............................................................................................670
Summary.............................................................................................................................................671
Appendix: Getting Started with UML..........................................................................................................672
Building a Business Use Case Diagram...............................................................................................672
Building a Workflow (Activity) Diagram............................................................................................675
Building a Use Case Diagram..............................................................................................................679
Building an Interaction Diagram.........................................................................................................684
Building a Class Diagram....................................................................................................................688
Web Modeling....................................................................................................................................691
Adding Class Relationships.................................................................................................................694
Building a Statechart Diagram.............................................................................................................696
Building a Component Diagram..........................................................................................................699
Building a Deployment Diagram.........................................................................................................701


Download

Another Software Engineering Books
Continue Reading ...

Related Posts with Thumbnails

Put Your Ads Here!

Recent Posts