CD内のtiqrshib20130329.tar.gzを利用したtiqrshibの
インストールについて。

以下では、Shibboleth IdP(ID、パスワード認証)が動作
している環境へのインストール手順として記述しています。

 =========================================
[1]Shibboleth SPをインストール、設定
[2]TiqrShibを配置(CDのtar.gzの解凍)
[3]関連ライブラリを配置
[4]ライブラリのバグ修正
[5]Apacheの設定
[6]ShibbolethへのTiqrShibハンドラー設定
[7]TiqrShibの初期値設定
 =========================================



[1]Shibboleth SPをIdPサーバにインストール、設定
Tiqr登録時のID,パスワード認証用。
IdPでは、フェデレーションとは別の、単独の
メタデータとして設定。
SPには、このIdPのメタデータのみを設定。

[2]TiqrShibを配置
  CDのtar.gzを解凍して、
   /var/tiqrzenddemo
  に配置。
   /var/www/html/TiqrShibをmkdirして、CDの
trans.phpを置きます。
    

[3]関連ライブラリを配置

【下記をダウンロードして配置】
Tiqr-library        :1.0.0
Tiqr-zendframework  :1.0.0
ZendFramework       :1.12.2-minimal
phpqrcode           :1.1.4

Tiqrの2つは
 https://tiqr.org/archives/196/
からダウンロードして配置。
======================
mkdir /var/www/library
cp \-rf tiqr-server-library-1.0.0/library/tiqr /var/www/library/libTiqr
cp \-rf tiqr-server-zendframework-1.0.0/library/tiqr-zf /var/www/library/tiqr-zf
cp \-rf phpqrcode /var/www/library/phpqrcode
ZendFramework-1.12.1-minimalを/usr/shareに展開して、
ln \-s ZendFramework-1.12.1-minimal ZendFramework
======================
【ライブラリ リンク作成】=>作業報告書P24
\(*) 上記はリンクでなく、直接でもよいです。
【library設定】=>作業報告書P21

[4]ライブラリのバグ修正
【ZendFramework修正】=>作業報告書P23
【Tiqr,Tiqr-zf修正】=>作業報告書P25-P30(P28はTiqrShibに反映済み)

[5]Apacheの設定
<httpd.conf>
&nbsp;追記:
&nbsp;&nbsp;&nbsp; =============
&nbsp;&nbsp;&nbsp; Alias /tiqr/ "/var/tiqrzenddemo/public/"
&nbsp;&nbsp;&nbsp; =============

<ssl.conf>
&nbsp;追記:
&nbsp;&nbsp;&nbsp; =============
&nbsp;&nbsp;&nbsp; <Location /tiqr>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RewriteEngine On
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RewriteBase /tiqr
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RewriteCond %{REQUEST_FILENAME} \-s \[OR\]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RewriteCond %{REQUEST_FILENAME} \-l \[OR\]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RewriteCond %{REQUEST_FILENAME} \-d
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RewriteRule \^.*$ - \[NC,L\]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RewriteRule \^.*$ /tiqr/index.php \[NC,L\]
&nbsp;&nbsp;&nbsp; </Location>
&nbsp;&nbsp;&nbsp; =============

【.htacsess設定】=>作業報告書P22

[6]ShibbolethへのTiqrShibハンドラー設定
CDのtiqrshibAuthn.javaをコンパイルして、tiqrshibAuthn.classを作成。
&nbsp; /usr/java/tomcat/webapps/idp/WEB-INF/class/を作成して配置。
コンパイルは、こんな感じです;
\--------------------------------------------\-
&nbsp;javac \-classpath /usr/java/tomcat/lib/servlet-api.jar:/root/shibIdP230/shibboleth-identityprovider-2.3.0/lib/shibboleth-common-1.3.0.jar:/root/shibIdP230/shibboleth-identityprovider-2.3.0/lib/shibboleth-identityprovider-2.3.0.jar:/root/shibIdP230/shibboleth-identityprovider-2.3.0/lib/shibboleth-jce-1.1.0.jar:/root/shibIdP230/shibboleth-identityprovider-2.3.0/lib/slf4j-api-1.6.1.jar:/root/shibIdP230/shibboleth-identityprovider-2.3.0/lib/openws-1.4.2.jar:/root/shibIdP230/shibboleth-identityprovider-2.3.0/lib/xmltooling-1.3.2.jar tiqrshibAuthn.java
\--------------------------------------------\-
web.xmlとhandler.xmlの設定。=>作業報告書P38,P39
\(*) handler.xmlでの設定は、UserPasswordハンドラーを残したままで、
(つまり、コメントアウトしないで、)追加して下さい。

【Shib設定】

(1) IdPの設定
・Username/PasswordHandlerをデフォルトにする設定。
/usr/java/tomcat/webapps/idp/WEB-INF/web.xmlに下記を追記。
==========================
&nbsp;&nbsp;&nbsp; <\!-\- Servlet for doing Username/Password authentication \-->
&nbsp;&nbsp;&nbsp; <servlet>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <servlet-name>UsernamePasswordAuthHandler</servlet-name>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <servlet-class>edu.internet2.middleware.shibboleth.idp.authn.provider.UsernamePasswordLoginServlet</servlet-class>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <init-param>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <param-name>authnMethod</param-name>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <param-value>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</param-value>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </init-param>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <load-on-startup>3</load-on-startup>
&nbsp;&nbsp;&nbsp; </servlet>
=========================

relying-party.xmlに下記を設定。
=========================
&nbsp;&nbsp;&nbsp; <rp:DefaultRelyingParty provider="https://IdPサーバ/idp/shibboleth"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; defaultSigningCredentialRef="IdPCredential"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; defaultAuthenticationMethod="urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport">
=========================

(2) IdPサーバのSPの設定

&nbsp;shibboleth2.xmlへのSessionInitiator追加
=========================
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\!-\- Special SessionInitiator for Tiqr\!\!\! \-->
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SessionInitiator type="SAML2" Location="/TiqrShib" id="siid1" entityID="https://simptest2.nec.test/idp/shibboleth" template="bindingTemplate.html" authnContextClassRef="urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport" />
=========================

&nbsp;/etc/httpd/conf.d/shibd.confへの追加
=========================
<Location /TiqrShib>
&nbsp; AuthType shibboleth
&nbsp; ShibRequestSetting requireSessionWith siid1
&nbsp; require valid-user
</Location>
=========================

(3) SPの設定(Tiqr認証を要求するIdPサーバとは別のSPの設定)
SessionInitiatorで、="urn:oasis:names:tc:SAML:2.0:ac:classes:MobileTwoFactorContract"を設定する。
==================
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SessionInitiator type="Chaining" Location="/DS" isDefault="true" id="tiqrshiblogin" authnContextClassRef="urn:oasis:names:tc:SAML:2.0:ac:classes:MobileTwoFactorContract">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SessionInitiator type="SAML2" template="bindingTemplate.html"/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SessionInitiator type="Shib1"/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SessionInitiator type="SAMLDS" URL="https://DSサーバ/ds/WAYF"/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SessionInitiator>
==================


[7]TiqrShibの初期値設定

application/Bootstrap.phpに初期値読み込みを設定。(=>作業報告書P34)
=====================
<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
&nbsp;&nbsp;&nbsp; // retrieve tiqrshib constants
&nbsp;&nbsp;&nbsp; protected function \_initConstants()
&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $options = $this->getOption('constants');

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (is_array($options)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach($options as $key => $value) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(\!defined($key)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; define($key, $value);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; }


&nbsp;&nbsp;&nbsp; protected function \_initLogger() {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $this->bootstrap("log");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $logger = $this->getResource("log");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Zend_Registry::set("logger", $logger);
&nbsp;&nbsp;&nbsp;&nbsp; }

}
=====================
&nbsp;\(*) CDのtiqrshibコードには、ログ出力コードを入れているため、
上記のLogger設定も必要。

【Tiqr初期値設定】(作業報告書P33)
&nbsp; /var/tiqrzenddemo/application/config/application.iniの設定を修正。

resources.tiqr.identifier = "vm2.peofiamp.nii.ac.jp"
↑サーバのFQDNを記入。
resources.tiqr.name = "vm2"
↑Tiqrサーバの名称(アプリ上に表示される)を記入。
resources.tiqr.logoUrl&nbsp; = "https://vm2.peofiamp.nii.ac.jp.nec.test/icons/gakunin-logo.png"
↑アプリに表示するロゴを指定。5KBくらいのpngファイル。100KBくらいだとアプリへのロードに時間が掛る。
constants.TIQRSHIB_DOMAIN = "nec.test"
↑IdPが送るeppnのセキュリティドメイン

↓以下のLDAP設定には、attribute-resolver.xmlと同じものを設定。
constants.TIQRSHIB_LDAP_HOST = "localhost"
constants.TIQRSHIB_LDAP_PORT = "389"
constants.TIQRSHIB_LDAP_BASEDN = "o=test_o,dc=ac,c=JP"
constants.TIQRSHIB_LDAP_BINDREQUIRESDN = "true"
constants.TIQRSHIB_LDAP_USERNAME = "cn=Manager,o=test_o,dc=ac,c=JP"
constants.TIQRSHIB_LDAP_PASSWORD = "password"