创建托管卡
“托管卡”**是由标识提供方颁发的信息卡。 它包含:
有关颁发该卡的实体的详细信息:
卡名称。
证书。
STS(安全令牌服务)和 MEX(元数据交换)终结点。
卡上显示的图像。
有关标识提供方确认的用户的声明列表。
有关用户如何使用标识提供方的 STS 进行身份验证以使用所需的声明值填充信息卡的详细信息。 此身份验证过程可以采用以下形式:证书、Kerberos 令牌、自行颁发的卡或者用户名/密码对(在某些情况下)。
提示
若要创建用于 CardSpace 的卡,标识提供方必须生成包含卡数据的已签名 XML 文件。 此信息卡以 .CRD 文件扩展名命名。
若要使用此示例,必须进行网站配置。 使用示例文件夹中提供的安装批处理文件可以完成配置:
Setup.bat
有关安装网站的更多信息以及一些疑难解答提示,请参见安装 CardSpace 示例证书。
编译卡编写器
在 CardWriter
文件夹中可找到卡编写器的源代码 (C#)。
ManagedCardWriter.cs
在 CardWriter
文件夹可找到卡编写器的源代码 (VB.NET):
ManagedCardWriter.vb
在 Visual Studio 2005 中加载项目文件 (CardWriter.csproj
) 并对其进行编译或在命令行(在其中对示例进行解压缩)中使用 msbuild。
msbuild /nologo /v:quiet CardWriter\CardWriter.csproj
这会将卡编写器编译到 \bin 文件夹,现在就可以从命令行运行该卡编写器了。
bin\cardwriter.exe
Usage:
ManagedCardWriter carddetails.ini [outputfilename.crd]
使用卡编写器
卡编写器使用 .INI 文件作为输入来生成 .CRD 文件。
bin\cardwriter.exe SampleCards\FabrikamUP.ini
Reading card config from
<install path >\FabrikamUP.ini
Card written to
<install path>\SampleCards\FabrikamUP.crd
提示
输出卡位于与源 .INI 文件相同的目录中。
了解 CardSpace 卡中的数据
在源 .INI 文件中,可以对一些节中的数据进行修改,以便针对特定用途生成卡。
卡类型示例
[CARD]
TYPE=UserNamePassword
使用卡创建器,每张卡均可使用一种身份验证类型以便使用标识提供方的 STS 进行身份验证。 卡类型可能为 UserNamePassword
、KerberosAuth
、SelfIssuedAuth
或 SmartCard
之一。
卡详细信息示例
[Details]
Name=My Card (U/P backed)
ID=http://www.fabrikam.com/card/unpw/randomnnumber123
version=1
image=images\fabrikam.jpg
在“Details”节中,有四个必填字段。
|
用户看到的卡的显示名称。 在将名称导入到标识选择器之后,用户可以对其进行修改。 |
|
这是卡的 ID。 使用同一 ID 导入卡会提示用户使用较新的卡替换旧卡。 在卡架构修订版本之间应保持卡 ID 的一致性。 |
|
同一张卡的各个新版本的版本号应按递增顺序增长。 |
|
在将图像导入到标识选择器之后,用户可以在卡上看到该图像。 用户无法对其进行更改。 |
颁发者详细信息示例
[Issuer]
Address=http://www.fabrikam.com:3074/sts
MexAddress=https://www.fabrikam.com:4074/sts/mex
PrivacyPolicy=http://www.fabrikam.com/PrivacyPolicy.xml
Certificate=LOCALMACHINE/MY/www.fabrikam.com
在“Issuer”节中,有四个必填字段。
|
标识提供方 STS 的终结点 URL。 |
|
STS 的 MEX 终结点。 在 CardSpace 中,MEX 终结点需要 HTTPS。 |
|
标识提供方的隐私策略所在位置的 URL。 |
|
其公钥用于对卡文件进行签名的证书的位置。 它的格式应为:位置/存储区名称/公用名(例如,localmachine/My/www.fabrikam.com)或者指向包含证书和私钥的 .PFX 文件的路径。 如果 .PFX 文件受密码保护,则还必须在 .INI 文件中添加 |
声明详细信息示例
[Claims]
1=https://schemas.microsoft.com/ws/2005/05/identity/claims/givenname
2=https://schemas.microsoft.com/ws/2005/05/identity/claims/surname 3=https://schemas.microsoft.com/ws/2005/05/identity/claims/emailaddress
4=https://www.contoso.com/myuritest
在“Claims”节中,列出了标识提供方支持的每个声明 URI。 使用标准声明 URI 集不需要任何其他信息,但使用自定义声明 URI 则需要在相应的节中列出每个自定义声明。
自定义声明 URI 详细信息示例
[https://www.contoso.com/myuritest]
display=My Super Claim
description=A claim for all to see
每个自定义声明 URI 必须详细描述创建的每个声明的显示名称和说明。 用户可在 CardSpace 标识选择器中看到这些信息。
支持的令牌类型示例
[TokenTypes]
1=urn:oasis:names:tc:SAML:1.0:assertion
2=http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1
标识提供方声明了 STS 支持的令牌类型。 它们将在“TokenTypes”节中作为 URN 列出。 每个 URN 位于独立的一行中,并具有作为字段名称的索引号(例如 1、2、3…)。
令牌详细信息示例
[Token Details]
RequiresAppliesTo=false
标识提供方可决定是否对任何依赖方颁发令牌或者是否需要依赖方在请求标识时表明他们的身份。
凭据
在此节中可列出所有凭据提示信息并将其编码到卡中。 对于不同的身份验证类型可能有不同的要求:
对于自行颁发的卡身份验证,值为卡中的 PPID 声明,在提供给标识提供方时,使用其证书。
[Credentials] value=eiavryEeugtsZibaD0moDOiIE+106HbYhYIbst73x5A= Hint=Enter your username and password
对于用户名/密码身份验证,值为向用户显示的用户名(可选)。
[Credentials] value=FrankLee Hint=Enter your username and password
对于证书身份验证,必须通过以下三种方法之一来标识证书:
证书的指纹。
对证书存储区中证书的引用,格式为:位置/存储区名称/公用名 (currentUser/My/FrankLee)
证书本身的哈希。
证书示例
[Credentials]
value=3ce25c9ef8b2d5d99a227e1ea1a28d7f001a3355
Hint=Insert your smartcard now
查看生成的卡
.CRD 格式是一种包含上述信息的 XML 文档。 标识提供方使用该格式以非常简洁的形式表示所有内容,而用户使用该格式将卡导入其集合。
此示例假定标识提供方颁发的卡用于确认汽车俱乐部中的成员资格,提供各种网站的访问服务或折扣信息。
签名
.CRD 文件的根元素为包封签名。
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<Reference URI="#_Object_InfoCard">
<Transforms>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<DigestValue>3x/Op7j/BUjCskLqMHNdfCyI/H8=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>
NT...0w==
</SignatureValue>
<KeyInfo>
<X509Data>
<X509Certificate>
MIIG…uEd
</X509Certificate>
<X509Certificate>
MIIE...Q==
</X509Certificate>
</X509Data>
</KeyInfo>
<Object Id="_Object_InfoCard">
...
</Object>
</Signature>
这可确保卡在颁发后应受到保护而不会被篡改。 这是通过使用签名来实现的。 此外,它还提供加密以确认卡确实是由汽车俱乐部颁发的,同时也演示了私钥的用法。
两个 X509Certificate
元素包含标识提供方(汽车俱乐部)的证书以及向汽车俱乐部颁发证书的证书颁发机构的证书。
在签名之后还有一个名为 InformationCard
的元素,该元素包含卡的实际元数据。 下面的示例演示了卡的 XML 元素。
<InformationCard xml:lang="en-us" xmlns="https://schemas.microsoft.com/ws/2005/05/identity">
<InformationCardReference />
<CardName />
<CardImage />
<Issuer />
<IssuerName />
<TimeIssued />
<TimeExpires />
<TokenServiceList />
<SupportedTokenTypeList />
<SupportedClaimTypeList />
<PrivacyNoticeAt />
</InformationCard>
<InformationCardReference>
包含卡 ID 和版本;用于后续导入操作以便能够对卡进行更新或覆盖。
<InformationCardReference>
<CardId>
http://www.fabrikam.com/card/unpw/randomnnumber123
</CardId>
<CardVersion>1</CardVersion>
</InformationCardReference>
<CardName>
包含描述性卡名称,用户在导入后可以对其进行修改。
<CardName>My Card</CardName>
<CardImage>
包含一个 base64 编码的图像,标识提供方可选择他们所喜欢的外观。 这将在卡内进行编码,并且不会在 URL 中引用以确保品牌提供方的一致性,而不依赖客户端解析链接的能力。
<CardImage MimeType="image/jpeg">
</CardImage>
<Issuer>
表示 STS 的 URI(每次使用托管卡时,将请求安全令牌 (RST) 消息发送到的地址)。<IssuerName>
为与之关联的描述性名称。
<Issuer>http://www.fabrikam.com:3074/sts</Issuer>
<TimeIssued>
和 <TimeExpires>
分别包含颁发操作发生的时间和卡的到期日期。 该到期日期应视为“支持此元数据协定的时间”,而不是帐户到期日期,帐户到期日期应作为帐户数据在 STS 进行处理。
<TimeIssued>2006-08-07T23:37:42.3533826Z</TimeIssued>
<TimeExpires>9999-12-31T23:59:59.9999999Z</TimeExpires>
<TokenServiceList>
包含 <TokenService>
元素列表,这些元素是用于获取 STS 元数据、安全地进行联系以及对传入请求进行身份验证的数据。
<TokenServiceList>
<TokenService>
<EndpointReference >
<Address />
<Metadata />
<Identity />
<UserCredential />
</TokenService>
</TokenServiceList>
<EndpointReference>
为 WS-Addressing 终结点引用,它又包含 STS 终结点;“Metadata”节包含 WS-MetadataExchange 终结点的地址。
<EndpointReference xmlns="http://www.w3.org/2005/08/addressing">
<Address>http://www.fabrikam.com:3074/sts</Address>
<Metadata>
<Metadata xmlns="https://schemas.xmlsoap.org/ws/2004/09/mex"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsx="https://schemas.xmlsoap.org/ws/2004/09/mex">
<wsx:MetadataSection >
<wsx:MetadataReference>
<Address xmlns="http://www.w3.org/2005/08/addressing">
https://www.fabrikam.com:4074/sts/mex
</Address>
</wsx:MetadataReference>
</wsx:MetadataSection>
</Metadata>
</Metadata>
<Identity>
包含与 STS 关联的证书,通常与初始签名中使用的证书相同。
<Identity xmlns="https://schemas.xmlsoap.org/ws/2006/02/addressingidentity">
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<X509Data>
<X509Certificate>
MIIGR…uEd
</X509Certificate>
</X509Data>
</KeyInfo>
</Identity>
</EndpointReference>
<UserCredential>
元素根据身份验证类型的不同而改变:
对于由个人卡支持的信息卡,
<PrivatePersonalIdentifier>
元素用于存储 PPID。<UserCredential> <SelfIssuedCredential> <PersonalPrivateIdentifier> eiavryEeugtsZibaD0moDOiIE+106HbYhYIbst73x5A= </PersonalPrivateIdentifier> </ SelfIssuedCredential > </UserCredential>
对于支持证书的卡,元素
<X509V3Credential>
由托管卡使用;<KeyIdentifier>
元素包含智能卡证书的哈希。<DisplayCredentialHint>
元素是在显示智能卡之前用户接收到的提示信息。<UserCredential> <X509V3Credential> <X509Data xmlns="http://www.w3.org/2000/09/xmldsig#"> <KeyIdentifier ValueType="http://docs.oasis-open.org/wss/2004/xx/oasis-2004xx-wss-soap-message-security-1.1#ThumbprintSHA1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 3ce25c9ef8b2d5d99a227e1ea1a28d7f001a3355 </KeyIdentifier> </ X509Data > </X509V3Credential> </UserCredential>
对于支持用户名/密码的卡,
<UsernamePasswordCredential>
保存卡的默认用户名。<UserCredential> <DisplayCredentialHint> Enter your username and password </DisplayCredentialHint> <UsernamePasswordCredential> <Username>FrankLee</Username> </UsernamePasswordCredential> </UserCredential>
<SupportedTokenTypeList>
包含 <TokenType>
元素的列表,该元素详细列出了 STS 支持的令牌类型。
<SupportedTokenTypeList>
<TokenType xmlns="https://schemas.xmlsoap.org/ws/2005/02/trust">
urn:oasis:names:tc:SAML:1.0:assertion
</TokenType>
</SupportedTokenTypeList>
<SupportedClaimTypeList>
包含卡支持的声明的列表。 单个声明由 <SupportedClaimType>
元素进行描述,其元素一目了然(DisplayTag
和 Description
)。 该示例使用了自行颁发声明集中的预定义声明 URI 以及自定义声明 URI,例如 https://www.contoso.com/myuritest。
<SupportedClaimTypeList>
<SupportedClaimType
uri="https://schemas.microsoft.com/ws/2005/05/identity/claims/givenname">
<DisplayTag>Given Name</DisplayTag>
<Description>Given Name</Description>
</SupportedClaimType>
<SupportedClaimType
Uri="https://schemas.microsoft.com/ws/2005/05/identity/claims/surname">
<DisplayTag>Last Name</DisplayTag>
<Description>Last Name</Description>
</SupportedClaimType>
<SupportedClaimType Uri="https://schemas.microsoft.com/ws/2005/05/identity/claims/emailaddress">
<DisplayTag>Email Address</DisplayTag>
<Description>Email Address</Description>
</SupportedClaimType>
<SupportedClaimType Uri=" https://www.contoso.com/myuritest">
<DisplayTag>My Super Claim</DisplayTag>
<Description>A claim for all to see</Description>
</SupportedClaimType>
</SupportedClaimTypeList>
隐私策略 URL 可在 <PrivacyNotice>
元素中找到:
<PrivacyNotice>
http://www.fabrikam.com/PrivacyPolicy.xml
</PrivacyNotice>
词汇表
托管卡 - 由标识提供方颁发的信息卡。 该信息卡包含有关安全令牌服务的元数据和标识提供方支持的声明。
标识提供方 - 标识提供方向用户颁发数字标识,这些数字标识包含有关用户数据的声明。
安全令牌服务 (STS) - 安全令牌服务将一个令牌与另一个令牌交换。 STS 根据对用户进行身份验证的方式授予包含声明的令牌。 从本质上而言,是服务器向用户分发数字标识信息。
请参见
其他资源
版权所有 (C) 2007 Microsoft Corporation。保留所有权利。