Last active
October 17, 2017 15:16
-
-
Save rpuggal/49f87733242b24026874cc0d5162ea91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import ITIM Packages | |
//importPackage(com.ibm.itim.apps); | |
//importPackage(java.util); | |
function getContext() | |
{ | |
system.setJavaProperty("java.security.auth.login.config", "C:/ibm/jaas_login_was.conf"); | |
system.setJavaProperty("com.ibm.CORBA.ConfigURL", "file:C:/IBM/sas.client.props"); | |
//system.setJavaProperty("com.ibm.CORBA.securityServerHost", "xx.xx.xx"); | |
//system.setJavaProperty("com.ibm.CORBA.securityServerPort", "9067"); | |
system.setJavaProperty("com.ibm.SSL.ConfigURL", "file:C:/IBM/ssl.client.props"); | |
//system.setJavaProperty("jdk.tls.client.protocols","TLSv1,TLSv1.1,TLSv1.2") | |
// THESE 4 FIELDS ARE REQUIRED TO GET PLATFORM CONTEXT | |
var appServerURL = "corbaloc:iiop:xx.xx.xx.xx:9067"; | |
var platformContextFactory = "com.ibm.itim.apps.impl.websphere.WebSpherePlatformContextFactory"; | |
var ejbUser = "isimsystem@itimCustomRealm"; | |
var ejbPwd = "=="; | |
//var ejbUser = "itim manager"; | |
//var ejbPwd = "xxxxx"; | |
var itimRealm = "itimCustomRealm"; | |
var env = new java.util.Hashtable(); | |
task.logmsg(appServerURL); | |
//var env = new Hashtable(); | |
//task.logmsg(Packages.com.ibm.itim.apps.InitialPlatformContext.CONTEXT_FACTORY); | |
//task.logmsg(com.ibm.itim.apps.InitialPlatformContext.CONTEXT_FACTORY); | |
env.put(Packages.com.ibm.itim.apps.InitialPlatformContext.CONTEXT_FACTORY, platformContextFactory); | |
env.put(Packages.com.ibm.itim.apps.InitialPlatformContext.PLATFORM_URL, appServerURL); | |
env.put(Packages.com.ibm.itim.apps.InitialPlatformContext.PLATFORM_PRINCIPAL, ejbUser); | |
env.put(Packages.com.ibm.itim.apps.InitialPlatformContext.PLATFORM_CREDENTIALS, ejbPwd); | |
env.put(Packages.com.ibm.itim.apps.InitialPlatformContext.PLATFORM_REALM, itimRealm); | |
var platform = null; | |
try | |
{ | |
platform = new com.ibm.itim.apps.InitialPlatformContext(env); | |
task.logmsg("Successfully got platform context"); | |
//task.logmsg(platform); | |
} | |
catch(e) | |
{ | |
task.logmsg("Error Class: " + e.getClass()); | |
task.logmsg("Error Message: " + e.getMessage()); | |
task.logmsg("Error LocalizedMessage: " + e.getLocalizedMessage()); | |
var stack = e.getStackTrace(); | |
var i = 0; | |
for(i = 0; i < stack.length; i++) { | |
task.logmsg(stack[i].toString()); | |
} | |
} | |
return platform; | |
} | |
function getSubject() | |
{ | |
var itimUser = "itim manager"; | |
var itimPwd = "xxxxxxx"; | |
//var handler = Packages.com.ibm.websphere.security.auth.callback.WSCallbackHandlerImpl(itimUser, "itimCustomRealm", itimPwd); | |
var handler = com.ibm.websphere.security.auth.callback.WSCallbackHandlerImpl(itimUser, "itimCustomRealm", itimPwd); | |
//task.logmsg(handler); | |
var loginContext = javax.security.auth.login.LoginContext("WSLogin", handler); | |
//task.logmsg(loginContext); | |
try | |
{ | |
loginContext.login(); | |
task.logmsg("Logged in"); | |
} | |
catch(e) | |
{ | |
task.logmsg("Error Class: " + e.getClass()); | |
task.logmsg("Error Message: " + e.getMessage()); | |
task.logmsg("Error LocalizedMessage: " + e.getLocalizedMessage()); | |
var stack = e.getStackTrace(); | |
var i = 0; | |
for(i = 0; i < stack.length; i++) { | |
task.logmsg(stack[i].toString()); | |
} | |
} | |
return loginContext.getSubject(); | |
} | |
var itimPlatform = getContext(); | |
var subject = getSubject(); | |
task.logmsg("subject "+subject); | |
var empDN = new com.ibm.itim.dataservices.model.DistinguishedName("erglobalid=00000000000000000007,ou=0,ou=people,erglobalid=00000000000000000000,ou=TCP,DC=COM"); | |
task.logmsg("loginContext: "+itimPlatform.toString() + " - " + subject); | |
var employeeMO = new com.ibm.itim.apps.identity.PersonMO(itimPlatform,subject,empDN); | |
task.logmsg("got here 1 "+employeeMO); | |
try { | |
var emp = employeeMO.getData(); | |
} | |
catch(e) | |
{ | |
task.logmsg("Error Class: " + e.getClass()); | |
task.logmsg("Error Message: " + e.getMessage()); | |
task.logmsg("Error LocalizedMessage: " + e.getLocalizedMessage()); | |
var stack = e.getStackTrace(); | |
var i = 0; | |
for(i = 0; i < stack.length; i++) { | |
task.logmsg(stack[i].toString()); | |
} | |
} | |
//task.logmsg(emp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment