Shibboleth 2.0安装指南(Linux)

1.   Identity Provider (IdP)安装

1.1. IdP安装概述

IdP的安装大致可分为网络平台的安装和Shibboleth IdP的安装两个部分。其中网络平台的安装包括jdk, openssl, httpd, tomcat等的安装。

IdP安装时,需要用到的软件包如下:

l   ntp-4.2.0.tar.gz (可选)

l   jdk-1_5_0_14-linux-i586.bin

l   openssl-0.9.8g.tar.gz

l   httpd-2.2.8.tar.gz

l   apache-tomcat-5.5.26.tar.gz

l   shibboleth-idp-2.0-rc2-bin.zip

需要说明的是,在安装IdP的过程中,将尽量使用普通用户来进行,在必须使用根用户的地方,将会用蓝字标出。

在本次安装中,该普通用户名为ncpku,建立该用户后,将出现目录/home/ncpku

定义NCPKU_HOME=/home/ncpku, NCPKU_COMMON=/home/ncpku/common。本次安装中,网络平台的软件都装在NCPKU_COMMON下。Shibboleth IdP安装在NCPKU_HOME/shibboleth-idp下。

安装软件时的源代码都放在NCPKU_HOME/allsrc下。

假设IdP安装在DNS名字为idp.ccnet.pku.edu.cn的服务器上。

参照本安装说明进行安装,将使IdP加入TestShib联盟。在安装之前,TestShib联盟会为每一台加入的IdP提供以下3个文件:

l   名为idp.ccnet.pku.edu.cn.crt的服务器证书;

l   名为idp.ccnet.pku.edu.cn.key.nopwd的服务器私钥;

l   名为testshib-providers.xml的联盟元文件。

1.2. IdP网络平台的搭建

1.2.1.    NTP时间服务

确认服务器上安装有NTP,可以使用ntpdate命令校正时间。

否则,利用安装包ntp-4.2.0.tar.gz进行安装。

# ./configure

#make

#make install

1.2.2.    新建文件myenv.shrestart.sh

1.2.2.1.       新建文件myenv.sh

NCPKU_HOME下新建文件myenv.sh

在其中写入如下内容:

export NCPKU_HOME=/home/ncpku

export NCPKU_COMMON=$NCPKU_HOME/common

export JAVA_HOME=$NCPKU_COMMON/jdk1.5.0_14

export OPENSSL_HOME=$NCPKU_COMMON/openssl-0.9.8g

export HTTPD_HOME=$NCPKU_COMMON/httpd-2.2.8

export CATALINA_HOME=$NCPKU_COMMON/apache-tomcat-5.5.26

export LD_LIBRARY_PATH=$OPENSSL_HOME/lib:$HTTPD_HOME/lib:$LD_LIBRARY_PATH

PATH=$JAVA_HOME/bin:$OPENSSL_HOME/bin:$HTTPD_HOME/bin:$CATALINA_HOME/bin:$PATH

export LANG=zh_CN

ntpdate pkuns.pku.edu.cn

hwclock -w

NCPKU_HOME下,

# chmod +x myenv.sh

以后每次登录后,都要运行以下命令

# . /home/ncpku/myenv.sh

1.2.2.2.       新建文件restart.sh

NCPKU_HOME下新建文件restart.sh

在其中写入如下内容:

$HTTPD_HOME/bin/apachectl -k stop

$CATALINA_HOME/bin/shutdown.sh

$HTTPD_HOME/bin/apachectl -k start -DSSL

$CATALINA_HOME/bin/startup.sh

NCPKU_HOME下,

# chmod +x myenv.sh

以后每次重启IdP,只需运行以下命令

# /home/ncpku/restart.sh

1.2.3.    jdk安装

jdk安装包jdk-1_5_0_14-linux-i586.bin拷贝到NCPKU_COMMON下。

# chmod +x jdk-1_5_0_14-linux-i586.bin

# ./ jdk-1_5_0_14-linux-i586.bin

1.2.4.    openssl安装

NCPKU_COMMON下新建目录openssl-0.9.8g

openssl安装包openssl-0.9.8g.tar.gz拷贝到NCPKU_HOME/allsrc下。

NCPKU_HOME/allsrc下,解压openssl-0.9.8g.tar.gz

# ./config threads shared zlib --prefix=$OPENSSL_HOME

# make

# make install

使用根用户执行以下命令:

# echo $OPENSSL_HOME/lib > /etc/ld.so.conf.d/ncpku_ld.conf

# ldconfig

1.2.5.    httpd安装

NCPKU_COMMON下新建目录httpd-2.2.8

httpd的安装包httpd-2.2.8.tar.gz拷贝到NCPKU_HOME/allsrc下。

NCPKU_HOME/allsrc下,解压httpd-2.2.8.tar.gz

# ./configure --prefix=$HTTPD_HOME --enable-rewrite --enable-so --enable-ssl --with-ssl=$OPENSSL_HOME --enable-proxy

# make

# make install

1.2.6.    tomcat安装

tomcat安装包apache-tomcat-5.5.26.tar.gz拷贝到NCPKU_COMMON下。

# tar zxf apache-tomcat-5.5.26.tar.gz

1.2.7.    httpdtomcat的配置

1.2.7.1.       httpd的基本配置

为了使httpd能够访问目录/home/ncpku,在目录/home/ncpku下,执行以下命令:

# chmod 755 /home/ncpku

修改HTTPD_HOME/conf/httpd.conf文件,

l  修改:ServerName idp.ccnet.pku.edu.cn

1.2.7.2.       httpdSSL相关的配置

修改HTTPD_HOME/conf/httpd.conf文件,

l  将以下行取消注释:Include conf/extra/httpd-ssl.conf

修改HTTPD_HOME/conf/extra/httpd-ssl.conf文件,

l  修改:ServerName idp.ccnet.pku.edu.cn:443

TestShib联盟所提供的idp.ccnet.pku.edu.cn.crtidp.ccnet.pku.edu.cn.key.nopwd拷贝到目录HTTPD_HOME/conf下。

HTTPD_HOME/conf/extra/httpd-ssl.conf中,

SSLCertificateFile conf/idp.ccnet.pku.edu.cn.crt

SSLCertificateKeyFile conf/idp.ccnet.pku.edu.cn.key.nopwd

1.2.7.3.       httpd中配置mod_proxy_ajp

HTTPD_HOME/conf/httpd.conf的末尾,加入

ProxyPass /idp/ ajp://localhost:8009/idp/

ProxyPass /jsp-examples/ ajp://localhost:8009/jsp-examples/

 

CATALINA_HOME/conf/server.xml中,在<Connector port="8009" …>中加入,

address="127.0.0.1" request.tomcatAuthentication="false"

1.2.7.4.       配置IdP使用Apache基本认证

HTTPD_HOME/conf/httpd.conf中,加入,

#***************Shibboleth installation Basic AuthN configuration start******

<Location /idp/Authn/RemoteUser>

    AuthType Basic

    AuthName "My Identity Provider"

    AuthUserFile conf/user.db

    require valid-user

</Location>

#***************Shibboleth installation Basic AuthN configuration stop******

HTTPD_HOME/bin下,

# htpasswd -c $HTTPD_HOME/conf/user.db user1

# htpasswd $HTTPD_HOME/conf/user.db user2

1.2.7.5.       配置IdPSP进行属性交换

HTTPD_HOME/conf/extra/httpd-ssl.conf中,在文件的末尾,加入

#***************Shibboleth installation attribute exchange configuration start******

Listen 8443

<VirtualHost _default_:8443>

    SSLEngine on

    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP

    SSLVerifyClient optional_no_ca

    SSLVerifyDepth 10

    SSLOptions +StdEnvVars +ExportCertData

    SSLCertificateFile conf/idp.ccnet.pku.edu.cn.crt

    SSLCertificateKeyFile conf/idp.ccnet.pku.edu.cn.key.nopwd

    ErrorLog logs/ssl_error_log

    TransferLog logs/ssl_access_log

</VirtualHost>

#***************Shibboleth installation attribute exchange configuration stop******

1.2.7.6.       检查在此之前的安装是否正确

由于Apache使用了1024以下的端口80443,所以为了启动Apache,需要用根用户来执行以下命令:

# $HTTPD_HOME/bin/apachectl -k start -DSSL

既可以使用普通用户ncpku也可以使用根用户来启动Tomcat,执行以下命令:

# $CATALINA_HOME/bin/startup.sh

为了检查到目前为止的安装是否正确,在浏览器中输入以下2个地址:

http://idp.ccnet.pku.edu.cn/jsp-examples/

https://idp.ccnet.pku.edu.cn/jsp-examples/

如果都能够显示Tomcat自带的示例程序jsp-examples的页面,则安装正确;否则,之前的安装过程存在错误。

1.3. IdP安装与配置

1.3.1.    IdP的编译与部署

NCPKU_HOME下新建目录shibboleth-idp

IdP的安装包shibboleth-idp-2.0-rc2-bin.zip拷贝到NCPKU_HOME/allsrc下,并使用以下命令解压。

# unzip shibboleth-idp-2.0-rc2-bin.zip

进入目录identityprovider,执行以下命令:

# chmod +x ant.sh

# ./ant.sh

之后,界面上出现以下问题,需要键入回答。

-- Is this a new installation?

-- Yes

-- Where should the Shibboleth Identity Provider software be installed?

-- /home/ncpku/shibboleth-idp

-- What is the host name of the Shibboleth Identity Provider server?

-- idp.ccnet.pku.edu.cn

进入identityprovider/endorsed

# cp *.jar $CATALINA_HOME/common/endorsed

NCPKU_HOME/shibboleth-idp/war下,

# cp idp.war $CATALINA_HOME/webapps

1.3.2.    使IdP加入cernetfed联盟

TestShib联盟所提供的testshib-providers.xml拷贝到目录NCPKU_HOME\shibboleth-idp\metadata下。

/home/ncpku/shibboleth-idp/conf/relying-party.xml中,修改元素<security:PrivateKey><security:Certificate>的内容,修改如下:

<security:PrivateKey>/home/ncpku/common/httpd-2.2.8/conf/idp.ccnet.pku.edu.cn.key.nopwd</security:PrivateKey>        <security:Certificate>/home/ncpku/common/httpd-2.2.8/conf/idp.ccnet.pku.edu.cn.crt</security:Certificate>

修改元素<MetadataProvider>的属性metadataFile为:

metadataFile="/home/ncpku/shibboleth-idp/metadata/testshib-providers.xml"

 

1.4. IdP的启动

启动IdP,需要:

l  使用根用户启动httpd: $HTTPD_HOME/bin/apachectl -k start -DSSL

l  启动tomcat: $CATALINA_HOME/bin/startup.sh

在新建了文件restart.sh之后,只需使用以下命令:

# /home/ncpku/restart.sh

1.5. IdP上与提供属性相关的配置

IdP上与提供属性相关的配置分为2部分:

l  NCPKU_HOME\shibboleth-idp\conf\attribute-filter.xml中配置ARP

l  NCPKU_HOME\shibboleth-idp\conf\attribute-resolver.xml中,属性定义和属性提供类(DataConnector).

1.5.1.    配置ARP

NCPKU_HOME\shibboleth-idp\conf\attribute-filter.xml中进行配置,

如在该文件中写入以下内容,

<AttributeFilterPolicy id="releaseUidToAnyone">

        <PolicyRequirementRule xsi:type="basic:ANY" />

        <AttributeRule attributeID="o:ou:uid">

            <PermitValueRule xsi:type="basic:ANY" />

        </AttributeRule>

    </AttributeFilterPolicy>

    <AttributeFilterPolicy id="releaseMailToAnyone">

        <PolicyRequirementRule xsi:type="basic:ANY" />

        <AttributeRule attributeID="o:ou:mail">

            <PermitValueRule xsi:type="basic:ANY" />

        </AttributeRule>

</AttributeFilterPolicy>

可以把名为” o:ou:uid”” o:ou:mail”的属性提供给任何SP

1.5.2.    配置属性定义和属性提供类

NCPKU_HOME\shibboleth-idp\conf\attribute-resolver.xml中,配置属性定义和属性提供类。

在目前安装的IdP上主要有以下3种属性提供类(DataConnector)

l  IdP自带的从LDAP中取得用户属性的DataConnector

l  IdP自带的提供固定值属性的StaticDataConnector

1.5.2.1.       IdP自带的从LDAP中取得用户属性的DataConnector

NCPKU_HOME\shibboleth-idp\conf\attribute-resolver.xml中,加入以下内容:

<resolver:AttributeDefinition id="o:ou:uid" xsi:type="Simple" xmlns="urn:mace:shibboleth:2.0:resolver:ad" sourceAttributeID="uid">

        <resolver:Dependency ref="pku_ldap" />

        <resolver:AttributeEncoder xsi:type="SAML1String" xmlns="urn:mace:shibboleth:2.0:attribute:encoder" name="pku:uid" />

        <resolver:AttributeEncoder xsi:type="SAML2String" xmlns="urn:mace:shibboleth:2.0:attribute:encoder" name="pku:uid" friendlyName="pku:uid" />

</resolver:AttributeDefinition>

 

<resolver:AttributeDefinition id="o:ou:mail" xsi:type="Simple" xmlns="urn:mace:shibboleth:2.0:resolver:ad" sourceAttributeID="mail">

        <resolver:Dependency ref="pku_ldap" />

        <resolver:AttributeEncoder xsi:type="SAML1String" xmlns="urn:mace:shibboleth:2.0:attribute:encoder" name="pku:mail" />

        <resolver:AttributeEncoder xsi:type="SAML2String" xmlns="urn:mace:shibboleth:2.0:attribute:encoder" name="pku:mail" friendlyName="pku:mail" />

</resolver:AttributeDefinition>

 

<resolver:DataConnector id="pku_ldap" xsi:type="LDAPDirectory" xmlns="urn:mace:shibboleth:2.0:resolver:dc" ldapURL="ldap://ldap.pku.edu.cn" baseDN="o=pku">

        <FilterTemplate>

            <![CDATA[(uid=$requestContext.principalName)]]>

        </FilterTemplate>

</resolver:DataConnector>

1.5.2.2.       IdP自带的提供固定值属性的StaticDataConnector

NCPKU_HOME\shibboleth-idp\conf\attribute-resolver.xml中,加入以下内容:

<resolver:AttributeDefinition id="o:ou:institution" xsi:type="Simple" xmlns="urn:mace:shibboleth:2.0:resolver:ad" sourceAttributeID="institution">

        <resolver:Dependency ref="static" />

        <resolver:AttributeEncoder xsi:type="SAML1String" xmlns="urn:mace:shibboleth:2.0:attribute:encoder" name="pku:institution" />

        <resolver:AttributeEncoder xsi:type="SAML2String" xmlns="urn:mace:shibboleth:2.0:attribute:encoder" name="pku:institution" friendlyName="pku:institution" />

</resolver:AttributeDefinition>

<resolver:DataConnector id="static" xsi:type="dc:Static" xmlns="urn:mace:shibboleth:2.0:resolver:dc">

     <Attribute id="institution">

          <Value>PKU</Value>

     </Attribute>

</resolver:DataConnector>

 


2.   Service Provider (SP)安装

2.1. SP安装概述

SP的安装大致可分为网络平台的安装和Shibboleth SP的安装两个部分。其中网络平台的安装包括httpd等的安装。

SP安装时,需要用到的软件包如下:

l   ntp-4.2.0.tar.gz (可选)

l   jdk-1_5_0_14-linux-i586.bin

l   openssl-0.9.8g.tar.gz

l   httpd-2.2.8.tar.gz

l   apache-tomcat-5.5.26.tar.gz

l   log4shib-1.0-1.i386.rpm

l   xerces-c-2.8.0-1.i386.rpm

l   xml-security-c-1.4.0-1.i386.rpm

l   xmltooling-1.0-5.i386.rpm

l   opensaml-2.0-5.i386.rpm

l   shibboleth-2.0-5.i386.rpm

需要说明的是,在安装SP的过程中,将尽量使用普通用户来进行,在必须使用根用户的地方,将会特别指出。

在本次安装中,该普通用户名为ncpku,建立该用户后,将出现目录/home/ncpku

定义NCPKU_HOME=/home/ncpku, NCPKU_COMMON=/home/ncpku/common。本次安装中,网络平台的软件都装在NCPKU_COMMON下。安装软件时的源代码都放在NCPKU_HOME/allsrc下。

本次SP的安装使用了RPM包,而没有从源代码开始安装。

假设SP安装在DNS名字为sp.ccnet.pku.edu.cn的电脑上。

参照本安装说明进行安装,将使IdP加入TestShib联盟。在安装之前,CERNETFed联盟会为每一台加入的SP提供以下4个文件:

l   名为sp.ccnet.pku.edu.cn.crt的服务器证书;

l   名为sp.ccnet.pku.edu.cn.key.nopwd的服务器私钥;

l   名为testshib-providers.xml的联盟元文件;

l   名为shibboleth2.xml的配置文件。

2.2. SP网络平台的搭建

2.2.1.    NTP时间服务

确认服务器上安装有NTP,可以使用ntpdate命令校正时间。

否则,利用安装包ntp-4.2.0.tar.gz进行安装。

# ./configure

#make

#make install

2.2.2.    新建文件myenv.shrestart.sh

2.2.2.1.       新建文件myenv.sh

NCPKU_HOME下新建文件myenv.sh

在其中写入如下内容:

export NCPKU_HOME=/home/ncpku

export NCPKU_COMMON=$NCPKU_HOME/common

export JAVA_HOME=$NCPKU_COMMON/jdk1.5.0_14

export OPENSSL_HOME=$NCPKU_COMMON/openssl-0.9.8g

export HTTPD_HOME=$NCPKU_COMMON/httpd-2.2.8

export CATALINA_HOME=$NCPKU_COMMON/apache-tomcat-5.5.26

export LD_LIBRARY_PATH=$OPENSSL_HOME/lib:$HTTPD_HOME/lib:$LD_LIBRARY_PATH

PATH=$JAVA_HOME/bin:$OPENSSL_HOME/bin:$HTTPD_HOME/bin:$CATALINA_HOME/bin:$PATH

export LANG=zh_CN

ntpdate pkuns.pku.edu.cn

hwclock -w

NCPKU_HOME下,

# chmod +x myenv.sh

以后每次登录后,都要运行以下命令

# . /home/ncpku/myenv.sh

2.2.2.2.       新建文件restart.sh

NCPKU_HOME下新建文件restart.sh

在其中写入如下内容:

$HTTPD_HOME/bin/apachectl -k stop

$CATALINA_HOME/bin/shutdown.sh

/etc/init.d/shibd stop

$HTTPD_HOME/bin/apachectl -k start -DSSL

$CATALINA_HOME/bin/startup.sh

/etc/init.d/shibd start

NCPKU_HOME下,

# chmod +x myenv.sh

以后每次重启SP,只需运行以下命令

# /home/ncpku/restart.sh

2.2.3.    jdk安装

jdk安装包jdk-1_5_0_14-linux-i586.bin拷贝到NCPKU_COMMON下。

# chmod +x jdk-1_5_0_14-linux-i586.bin

# ./ jdk-1_5_0_14-linux-i586.bin

2.2.4.    openssl安装

NCPKU_COMMON下新建目录openssl-0.9.8g

openssl安装包openssl-0.9.8g.tar.gz拷贝到NCPKU_HOME/allsrc下。

NCPKU_HOME/allsrc下,解压openssl-0.9.8g.tar.gz

# ./config threads shared zlib --prefix=$OPENSSL_HOME

# make

# make install

使用根用户执行以下命令:

# echo $OPENSSL_HOME/lib > /etc/ld.so.conf.d/ncpku_ld.conf

# ldconfig

2.2.5.    httpd安装

NCPKU_COMMON下新建目录httpd-2.2.8

httpd的安装包httpd-2.2.8.tar.gz拷贝到NCPKU_HOME/allsrc下。

NCPKU_HOME/allsrc下,解压httpd-2.2.8.tar.gz

# ./configure --prefix=$HTTPD_HOME --enable-rewrite --enable-so --enable-ssl --with-ssl=$OPENSSL_HOME --enable-proxy

# make

# make install

2.2.6.    tomcat安装

tomcat安装包apache-tomcat-5.5.26.tar.gz拷贝到NCPKU_COMMON下。

# tar zxf apache-tomcat-5.5.26.tar.gz

2.2.7.    httpdtomcat的配置

2.2.7.1.       httpd的基本配置

为了使httpd能够访问目录/home/ncpku,在目录/home/ncpku下,执行以下命令:

# chmod 755 /home/ncpku

修改HTTPD_HOME/conf/httpd.conf文件,

l  修改:ServerName sp.ccnet.pku.edu.cn

2.2.7.2.       httpdSSL相关的配置

修改HTTPD_HOME/conf/httpd.conf文件,

l  修改:将以下行取消注释:Include conf/extra/httpd-ssl.conf

修改HTTPD_HOME/conf/extra/httpd-ssl.conf文件,

l  修改:ServerName sp.ccnet.pku.edu.cn:443

TestShib联盟所提供的sp.ccnet.pku.edu.cn.crtsp.ccnet.pku.edu.cn.key.nopwd拷贝到目录HTTPD_HOME/conf下。

HTTPD_HOME/conf/extra/httpd-ssl.conf中,

SSLCertificateFile conf/sp.ccnet.pku.edu.cn.crt

SSLCertificateKeyFile conf/sp.ccnet.pku.edu.cn.key.nopwd

2.2.7.3.       httpd中配置mod_proxy_ajp

HTTPD_HOME/conf/httpd.conf的末尾,加入

ProxyPass /jsp-examples/ ajp://localhost:8009/jsp-examples/

 

CATALINA_HOME/conf/server.xml中,在<Connector port="8009" …>中加入,

address="127.0.0.1" request.tomcatAuthentication="false"

2.2.7.4.       检查在此之前的安装是否正确

由于Apache使用了1024以下的端口80443,所以为了启动Apache,需要用根用户来执行以下命令:

# $HTTPD_HOME/bin/apachectl -k start -DSSL

既可以使用普通用户ncpku也可以使用根用户来启动Tomcat,执行以下命令:

# $CATALINA_HOME/bin/startup.sh

为了检查到目前为止的安装是否正确,在浏览器中输入以下2个地址:

http://sp.ccnet.pku.edu.cn/jsp-examples/

https://sp.ccnet.pku.edu.cn/jsp-examples/

如果都能够显示Tomcat自带的示例程序jsp-examples的页面,则安装正确;否则,之前的安装过程存在错误。

2.3. SP的安装与基本配置

先把以下rpm包拷贝到NCPKU_HOME/allsrc下:

l   log4shib-1.0-1.i386.rpm

l   xerces-c-2.8.0-1.i386.rpm

l   xml-security-c-1.4.0-1.i386.rpm

l   xmltooling-1.0-5.i386.rpm

l   opensaml-2.0-5.i386.rpm

l   shibboleth-2.0-5.i386.rpm

2.3.1.    安装5rpm

NCPKU_HOME/allsrc下,使用根用户严格按顺序执行以下命令:

# rpm -ivh log4shib-1.0-1.i386.rpm

# rpm -ivh xerces-c-2.8.0-1.i386.rpm

# rpm -ivh xml-security-c-1.4.0-1.i386.rpm

# rpm �Civh xmltooling-1.0-5.i386.rpm

# rpm -ivh opensaml-2.0-5.i386.rpm

# rpm -ivh shibboleth-2.0-5.i386.rpm

 

SP 安装在/etc/shibboleth路径下。

/etc/init.d下出现了SP中守护进程shibd的启动程序shibd

要启动shibd,使用 # /etc/init.d/shibd start,或使用# service shibd start .

要停止shibd,使用 # /etc/init.d/shibd stop,或使用# service shibd stop .

2.3.2.    修改Apache的配置

HTTPD_HOME/conf/httpd.conf中,加入

Include /etc/shibboleth/apache22.config

HTTPD_HOME/conf/httpd.conf中,修改如下:

UseCanonicalName On

2.3.3.    配置SP

①将联盟所提供的shibboleth2.xml拷贝到/etc/shibboleth下。

②将联盟所提供的testshib-providers.xml拷贝到/etc/shibboleth下。

③修改/etc/shibboleth/shibboleth2.xml中的<CredentialResolver>元素为:

<CredentialResolver type="File">

  <Key>

<Path>/home/ncpku/common/httpd-2.2.8/conf/sp.ccnet.pku.edu.cn.key.nopwd</Path>

  </Key>

  <Certificate>

    <Path>/home/ncpku/common/httpd-2.2.8/conf/sp.ccnet.pku.edu.cn.crt</Path>

  </Certificate>

</CredentialResolver>

④修改/etc/shibboleth/shibboleth2.xml中的<MetadataProvider>元素为:

<MetadataProvider type="XML" file="/etc/shibboleth/testshib-providers.xml"/>

⑤在/etc/shibboleth/shibboleth2.xml中,加入一个元素<SessionInitiator>,如下:

<SessionInitiator type="Chaining" Location="/Login2"  id="idp_ccnet" relayState="cookie" entityID="https://idp.ccnet.pku.edu.cn/idp/shibboleth">

  <SessionInitiator type="SAML2" defaultACSIndex="1" template="/etc/shibboleth/bindingTemplate.html"/>

   <SessionInitiator type="Shib1" defaultACSIndex="5"/>

</SessionInitiator>

⑥在HTTPD_HOME/conf/httpd.conf中,加入

ProxyPass /testidpccnet ajp://localhost:8009/testidpccnet

⑦在/etc/shibboleth/shibboleth2.xml的元素<Host name="sp.ccnet.pku.edu.cn">中,加入一个元素<Path>如下:

<Path name="testidpccnet" authType="shibboleth" requireSession="true" requireSessionWith="idp_ccnet"/>

⑧在/etc/shibboleth/apache22.config中,加入

<Location /testidpccnet>

  AuthType shibboleth

  ShibRequireSession On

  require valid-user

  ShibUseHeaders On

</Location>

2.3.4.    配置SP的日志模块

/etc/shibboleth/native.logger中,修改如下,

l  第2行,log4j.rootCategory=DEBUG, shibd_log

l  5行,log4j.category.XMLTooling.XMLObject=DEBUG

l  10行,log4j.appender.native_log.fileName=/etc/shibboleth/log/native.log

/etc/shibboleth/shibd.logger中,

l  2行,log4j.appender.shibd_log.fileName=/etc/shibboleth/shibd.log

l  5行,log4j.category.SAML.XML=DEBUG

l  9行,log4j.category.Shibboleth-TRANSACTION=DEBUG, tran_log

l  24行,log4j.appender.shibd_log.fileName=/etc/shibboleth/log/shibd.log

/etc/shibboleth下,创建目录log,在/etc/shibboleth/log下创建文件shibd.log, native.logtransaction.log

# chmod a+w shibd.log

# chmod a+w native.log

# chmod a+w transaction.log

 

2.4节中的方法启动SP,在IE中访问https://sp.ccnet.pku.edu.cn/testidpccnet时,就会被重定向到idp.ccnet上,idp.ccnet会要求用户进行认证,认证通过后,用户被重定向到sp.ccnet上用户要访问的链接处。

2.4. SP的启动

启动SP包括:

l  使用根用户启动shibd: /etc/init.d/shibd start

l  使用根用户启动httpd: $HTTPD_HOME/bin/apachectl -k start �CDSSL

l  启动tomcat: $CATALINA_HOME/bin/startup.sh

在新建了文件restart.sh之后,只需使用以下命令:

# /home/ncpku/restart.sh

2.5. SP上与接收属性相关的配置

为了在Web Application中取得用户属性,在SP上需要进行的配置可以分为以下3部分:

l  /etc/shibboleth/attribute-map.xml中配置属性映射。

l  /etc/shibboleth/attribute-policy.xml中配置属性接受策略(AAP)

l  /etc/shibboleth/apache22.config/etc/shibboleth/shibboleth.xml中把特定的URL配置为受保护的资源

l  对于Java Web Application来说,需要在$HTTPD_HOME/conf/ssl.conf中要求JK对于特定的URL把用户属性以环境变量的方式传给Tomcat;而对于PHP应用来说,直接在PHP程序中就可以取得用户的属性。

下面以名为”kuayu”Web Application为例。

2.5.1.    /etc/shibboleth/attribute-map.xml中配置属性映射

/etc/shibboleth/attribute-map.xml中加入以下内容:

<Attribute name="pku:uid" id="pku:sp:uid"/>

<Attribute name="pku:mail" id="pku:sp:mail"/>

2.5.2.    /etc/shibboleth/attribute-policy.xml中配置属性接受策略(AAP)

在缺省情况下,SP允许每个属性到达应用程序,无需特殊配置。

2.5.3.    保护特定的URL

2.3.3的⑥、⑦和⑧,即:

⑥在HTTPD_HOME/conf/httpd.conf中,加入

ProxyPass /testidpccnet ajp://localhost:8009/testidpccnet

⑦在/etc/shibboleth/shibboleth2.xml的元素<Host name="sp.ccnet.pku.edu.cn">中,加入一个元素<Path>如下:

<Path name="testidpccnet" authType="shibboleth" requireSession="true" requireSessionWith="idp_ccnet"/>

⑧在/etc/shibboleth/apache22.config中,加入

<Location /testidpccnet>

  AuthType shibboleth

  ShibRequireSession On

  require valid-user

  ShibUseHeaders On

</Location>

 

2.5.4.    针对Java Web Application

”kuayu”中,使用以下语句来取得用户的属性:

String uid = request.getHeader("pku:sp:uid");

String uid = request.getHeader("pku:sp:mail");

2.5.5.    针对PHP应用

针对PHP应用,在Apache上安装了PHP模块后,使用以下2句来取得用户的属性:

echo $_SERVER['pku:sp:uid'];

echo $_SERVER['pku:sp:mail'];