DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> XML學習教程 >> XML詳解
理解 IBM InfoSphere MDM Server 安全性(4):以 SAML 斷言傳遞用戶身份
編輯:XML詳解     

簡介

IBM InfoSphere MDM Server 允許用戶依自己的格式,在 MDM 安全框架中傳遞並處理安全資料。本文簡要說明如何借助這種機制支援 SAML 斷言,並延續前一篇《理解 IBM InfoSphere MDM Server 安全性》中「身份驗證與身份斷言」小節的討論。

你可以透過控制物件(Control Object),把 SAML 的身份驗證與身份屬性語句傳遞給 MDM Server。MDM Server 會解析這些 SAML 斷言,從中萃取用戶身份與組成員關係。由於這些語句保持 XML 格式,天然能支援各種擴充(業務代理、資料擴充或行為擴充)。

什麼是 SAML

SAML 是 Security Assertion Markup Language(安全斷言標記語言)的縮寫。維基百科將它定義為「一種基於 XML 的標準,用於在安全域之間——也就是在身份提供者(斷言的生產者)與服務提供者(斷言的消費者)之間——交換身份驗證與授權資料。SAML 由 OASIS Security Services Technical Committee 開發」。

把用戶身份信息傳遞給 MDM Server

MDM Server 為用戶端提供了幾種呼叫服務操作的方式:

  • 透過 RMI/IIOP,在服務控制器上直接呼叫。
  • 透過 HTTP,以 Web 服務操作的形式呼叫。
  • 透過 JMS,異步行呼叫。

無論選擇哪個介面,所有呼叫最終都會匯集到服務控制器。服務控制器是請求與響應框架的入口點,它會依事務上下文挑選一個請求解析器;解析器接著解析請求業務物件——該物件的標頭含一個控制物件,主體則含一個事務物件。

MDM Server 要求控制物件中傳遞的用戶身份信息,須為明文文字值或 SAML 斷言。以下分別說明這兩種方式。

明文文字值

你可以透過控制物件的 requesterName 與 userRoles 屬性,以明文文字值的形式把用戶身份信息交給 MDM Server。一名用戶可擁有數個角色,這些角色能一個接一個地傳入 MDM Server。

清單 1 是用戶 Jane Doe 的請求範例:requesterName 為 'jdoe',該用戶具備 CallCentAppUser 與 CstSuppRelL2 兩個角色。

清單 1. 以明文文字形式傳遞的用戶身份信息

<?XML version="1.0" encoding="UTF-8"?>
<TCRMService xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="myTCRM.xsd">
<RequestControl>
<requestID>123501</requestID>
<DWLControl>
. . .
<requesterName>jdoe</requesterName>
<userRole>CallCentAppUser</userRole>
<userRole>CstSuppRepL2</userRole>
. . .
</DWLControl>
</RequestControl>
<TCRMTx>
. . .
</TCRMTx>
</TCRMService>

SAML 斷言

你也可以把用戶身份信息以身份驗證斷言的形式傳給 MDM Server,這種斷言同時承載了用戶身份及其屬性(角色)。

把 SAML 斷言送達 MDM Server,是服務消費者的責任。服務消費者可以直接向身份提供者索取 SAML 斷言,也可以取得其他格式的身份資料,再自行轉換為 SAML 斷言。

在整個事務生命週期的各個階段,SAML 斷言語句都會被持續傳遞,因此各種擴充也能隨時取用。預設情況下,MDM Server 能從 AuthenticationData 中取得控制物件的 requesterName 與 userRoles 屬性;而取自 SAML 斷言的資訊,優先於透過控制物件屬性傳遞的資訊。在 SAML 斷言整合特性問世之前的 MDM Server 版本裡,一直沿用控制物件的 requesterName 與 userRoles 屬性;即便如今已能在 SAML 斷言中傳遞用戶身份,MDM Server 內部各處仍會使用 requesterName 與 userRoles 屬性。

清單 2 是用戶 Jane Doe 的請求範例:其身份為 'jdoe',擁有 CallCentAppUser 與 CstSuppRelL2 兩個角色。請注意,'jdoe' 是作為 AuthenticationStatement 中的 NameIdentifier 傳遞,而兩個角色則作為 AttributeStatement 中的 AttributeValue 傳遞。

清單 2. 以 SAML 斷言形式傳遞的用戶身份信息

<?XML version="1.0" encoding="UTF-8"?>
<TCRMService xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="myTCRM.xsd">
<RequestControl>
<requestID>123501</requestID>
<DWLControl>
. . .
<authData><![CDATA[
<saml:Assertion XMLns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
MajorVersion="1" MinorVersion="1" AssertionID=". . ."
Issuer=". . ." IssueInstant="2008-11-21T10:35:18.796Z"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:oasis:names:tc:SAML:1.0:assertion
oasis-sstc-saml-schema-assertion-1.1.xsd">
<saml:Conditions NotBefore=". . ." NotOnOrAfter=". . .">. . .</saml:Conditions>
<saml:AuthenticationStatement
AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:passWord"
AuthenticationInstant="2008-11-21T10:35:08.707Z">
<saml:Subject>
<saml:NameIdentifier
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName">
jdoe
</saml:NameIdentifier>
</saml:Subject>
</saml:AuthenticationStatement>
<saml:AttributeStatement>
<saml:Subject>
<saml:SubjectConfirmation>
<saml:ConfirmationMethod>. . .</saml:ConfirmationMethod>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Attribute AttributeName="urn:wcc:dir:attribute-def:userRoles"
AttributeNamespace="urn:wcc:attributeNamespace:uri">
<saml:AttributeValue>
CallCentAppUser
</saml:AttributeValue>
<saml:AttributeValue>
CstSuppRepL2
</saml:AttributeValue>
</saml:Attribute>
</saml:AttributeStatement>
</saml:Assertion>
]]></authData>
. . .
</DWLControl>
</RequestControl>
<TCRMTx>
. . .
</TCRMTx>
</TCRMService>

把 SAML 斷言整合進 MDM Server 安全框架

MDM Server 安全框架定義了解析事務請求中身份驗證斷言所需的介面,斷言格式則由用戶自行決定。MDM Server 內建一個預設的身份驗證斷言解析器,支援 SAML,且預設支援 SAML 1.1 斷言。

下圖的類別圖說明了 SAML 斷言、安全資料解析器與控制物件之間的關係。

圖 1. 使用 SAML11parser 解析用戶身份信息

在 MDM Server 中使用 SAML 斷言,流程如下:

  • 請求解析器呼叫控制物件的 setAuthData() 方法,把事務請求中 authData 標籤的值(即 SAML 斷言)設定進去。
  • 選用 SAML11Parser 解析 SAML 斷言。這個解析器實作了 ISecurityDataParser 介面。
  • SAML11Parser 用從 SAML 斷言解析出的用戶 ID 與/或用戶角色,填充 AuthenticationData 物件;原始的 SAML 斷言也會一併存進 AuthenticationData。
  • 控制物件包含 AuthenticationData。在整個事務處理過程中,控制物件作為事務上下文物件被傳遞,因此 MDM Server 與各擴充都能在事務處理全程取用 SAML 斷言。

請求與響應範例

清單 3 是 addContract 事務的 XML 請求範例,其中的用戶身份信息以 SAML 斷言形式傳遞。

清單 3. addContract 事務請求,以 SAML 斷言形式傳遞用戶身份信息

<?XML version="1.0" encoding="UTF-8"?>
<TCRMService xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="myTCRM.xsd">
<RequestControl>
<requestID>123501</requestID>
<DWLControl>
<requesterLanguage>100</requesterLanguage>
<authData><![CDATA[
<saml:Assertion XMLns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
MajorVersion="1" MinorVersion="1" AssertionID=". . ."
Issuer=". . ." IssueInstant="2008-11-21T10:35:18.796Z"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:oasis:names:tc:SAML:1.0:assertion
oasis-sstc-saml-schema-assertion-1.1.xsd">
<saml:Conditions NotBefore=". . ." NotOnOrAfter=". . .">. . .</saml:Conditions>
<saml:AuthenticationStatement
AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:passWord"
AuthenticationInstant="2008-11-21T10:35:08.707Z">
<saml:Subject>
<saml:NameIdentifier
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName">
jdoe
</saml:NameIdentifier>
</saml:Subject>
</saml:AuthenticationStatement>
<saml:AttributeStatement>
<saml:Subject>
<saml:SubjectConfirmation>
<saml:ConfirmationMethod>. . .</saml:ConfirmationMethod>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Attribute AttributeName="urn:wcc:dir:attribute-def:userRoles"
AttributeNamespace="urn:wcc:attributeNamespace:uri">
<saml:AttributeValue>
CallCentAppUser
</saml:AttributeValue>
<saml:AttributeValue>
CstSuppRepL2
</saml:AttributeValue>
</saml:Attribute>
</saml:AttributeStatement>
</saml:Assertion>
]]></authData>
</DWLControl>
</RequestControl>
<TCRMTx>
<TCRMTxType>addContract</TCRMTxType>
<TCRMTxObject>TCRMContractBObj</TCRMTxObject>
<TCRMObject>
<TCRMContractBObj>
<ContractIdPK/>
<LineOfBusiness>life ins</LineOfBusiness>
<CurrencyType>1</CurrencyType>
<FrequencyModeType>1</FrequencyModeType>
<BillingType>5</BillingType>
<PremiumAmount>200</PremiumAmount>
<NextBillingDate>2009-01-01</NextBillingDate>
<CurrentCashValueAmount>300.00</CurrentCashValueAmount>
<BrandName>ul</BrandName>
<ServiceOrgName>KLM</ServiceOrgName>
<ServiceProvId>1991</ServiceProvId>
<BusOrgunitId>444</BusOrgunitId>
</TCRMContractBObj>
</TCRMObject>
</TCRMTx>
</TCRMService>

清單 4 則是這樁事務的 XML 響應範例,其中的 SAML 斷言會原封不動地回傳。

清單 4. addContract 事務響應,在響應中返回傳遞的 SAML 斷言

<?XML version="1.0" encoding="UTF-8"?>
<TCRMService xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="tCRMResponse.xsd">
<ResponseControl>
<ResultCode>SUCCESS</ResultCode>
<ServiceTime>125</ServiceTime>
<DWLControl>
<requesterLanguage>100</requesterLanguage>
<requesterLocale>en</requesterLocale>
<requesterName>jdoe</requesterName>
<requestID>123501</requestID>
<userRole>CallCentAppUser</userRole>
<userRole>CstSuppRepL2</userRole>
<authData><![CDATA[
<saml:Assertion XMLns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
MajorVersion="1" MinorVersion="1" AssertionID=". . ."
Issuer=". . ." IssueInstant="2008-11-21T10:35:18.796Z"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:oasis:names:tc:SAML:1.0:assertion
oasis-sstc-saml-schema-assertion-1.1.xsd">
<saml:Conditions NotBefore=". . ." NotOnOrAfter=". . .">. . .</saml:Conditions>
<saml:AuthenticationStatement
AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:passWord"
AuthenticationInstant="2008-11-21T10:35:08.707Z">
<saml:Subject>
<saml:NameIdentifier
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName">
jdoe
</saml:NameIdentifier>
</saml:Subject>
</saml:AuthenticationStatement>
<saml:AttributeStatement>
<saml:Subject>
<saml:SubjectConfirmation>
<saml:ConfirmationMethod>. . .</saml:ConfirmationMethod>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Attribute AttributeName="urn:wcc:dir:attribute-def:userRoles"
AttributeNamespace="urn:wcc:attributeNamespace:uri">
<saml:AttributeValue>
CallCentAppUser
</saml:AttributeValue>
<saml:AttributeValue>
CstSuppRepL2
</saml:AttributeValue>
</saml:Attribute>
</saml:AttributeStatement>
</saml:Assertion>
]]></authData>
</DWLControl>
</ResponseControl>
<TxResponse>
<RequestType>addContract</RequestType>
<TxResult>
<ResultCode>SUCCESS</ResultCode>
</TxResult>
<ResponseObject>
<TCRMContractBObj>
<BillingType>5</BillingType>
<BillingValue>Payroll Deduction</BillingValue>
<BrandName>ul</BrandName>
<BusOrgunitId>444</BusOrgunitId>
<ContractIdPK>938122728173367195</ContractIdPK>
<ContractLastUpdateDate>2008-11-21 10:35:33.671</ContractLastUpdateDate>
<ContractLastUpdateTxId>430122728173365655</ContractLastUpdateTxId>
<ContractLastUpdateUser>jdoe</ContractLastUpdateUser>
<CurrencyType>1</CurrencyType>
<CurrencyValue>U.S. Dollar</CurrencyValue>
<CurrentCashValueAmount>300.00</CurrentCashValueAmount>
<FrequencyModeType>1</FrequencyModeType>
<FrequencyModeValue>Annual</FrequencyModeValue>
<LineOfBusiness>life ins</LineOfBusiness>
<NextBillingDate>2009-01-01 23:59:59.0</NextBillingDate>
<PremiumAmount>200</PremiumAmount>
<ServiceOrgName>KLM</ServiceOrgName>
<ServiceProvId>1991</ServiceProvId>
<DWLStatus>
<Status>0</Status>
</DWLStatus>
</TCRMContractBObj>
</ResponseObject>
</TxResponse>
</TCRMService>

使用其他安全資料格式

如前所述,安全資料的格式可由用戶自行決定。用戶端以 CDATA 格式,在 authData 標籤中傳遞安全資料。請求與響應框架中的請求解析器會原樣保留 authData 並設定控制物件;接著,自訂的安全資料解析器從 authData 中解析出用戶 ID 與用戶角色;最後,框架中的建構器組裝響應,並按照請求進來時所用的格式,把 authData 回傳出去。

若要改用其他安全資料格式,步驟如下:

  • 建立一個實作 ISecurityDataParser 介面的解析器。
  • 以剛建立的類別名稱,設定配置儲存庫中的組態項 /DWLCommonServices/Security/SAML/security_data_parser。
  • 把新類別打包成 jar 檔,並讓 MDM Server 企業應用程式能取用這個 jar。
  • 在 DWLCommonServices EJB 專案的 MANIFEST.MF 檔案中,加入該 jar 檔名。
  • 重新啟動伺服器,以新的安全資料格式進行測試。

結語

InfoSphere MDM Server 的安全框架提供了一套靈活的機制,讓用戶端得以依自己的格式傳遞用戶身份信息。MDM Server 預設即支援 SAML 斷言,而當你有其他需求時,也能輕易換上自訂的安全資料格式。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved