SAML トークン内の SAML 属性の作成

SAML ランタイム API を使用して、SAML 属性を含んでいる SAML トークン を作成することができます。また、既存の SAML トークン から SAML 属性を抽出することもできます。

このタスクについて

WebSphere® Application Server を使用しているときは、 SAML トークン・ライブラリー API を用いて SAML 属性を作成できます。 SAML 属性は CredentialConfig オブジェクト に追加され、このオブジェクトは SAML トークンを生成するのに使用されます。また、この API は、 既存の SAML トークンから SAML 属性を抽出し、それらの属性を処理するという 機能も備えています。

SAML 属性を含んでいる SAML トークン を作成するには、以下の手順を実行します。

手順

  1. 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");
  2. SAMLTokenFactory を使用して、SAML 属性を含む CredentialConfig オブジェクト を作成します。このメソッドは、Java セキュリティー 権限 wssapi.SAMLTokenFactory.newCredentialConfig を必要とします。
    1. com.ibm.wsspi.wssecurity.saml.config.CredentialConfig オブジェクトを 作成し、有効なプリンシパル名を設定します。
    2. SAML 属性を作成します。
    3. SAML 属性リストを作成し、SAML 属性をリストに追加します。
    4. 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);
  3. CredentialConfig をパラメーターとして指定 し、com.ibm.websphere.wssecurity.wssapi.token.SAMLTokenFactory newSAMLToken メソッドを 使用して、属性を含んでいる SAML トークンを作成します。 このステップでは、 RequesterConfig reqData オブジェクト と ProviderConfig samlIssuerCfg オブジェクトが既に作成済みであると 想定しています。これらのオブジェクトについて詳しくは、RequesterConfig および ProviderConfig についての説明を参照してください。
    1. SAMLTokenFactory のインスタンスを取得します。
    2. 次の例のように、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);
  4. オプション: 既存の SAML トークンから SAML 属性 を抽出します。このステップは、受け取った SAML トークンから SAML 属性を 抽出する際に役立ちます。SAML アサーションを受け取り、その表明に含まれている属性を処理する必要がある場合に、このステップを使用できます。
    1. パラメーターとしてトークンを使用して getSAMLAttributes() メソッドを 呼び出すことによって、トークン内の SAML 属性のリストを取得します。 このメソッドは、Java セキュリティー権限 wssapi.SAMLToken.getSAMLAttributes を必要とします。
    2. リストにイテレーターを適用します。
    3. リストを繰り返して、アプリケーションに必要な追加処理があれば 実行します。
    以下の例を参照してください。
    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();
    
       }

トピックのタイプを示すアイコン タスク・トピック



タイム・スタンプ・アイコン 最終更新: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=twbs_managesamlattribs
ファイル名:twbs_managesamlattribs.html