次に、Identity Management Frameworkの設定を行います。 「C:\workspace_jboss\.metadata\.plugins\org.jboss.ide.eclipse.as.core\JBoss_4.2_Runtime_Server\deploy\jboss-sso.sar\conf\」の「sso.cfg.xml」を開いて、以下の個所を修正してください。
<identity-management>
<!-- Login Provider that works with an LDAP repository such as Red Hat Directory Server, OpenLDAP etc -->
<login>
<provider
id="si:jboss-sso:ldap:login" class="org.jboss.security.idm.ldap.LDAPIdentityProvider">
<property name="connectionURL">
jdbc:ldap://localhost:389/o=JBossAdmin,c=com?SEARCH_SCOPE:=s
ubTreeScope&secure:=false&concat_atts:=true&size_limit:=10000000……接続先の設定
</property>
<property name="username">cn=admin,o=JBossAdmin,c=com</property>……ユーザー名の設定
<property name="password">admin</property>……パスワードの設定
<property name="identityOu">admin</property>……identityグループの設定
<property name="roleOu">JBossAdmin</property>……権限グループの設定
</provider>
</login>
:
:
【省略】
:
:
<sso-processor>
<processor class="org.jboss.security.saml.JBossSingleSignOn">
<property name="trustServer">http://localhost:8080/federate/trust </property>……trust serverの接続URLの設定
</processor>
</sso-processor>
</jboss-sso>
「C:\workspace_jboss\.metadata\.plugins\org.jboss.ide.eclipse.as.core\JBoss_4.2_Runtime_1_Server\deploy\jboss-sso.sar\META-INF」直下の「jboss-service.xml」に以下のコードを追加してください。
<!-- Bind a remote LDAP server -->
<mbean code="org.jboss.naming.ExternalContext"
name="jboss.jndi:service=ExternalContext,jndiName=external/ldap/jboss">
<attribute name="JndiName">external/ldap/jboss</attribute>
<attribute name="Properties">
java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory
java.naming.provider.url=ldap://localhost:389/o=ssosample,c=com
java.naming.security.principal=cn=admin
java.naming.security.authentication=none ……【1】
java.naming.security.credentials=admin
</attribute>
<attribute name="InitialContext"> javax.naming.ldap.InitialLdapContext </attribute>
<attribute name="RemoteAccess">true</attribute>
</mbean>
上記、コード3はリモートでLDAPサーバに接続するための設定です。ただし、LDAPサーバへの接続はJBoss SSOが行います。
今回この設定を行った理由は、「デプロイ時にJNDIの設定が行われていない」というエラーを回避するためだけです(LDAPサーバへの接続を有効にするときは、【1】の「none」の個所に「simple」と表記してください)。
sampleSX\WebContent\WEB-INF直下にcontext.xmlを作成してください。
context.xml内は以下の通りです。
<?xml version="1.0"?>
<Context>
<!--
logoutURL - URL for performing logout/signout function in your application
-->
<Valve className="org.jboss.security.valve.SSOAutoLogout"
logoutURL="http://localhost:8080/sampleSX/home.seam"></Valve>……ログアウトURLの設定
<!--
assertingParty - this is the partnerId of this application as a part of a federation of multiple partner sites
-->
<Valve className="org.jboss.security.valve.SSOTokenManager"
assertingParty="admin"></Valve>……統合されたときにWebアプリケーションを特定するためのIDを設定
<!--
tomcat built-in AuthenticationTypes: FORM,BASIC,DIGEST,CLIENT-CERT
-->
<Valve className="org.jboss.security.valve.SSOAutoLogin"
authType="FORM"></Valve>
</Context>
同様にssoTestプロジェクト内にも、context.xmlを作成します。ssoTestプロジェクトのcontext.xmlは以下の通りです。
<?xml version="1.0"?>
<Context>
<!--
logoutURL - URL for performing logout/signout function in your application
-->
<Valve className="org.jboss.security.valve.SSOAutoLogout"
logoutURL="http://localhost:8080/ssoTest/home.seam"></Valve>
<!--
assertingParty - this is the partnerId of this application as a part of a federation of multiple partner sites
-->
<Valve className="org.jboss.security.valve.SSOTokenManager"
assertingParty="admin"></Valve>
<!--
tomcat built-in AuthenticationTypes: FORM,BASIC,DIGEST,CLIENT-CERT
-->
<Valve className="org.jboss.security.valve.SSOAutoLogin"
authType="FORM"></Valve>
</Context>
JBossのアプリケーションサーバにプロジェクトを追加します。JBoss 4.2 Runtime Serverを右クリックして、[Add and Remove Projects]を選択してください。
sampleSX、sampleSXのリソースファイル、ssoTest、ssoTestのリソースファイルを選択してAddボタンをクリックしてください。以下の図12のようになるはずです。
それでは、サーバを起動してみましょう。「JBoss 4.2 Runtime Server」を右クリックして、[Start]を選択してください。
Eclipseのコンソールに、以下のようなメッセージが表示されたら起動成功です。
18:29:30,593 INFO [Federation] Federation service successfully started...............
以上、今回はID管理やシングルサインオンの常識について説明しましたが、いかがでしたでしょうか。
さまざまな環境構築を必要とするため、慣れるまではシングルサインオンをアプリケーションに組み込むことは決して簡単ではありません。しかし、本連載で説明したようにシングルサインオンは非常に有効な技術であるため、ぜひとも覚えておきたい技術の1つです。本稿が、シングルサインオンに挑戦するきっかけになれば幸いです。
株式会社ビーブレイクシステムズ開発部所属
相原 淳(あいはら じゅん)
専門分野:Webシステム開発・保守
2008年よりビーブレイクシステムズに在籍。
前職では、Javaを用いたWEB系のシステム開発や保守作業に従事。Javaの開発を行っていく中で、オープンソースに興味を持ち、その分野で活躍できるビーブレイクシステムズに転職し、現在に至る。
2008年より、株式会社ビーブレイクシステムズに在籍
多田 丈晃(ただ たけあき)
システム開発の様々な工程を経験し、果ては新人研修まで担当したが、さらなる高みを目指してJavaとOSSに強いビーブレイクシステムズの門をたたく。
同僚の知識量と能力の高さに驚きつつ、日々研鑽を続けている。
株式会社ビーブレイクシステムズ技術担当取締役
上川 伸彦(かみかわ のぶひこ)
RDB製品の開発、各種業界団体におけるXML/EDI標準の策定やSOA基盤の設計などに従事。最近は、ITコンサル業よりも、業務システムの構築に携わることが多く、お客さまからの無理難題と向き合う日々を送っている。
Copyright © ITmedia, Inc. All Rights Reserved.