Retrieve username and password of the current modifier of WI
3 answers
Let me explain.
By user/modifier I mean, for example the person who would open a work item and change the state from 'New' to 'In Progress'. I want to retrieve the username and password of this user, that is whoever is modifying and saving the work item during the current execution of code(BuildOnStateChangeParticipant.java).
Please let me know if I am not clear.
Thanks!
Comments
you can get the userid, not the password.
And the user ID of the user in which context a server extension such as a Participant runs can be retrieved using this.getAuthenticatedContributor().
Amd Sam is right, you can't get the password that way. If you could, this would be a huge security breach.
Another thought, what is the use case? You should try to use the tools out of the box and not create too much own code. You can do it, sometimes there is no way around it, but if you create too much extension code, it becomes very expensive. So try not to, unless there is a business reason, which means you save more money later than spending the money on development and maintenance of the code.
And as a last thought, you could also use the feeds to listen to who changed the work items. This would also not require to extend RTC, you would use an external feed reader to get and process the events.
Thank you Ralph and Sam for replying. The use case is that, the build.xml I use has scripts that run in AFS. Hence I am using the AFS username and password as RTC credentials and I am trying to retrieve it from the code and then pass it to build.xml, where I can login to AFS and run my scripts. I don't want to hard code the username and password in the ant task(rexec) that I am using, hence I am trying to retrieve the UID and password from the code and pass it to build.xml.
Ralph, I used this.getAuthenticatedContributor(), but this object does not have methods that would give the name of the modifier, for example ADMIN or ananya
Thanks for your help,
Ananya
this.getAuthenticatedContributor() returns the contributor that is performing the Participant, which is the person modifying. You can also access the work item *s attribute workItem.getModifiedBy().
All return an IContributor or IContributorHandle. Search in my blog how to get the contributor object from that to get more data.
You won't however be able to get the password. I doubt RTC knows it. That is known on a lower level in LDAP or Tomcat. I am sure you can not access it. That is why the JBE uses a technical user to do all the build and only adds the requestor as contributor.
IContributor authenticatedContributor = (IContributor)(getService(IRepositoryItemService.class).fetchItem(getAuthenticatedContributor(), null));
authenticatedContributor.getUserId();
Thanks,
Ananya
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Dec 07 '12, 5:15 a.m.It is unclear what you want to do and why, please be more specific.