Created
April 25, 2016 01:15
-
-
Save fjunior87/1366b08f60983026b4bb4957962f45d2 to your computer and use it in GitHub Desktop.
Example of Sling/JackRabbit SystemUser Creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void createSystemUser(BundleContext bundleContext) { | |
ServiceReference SlingRepositoryFactoryReference = bundleContext.getServiceReference(SlingRepository.class.getName()); | |
SlingRepository repository = (SlingRepository)bundleContext.getService(SlingRepositoryFactoryReference); | |
Session session = null; | |
try { | |
session = repository.loginAdministrative(null); | |
UserManager usrMgr = ((JackrabbitSession)session).getUserManager(); | |
usrMgr.createSystemUser("usersSystemUser", null); | |
} catch (RepositoryException e) { | |
LOGGER.error("Error while creating user", e); | |
} finally { | |
if(session != null && session.isLive()) { | |
session.logout(); | |
session = null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment