IdP検出サービスの実装

前述のように、OAM/SPは、フェデレーションSSO操作に使用するIdPを決定する機能を持つリモートIdP検出サービスを使用するように構成できます。

OASISによって公開される「アイデンティティ・プロバイダ検出サービス・プロトコルおよびプロファイル」SAML 2.0仕様は、SAML 2.0 SPとIdP検出サービス間の相互作用プロトコルを定義します。

この記事では、サンプルのIdP検出サービスを実装し、そのサービスを使用するようにOAM/SPを構成します。

IdP検出サービス・プロトコル

前述のように、IdP検出サービス・フローは仕様(http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-idp-discovery.pdf?)で説明されており、次のステップで構成されています。

プロトコル交換とは別に、実装者が許容できる任意の方法でサービスを実装できます。

カスタム・サービス

概要

この例では、次のことを行うサービスを記述します。

実装に関して:

サンプル・ページ

カスタムIdP検出サービスは、次の2つのJSPページで構成されています。

実装

ランディング・ページ

<%@ page buaer="5kb" autoFlush="true" session="false"%\> \<%@ page language="java"import="java.util.\*,sun.misc.\*,java.net.\*"%>

<%response.setHeader("Expires", "Sat, 1 Jan 200000:00:00 GMT"); response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-cache"); request.setCharacterEncoding("UTF-8"); response.setContentType("text/html; charset=UTF-8");

// list of known IdPs, keys being the displayed names,and values the ProviderID/Issuer IDs

Map idps = new HashMap(); idps.put("AcmeIdP", "https://acme.com/fed"); idps.put("IdP1", "https://idp1.com/saml"); idps.put("MyIdentiyProvider.com", "https://myidentityprovider.com/saml2.0");

// entityID of the requesting SP

String entityID = request.getParameter("entityID");

// the query parameter that contains the IdP's ProviderID/Issuer when

// redirecting the user back to the SP

String returnIDParam = request.getParameter("returnIDParam");

// the URL where the user should be redirected at the SP

String returnURL = request.getParameter("return");

// check if the IDPDiscService cookie is set, and if it is a known IdP

Cookie\[\] cookies = request.getCookies();

if (cookies != null && cookies.length \> 0)

{

for (int i = 0; i \< cookies.length; i++)

{

if ("IDPDiscService".equals(cookies\[i\].getName()))

{

// decode the idp

BASE64Decoder b64 = new BASE64Decoder();

String idp = new

String(b64.decodeBuaer(cookies\[i\].getValue()));

if (idps.containsValue(idp))

{

// redirects to the SP

StringBuaer redirectStringBuaer = new

StringBuaer(returnURL);

if (returnURL.indexOf('?') == -1)

redirectStringBuaer.append("?");

else if (returnURL.charAt(returnURL.length() - 1)

!= '&')

redirectStringBuaer.append("&");

redirectStringBuaer.append(returnIDParam);

redirectStringBuaer.append("="); redirectStringBuaer.append(URLEncoder.encode(idp));

response.sendRedirect(redirectStringBuaer.toString());

return;

}

}

}

}

%>

<html>

<head>

<title>Select your Single Sign-On Server</title>

</head>

<body>

<p style="text-align: center;"\>Select your SingleSign-On Server</p>

<form action="/idpdiscoveryservice/submit.jsp" method="post" name="idpselection"/>

<input name="entityID" type="hidden" value="<%=entityID%\>" />

<input name="returnIDParam" type="hidden" value="<%=returnIDParam%\>" />

<input name="return" type="hidden" value="<%=returnURL%>" />

<p style="text-align: center;"\>Single Sign-On Server:

<select name="selectedidp"\>

<%Iterator idpsIterator = idps.keySet().iterator();while(idpsIterator.hasNext())

{

String displayIdP = (String)idpsIterator.next();

String providerIDIdP = (String)idps.get(displayIdP);
%>

<option value="<%=providerIDIdP%>">

<%=displayIdP%><option>

<%

}

%>

</select>

</p>

<p style="text-align: center;">

<input name="submit" type="submit"value="Submit" />

</p>

</form>

</body>

</html>

ページの送信

<%@ page buaer="5kb" autoFlush="true" session="false"%> <%@ page language="java"import="java.util.*,sun.misc.*,java.net.*"%>

<%response.setHeader("Expires", "Sat, 1 Jan 200000:00:00 GMT"); response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-cache"); request.setCharacterEncoding("UTF-8"); response.setContentType("text/html; charset=UTF-8");

// list of known IdPs with values being the ProviderID/Issuer IDs

List idps = new ArrayList(); idps.add("https://acme.com/fed"); idps.add("https://idp1.com/saml"); idps.add("https://myidentityprovider.com/saml2.0");

// entityID of the requesting SP

String entityID = request.getParameter("entityID");

// the query parameter that contains the IdP's ProviderID/Issuer when

// redirecting the user back to the SP

String returnIDParam =request.getParameter("returnIDParam");

// the URL where the user should be redirected at the SP

String returnURL = request.getParameter("return");

// the idp selected by the user

String idp = request.getParameter("selectedidp");

// check that the selected IdP is one of the known IdPs

if (!idps.contains(idp))

throw new Exception("Unknown IdP");

// save the idp in the IDPDiscService cookie

BASE64Encoder b64Encoder = new

BASE64Encoder();

response.addHeader("Set-Cookie", "IDPDiscService="

+

b64Encoder.encode(idp.getBytes()) + "; expires=Wed, 01-Jan-2020 00:00:00 GMT; path=/");

// redirects to the SP

StringBuaer redirectStringBuaer = new StringBuaer(returnURL); if (returnURL.indexOf('?') == -1) redirectStringBuaer.append("?");

else if (returnURL.charAt(returnURL.length() - 1) != '&')

redirectStringBuaer.append("&"); redirectStringBuaer.append(returnIDParam); redirectStringBuaer.append("="); redirectStringBuaer.append(URLEncoder.encode(idp));

response.sendRedirect(redirectStringBuaer.toString());

%>

パッケージング

これらのファイルのみを含むディレクトリにlanding.jspおよびsubmit.jspを配置したら、JARツールを使用してidpDiscService.war WAR Aleを作成します。

jar cvf idpDiscService.war *.jsp

そのWARファイルの内容は、unzipコマンドで確認できます: ` unzip - l idpDiscService.WAR Archive: idpDiscService.WAR`

長さ 日付 時間 名前
0 01-09-2014 19:00 メタイン/
76 01-09-2014 19:00 メタイン/MANIFEST.MF
2898 01-09-2014 19:57 landing.jsp
1838 01-09-2014 19:57 submit.jsp
4812     4ファイル

次に、/idpdiscoveryserviceをルート・パスとして使用して、このWARファイルをJ2EEコンテナにデプロイします。これにより、/idpdiscoveryservice /landing.jspおよび/idpdiscoveryservice/submit.jspを使用して両方のページにアクセスできます。

OAM/SPの構成

IdP検出サービスを使用するようにOAM/SPを構成するには、次のステップを実行します。

  1. $IAM_ORACLE_HOME/common/bin/WLST.shを実行して、WLST環境を入力します。

  2. WLS管理サーバー(connect())に接続します。

  3. ドメイン・ランタイム・ブランチdomainRuntime()に移動します

  4. IdP検出サービスを使用するためのOAM/SPの有効化/無効化: ` putBooleanProperty("/spglobal /idpdiscoveryserviceenabled"、 "true")`

  5. リモートIdP検出サービスの場所を設定します: putStringProperty("/spglobal /idpdiscoveryserviceurl","http://remote.idp.disc.service.com /idpdiscoveryservice/landing.jsp")

  6. WLST環境を終了します: exit()

テスト

OAM/SPを起動してフェデレーションSSOを起動すると、カスタムのIdP検出サービス(/idpdiscoveryservice/landing.jsp)にユーザーがリダイレクトされます。

初回訪問時に、ユーザーにドロップダウン・リストが表示され、IdP SSOサーバーを選択するように求められます。

図IdP_SSO_Server.jpgの説明

/idpdiscoveryservice /submit.jspに選択を送信すると、ページによって選択が検証され、IDPDiscService Cookieに保存されて、IdPのProviderIDを使用してユーザーをOAM/SPにリダイレクトします。そこから、OAM/SPはそのIdPでフェデレーションSSOを開始します。

次にOAM/SPがそのユーザーのフェデレーションSSOを開始したとき:

その他の学習リソース

docs.oracle.com/learnで他のラボを探すか、Oracle Learning YouTubeチャネルで無料のラーニング・コンテンツにアクセスしてください。また、education.oracle.com/learning-explorerにアクセスしてOracle Learning Explorerになります。

製品ドキュメントについては、Oracle Help Centerを参照してください。