SAML トークン内の SAML 属性の作成
SAML ランタイム API を使用して、SAML 属性を含んでいる SAML トークン を作成することができます。また、既存の SAML トークン から SAML 属性を抽出することもできます。
このタスクについて
SAML 属性を含んでいる SAML トークン を作成するには、以下の手順を実行します。
手順
- com.ibm.wsspi.wssecurity.saml.data.SAMLAttribute オブジェクトを初期化します。これによって、以下の例のように、アドレスに基づいた SAML 属性が作成されます。
SAMLAttribute sattribute = new SAMLAttribute("urn:oid:2.5.4.20", //Name new String[] {" any address"}, //Attribute Values null, /*XML Attributes empty on this example*/ "urn:oasis:names:tc:SAML:2.0:profiles:attribute:X500", //NameSpace "urn:oasis:names:tc:SAML:2.0:attrname-format:uri", //format "Address");
- SAMLTokenFactory を使用して、SAML 属性を含む CredentialConfig オブジェクト
を作成します。このメソッドは、Java セキュリティー
権限 wssapi.SAMLTokenFactory.newCredentialConfig を必要とします。
- com.ibm.wsspi.wssecurity.saml.config.CredentialConfig オブジェクトを 作成し、有効なプリンシパル名を設定します。
- SAML 属性を作成します。
- SAML 属性リストを作成し、SAML 属性をリストに追加します。
- SAML 属性リストを CredentialConfig オブジェクト に追加します。
SAMLTokenFactory samlFactory = SAMLTokenFactory.getInstance("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0");//samlTokenType CredentialConfig credentialConfig = samlFactory.newCredentialConfig(); credentialConfig.setRequesterNameID("any name"); SAMLAttribute sattribute = new SAMLAttribute("urn:oid:2.5.4.20", //Name new String[] {" any address"}, //Attribute Values null, /*XML Attributes empty on this example*/ "urn:oasis:names:tc:SAML:2.0:profiles:attribute:X500", //NameSpace "urn:oasis:names:tc:SAML:2.0:attrname-format:uri", //format "Address"); ArrayList<SAMLAttribute> al = new ArrayList<SAMLAttribute>(); al.add(sattribute); credentialConfig.setSAMLAttributes(al);
- CredentialConfig をパラメーターとして指定
し、com.ibm.websphere.wssecurity.wssapi.token.SAMLTokenFactory newSAMLToken メソッドを
使用して、属性を含んでいる SAML トークンを作成します。 このステップでは、
RequesterConfig reqData オブジェクト
と ProviderConfig samlIssuerCfg オブジェクトが既に作成済みであると
想定しています。これらのオブジェクトについて詳しくは、RequesterConfig および
ProviderConfig についての説明を参照してください。
- SAMLTokenFactory のインスタンスを取得します。
- 次の例のように、SAMLTokenFactory から newSAMLToken メソッドを使用して、SAML トークン
を作成します。
SAMLTokenFactory samlFactory = SAMLTokenFactory.getInstance("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1"); SAMLToken aSamlToken = samlFactory.newSAMLToken(credentialConfig, reqData, samlIssuerCfg);
- オプション: 既存の SAML トークンから SAML 属性
を抽出します。このステップは、受け取った SAML トークンから SAML 属性を
抽出する際に役立ちます。SAML アサーションを受け取り、その表明に含まれている属性を処理する必要がある場合に、このステップを使用できます。
- パラメーターとしてトークンを使用して getSAMLAttributes() メソッドを 呼び出すことによって、トークン内の SAML 属性のリストを取得します。 このメソッドは、Java セキュリティー権限 wssapi.SAMLToken.getSAMLAttributes を必要とします。
- リストにイテレーターを適用します。
- リストを繰り返して、アプリケーションに必要な追加処理があれば 実行します。
List<SAMLAttribute> aList = aSAMLToken.getSAMLAttributes(); java.util.Iterator<SAMLAttribute> i = aList.iterator(); while(i.hasNext()){ SAMLAttribute anAttribute = i.next(); //do something with namespace String namespace = anAttribute.getAttributeNamespace(); //do something with name String name = anAttribute.getName(); //do something with friendly name String friendlyName = anAttribute.getFriendlyName(); //process sring attribute values String[] stringAttributeValues = anAttribute.getStringAttributeValue(); //process XML attribute values XMLStructure[] xmlAttributeValues = (XMLStructure[]) anAttribute.getXMLAttributeValue(); }
サブトピック
SAML ユーザー属性
SAML アサーションは、SAML トークンのプリンシパルに関連するユーザー属性を含むことができます。1 つの SAML アサーションが複数のユーザー属性を含むことができます。


http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=twbs_managesamlattribs
ファイル名:twbs_managesamlattribs.html