How do I add user in JIRA 4.3.3 using com.opensymphony.user.UserManager

Vikas Khengare June 6, 2011

Hi,

I am using old plugin which is designed for JIRA 3.13.1 to create users. Now I have made some API changes to work it in JIRA 4.3.3.

According to 4.3.3 docs, http://confluence.atlassian.com/display/JIRA043/JIRA+4.3+Upgrade+Guide#JIRA4.3UpgradeGuide-com.opensymphony.user.UserManagerisdeprecated but still I am continuing with com.opensymphony.user.UserManager to create new users for JIRA.

I am using com.opensymphony.user.UserManager class to create user but not able to do so. It is throwing 2 errors

user.provider.crowd.EmbeddedCrowdCredentialsProvider] Error creating user : validUserName : com.atlassian.crowd.exception.InvalidCredentialException: You cannot have an empty password
com.atlassian.crowd.exception.InvalidCredentialException: You cannot have an empty password
at com.atlassian.crowd.directory.InternalDirectoryUtilsImpl.validateCredential(InternalDirectoryUtilsImpl.java:42)
at com.atlassian.crowd.directory.InternalDirectory.prepareUserCredentialForAdd(InternalDirectory.java:123)
at com.atlassian.crowd.directory.InternalDirectory.addUser(InternalDirectory.java:79)
at com.atlassian.crowd.directory.DelegatedAuthenticationDirectory.addUser(DelegatedAuthenticationDirectory.java:242)
at com.atlassian.crowd.manager.directory.DirectoryManagerGeneric.addUser(DirectoryManagerGeneric.java:309)
at com.atlassian.crowd.manager.application.ApplicationServiceGeneric.addUser(ApplicationServiceGeneric.java:356)
at com.atlassian.crowd.embedded.core.CrowdServiceImpl.addUser(CrowdServiceImpl.java:293)
at com.atlassian.crowd.embedded.core.DelegatingCrowdService.addUser(DelegatingCrowdService.java:85)
at com.atlassian.crowd.embedded.core.FilteredCrowdServiceImpl.addUser(FilteredCrowdServiceImpl.java:43)
at com.opensymphony.user.provider.crowd.EmbeddedCrowdCredentialsProvider.create(EmbeddedCrowdCredentialsProvider.java:74)
at com.opensymphony.user.UserManager.createEntity(UserManager.java:346)
at com.opensymphony.user.UserManager.createUser(UserManager.java:245)

com.opensymphony.user.ImmutableException: No provider successfully created entity rutushah
at com.opensymphony.user.UserManager.createEntity(UserManager.java:353)
at com.opensymphony.user.UserManager.createUser(UserManager.java:245)

HELP: What could be the reason for above errors?

Thank you

4 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
brainicorn
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 15, 2011

In JIRA 4.3 we now use embedded Crowd for user management. For the most part it's binary compatible with the old OSUser API, meaning you can still use the OSUser User objects if you must. However, since the user management is now backed by embedded Crowd which requires a valid username and password to create a user, the OS UserManager probably won't work for creating users since it doesn't allow you to pass in the passowrd.

Basically the error you're getting is Crowd complaining about an empty password when you try to create a user.

The best thinbg to do at this point is to refactor the code for user creation to use the com.atlassian.jira.user.util.UserUtil class.

User newUser = userUtil.createUserNoNotification(username, password, email, displayName);

Other parts of the old UserManager may still work if you're just useing it to retrieve users, but I'd say since you have to refactor for creation, it's probably best to just refactor all of the user stuff at once. I've gone through this exercise with a few plugins and it's really not that bad since the new API kepps a lot of the same classnames/method names.

0 votes
Vikas Khengare June 15, 2011
Hi Jonathan, Thanks for your reply. My plugin is totally depends on com.opensymphony for User Management Operations. I thought instead of changing whole code lets change only few parts of it to make it work in 4.3.3 because of time constriants. For long term, I should use UserService API provided by JIRA itself. So is there any way to resolve this issue? Programmatically or by settings?
0 votes
Vikas Khengare June 15, 2011

Hi Jonathan,

Thanks for your reply.

My plugin is totally depends on com.opensymphony for User Management Operations. I thought instead of changing whole code lets change only few parts of it to make it work in 4.3.3 because of time constriants.

For long term, I should use UserService API provided by JIRA itself.

So is there any way to resolve this issue? Programmatically or by settings?

0 votes
brainicorn
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 13, 2011
If you're making changes, why are you sticking with the old user manager?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events