It's all about the answers!

Ask a question

Retrieve username and password of the current modifier of WI


Ananya Joisa (4552124) | asked Dec 07 '12, 4:49 a.m.
Hi,

I am trying to retrieve and print the username and password of the user who has logged into RTC currently and is modifying the work item. Could someone please guide me on how to do this?

Thanks for your help!
Ananya

Comments
Ralph Schoon commented Dec 07 '12, 5:15 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

It is unclear what you want to do and why, please be more specific.

3 answers



permanent link
Ananya Joisa (4552124) | answered Dec 08 '12, 9:43 a.m.
Hi Ralph,

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
sam detweiler commented Dec 08 '12, 5:52 p.m.

you can get the userid, not the password.


Ralph Schoon commented Dec 09 '12, 4:51 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Ralph Schoon commented Dec 09 '12, 4:56 p.m. | edited Dec 09 '12, 4:56 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Ananya Joisa commented Dec 14 '12, 8:50 a.m.

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


Ralph Schoon commented Dec 14 '12, 9:07 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


permanent link
sam detweiler (12.5k6195201) | answered Dec 09 '12, 6:37 p.m.
watch out using feeds, these must be polled, and as such can have a detrimental impact on the system.

permanent link
Ananya Joisa (4552124) | answered Dec 21 '12, 4:54 a.m.
Thank you Ralph, for replying. I was able to get help to retrieve the userId. The following worked for me.

IContributor authenticatedContributor = (IContributor)(getService(IRepositoryItemService.class).fetchItem(getAuthenticatedContributor(), null));
        authenticatedContributor.getUserId();

Thanks,
Ananya

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.