There are many occasions I need to xog in custom or OOB object using GEL script and if you use static username and password you need to keep maintain script to change password when security policy force you to change it.
There can be also situation where you want to xog in object using user who kicked off process, in that case you can get username based on process instance id and get his/her session ID without knowing his password.
Following is the code snippet to get session ID from clarity for given user without knowing password.
<!-- Start - Generate XOG Session ID using the XOG_UserName parameter supplied -->
<core:new className="com.niku.union.security.DefaultSecurityIdentifier" var="secId"/>
<core:invokeStatic className="com.niku.union.security.UserSessionControllerFactory" method="getInstance" var="userSessionCtrl"/>
<core:set value="${userSessionCtrl.init(XOG_UserName, secId)}" var="secId"/>
<core:set value="${secId.getUserName()}" var="XOGUsername"/>
<core:set value="${secId.getPWD()}" var="XOGPassword"/>
<core:set value="${secId.getSessionId()}" var="sessionID"/>
<gel:log category="XOG" level="INFO">Username for XOG set - ${XOGUsername}</gel:log>
<core:choose>
<core:when test="${XOGPassword == null}">
<gel:log category="XOG" level="WARN">Password not found for ${XOG_UserName}</gel:log>
</core:when>
<core:otherwise>
<gel:log category="XOG" level="INFO">[Encrypted Password Located for ${XOG_UserName}]</gel:log>
</core:otherwise>
</core:choose>
<gel:log category="XOG" level="INFO">Session ID set - ${sessionID}</gel:log>
<!-- End - Generate XOG Session ID using the XOG_UserName parameter supplied -->