0
votes

I'm busy setting up an oak repository. Everything works fine when I use the default admin user, but when I try to use the UserManager to set up new accounts I either get a login failure exception, or using an alternate repository setup, I can create the user, but when I log in using that user, session.getUserID returns null.

Method 1, yields loginException:

Map<String, Object> userParams = getSecurityProviderUserParams();
ConfigurationParameters config =  ConfigurationParameters.of(ImmutableMap.of(UserConfiguration.NAME, ConfigurationParameters.of(userParams)));        
SecurityProvider sp = new SecurityProviderImpl(config);
uc = new UserConfigurationImpl(sp);
ConfigurationParameters cp = uc.getParameters();

QueryEngineSettings qes = new QueryEngineSettings();
QueryIndexProvider qip = new ReferenceIndexProvider();
contentRepository = new ContentRepositoryImpl(ns, new CommitRateLimiter(), "csmp", qes, qip, sp);
contentSession = contentRepository.login(new SimpleCredentials("admin", "admin".toCharArray()), null);
Root localRoot = contentSession.getLatestRoot();
um = uc.getUserManager(localRoot, NamePathMapper.DEFAULT);
um.createUser("boswelrp", "testpass");
repo = new Jcr(new Oak(ns)).createRepository();

And to log in I use:

oakRepo.login(username, password);

The application is already secured, so all I really want to accomplish is to log in with a user account so the createdBy/modifiedBy fields can be auto populated.

1
This question is too broad.Jørgen R
Thanks, hopefully my intention is a bit clearer.raymondboswel

1 Answers

2
votes

As luck would have it, I just found the answer in the oak mailing list.

session = repo.login(new SimpleCredentials("admin", "admin".toCharArray()));

if(session instanceof JackrabbitSession)
{
     UserManager um = ((JackrabbitSession) session).getUserManager();
}