Guest User

Untitled

a guest
Oct 18th, 2017
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. // Import ITIM Packages
  2. //importPackage(com.ibm.itim.apps);
  3. //importPackage(java.util);
  4.  
  5.  
  6. function getContext()
  7. {
  8. system.setJavaProperty("java.security.auth.login.config", "C:/ibm/jaas_login_was.conf");
  9. system.setJavaProperty("com.ibm.CORBA.ConfigURL", "file:C:/IBM/sas.client.props");
  10. //system.setJavaProperty("com.ibm.CORBA.securityServerHost", "xx.xx.xx");
  11.  
  12. //system.setJavaProperty("com.ibm.CORBA.securityServerPort", "9067");
  13. system.setJavaProperty("com.ibm.SSL.ConfigURL", "file:C:/IBM/ssl.client.props");
  14. //system.setJavaProperty("jdk.tls.client.protocols","TLSv1,TLSv1.1,TLSv1.2")
  15. // THESE 4 FIELDS ARE REQUIRED TO GET PLATFORM CONTEXT
  16. var appServerURL = "corbaloc:iiop:xx.xx.xx.xx:9067";
  17.  
  18. var platformContextFactory = "com.ibm.itim.apps.impl.websphere.WebSpherePlatformContextFactory";
  19. var ejbUser = "isimsystem@itimCustomRealm";
  20. var ejbPwd = "==";
  21. //var ejbUser = "itim manager";
  22. //var ejbPwd = "xxxxx";
  23. var itimRealm = "itimCustomRealm";
  24.  
  25. var env = new java.util.Hashtable();
  26. task.logmsg(appServerURL);
  27. //var env = new Hashtable();
  28. //task.logmsg(Packages.com.ibm.itim.apps.InitialPlatformContext.CONTEXT_FACTORY);
  29. //task.logmsg(com.ibm.itim.apps.InitialPlatformContext.CONTEXT_FACTORY);
  30. env.put(Packages.com.ibm.itim.apps.InitialPlatformContext.CONTEXT_FACTORY, platformContextFactory);
  31. env.put(Packages.com.ibm.itim.apps.InitialPlatformContext.PLATFORM_URL, appServerURL);
  32. env.put(Packages.com.ibm.itim.apps.InitialPlatformContext.PLATFORM_PRINCIPAL, ejbUser);
  33. env.put(Packages.com.ibm.itim.apps.InitialPlatformContext.PLATFORM_CREDENTIALS, ejbPwd);
  34. env.put(Packages.com.ibm.itim.apps.InitialPlatformContext.PLATFORM_REALM, itimRealm);
  35. var platform = null;
  36.  
  37. try
  38. {
  39.  
  40. platform = new com.ibm.itim.apps.InitialPlatformContext(env);
  41. task.logmsg("Successfully got platform context");
  42. //task.logmsg(platform);
  43. }
  44. catch(e)
  45. {
  46. task.logmsg("Error Class: " + e.getClass());
  47. task.logmsg("Error Message: " + e.getMessage());
  48. task.logmsg("Error LocalizedMessage: " + e.getLocalizedMessage());
  49.  
  50. var stack = e.getStackTrace();
  51. var i = 0;
  52. for(i = 0; i < stack.length; i++) {
  53. task.logmsg(stack[i].toString());
  54. }
  55. }
  56.  
  57. return platform;
  58. }
  59.  
  60. function getSubject()
  61. {
  62.  
  63. var itimUser = "itim manager";
  64. var itimPwd = "xxxxxxx";
  65.  
  66. //var handler = Packages.com.ibm.websphere.security.auth.callback.WSCallbackHandlerImpl(itimUser, "itimCustomRealm", itimPwd);
  67. var handler = com.ibm.websphere.security.auth.callback.WSCallbackHandlerImpl(itimUser, "itimCustomRealm", itimPwd);
  68. //task.logmsg(handler);
  69. var loginContext = javax.security.auth.login.LoginContext("WSLogin", handler);
  70. //task.logmsg(loginContext);
  71. try
  72. {
  73. loginContext.login();
  74. task.logmsg("Logged in");
  75. }
  76. catch(e)
  77. {
  78. task.logmsg("Error Class: " + e.getClass());
  79. task.logmsg("Error Message: " + e.getMessage());
  80. task.logmsg("Error LocalizedMessage: " + e.getLocalizedMessage());
  81.  
  82. var stack = e.getStackTrace();
  83. var i = 0;
  84. for(i = 0; i < stack.length; i++) {
  85. task.logmsg(stack[i].toString());
  86. }
  87. }
  88.  
  89. return loginContext.getSubject();
  90. }
  91.  
  92.  
  93. var itimPlatform = getContext();
  94. var subject = getSubject();
  95. task.logmsg("subject "+subject);
  96. var empDN = new com.ibm.itim.dataservices.model.DistinguishedName("erglobalid=00000000000000000007,ou=0,ou=people,erglobalid=00000000000000000000,ou=TCP,DC=COM");
  97. task.logmsg("loginContext: "+itimPlatform.toString() + " - " + subject);
  98. var employeeMO = new com.ibm.itim.apps.identity.PersonMO(itimPlatform,subject,empDN);
  99. task.logmsg("got here 1 "+employeeMO);
  100. try {
  101. var emp = employeeMO.getData();
  102. }
  103. catch(e)
  104. {
  105. task.logmsg("Error Class: " + e.getClass());
  106. task.logmsg("Error Message: " + e.getMessage());
  107. task.logmsg("Error LocalizedMessage: " + e.getLocalizedMessage());
  108.  
  109. var stack = e.getStackTrace();
  110. var i = 0;
  111. for(i = 0; i < stack.length; i++) {
  112. task.logmsg(stack[i].toString());
  113. }
  114. }
  115. //task.logmsg(emp);
Add Comment
Please, Sign In to add comment