OIM是Oracle出品的一个身份管理解决方案,提供了API可以给第三方程序调用。今天尝试了一下如何从OIM外部调用API,并调用API完成用户注册功能。
使用的产品是OIM10g,具体版本号是9.1.0.2。具体的步骤我就不写了,这一部分Oracle写的还是比较多。
简单步骤如下:
1、先用Eclipse建立一个工程,将OIM相关类引入,按照你的要求编写一个API调用程序,并导出为jar包,比如:oimtest.jar
2、从安装好的OIM Design Console中找到CustomClient.zip,并解压。
3、解压后,要将OIM Design Console安装目录下的ext和lib两个目录的内容copy到解压后的CustomClient目录下,覆盖原有的内容。
4、安装文档 中说的修改相应部分。
5、把oimtest.jar拷贝到CustomerClient下的lib目录下,并在basecp或者classpath批处理文件中引用这个jar包
6、运行xlCustomClient.bat或者wsCustomClient.bat即可
由于时间不多不能写出详细的步骤,具体参考可以参考如下链接:
Using the Oracle Identity Manager API
http://download.oracle.com/docs/cd/E14049_01/doc.9101/e14058/chapter1.htm#sthref11
另外我写的调用OIM API的代码如下:
package xxx.xxx.oim.test; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Enumeration; import java.util.HashMap; import java.util.Hashtable; import Thor.API.tcResultSet; import Thor.API.tcUtilityFactory; import Thor.API.Exceptions.tcAPIException; import Thor.API.Exceptions.tcAttributeMissingException; import Thor.API.Exceptions.tcChallengeInfoException; import Thor.API.Exceptions.tcChallengeNotSetException; import Thor.API.Exceptions.tcColumnNotFoundException; import Thor.API.Exceptions.tcDuplicateSelfRegistrationException; import Thor.API.Exceptions.tcDuplicateUserException; import Thor.API.Exceptions.tcFormNotFoundException; import Thor.API.Exceptions.tcInvalidAttributeException; import Thor.API.Exceptions.tcInvalidLookupException; import Thor.API.Exceptions.tcInvalidManagerException; import Thor.API.Exceptions.tcInvalidValueException; import Thor.API.Exceptions.tcLoginAttemptsExceededException; import Thor.API.Exceptions.tcObjectNotFoundException; import Thor.API.Exceptions.tcOrganizationNotFoundException; import Thor.API.Exceptions.tcPasswordExpiredException; import Thor.API.Exceptions.tcPasswordResetAttemptsExceededException; import Thor.API.Exceptions.tcRequestInvalidException; import Thor.API.Exceptions.tcRequestNotFoundException; import Thor.API.Exceptions.tcRequestObjectInvalidException; import Thor.API.Exceptions.tcRequestOrganizationInvalidException; import Thor.API.Exceptions.tcRequiredDataMissingException; import Thor.API.Exceptions.tcUserAccountDisabledException; import Thor.API.Exceptions.tcUserAccountInvalidException; import Thor.API.Exceptions.tcUserAlreadyLoggedInException; import Thor.API.Operations.tcFormInstanceOperationsIntf; import Thor.API.Operations.tcLookupOperationsIntf; import Thor.API.Operations.tcObjectOperationsIntf; import Thor.API.Operations.tcOrganizationOperationsIntf; import Thor.API.Operations.tcPasswordOperationsIntf; import Thor.API.Operations.tcPropertyOperationsIntf; import Thor.API.Operations.tcRequestOperationsIntf; import Thor.API.Operations.tcUserOperationsIntf; import com.thortech.xl.crypto.tcCryptoException; import com.thortech.xl.crypto.tcCryptoUtil; import com.thortech.xl.crypto.tcSignatureMessage; import com.thortech.xl.dataaccess.tcDataProvider; import com.thortech.xl.util.config.ConfigurationClient; public class UserOperations { tcUserOperationsIntf userops; tcPropertyOperationsIntf propops; tcRequestOperationsIntf reqops; tcOrganizationOperationsIntf orgops; tcObjectOperationsIntf objops; tcFormInstanceOperationsIntf formops; tcLookupOperationsIntf lkupops; tcPasswordOperationsIntf pwdOps; public UserOperations() { } public tcUtilityFactory getAdminConnection() throws tcCryptoException, tcAPIException, tcUserAccountDisabledException, tcPasswordResetAttemptsExceededException, tcLoginAttemptsExceededException, tcUserAccountInvalidException, tcUserAlreadyLoggedInException, tcChallengeNotSetException, tcPasswordExpiredException { ConfigurationClient.ComplexSetting config = ConfigurationClient .getComplexSettingByPath("Discovery.CoreServer"); final Hashtable env = config.getAllSettings(); // tcSignatureMessage moSignature = // tcCryptoUtil.sign("xelsysadm","PrivateKey"); // tcUtilityFactory utilityFactory = new tcUtilityFactory(env, // moSignature); tcUtilityFactory utilityFactory = new tcUtilityFactory(env, "xelsysadm", "xxxxx"); return utilityFactory; } public void createRegistrationRequest() { ConfigurationClient.ComplexSetting config = ConfigurationClient .getComplexSettingByPath("Discovery.CoreServer"); final Hashtable env = config.getAllSettings(); try { tcUtilityFactory tcutil = getAdminConnection(); Hashtable quesAns = new Hashtable(); HashMap user = new HashMap(); user.put("Users.User ID", "SelfTesting"); user.put("Users.First Name", "SelfTesting"); user.put("Users.Last Name", "SelfTesting"); user.put("Users.Email", "SelfTesting@email.com"); user.put("Users.Password", "SelfTesting"); user.put("ConfirmPassword", "SelfTesting"); user.put("Organization", "test22"); tcUtilityFactory.createRegistrationRequest(env, user, quesAns); } catch (tcCryptoException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (tcAPIException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (tcUserAccountDisabledException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (tcPasswordResetAttemptsExceededException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (tcLoginAttemptsExceededException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (tcUserAccountInvalidException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (tcUserAlreadyLoggedInException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (tcChallengeNotSetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (tcPasswordExpiredException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (tcDuplicateSelfRegistrationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (tcRequiredDataMissingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (tcChallengeInfoException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (tcOrganizationNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (tcInvalidManagerException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (tcDuplicateUserException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }