WebSphere 管理主控台
預設入口:https://localhost:9090/admin/。操作前建議 backupConfig 備份現有配置。
1. 啟用全域安全性
2. 配置 J2C 認證別名 (資料庫連線身分)
- Security → JAAS Configuration → J2C Authentication Data → New
- Alias:
db2Alias,User ID/Password:資料庫合法帳號 (如 db2inst1)
3. 建立 JDBC Provider
- Resources → JDBC Providers → New
- 選擇 DB2 Legacy CLI-based Type 2 JDBC Driver (較簡單,JCC 需額外配置)
- Classpath 指向
db2java.zip 完整路徑
4. 建立 DataSource 綁定 J2C 別名
- Resources → JDBC Providers → 選擇上述 Provider → Data Sources → New
- Name:
sampleDataSource,JNDI Name:jdbc/sampleDataSource (必須與 WAR 中 web.xml 定義一致)
- Component-managed Authentication Alias:選擇
db2Alias → 所有連線透過此身分建立
- **測試連線** 驗證配置正確
5. 部署 EAR 應用程式
- Applications → Install New Application → 指定 EAR 路徑 (如
DefaultEAR.ear)
- 後續步驟接受預設,或調整 Role-to-User 映射 (目標機器用戶不同)
- Applications → Enterprise Applications → 勾選應用 → Start
6. 客戶端驗證與開發提示
- 瀏覽器訪問
https://localhost:9080/SecureDADX/index.html,忽略自簽憑證警告
- 測試
list.dadx,以**授權用戶**與**未授權用戶**分別登入驗證授權生效
- 程式端呼叫安全 Web Service:依 API 環境設定 UsernameToken (JAX-RPC 參考 Sun 教學
Security for JAX-RPC 章節)