日期:2014-05-17  浏览次数:20936 次

windows下ITIM admin API开发环境配置,部署至tomcat

开发环境构建
1. ibm_sdk50 java.security.
?
A. 下载/opt/IBM/itim/extensions/5.1/examples/apps/bin/jaas_login_was.conf 至D:/jaas_login_was.conf
B.修改 java.security文件( D:\IBM\eclipseDevelopmentPackage\ibm_sdk50\jre\lib\security\ java.security ),尾部添加如下
login.config.url.1=file:///D:/jaas_login_was.conf

2.添加依赖的jar包列表至WEB-INF/lib及其它配置:
APP_SRV_TOP=/opt/IBM/WebSphere/AppServer/profiles/AppSrv01
ITIM_HOME=/opt/IBM/itim

$ITIM_HOME/lib/api_ejb.jar
$ITIM_HOME/lib/itim_api.jar
$ITIM_HOME/lib/itim_common.jar
$ITIM_HOME/lib/itim_server_api.jar
$ITIM_HOME/lib/jlog.jar
$APP_SRV_TOP/runtime/com.ibm.ws.admin.client_6.1.0.jar
$APP_SRV_TOP/plugins/com.ibm.ws.ejbportable_6.1.0.jar

下载$ITIM_HOME/data/tmsMessages.properties

C:\WINDOWS\system32\drivers\etc\hosts中 添加域名映射如下
192.168.2.12?

? ??? itim

4.项目的目录结构图如下:
windows下ITIM?<wbr>admin?<wbr>API开发环境配置,部署至tomcat


5.部署至apache-tomcat-6.0.18服务器中
A.配置apache-tomcat-6.0.18运行jre
在apache-tomcat-6.0.18/bin/setclasspath.bat中添加JRE_HOME:
set JRE_HOME="D:\IBM\eclipseDevelopmentPackage\ibm_sdk50\jre"
B.拷贝$APP_SRV_TOP/runtime/com.ibm.ws.admin.client_6.1.0.jar到apache-tomcat-6.0.18/lib中

附录代码
PersonMgr.java
package com.likegene.demo;

import java.rmi.RemoteException;
import java.util.Collection;
import java.util.Hashtable;
import java.util.ResourceBundle;

import javax.security.auth.Subject;
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;

import com.ibm.itim.apps.ApplicationException;
import com.ibm.itim.apps.InitialPlatformContext;
import com.ibm.itim.apps.PlatformContext;
import com.ibm.itim.apps.Request;
import com.ibm.itim.apps.identity.PersonMO;
import com.ibm.itim.apps.identity.PersonManager;
import com.ibm.itim.apps.jaas.callback.PlatformCallbackHandler;
import com.ibm.itim.apps.provisioning.PasswordManager;


public class PersonMgr {

??? static ResourceBundle rb = ResourceBundle.getBundle("context");

??? public Subject getSubject(PlatformContext platform) {

??? ??? String itimManager = rb.getString("itimManager");
??? ??? String itimManagerPwd = rb.getString("itimManagerPwd");
??? ??? Subject subject = null;
??? ??? try {
??? ??? ??? PlatformCallbackHandler handler = new PlatformCallbackHandler(
??? ??? ??? ??? ??? itimManager, itimManagerPwd);
??? ??? ??? handler.setPlatformContext(platform);
??? ??? ??? LoginContext lc = new LoginContext("ITIM", handler);
??? ??? ??? lc.login();
??? ??? ??? subject = lc.getSubject();
??? ??? }

??? ??? catch (LoginException e) {
??? ??? ??? e.printStackTrace();
??? ??? }

??? ??? return subject;
??? }

??? public PlatformContext getPlatform() {

??? ??? String platformContextFactory = rb.getString("contextFactory");
??? ??? String ejbUser = rb.getString("ejbUser");
??? ??? String appServerURL = rb.getString("appServerURL");
??? ??? String ejbPwd = rb.getString("ejbPwd");

??? ??? Hashtable<String, String> env = new Hashtable<String, String>();
??? ??? env.put(InitialPlatformContext.CONTEXT_FACTORY, platformContextFactory);
??? ??? env.put(PlatformContext.PLATFORM_URL, appServerURL);
??? ??? env.put(PlatformContext.PLATFORM_PRINCIPAL, ejbUser);
??? ??? env.put(PlatformContext.PLATFORM_CREDENTIALS, ejbPwd);
??? ?