| Oracle® Fusion Middleware Oracle WebLogic Serverセキュリティのプログラミング 11g リリース1(10.3.6) B61619-04 | 
 | 
|  前 |  次 | 
SAML (Security Assertion Markup Language)は、様々なエンティティの間でセキュリティ情報をやり取りするためのXMLベースのプロトコルです。SAML標準は、Web上のソフトウェア・エンティティの間でセキュリティ情報を交換するためのフレームワークを定義します。SAMLセキュリティは、アサーション側と依存側の対話に基づいています。
SAMLは、シングル・サインオン機能を提供します。1つの場所で認証されたユーザーは、あらためてログインしなくても、別の場所のサービス・プロバイダにアクセスできます。
WebLogic Serverは、SAMLバージョン2.0および1.1をサポートしています。WebLogic Server実装では、以下がサポートされます。
SAML 1.1のWeb SSOのHTTP POSTおよびHTTPアーティファクト・バインディング。SAML 2.0では、Web SSOプロファイルのHTTPリダイレクト・バインディングが追加されます。
SAML認証文とSAML属性文(SAML認可文はサポートされません)
WebLogic Server環境でのSAMLおよびSAMLアサーションの概要については、『Oracle WebLogic Serverのセキュリティの理解』のSecurity Assertion Markup Language (SAML)に関する項を参照してください。
SAML資格証明マッピング・プロバイダの構成の詳細は、『Oracle WebLogic Serverの保護』のSAML 1.1のためのSAML資格証明マッピング・プロバイダの構成に関する項およびSAML 2.0のためのSAML 2.0資格証明マッピング・プロバイダの構成に関する項を参照してください。
SAML仕様については、http://www.oasis-open.orgを参照してください。「Technical Overview of the OASIS Security Assertion Markup Language (SAML) V1.1」(http://www.oasis-open.org/committees/download.php/6628/sstc-saml-tech-overview-1.1-draft-05.pdf)および 「Security Assertion Markup Language (SAML) 2.0 Technical Overview」(http://www.oasis-open.org/committees/download.php/11511/sstc-saml-tech-overview-2.0-draft-03.pdf)も参照してください。
この節では、以下のトピックを取り上げます。
表9-1に、WebLogic SAML APIの一覧を示します。表9-2に、WebLogic SAML 2.0 APIの一覧を示します。詳細についてはJavadocを参照してください。
表9-1 WebLogic SAML API
| WebLogic SAML API | 説明 | 
|---|---|
| WebLogic SAMLパッケージ。 | |
| アーティファクト・プロファイルのアサーションを格納および取得するためのメソッドを定義するインタフェース。このインタフェースは非推奨であり、SAMLAssertionStoreV2が推奨されます。 | |
| SAMLAssertionStoreV2インタフェースはSAMLAssertionStoreインタフェースの拡張で、SAML ARSからのアサーションをリクエストする宛先サイトを特定および認証するためのメソッドが追加されています。 V2は、SAML仕様のバージョン2ではなく、WebLogic SAMLプロバイダの2番目のバージョンを表します。 | |
| サブジェクトからSAMLAssertionの属性へのマッピングを実行するためのインタフェース。 | |
| SAMLアサーションのフィールドにサブジェクト情報をマッピングするために使用するメソッドを定義するインタフェース。 | |
| SAML属性文から属性プリンシパルへのマッピングを実行するためのインタフェース。 | |
| SAMLアサーションの情報をユーザー名およびグループ名にマッピングするために使用するメソッドを定義するインタフェース。 | |
| POSTプロファイルの使用を1回に強制するため、アサーションIDをキャッシュするメソッドを定義するインタフェース。 このインタフェースを実装するクラスには、引数を取らないパブリック・コンストラクタが必要です。 | |
| このクラスのインスタンスは、ユーザーおよびグループの情報を名前マッパーとやり取りするために使用します。このクラスによって、いくつかの便利な定数も定義されます。 | |
| SAMLAssertionStoreV2.retrieveAssertionInfo()によって返されるAssertionInfoクラス。このクラスには、取得したアサーションと、その関連情報が格納されます。SAMLAssertionStoreV2インタフェースの実装はこのクラスを返す必要があります。 | |
| SAMLAssertion AttributeStatementの1つの属性を表すクラス。 | |
| SAMLAssertionのAttributeStatementを表すクラス。 | |
| SAMLアサーションのユーザー名とグループ情報を表すために使用します。 | |
| SAMLCommonPartner | SAML 1.1パートナに共通の属性の抽象表現。 | 
| SAMLRelyingParty | SAMLリライイング・パーティ・レジストリ内のSAMLリライイング・パーティ・エントリを表します。 | 
| SAMLAssertingParty | LDAPアサーティング・パーティ・レジストリ内のSAMLアサーティング・パーティ・エントリを表します。 | 
| SAMLPartner | SAMLパートナの抽象表現。 | 
| 注意:SAML名前マッパー・クラスは、システム・クラスパスに含めなければなりません。カスタムのSAMLIdentityAssertionNameMapper、SAMLCredentialNameMapper、SAMLAssertionStore、またはSAMLUsedAssertionCacheを作成した場合は、それぞれに対応するクラスをシステム・クラスパスに含める必要があります。 | 
表9-2 WebLogic SAML 2.0 API
| WebLogic SAML 2.0 API | 説明 | 
|---|---|
| WebLogicセキュリティ・レルムでSAML 2.0セキュリティ・プロバイダを構成、制御、およびモニターするためのインタフェースとクラスを提供します。 | |
| SAML 2.0 Assertion AttributeStatementの1つの属性を表すクラス。 | |
| SAML 2.0アサーションのAttributeStatementを表すクラス。 | |
| サブジェクトからSAML 2.0 Assertionの属性へのマッピングを実行するためのインタフェース。 | |
| ユーザーとグループの情報をSAML 2.0アサーションにマッピングするために使用するインタフェース。 | |
| SAML 2.0属性文から属性プリンシパルへのマッピングを実行するためのインタフェース。 | |
| SAML 2.0アサーションに格納されたユーザー情報をローカル・ユーザー名にマップするために使用するインタフェース。 | |
| SAML 2.0アサーションに格納されたユーザー名とグループ情報を表すために使用します。 | |
| SAML 2.0 IDプロバイダおよびサービス・プロバイダ・パートナとメタデータの抽象インタフェース。 | |
| バインディング・クライアント・パートナとは、バックエンド・チャネルの通信をサポートするパートナ。 | |
| SAML 2.0 IDプロバイダ・パートナの抽象表現。 | |
| SAML 2.0サービス・エンドポイントの抽象表現。 | |
| このクラスは、アーティファクト解決サービスのエンド・ポイントのように索引化可能なエンド・ポイントを表します。 | |
| メタデータ・パートナは、主にSAML 2.0メタデータ・プロファイルで必要なパートナの連絡先情報を格納します。 | |
| SAML 2.0パートナの抽象表現。このインタフェースはパートナの必須情報を定義します。 | |
| SAML 2.0サービス・プロバイダ・パートナの抽象表現。 | |
| Web SSOプロファイルのSAML 2.0 IDプロバイダ・パートナの抽象表現。 | |
| Web SSOプロファイルのSAML 2.0パートナの抽象表現。 | |
| Web SSOプロファイルのSAML 2.0サービス・プロバイダ・パートナの抽象表現。 | |
| WSS SAMLトークン・プロファイルのSAML 2.0 IDプロバイダ・パートナの抽象表現。 | |
| WSS SAMLトークン・プロファイルのSAML 2.0パートナの抽象表現。 | |
| WSS SAMLトークン・プロファイルのSAML 2.0サービス・プロバイダ・パートナの抽象表現。特定の属性やメソッドはありません。 | 
SAML POSTプロファイル処理のためにカスタムPOSTフォームを指定した場合、POSTフォームに渡されるパラメータ名は、どのSAMLプロバイダが構成されているかによって異なります。
V2プロバイダを構成すると有効になるWebLogic Server 9.1以降のフェデレーション・サービス実装の場合は、表9-3を参照してください。
V1プロバイダを構成すると有効になるWebLogic Server 9.0 SAMLのサービス実装の場合は、表9-4を参照してください。
これらの表には、返されたJavaオブジェクトをキャストするために必要なパラメータ名とそのデータ型を示します。
どちらの実装でも、SAMLレスポンス自体は、SAMLで指定されたパラメータ名を使用して渡されます。
SAMLレスポンス(文字列)は、base64でエンコードされたSAMLレスポンス要素です。
表9-3 SAML V2プロバイダのカスタムPOSTフォーム・パラメータ
| パラメータ | 説明 | 
|---|---|
| TARGET(文字列) | 受信したサイト間転送サービス(ITS)リクエストで、問合せパラメータとして指定されるTARGET URL。 | 
| SAML_AssertionConsumerURL(文字列) | 宛先サイト(フォームをPOSTする必要のあるサイト)のアサーション・コンシューマ・サービス(ACS)のURL。 | 
| SAML_AssertionConsumerParams(マップ) | このマップには、リライイング・パーティ用に構成されたアサーション・コンシューマ・パラメータの名前と値のマッピングが含まれます。名前と値は文字列です。 | 
| SAML_ITSRequestParams(マップ) | このマップには、ITSリクエストで受信した問合せパラメータの名前と値のマッピングが含まれます。名前と値は文字列です。マップが空の場合もあります。TARGETパラメータおよびRPID (Rich Presence Information Data)形式のパラメータは、マップがフォームに渡される前にマップから削除されます。 | 
ソース・サイトを構成するためにSAML 1.1資格証明マッピング・プロバイダ・バージョン2を使用しても、非WebLogic Serverプラットフォームに実装されているサードパーティのSAMLリライイング・パーティを構成する場合、WebLogic Serverによって生成されるSAMLアサーションは、構成済のサードパーティのSAMLリライイング・パーティによって要求されるすべての属性をサポートするわけではありません。この場合、アサーションの期待される特定の属性が使用できないため、リライイング・パーティはアサーティング・パーティと共に機能しない可能性があります。
SAMLCredentialAttributeMapper (WebLogic Serverによって提供される)を実装することによって、サードパーティのSAMLリライイング・パーティに要求される特定のSAML 1.1アサーション属性に対してサブジェクトをマッピングする、カスタムSAML名マッパーを作成できます。SAMLCredentialAttributeMapperの詳細は、『Oracle WebLogic Server APIリファレンス』を参照してください。
次の項では、カスタムSAML名マッパーを作成する方法を説明します。
SAMLCredentialAttributeMapperインタフェースのカスタム実装を作成するには、次の手順を実行する必要があります。
次に示すクラスを使用し、アサーションの属性データを記述します。
また、SAMLCredentialNameMapperインタフェースを実装します。SAMLCredentialAttributeMapperおよびSAMLCredentialNameMapperインタフェースは、同一の実装内に存在する必要があります。
SAMLCredentialNameMapperインタフェースも実装すると、後でWebLogic Server管理コンソールを使用して、NameMapperClassName属性をこのSAMLCredentialAttributeMapperインスタンスのクラス名に設定できます。
SAML資格証明マッピング・プロバイダ・バージョン2のユーザー名マッパー・クラス名属性を使用し、アクティブ・セキュリティ・レルムでカスタムSAML名マッパーを構成します。
SAML資格証明マッピング・プロバイダ・バージョン2に構成する名前マッパー・クラス名は、「コンソールでカスタムSAMLCredentialAttributeMapperクラスを使用可能にする」で説明されているように、該当プロバイダのデフォルトとして使用されます。ただし、SAML資格証明マッピング・プロバイダ・バージョン2に構成されたリライイング・パーティのすべてまたはいずれかに特有の名前マッパー・クラス名を任意で設定できます。この方法で名前マッパー・クラス名を設定すると、デフォルト値はオーバーライドされます。構成済のSAMLリライイング・パーティに異なる属性が必要な場合、複数のSAMLCredentialAttributeMapper実装を作成できます。
この項では、カスタムSAML名マッパー実装の作成時に使用する必要がある新しいクラス、インタフェース、およびメソッドを説明します。コードの例は、例として使用するカスタムSAMLCredentialAttributeMapperクラスを参照してください。
例9-1は、SAMLAttributeStatementInfoクラスのメソッドおよび引数を示します。埋込みコメントによって追加情報およびコンテキストが提供されます。
例9-1 SAMLAttributeStatementInfoクラスのリスト
/**
 * A class that represents the attributes of an AttributeStatement
 * in a SAML Assertion
 */
class SAMLAttributeStatementInfo {
/**
 * Constructs a SAMLAttributeStatementInfo with
 * no attributes. The SAMLAttributeStatementInfo
 * represents a empty SAMLAttributeStatement. It is
 * expected that SAMLAttributeInfo elements will be
 * added to this instance.
 *
Public SAMLAttributeStatementInfo();
/**
 * Constructs a SAMLAttributeStatementInfo containing multiple
 * SAMLAttributeInfo elements. The SAMLAttributeStatementInfo
 * represents a SAML AttributeStatement with multiple Attributes.
 *
 *
 * @param data SAMLAttributeInfo
 */
    public SAMLAttributeStatementInfo(Collection data);
/**
 * returns a Collection of SAMLAttributeInfo elements. The
 * collection represents the Attributes contained by
 * a single AttributeStatement of a SAML Assertion
 *
 * The returned Collection is immutable and may be empty.
 *
 * @return Collection
 */
    public Collection getAttributeInfo();
/**
 * adds a Collection of SAMLAttributeInfo instances to
 * this SAMLAttributeStatementInfo instance, to the
 * end of the existing list, in the order that the
 * param Collection iterates through the Collection.
 *
 * See SAMLAttributeInfo(String, String, Collection)
 * for information on parameter handling.
 *
 * @param data
 *
 */
    public void setAttributeInfo(Collection data);
/**
 * Adds a single SAMLAttributeInfo instance to this
 * SAMLAttributeStatementInfo instance, at the end of
 * the existing list.
 *
 * See SAMLAttributeInfo(String, String, Collection)
 * for information on parameter handling.
 *
 * @param info
 */
    public void addAttributeInfo(SAMLAttributeInfo info);
例9-2は、SAMLAttributeInfoクラスのメソッドおよび引数を示します。埋込みコメントによって追加情報およびコンテキストが提供されます。
例9-2 SAMLAttributeInfoクラスのリスト
/**
 * A class that represents a single Attribute of a SAML Assertion
 * AttributeStatement.
 */
class SAMLAttributeInfo {
/**
 * Constructs a SAMLAttributeInfo instance with all null fields
 */
   public SAMLAttributeInfo();
/**
 * Constructs a SAMLAttributeInfo instance representing the SAML 1.1
 * Attribute fields
 *
 * null elements of the Collection are ignored.
 * Elements with null 'name' or 'namespace' fields
 * are ignored; the resulting SAMLAttributeInfo will not
 * be included in a created SAMLAssertion. Null
 * attribute values are added as the empty string (ie, “”).
 * @param name String
 * @param namespace String
 * @param values Collection of String values
 */
    public SAMLAttributeInfo(String name, String namespace, Collection values;
/**
 * Constructs a SAMLAttributeInfo instance representing the attribute fields
 * See SAMLAttributeInfo(String, String, Collection) for
 * information on parameter handling.
 *
 * @param name String
 * @param namespace String
 * @param value String
 */
    public SAMLAttributeInfo(String name, String namespace, String value);
/**
 * sets the name and namespace of this attribute
 * See SAMLAttributeInfo(String, String, Collection) for
 * information on parameter handling.
 *
 * @param name String, cannot be null
 * @param namespace String, cannot be null
 */
    public void setAttributeName(String name, String namespace);
/**
 * returns the name of this attribute.
 * @return String
 */
    public String getAttributeName();
/**
 * returns a String representing this attribute's namespace
 * @return String
 */
    public String getAttributeNamespace();
/**
 * sets a Collection of Strings representing this attribute's values
 * an empty collection adds no values to this instance, collection elements
 * that are null are added as empty strings.
 *
 * @param values Collection
 */
    public void setAttributeValues(Collection values);
/**
 * adds a single String value to the end
 * of this instance's Collection of elements
 * See SAMLAttributeInfo(String, String, Collection) for
 * information on parameter handling.
 *
 * @param value String
 */
    public void addAttributeValue(String value);
/**
 * returns a Collection of Strings representing this
 * attribute's values, in the order they were added.
 * If this attribute has no values, the returned
 * value is null.
 *
 * @return Collection
 */
    public Collection getAttributeValues();
}
SAML資格証明マッピング・プロバイダ・バージョン2は、カスタムSAML名マッパーが属性マッピング・インタフェースの実装であるかどうかを判断します。属性マッピング・インタフェースの実装の場合、属性マッピング・インタフェースのメソッドを呼び出し、生成されたSAMLアサーションに書き込むSAML属性の名前/値のペアを取得します。実装で属性マッピング・インタフェースをサポートしない場合、属性マッピングはそのまま省略されます。
SAML資格証明マッピング・プロバイダ・バージョン2は、カスタム属性マッパーから取得された属性名または属性値を検証しません。属性名および属性値は次のとおりに処理されます。
NULL以外の属性名とネームスペースを持つ任意の属性がSAMLアサーションに書き込まれます。
NULL属性名またはネームスペースを持つ属性は無視され、後続の同一Collection属性は通常とおりに処理されます。
NULL値を持つ任意の属性が、""の値と共にSAMLAttributeInfoインスタンスに書き込まれます。結果のSAMLアサーションは、文字列<AttributeValue></AttributeValue>として書き込まれます。
例9-3 SAMLCredentialAttributeMapperインタフェースのリスト
/**
 * Interface used to perform mapping of Subject to SAMLAssertions
 * attributes.
 * <p>
 * To specify an instance of this interface to be used by the SAML
 * Credential Mapper, set the <tt>NameMapperClassName</tt> attribute.
 * <p>
 * Classes implementing this interface must have a public no-arg
 * constructor and must be in the system classpath.
 *
 * @author Copyright (c) 2008 by BEA Systems, Inc. All Rights Reserved.
 */
public interface SAMLCredentialAttributeMapper
{
/**
 * Maps a <code>Subject</code> to a set of values used to construct a
 * <code>SAMLAttributeStatementInfo</code> element for a SAML assertion.
 * The returned <code>Collection</code> contains
 * SAMLAttributeStatementInfo elements, each element
 * of which will be used to
 * construct a SAML <code>AttributeStatement</code> element for the SAML
 * assertion.
 *
 * @param subject The <code>Subject</code> that should be mapped.
 * @param handler The <code>ContextHandler</code> passed to the SAML
 * Credential Mapper.
 *
 * @return A <code>Collection</code> of SAMLAttributeStatementInfo
 * instances,or <code>null</code> if no mapping is made.
 */
    public Collection mapAttributes(Subject subject, ContextHandler handler);
SAMLCredentialNameMapperは、SAMLNameMapperInfoクラスで新規メソッドを呼び出し、認証方式属性を取得してSAMLアサーションに書き込まれるように設定します。
新規メソッドは例9-4で示されています。埋込みコメントによって追加情報およびコンテキストが提供されます。
例9-4 SAMLNameMapperInfoクラスのリスト
public class SAMLNameMapperInfo
{
[ existing definition ]
/**
 * Called by the SAML Credential Name Mapper implementation to set
 * the authentication method attribute to be written to the SAML Assertion.
 * See SAML 1.1 Assertions and Protocols, Section 7.1 for possible
 * values returned.
 *
 * @param value the Authentication Method
 */
    public void setAuthenticationMethod(String value);
/**
 * Called by the SAML Credential Mapper to retrive the authentication
 * method attribute to be written to the SAML Assertion. See SAML 1.1
 * Assertions and Protocols, Section 7.1 for possible values returned.
 *
 * @return the Authentication Method
 */
    public String getAuthenticationMethod();
例9-5は、SAMLCredentialNameMapperおよびSAMLCredentialAttributeMapperインタフェースの実装例を示します。
SAMLCredentialNameMapperの実装例が、サブジェクトに保存されたユーザー情報とグループ情報をマッピングする一方で、SAMLCredentialAttributeMapperの実装例はContextHandlerに保存された属性情報をマッピングします。
この例では、属性がContextHandlerに配置される仕組みは示されていません。
SAMLCredentialAttributeMapperを実装し、ContextHandlerではなくサブジェクトに保存された情報をマッピングできます。
埋込みコメントによって追加情報およびコンテキストが提供されます。
例9-5 例として使用するカスタムSAMLCredentialAttributeMapperクラスのリスト
import java.util.ArrayList;
import java.util.Collection;
import java.util.Set;
import javax.security.auth.Subject;
import weblogic.security.providers.saml.SAMLAttributeStatementInfo;
import weblogic.security.providers.saml.SAMLAttributeInfo;
import weblogic.security.providers.saml.SAMLCredentialNameMapper;
import weblogic.security.providers.saml.SAMLCredentialAttributeMapper;
import weblogic.security.providers.saml.SAMLNameMapperInfo;
import weblogic.security.service.ContextHandler;
import weblogic.security.service.ContextElement;
import weblogic.security.spi.WLSGroup;
import weblogic.security.spi.WLSUser;
/**
 * @exclude
 *
 * The <code>CustomSAMLAttributeMapperImpl</code> class implements
 * name and attribute mapping for the SAML Credential Mapper.
 *
  * @author Copyright (c) 2004 by BEA Systems, Inc. All Rights Reserved.
  */
public class CustomSAMLAttributeMapperImpl implements
SAMLCredentialNameMapper,SAMLCredentialAttributeMapper
{
/**
 * Your logging code here
 */
        private final static String defaultAuthMethod =
     "urn:oasis:names:tc:SAML:1.0:am:unspecified";
        private final static String SAML_CONTEXT_ATTRIBUTE_NAME =
     "com.bea.contextelement.saml.context.attribute.name";
        private String nameQualifier = null;
        private String authMethod = defaultAuthMethod;
        public CustomSAMLAttributeMapperImpl()
        {
               // make constructor public
        }
/**
 * Set the name qualifier value
 */
        public synchronized void setNameQualifier(String nameQualifier) {
             this.nameQualifier = nameQualifier;
        }
/**
 * Map a <code>Subject</code> and return mapped user and group
 * info as a <code>SAMLNameMapperInfo</code> object.
 */
         public SAMLNameMapperInfo mapSubject(Subject subject, ContextHandler handler) {
               // Provider checks for null Subject...
               Set subjects = subject.getPrincipals(WLSUser.class);
               Set groups = subject.getPrincipals(WLSGroup.class);
               String userName = null;
               if (subjects == null || subjects.size() == 0) {
                   yourlogcode("mapSubject: No valid WLSUser principals
                   found in Subject, returning null");
                   return null;
               }
               if (groups == null || groups.size() == 0) {
                   yourlogcode("mapSubject: No valid WLSGroup pricipals
                   found in Subject, continuing");
               }
               if (subjects.size() != 1) {
                   yourlogcode("mapSubject: More than one WLSUser
                   principal found in Subject, taking first user only");
               }
               userName = ((WLSUser)subjects.iterator().next()).getName();
               if (userName == null || userName.equals("")) {
                   yourlogcode("mapSubject: Username string is null or
                   empty, returning null");
                   return null;
               }
               // Return mapping information...
                  yourlogcode("mapSubject: Mapped subject: qualifier: " +
                  nameQualifier + ", name: " + userName + ", groups: " + groups);
                  return new SAMLNameMapperInfo(nameQualifier, userName,
                  groups);
         }
/**
 * Map a <code>String</code> subject name and return mapped user and group
 * info as a <code>SAMLNameMapperInfo</code> object.
 */
         public SAMLNameMapperInfo mapName(String name, ContextHandler handler) {
                yourlogcode("mapName: Mapped name: qualifier: " +
                nameQualifier + ", name: " + name);
                return new SAMLNameMapperInfo(nameQualifier, name, null);
         }
/**
 * Returns the SAML AttributeName for group information.
 *
 * @return The AttributeName.
 */
         public String getGroupAttrName() {
                return SAMLNameMapperInfo.BEA_GROUP_ATTR_NAME;
         }
/**
 * Returns the SAML AttributeNamespace for group information.
 *
 * @return The AttributeNamespace.
 */
         public String getGroupAttrNamespace() {
                return SAMLNameMapperInfo.BEA_GROUP_ATTR_NAMESPACE;
         }
/**
 * set the auth method.
 * @param method String
 */
         public void setAuthenticationMethod(String method)
         {
                if (method != null)
                  authMethod = method;
         }
/**
 * get the auth method
 * @return method String
 */
         public String getAuthenticationMethod()
         {
                return authMethod;
         }
/**
 * maps a Subject/Context to a Collection of SAMLAttributeStatementInfo
 * instances.
 *
 * @return <code>Collection</code>
 */
         public Collection mapAttributes(Subject subject, ContextHandler handler)
         {
                yourlogcode("mapAttributes: Subject: "+subject.toString()+",
                   ContextHandler: "+handler.toString());
                Object element = handler.getValue(SAML_CONTEXT_ATTRIBUTE_NAME);
                yourlogcode("mapAttributes: got element from ContextHandler");
                yourlogcode("mapAttributes: element is a:"+element.getClass().getName());
                TestAttribute[] tas = (TestAttribute[])element;
/*
 * loop through all test attributes and write a SAMLAttributeStatementInfo
 * for each one.
 */
           ArrayList statementList = new ArrayList();
           for (int k = 0; k < tas.length; k++)
            {
             ArrayList al = null;
             String[] values = tas[k].getValues();
             if (values != null)
             {
               al = new ArrayList();
               for (int i = 0; i < values.length; i++)
               if (values[i] != null)
                  al.add(values[i]);
               else al.add("");
             }
               SAMLAttributeInfo ai = new SAMLAttributeInfo(tas[k].getName(),
                tas[k].getNamespace(), al);
               SAMLAttributeStatementInfo asi = new
                 SAMLAttributeStatementInfo();
               asi.addAttributeInfo(ai);
               statementList.add(asi);
            }
            return statementList;
         }
}
SAML資格証明マッピング・プロバイダ・バージョン2がこのSAMLCredentialAttributeMapperインスタンスを使用するようにするには、WebLogic Server管理コンソールを使用して既存のNameMapperClassName属性をこのSAMLCredentialAttributeMapperインスタンスのクラス名に設定します。
つまり、名前マッパー・クラス名属性のコンソール制御を使用して、アクティブ・セキュリティ・レルムでSAMLCredentialAttributeMapperのクラス名を指定します。
次のいずれかの方法を使用してユーザー名マッパー・クラス名属性を構成できます。
SAMLプロバイダ・バージョン2の場合は1回のみ実行
1つ以上のリライイング・パーティの場合は個別に実行
SAML資格証明マッピング・プロバイダ・バージョン2の場合は両方を実行し、リライイング・パーティに対しては個別に実行します。
WebLogic SAML資格証明マッピング・プロバイダ・バージョン2を使用してカスタム・ユーザー名マッパーを使用するには、次の手順を実行します。
まだ行っていない場合、管理コンソールのチェンジ・センターで「ロックして編集」をクリックします。
「セキュリティ・レルム」ページで、構成しているレルム名を選択します(たとえばTestRealm)。
「プロバイダ」>「資格証明マッピング」を展開し、SAML資格証明マッピング・プロバイダ・バージョン2の名前を選択します。
「プロバイダ固有」タブを選択します。
「デフォルト名前マッパーのクラス名」フィールドで、SAMLCredentialAttributeMapper実装のクラス名を入力します。
クラス名はシステムのクラスパスに存在する必要があります。
「保存」をクリックします。
チェンジ・センターで「変更のアクティブ化」をクリックしてこれらの変更をアクティブ化します。
SAMLリライイング・パーティを構成するとき、そのリライイング・パーティに固有の名前マッパー・クラスを任意で設定できます。このクラスは、デフォルトの名前マッパー・クラス名に対してここで設定したデフォルト値をオーバーライドします。
管理コンソールで名前マッパー・クラス名を設定する方法の詳細は、『Oracle WebLogic Server管理コンソールのヘルプ』のカスタム・ユーザー名マッパーの構成に関する項を参照してください。
この項では、SAML SSO属性サポートおよび、それをSAML 2.0およびSAML 1.1と共に使用する方法を説明します。次のトピックが説明されています。
SAMLアサーションとは、サブジェクト上で実行された認可操作、サブジェクトの属性情報、または特定のリソースについてサブジェクトに適用している認可データのいずれかに関して、SAML認証局によって作成されたデータです。
SAML仕様(http://www.oasis-open.orgを参照してください)によって、特定のサブジェクトに関する不特定の追加情報を、アサーション内の属性文としてSAMLパートナ間で交換することが可能になります。そのため、SAML属性アサーションとは、サブジェクトの属性に関してサイトが決定した情報を伝達する特定のタイプのSAMLアサーションということになります。
以前のバージョンのWebLogic Serverでは、SAML 1.1資格証明マッピング・プロバイダは、アサーションに含まれるIDの所属先グループを指定するサブジェクト内に保存された属性情報をサポートしていました。
このリリースのWebLogic Serverでは、追加属性(グループ情報以外)を取得してSAMLアサーションに書き込んだり、着信SAMLアサーションからの属性のマップを可能にするカスタム属性マッパーの使用をサポートするために、SAML 1.1および2.0の資格証明マッピング・プロバイダとアイデンティティ・アサーション・プロバイダのメカニズムが強化されています。
これを実行するには:
(SAML IDプロバイダ・サイト上の)SAML資格証明マッパーは、このカスタム属性マッパーの存在に基づいて属性をパッケージする方法を決定します。
(SAML サービス・プロバイダ・サイト上の)SAML IDアサーション・プロバイダは、このカスタム名前マッパーの構成に基づいて属性を取得する方法を決定します。
Javaサブジェクトは、アサーションから取得された属性をアプリケーションで使用できるようにするために使用されます。これには、SAML認証プロバイダが構成され、仮想ユーザーがSAMLパートナ上で有効化されている必要があります。
このリリースには、SAML 2.0用の次に示す新規SAML属性のAPIが含まれます。
SAML 1.1の場合、次の既存SAML属性のAPIをかわりに使用できます。
次の項では、これらのSAML属性のAPIの使用について説明します。
SAML 1.1では、SAML属性の名前フォーマットを規定していません。
ただし、SAML 2.0基本属性プロファイルのみはSAML 2.0でサポートされています。SAML2AttributeInfoでurn:oasis:names:tc:SAML:2.0:attrname-format:basic名前フォーマットを持つ属性のみが、SAML 2.0アサーションに書き込まれます。
urn:oasis:names:tc:SAML:2.0:attrname-format:basic名前フォーマットはデフォルトなので、設定する必要はありません。
名前フォーマットをどうしても設定する場合、次に示すようにSAML2.AttributeInfo.setAttributeNameFormatメソッドでurn:oasis:names:tc:SAML:2.0:attrname-format:basicを指定する必要があります。
SAML2AttributeInfo attrInfo = new SAML2AttributeInfo(
"AttributeWithSingleValue", "ValueOfAttributeWithSingleValue");
attrInfo.setAttributeNameFormat("urn:oasis:names:tc:SAML:2.0:attrname-format:basic");
attrs.add(attrInfo);
構成された属性マッパーが呼び出されると、Collection<SAML2AttributeStatementInfo>が返されます。複数の属性文を指定できます。それぞれの属性文には複数の属性が含まれ、それぞれの属性には複数の属性値が含まれる可能性があります。
この実行例は次のとおりです。
private Collection<SAML2AttributeStatementInfo> getAttributeStatementInfo(
Subject subject, ContextHandler handlers) {
Collection<SAML2AttributeInfo> attrs = new ArrayList<SAML2AttributeInfo>();
 
SAML2AttributeInfo attrInfo = new SAML2AttributeInfo(
"AttributeWithSingleValue", "ValueOfAttributeWithSingleValue");
attrInfo.setAttributeNameFormat("urn:oasis:names:tc:SAML:2.0:attrname-format:basic");
attrs.add(attrInfo);
 
ArrayList<String> v = new ArrayList<String>();
v.add("Value1OfAttributeWithMultipleValue");
v.add("Value2OfAttributeWithMultipleValue");
v.add("Value3OfAttributeWithMultipleValue");
SAML2AttributeInfo attrInfo1 = new SAML2AttributeInfo(
"AttributeWithMultipleValue", v);
attrInfo1.setAttributeNameFormat("urn:oasis:names:tc:SAML:2.0:attrname-format:basic");
 
attrs.add(attrInfo1);
 
SAML2AttributeInfo attrInfo2 = new SAML2AttributeInfo(
"AttributeWithInvalidNameFormat",
"ValueOfAttributeWithInvalidNameFormatValue");
attrInfo2.setAttributeNameFormat("urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified");
attrs.add(attrInfo2);
 
SAML2AttributeInfo attrInfo3 = new SAML2AttributeInfo(
"AttributeWithNullValue", "null");
attrInfo3.setAttributeNameFormat("urn:oasis:names:tc:SAML:2.0:attrname-format:basic");
attrs.add(attrInfo3);
:
:
Collection<SAML2AttributeStatementInfo> attrStatements = new ArrayList<SAML2AttributeStatementInfo>();
attrStatements.add(new SAML2AttributeStatementInfo(attrs));
attrStatements.add(new SAML2AttributeStatementInfo(attrs1));
return attrStatements;
}
この項では、SAML属性を実装するためにたどるプロセスを段階を踏んで説明します。
| 注意:この項では、使用する例にSAML 2.0インタフェース名を使用します。SAML 1.1の使用法は、マッパー関連クラスとパートナ関連クラスのインタフェース名およびマッパーの構成に使用される属性名とメソッド名が異なる点以外は酷似しています。 | 
SAML資格証明マッピング(IDプロバイダ)サイトから、
SAML2AttributeInfoおよびSAML2AttributeStatementInfoクラスをインスタンス化します。
SAML2CredentialAttributeMapperインタフェースを実装します。
また、同一の実装でSAML2CredentialNameMapperインタフェースを実装します。(SAML2CredentialAttributeMapperおよびSAML2CredentialNameMapperインタフェースは、両方とも同一の実装内に存在する必要があります。)
SAML2CredentialNameMapperインタフェースを実装すると、WebLogic Server管理コンソールを使用して、NameMapperClassName属性をSAML2CredentialAttributeMapperインスタンスのクラス名に設定できます。
WebLogic Server管理コンソールを使用すると、新しいカスタム属性マッパーを識別するためにSAML資格証明マッピング・プロバイダのNameMapperClassName属性を使用して、SAMLプロバイダ上または各パートナ上で新しいカスタム属性マッパーを構成できます。「コンソールでカスタムSAML資格証明属性マッパーのクラスを使用可能にする」を参照してください。
SAML資格証明マッピング・プロバイダは、構成済のカスタム名マッパーが属性マッピング・インタフェースの実装であるかどうかを判定します。実装である場合、このプロバイダはカスタム属性マッピング・インタフェースを呼び出し、生成されたSAMLアサーションに書き込むための属性値を取得します。
SAML資格証明マッピング・プロバイダは、カスタム属性マッパーから取得された属性名または属性値を検証しません。
NULL以外の属性名を持つ任意の属性がSAMLアサーションの属性文に書き込まれます。NULLまたは空の属性名を持つ属性は無視され、次の属性が処理されます。
属性に複数の値が含まれる場合、各値はSAML属性文で単一の<Attribute>の<AttributeValue>要素として表示されます。
SAML 1.1の場合、NULL値を持つ属性は空の文字列("")としてSAMLアサーションに書き込まれます。
SAML 2.0の場合、NULLまたは空の属性値はアサーションおよび『OASIS SAML V2.0用プロトコル2005年3月』 (http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf)に基づいて処理されます。
urn:oasis:names:tc:SAML:2.0:attrname-format:basic以外の名前フォーマットを持つ属性はスキップされます。
SAML IDアサーション(サービス・プロバイダ)サイトから:
同一の実装でSAML2IdentityAsserterAttributeMapperおよびSAML2IdentityAsserterNameMapperインタフェースを実装します。(SAML2IdentityAsserterAttributeMapperおよびSAML2IdentityAsserterNameMapperインタフェースは、両方とも同一の実装内に存在する必要があります)
SAML2IdentityAsserterNameMapperインタフェースを実装すると、WebLogic Server管理コンソールを使用して、NameMapperClassName属性をSAML2IdentityAsserterAttributeMapperインスタンスのクラス名に設定できます。
WebLogic Server管理コンソールを使用して、「コンソールでカスタムSAML IDアサーション・プロバイダ・クラスを使用可能にする」で説明されているように、SAML IDアサーション・プロバイダを構成します。NameMapperClassName属性をカスタムSAML2IdentityAsserterAttributeMapperインスタンスのクラス名に設定します。
SAML IDアサーション・プロバイダは、受信側のSAMLアサーションの<AttributeStatement>要素を処理し、SAML属性文のコレクションを構築します。
SAML IDアサーション・プロバイダは、構成済カスタム名マッパーがSAML2IdentityAsserterAttributeMapperインタフェースを実装するかどうかを決定します。実装しない場合、SAML IDアサーション・プロバイダはmapAttributeInfoメソッドを呼び出し、SAMLアサーションの属性を取得します。
mapAttributeInfoメソッドは、SAMLアサーションで属性文の属性を示すSAMLAttributeStatementInfoインスタンスのCollectionを取得し、任意のアプリケーションに固有の方法で対象の属性にマッピングします。
SAML IDアサーション・プロバイダは、SAMLアサーションから取得した属性をJavaサブジェクトを介してコンシューマで使用できるようにします。これには、SAML認証プロバイダが構成され、仮想ユーザーがSAMLパートナ上で有効化されている必要があります。
マッパーから返された属性は、マッピングされた属性のクラス・タイプに応じて、サブジェクト・プリンシパルまたはプライベートな資格証明として保存されます。具体的には、マッパーがPrincipalオブジェクトのコレクションを返す場合、マッピングされた属性はサブジェクト・プリンシパル設定に保存されます。それ以外の場合、サブジェクトのプライベートな資格証明の設定は、マッピングされた属性を伝達するために使用されます。
消費コードは、例9-7で示されるように、マッパーがサブジェクトに追加される属性を表すのに使用するオブジェクトのクラス・タイプの情報を取得する必要があります。
SAML IDアサーション・プロバイダは、ContextHandlerおよび属性マッパーを確認します。(この段階説明では、手順4で説明されているように属性マッパーがあることを想定しています)。
| 注意: ContextHandlerと属性マッパーの両方が存在して構成されている場合、『Oracle WebLogic ServerのWebLogic Webサービスの保護』で説明されているように、かわりに属性はContextHandlerを介してWebサービスに対して使用できるようになります。 | 
この項では、追加属性をSAMLアサーションに書き込めるようにするSAML 2.0属性インタフェースの実装例を説明します。
例9-6は、SAML2CredentialNameMapperインタフェースおよびSAML2CredentialAttributeMapperインタフェースの両方を実装する単一のクラス例を示します。
例9-6 SAML 2.0資格証明属性マッパー
public class CustomSAML2CredentialAttributeMapperImpl implements
SAML2CredentialNameMapper, SAML2CredentialAttributeMapper {
private String nameQualifier = null;
 
public Collection<SAML2AttributeStatementInfo> mapAttributes(
Subject subject, ContextHandler handler) {
return getAttributeStatementInfo(subject, handler);
}
       /**
         * same as SAML2NameMapperImpl
         */
        public SAML2NameMapperInfo mapName(String name, ContextHandler handler) {
                System.out
                               .println("CustomSAML2CredentialAttributeMapperImpl:mapName: Mapped name: qualifier: "
                                        + nameQualifier + ", name: " + name);
                return new SAML2NameMapperInfo(nameQualifier, name, null);
        }
 
        /**
         * same as SAML2NameMapperImpl
         */
        public synchronized void setNameQualifier(String nameQualifier) {
                this.nameQualifier = nameQualifier;
        }
 
        /**
         * same as SAML2NameMapperImpl
         */
         public SAML2NameMapperInfo mapSubject(Subject subject,
                        ContextHandler handler) {
 
                // Provider checks for null Subject...
                Set subjects = subject.getPrincipals(WLSUser.class);
                Set groups = subject.getPrincipals(WLSGroup.class);
                String userName = null;
                Set<String> groupStrings = new java.util.HashSet();
 
                if (subjects == null || subjects.size() == 0) {
                        System.out
                                        .println("CustomSAML2CredentialAttributeMapperImpl:mapSubject: No valid WLSUser pricipals found in Subject, returning null");
                        return null;
                }
 
                if (groups == null || groups.size() == 0) {
                        System.out
                                        .println("CustomSAML2CredentialAttributeMapperImpl:mapSubject: No valid WLSGroup pricipals found in Subject, continuing");
                }
                 else{
                 java.util.Iterator<WLSGroup> it = groups.iterator();
                 while(it.hasNext()){
                 WLSGroup wg = it.next();
                 groupStrings.add(wg.getName());
                 }
                 }
                if (subjects.size() != 1) {
                        System.out
                                        .println("CustomSAML2CredentialAttributeMapperImpl:mapSubject: More than one WLSUser principal found in Subject, taking first user only");
                }
 
                userName = ((WLSUser) subjects.iterator().next()).getName();
                if (userName == null || userName.equals("")) {
                        System.out
                                        .println("CustomSAML2CredentialAttributeMapperImpl:mapSubject: Username string is null or empty, returning null");
                        return null;
                }
 
                // Return mapping information...
                System.out
                                TRACE.info("CustomSAML2CredentialAttributeMapperImpl:mapSubject: Mapped subject: qualifier: "
                                                + nameQualifier
                                                + ", name: "
                                                + userName
                                                + ", groups: "
                                                + groups);
  SAML2NameMapperInfo saml2NameMapperInfo = new
  SAML2NameMapperInfo(nameQualifier, userName, groupStrings);
   //SAML2NameMapperInfo saml2NameMapperInfo = new
  SAML2NameMapperInfo(nameQualifier, userName, groups);
                return new SAML2NameMapperInfo(nameQualifier, userName, groups);
        }
private Collection<SAML2AttributeStatementInfo> getAttributeStatementInfo(
Subject subject, ContextHandler handlers) {
Collection<SAML2AttributeInfo> attrs = new ArrayList<SAML2AttributeInfo>();
 
SAML2AttributeInfo attrInfo = new SAML2AttributeInfo(
"AttributeWithSingleValue", "ValueOfAttributeWithSingleValue");
attrInfo.setAttributeNameFormat("urn:oasis:names:tc:SAML:2.0:attrname-format:basic");
attrs.add(attrInfo);
 
ArrayList<String> v = new ArrayList<String>();
v.add("Value1OfAttributeWithMultipleValue");
v.add("Value2OfAttributeWithMultipleValue");
v.add("Value3OfAttributeWithMultipleValue");
SAML2AttributeInfo attrInfo1 = new SAML2AttributeInfo(
"AttributeWithMultipleValue", v);
attrInfo.setAttributeNameFormat("urn:oasis:names:tc:SAML:2.0:attrname-format:basic");
 
attrs.add(attrInfo1);
: 
:
Collection<SAML2AttributeStatementInfo> attrStatements = new ArrayList<SAML2AttributeStatementInfo>();
attrStatements.add(new SAML2AttributeStatementInfo(attrs));
attrStatements.add(new SAML2AttributeStatementInfo(attrs1));
return attrStatements;
}
}
「コンソールでカスタムSAML資格証明属性マッパーのクラスを使用可能にする」で説明されているように、WebLogic Server管理コンソールを使用して、マッパー実装の完全修飾クラス名にユーザー名マッパー・クラス名を構成します。
カスタム・マッパー実装によって返されたSAML2AttributeStatementInfoオブジェクトのコレクションでカプセル化された属性は、SAML 2.0資格証明マッピング・プロバイダによって生成されたアサーションに含まれます。
例9-7は、SAML2IdentityAsserterNameMapperおよびSAML2IdentityAsserterAttributeMapperの実装例を示します。
例9-7 カスタムSAML 2.0 IDアサーション・プロバイダ属性マッパー
public class CustomSAML2IdentityAsserterAttributeMapperImpl implements
SAML2IdentityAsserterNameMapper, SAML2IdentityAsserterAttributeMapper {
/**
 * same as SAML2NameMapperImpl
 */
public String mapNameInfo(SAML2NameMapperInfo info, ContextHandler handler) {
// Get the user name ...
String userName = info.getName();
System.out
.println("CustomSAML2IdentityAsserterAttributeMapperImpl:mapNameInfo: returning name: "
+ userName);
return userName;
}
}
:
:
public Collection<Object> mapAttributeInfo0(
Collection<SAML2AttributeStatementInfo> attrStmtInfos,
ContextHandler contextHandler) {
if (attrStmtInfos == null || attrStmtInfos.size() == 0) {
System.out
.println("CustomIAAttributeMapperImpl: attrStmtInfos has no elements");
return null;
}
 
Collection<Object> customAttrs = new ArrayList<Object>();
 
for (SAML2AttributeStatementInfo stmtInfo : attrStmtInfos) {
Collection<SAML2AttributeInfo> attrs = stmtInfo.getAttributeInfo();
if (attrs == null || attrs.size() == 0) {
System.out
.println("CustomIAAttributeMapperImpl: no attribute in statement: "
+ stmtInfo.toString());
} else {
for (SAML2AttributeInfo attr : attrs) {
if (attr.getAttributeName().equals("AttributeWithSingleValue")){
    CustomPrincipal customAttr1 = new CustomPrincipal(attr
.getAttributeName(), attr.getAttributeNameFormat(),
attr.getAttributeValues());
    customAttrs.add(customAttr1);
}else{
String customAttr = new StringBuffer().append(
attr.getAttributeName()).append(",").append(
attr.getAttributeValues()).toString();
customAttrs.add(customAttr);
}
}
}
}
return customAttrs;
}
 
public Collection<Principal> mapAttributeInfo(
Collection<SAML2AttributeStatementInfo> attrStmtInfos,
ContextHandler contextHandler) {
if (attrStmtInfos == null || attrStmtInfos.size() == 0) {
System.out
.println("CustomIAAttributeMapperImpl: attrStmtInfos has no elements");
return null;
}
 
Collection<Principal> pals = new ArrayList<Principal>();
 
for (SAML2AttributeStatementInfo stmtInfo : attrStmtInfos) {
Collection<SAML2AttributeInfo> attrs = stmtInfo.getAttributeInfo();
if (attrs == null || attrs.size() == 0) {
System.out
.println("CustomIAAttributeMapperImpl: no attribute in statement: "
+ stmtInfo.toString());
} else {
for (SAML2AttributeInfo attr : attrs) {
CustomPrincipal pal = new CustomPrincipal(attr
.getAttributeName(), attr.getAttributeNameFormat(),
attr.getAttributeValues());
pals.add(pal);
}
}
}
return pals;
}
SAML 2.0 IDアサーション・プロバイダは、SAMLアサーションから取得した属性をサブジェクトを介してコンシューマで使用できるようにします。
「コンソールでカスタムSAML IDアサーション・プロバイダ・クラスを使用可能にする」で説明されているように、WebLogic Server管理コンソールを使用して、マッパー実装の完全修飾クラス名にユーザー名マッパー・クラス名を構成します。
仮想ユーザーがSAMLでログインすることを許可している場合は、SAML認証プロバイダのインスタンスを作成して構成する必要があります。詳細は、「SAML認証プロバイダの構成」を参照してください。
仮想ユーザーが有効化しており、SAML認証プロバイダが構成されている場合、カスタム属性マッパーによって返される属性がサブジェクトに追加されます。
マッパーから返された属性は、マッピングされた属性のクラス・タイプに応じて、サブジェクト・プリンシパルまたはプライベートな資格証明として保存されます。具体的には、マッパーがPrincipalオブジェクトのコレクションを返す場合、マッピングされた属性はサブジェクト・プリンシパル設定に保存されます。それ以外の場合、サブジェクトのプライベートな資格証明の設定は、マッピングされた属性を伝達するために使用されます。コード例では、両方のアプローチが示されています。
アプリケーション・コードは、サブジェクトに追加される属性を示すためにマッパーが使用するオブジェクトのクラス・タイプに関する情報を取得する必要があります。アプリケーションは、顧客属性マッパーが属性の表示に使用するクラス・タイプが付与されると、サブジェクトのプライベートな資格証明またはプリンシパルの設定からSAML属性を取得できます。
この項では、追加属性をSAMLアサーションに書き込めるようにするSAML 1.1属性インタフェースの実装例を説明します。
例9-8は、SAMLCredentialNameMapperインタフェースおよびSAMLCredentialAttributeMapperインタフェースの両方を実装する単一のクラス例を示します。
例9-8 SAML 1.1資格証明属性マッパー
public class CustomCredentialAttributeMapperImpl implements
    SAMLCredentialNameMapper, SAMLCredentialAttributeMapper {
  private String nameQualifier = null;
 
  public Collection<SAMLAttributeStatementInfo> mapAttributes(Subject subject,
      ContextHandler handler) {
    return AttributeStatementInfoGenerator.getInfos(subject, handler);
  }
…
public SAMLNameMapperInfo mapSubject(Subject subject, ContextHandler handler) {
 
    // Provider checks for null Subject...
    Set subjects = subject.getPrincipals(WLSUser.class);
    Set groups = subject.getPrincipals(WLSGroup.class);
    String userName = null;
:
 userName = ((WLSUser) subjects.iterator().next()).getName();
    if (userName == null || userName.equals("")) {
      System.out
          .println("CustomCredentialAttributeMapperImpl:mapSubject: Username string is null or empty, returning null");
      return null;
    }
:
    // Return mapping information...
    System.out
        .println("CustomCredentialAttributeMapperImpl:mapSubject: Mapped subject: qualifier: "
            + nameQualifier + ", name: " + userName + ", groups: " + groups);
    return new SAMLNameMapperInfo(nameQualifier, userName, groups);
  }
:
:
class AttributeStatementInfoGenerator {
  static final String SAML_ATTR_NAME_SAPCE = "urn:bea:security:saml:attributes";
 
  static Collection<SAMLAttributeStatementInfo> getInfos(Subject subject,
      ContextHandler handlers) {
    SAMLAttributeInfo info1 = new SAMLAttributeInfo("AttributeWithSingleValue",
        SAML_ATTR_NAME_SAPCE, "ValueOfAttributeWithSingleValue");
 
    ArrayList<String> v2 = new ArrayList<String>();
    v2.add("Value1OfAttributeWithMultipleValue");
    v2.add("Value2OfAttributeWithMultipleValue");
    SAMLAttributeInfo info2 = new SAMLAttributeInfo("AttributeWithMultipleValue",
        SAML_ATTR_NAME_SAPCE, v2);
 
    SAMLAttributeStatementInfo stmt1 = new SAMLAttributeStatementInfo();
    stmt1.addAttributeInfo(info1);
    stmt1.addAttributeInfo(info2);
 
    ArrayList<SAMLAttributeStatementInfo> result = new ArrayList<SAMLAttributeStatementInfo>();
    result.add(stmt1);
:
:
    return result;
  }
「コンソールでカスタムSAML資格証明属性マッパーのクラスを使用可能にする」で説明されているように、WebLogic Server管理コンソールを使用して、マッパー実装の完全修飾クラス名にユーザー名マッパー・クラス名を構成します。
カスタム・マッパー実装によって返されたSAMLAttributeStatementInfoオブジェクトのコレクションでカプセル化された属性は、SAML 1.1資格証明マッピング・プロバイダによって生成されたアサーションに含まれます。
例9-9は、SAMLIdentityAssertionNameMapperおよびSAMLIdentityAssertionAttributeMapperの実装例を示します。
例9-9 カスタムSAML 1.1 IDアサーション・プロバイダ属性マッパー
public class CustomIdentityAssertionAttributeMapperImpl implements
    SAMLIdentityAssertionNameMapper, SAMLIdentityAssertionAttributeMapper {
  public String mapNameInfo(SAMLNameMapperInfo info, ContextHandler handler) {
    // Get the user name ...
    String userName = info.getName();
    System.out
        .println("CustomIdentityAssertionAttributeMapperImpl:mapNameInfo: returning name: "
            + userName);
    return userName;
  }
:
public void mapAttributeInfo(
      Collection<SAMLAttributeStatementInfo> attrStmtInfos,
      ContextHandler contextHandler) {
    if (attrStmtInfos == null || attrStmtInfos.size() == 0) {
      System.out
          .println("CustomIAAttributeMapperImpl: attrStmtInfos has no elements");
      return;
    }
:
   Object obj = contextHandler  .getValue(ContextElementDictionary.SAML_ATTRIBUTE_PRINCIPALS);
    if (obj == null || !(obj instanceof Collection)) {
      System.out.println("CustomIAAttributeMapperImpl: can't get "
          + ContextElementDictionary.SAML_ATTRIBUTE_PRINCIPALS
          + " from context handler");
      return;
    } 
:
    Collection<Principal> pals = (Collection<Principal>) obj;
 
    for (SAMLAttributeStatementInfo stmtInfo : attrStmtInfos) {
      Collection<SAMLAttributeInfo> attrs = stmtInfo.getAttributeInfo();
      if (attrs == null || attrs.size() == 0) {
        System.out
            .println("CustomIAAttributeMapperImpl: no attribute in statement: "
                + stmtInfo.toString());
      } else {
        for (SAMLAttributeInfo attr : attrs) {
          CustomPrincipal pal = new CustomPrincipal(attr.getAttributeName(),
              attr.getAttributeNamespace(), attr.getAttributeValues());
          pals.add(pal);
        }
      }
    }
  }
SAML 1.1 IDアサーション・プロバイダは、SAMLアサーションから取得した属性をサブジェクトを介してコンシューマで使用できるようにします。
「コンソールでカスタムSAML IDアサーション・プロバイダ・クラスを使用可能にする」で説明されているように、WebLogic Server管理コンソールを使用して、マッパー実装の完全修飾クラス名にユーザー名マッパー・クラス名を構成します。
仮想ユーザーがSAMLでログインすることを許可している場合は、SAML認証プロバイダのインスタンスを作成して構成する必要があります。詳細は、「SAML認証プロバイダの構成」を参照してください。
仮想ユーザーが有効化しており、SAML認証プロバイダが構成されている場合、カスタム属性マッパーによって返される属性がサブジェクトに追加されます。
マッパーから返された属性は、マッピングされた属性のクラス・タイプに応じて、サブジェクト・プリンシパルまたはプライベートな資格証明として保存されます。具体的には、マッパーがPrincipalオブジェクトのコレクションを返す場合、マッピングされた属性はサブジェクト・プリンシパル設定に保存されます。それ以外の場合、サブジェクトのプライベートな資格証明の設定は、マッピングされた属性を伝達するために使用されます。
アプリケーション・コードは、サブジェクトに追加される属性を示すためにマッパーが使用するオブジェクトのクラス・タイプに関する情報を取得する必要があります。アプリケーションは、顧客属性マッパーが属性の表示に使用するクラス・タイプが付与されると、サブジェクトのプライベートな資格証明またはプリンシパルの設定からSAML属性を取得できます。
SAML資格証明マッピング・プロバイダがSAML2CredentialAttributeMapper (SAML 2.0)またはSAMLCredentialAttributeMapper (SAML 1.1)インスタンスを使用するようにするには、WebLogic Server管理コンソールを使用して既存のNameMapperClassName属性をこのSAML2CredentialAttributeMapperまたはSAML2CredentialAttributeMapperインスタンスのクラス名に設定します。
つまり、名前マッパー・クラス名属性のコンソール制御を使用して、アクティブ・セキュリティ・レルムでSAML2CredentialAttributeMapperまたはSAMLCredentialAttributeMapperインスタンスのクラス名を指定します。
WebLogic SAML資格証明マッピング・プロバイダを使用してカスタム・ユーザー名マッパーを使用するには、次の手順を実行します。
まだ行っていない場合、管理コンソールのチェンジ・センターで「ロックして編集」をクリックします。
「セキュリティ・レルム」ページで、構成しているレルム名を選択します(たとえばTestRealm)。
「プロバイダ」>「資格証明マッピング」を展開し、SAML 2.0資格証明マッピング・プロバイダの名前またはSAML資格証明マッピング・プロバイダ・バージョン2を選択します。
「プロバイダ固有」タブを選択します。
「名前マッパーのクラス名」(SAML 2.0)または「デフォルト名前マッパーのクラス名」(SAML 1.1)フィールドで、SAML2CredentialAttributeMapperまたはSAMLCredentialAttributeMapper実装のクラス名を入力します。
クラス名はシステムのクラスパスに存在する必要があります。
「保存」をクリックします。
チェンジ・センターで「変更のアクティブ化」をクリックしてこれらの変更をアクティブ化します。
SAML IDアサーション・プロバイダがこのSAML2IdentityAsserterAttributeMapper (SAML 2.0)またはSAMLIdentityAssertionAttributeMapper (SAML 1.1)インスタンスを使用するようにするには、WebLogic Server管理コンソールを使用して既存のNameMapperClassName属性をこのSAML2IdentityAsserterAttributeMapperまたはSAMLIdentityAssertionAttributeMapperインスタンスのクラス名に設定します。
つまり、名前マッパー・クラス名属性のコンソール制御を使用して、アクティブ・セキュリティ・レルムでSAML2IdentityAsserterAttributeMapperまたはSAMLIdentityAssertionAttributeMapperインスタンスのクラス名を指定します。
WebLogic SAML IDアサーション・プロバイダを使用してカスタム・ユーザー名マッパーを使用するには、次の手順を実行します。
まだ行っていない場合、管理コンソールのチェンジ・センターで「ロックして編集」をクリックします。
「セキュリティ・レルム」ページで、構成しているレルム名を選択します(たとえばTestRealm)。
「プロバイダ」>「認証」を展開し、SAML 2.0 IDアサーション・プロバイダの名前またはSAML IDアサーション・プロバイダ・バージョン2を選択します。
「プロバイダ固有」タブを選択します。
「名前マッパーのクラス名」(SAML 2.0)または「デフォルト名前マッパーのクラス名」(SAML 1.1)フィールドで、SAML2IdentityAsserterAttributeMapperまたはSAMLIdentityAssertionAttributeMapper実装のクラス名を入力します。
クラス名はシステムのクラスパスに存在する必要があります。
「保存」をクリックします。
チェンジ・センターで「変更のアクティブ化」をクリックしてこれらの変更をアクティブ化します。
管理コンソールで名前マッパー・クラス名を設定する方法の詳細は、『Oracle WebLogic Server管理コンソールのヘルプ』のカスタム・ユーザー名マッパーの構成に関する項を参照してください。