1?????? 目的
在進(jìn)行 Globus 項目開發(fā)的過程中,需要在 Windows 下通過 Web 服務(wù)調(diào)用 Globus 的服務(wù)(如 RFT )。但是在編寫程序的時候遇到了一系列的問題。幾經(jīng)周折,終于搞定。遂將解決方法總計如下,以供大家參考。
2?????? 證書問題
由于 Globus 的安全問題,需要使用證書才能訪問服務(wù)。這里,有三種證書,分別是 CA 證書、用戶證書和代理證書。我們可以從以及安裝好 Globus 的 Linux 主機上將用戶證書(連同用戶的私鑰)和 CA 證書一同拷貝到 Windows 上使用。
用戶證書和用戶私鑰通常位于用戶根目錄中:
$HOME\.globus\usercert.pem
$HOME\.globus\userkey.pem
用戶證書和用戶私鑰用來生成代理證書。
CA 證書在校驗用戶證書的有效性時使用,位于
/etc/grid-security/certificates/a
代理證書是訪問 Globus 服務(wù)時實際使用的證書,它可以通過上面的證書來生成。但是生成代理證書需要進(jìn)行如下操作。
2.1 ?? 安裝 ws-core
設(shè)置環(huán)境變量 GLOBUS_LOCATION ,
set %GLOBUS_LOCATION%=some_where_ws-core_installed
下載
ws-core-
2.2 ?? 安裝 cog-jglobus
設(shè)置環(huán)境變量 COG_INSTALL_PATH ,
set %COG_INSTALL_PATH=some_where_cog-jglobus_installed
從 http://wiki.cogkit.org 下載 cog-jglobus-1.4-bin.zip ,解壓到 %COG_INSTALL_PATH 目錄。
運行:
%COG_INSTALL_PATH\bin\setup
根據(jù)提示,指定用戶證書、私鑰, CA 證書以及代理證書的位置。
成功安裝后,會在 Windows 用戶根目錄下生成 .globus 目錄,并在該目錄下建立一個 cog.properties 文件。該文件內(nèi)容大致如下:
#Java CoG Kit Configuration File
#Tue Dec 12 18:34:00 CST 2006
usercert=C\:\\Documents and Settings\\Administrator\\.globus\\usercert.pem
userkey=C\:\\Documents and Settings\\Administrator\\.globus\\userkey.pem
proxy=C\:\\DOCUME~1\\ADMINI~1\\LOCALS~1\\Temp\\x509up_u_administrator
cacert=C\:\\Documents and Settings\\cert\\a
后面, grid-proxy-init 會根據(jù)這個文件來查找和生成證書。
如果沒有正確設(shè)置 cog.properties 文件,會產(chǎn)生如下異常:
Exception in thread "main" . Caused by AxisFault
?faultCode: {
http://schemas.xmlsoap.org/soap/envelope/}Server.userException
?faultSubcode:
?faultString:
org.globus.common.ChainedIOException
: Authentication failed [Caused by: Failure unspecified at GSS-API level [Caused by: Unknown CA]]
?faultActor:
?faultNode:
?faultDetail:
??? {http://xml.apache.org/axis/}stackTrace:Authentication failed. Caused by Failure unspecified at GSS-API level. Caused by
COM.claymoresystems.ptls.SSLThrewAlertException
: Unknown CA
這是由于無法定位 CA 證書造成的。
2.3 ?? 生成代理證書
運行 grid-proxy-init 獲得用戶的代理證書:
%GLOBUS_LOCATION\bin\grid-proxy-init
這樣可以在指定位置生成代理證書。通常這樣生成的代理證書只有 12 小時的有效期。為了方便開發(fā),可以加入 -hours 參數(shù)為代理證書指定一個相對比較長的有效期。
如果沒有代理證書,就會拋出如下異常:
Exception in thread "main" org.globus.gsi.GlobusCredentialException: Proxy file (C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\x509up_u_administrator) not found.
??? at org.globus.gsi.GlobusCredential.<init>(GlobusCredential.java:98)
?????? at org.globus.gsi.GlobusCredential.getDefaultCredential(GlobusCredential.java:526)
3?????? 配置域名
由于在證書中使用了域名,如果此時域名服務(wù)器無法對服務(wù)器的 IP 地址進(jìn)行解析,需要修改 hosts 文件來指定域名。
否則,會拋出類似如下的異常:
[main] ERROR delegation.DelegationUtil? -
org.globus.common.ChainedIOException
: Authentication failed [Caused by: Operation unauthorized (Mechanism level: Authorization failed. Expected "/CN=host/192.168.1.129" target but received "/O=Grid/OU=GlobusTest/OU=simpleCA-mci.uestc.edu.cn/CN=host/mci.uestc.edu.cn")]
Exception in thread "main" . Caused by AxisFault
?faultCode: {
http://schemas.xmlsoap.org/soap/envelope/}Server.userException
?faultSubcode:
?faultString:
org.globus.common.ChainedIOException
: Authentication failed [Caused by: Operation unauthorized (Mechanism level: Authorization failed. Expected "/CN=host/192.168.1.129" target but received "/O=Grid/OU=GlobusTest/OU=simpleCA-mci.uestc.edu.cn/CN=host/mci.uestc.edu.cn")]
?faultActor:
?faultNode:
?faultDetail:
??? {http://xml.apache.org/axis/}stackTrace:Authentication failed. Caused by GSSException : Operation unauthorized (Mechanism level: Authorization failed. Expected "/CN=host/192.168.1.129" target but received "/O=Grid/OU=GlobusTest/OU=simpleCA-mci.uestc.edu.cn/CN=host/mci.uestc.edu.cn")
4?????? 配置 Eclipse
為了使程序可以正常執(zhí)行,還需要對 Eclipse 工程進(jìn)行配置。
4.1 ?? 指定 client-config.wsdd
在 Eclipse 工程的虛擬機參數(shù)中加入 -Daxis.ClientConfigFile=share\client-config.wsdd 來指定 client-config.wsdd 文件。可以從 Linux 上拷貝 $GLOBUS_LOCATION\client-config.wsdd 得到。
否則,會拋出如下異常:
[main] ERROR delegation.DelegationUtil? - No client transport named 'https' found!
Exception in thread "main" . Caused by AxisFault
?faultCode: {
http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
?faultSubcode:
?faultString: No client transport named 'https' found!
?faultActor:
?faultNode:
?faultDetail:
??? {http://xml.apache.org/axis/}stackTrace:No client transport named 'https' found!
4.2 ?? 指定 ws-core 安裝路徑
在 Eclipse 工程的虛擬機參數(shù)中加入 -DGLOBUS_LOCATION=%GLOBUS_LOCATION 指定 Windows 中 ws-core 的安裝路徑。
否則,可能拋出如下異常:
Exception in thread "main" Container failed to initialize. Caused by
org.apache.axis.ConfigurationException
: Configuration file directory '.\etc' does not exist or is not a directory or is not readable.
org.apache.axis.ConfigurationException : Configuration file directory '.\etc' does not exist or is not a directory or is not readable.
5?????? 總結(jié)
以上是在 Windows 平臺下基于 Web 服務(wù)開發(fā) Globus 應(yīng)用時遇到的問題以及解決辦法。