/** * Create a session with the given credentials. * Caller must log out the returned session after use. */ public Session createSession(Credentials credentials) throws LoginException, RepositoryException { // since the backing systemSession can be shared by different RepositoryJobExecutionContext's and there can // be multiple threads involved, we need to synchronize on systemSession during impersonation synchronized (systemSession) { return systemSession.impersonate(credentials); } }
@Override public void runTest() throws RepositoryException { for (int i = 0; i < COUNT; i++) { admin.impersonate(creds).logout(); } } }
/** * Forwards the method call to the underlying session. The returned * session is wrapped into a session decorator using the decorator factory. * * @return decorated session */ public Session impersonate(Credentials credentials) throws LoginException, RepositoryException { Session newSession = session.impersonate(credentials); return factory.getSessionDecorator(repository, newSession); }
@Override public Session impersonate(Credentials credentials) throws LoginException, RepositoryException { Session newSession = session.impersonate(credentials); return DecoratorFactoryImpl.getSessionDecorator(newSession, credentials); }
@Override public Session impersonate(Credentials credentials) throws RepositoryException { Session impersonateDelegate = delegate.impersonate(credentials); return SessionFacade.findBestWrapper(impersonateDelegate, true); }
@Override public Session impersonate(Credentials credentials) throws LoginException, RepositoryException { return getWrappedSession().impersonate(credentials); }
@Override public Session impersonate( Credentials c ) throws LoginException, RepositoryException { return session().impersonate(c); }
public Session createImpersonatedSession() throws RepositoryException { final Session session = node.getSession(); return session.impersonate(new SimpleCredentials(session.getUserID(), new char[]{})); }
@Override default Session impersonate(final Credentials credentials) throws LoginException, RepositoryException { return wrapSession(unwrapSession().impersonate(credentials)); }
public WorkflowManagerImpl(Session session) throws RepositoryException { this.userSession = session; SimpleCredentials workflowuser = new SimpleCredentials("workflowuser", new char[]{}); workflowuser.setAttribute(NO_SYSTEM_IMPERSONATION, Boolean.TRUE); this.workflowSession = session.impersonate(workflowuser); ((HippoSession)workflowSession).disableVirtualLayers(); configurationId = session.getRootNode().getNode(CONFIGURATION_PATH + "/" + WORKFLOWS_PATH).getIdentifier(); workflowLogger = new WorkflowLogger(workflowSession); }
/** {@inheritDoc} */ public RemoteSession impersonate(Credentials credentials) throws RepositoryException, RemoteException { try { Session newSession = session.impersonate(credentials); return getFactory().getRemoteSession(newSession); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
@Override public Session login() throws RepositoryException { final SimpleCredentials credentials = new SimpleCredentials("system", new char[]{}); return DecoratorFactoryImpl.getSessionDecorator(repositoryImpl.getRootSession(workspaceName).impersonate(credentials), credentials); }
protected ConfigurationServiceImpl initializeConfiguration(final Session rootSession) throws RepositoryException { log.info("LocalHippoRepository initialize configuration"); final SimpleCredentials credentials = new SimpleCredentials("system", new char[]{}); final Session configurationServiceSession = DecoratorFactoryImpl.getSessionDecorator(rootSession.impersonate(credentials), credentials); migrateToV12IfNeeded(configurationServiceSession, false); return new ConfigurationServiceImpl().start(configurationServiceSession,() -> start(rootSession)); }
protected void start(final Session rootSession) throws RepositoryException { jackrabbitRepository.enableVirtualLayer(true); moduleManager = new ModuleManager(rootSession.impersonate(new SimpleCredentials("system", new char[]{}))); moduleManager.start(); nodeTypesChangeTracker = new NodeTypesChangeTracker(rootSession.impersonate(new SimpleCredentials("system", new char[]{}))); nodeTypesChangeTracker.start(); ((HippoSecurityManager) jackrabbitRepository.getSecurityManager()).configure(); }
/** * {@inheritDoc} */ public SessionInfo impersonate(SessionInfo sessionInfo, Credentials credentials) throws LoginException, RepositoryException { Credentials duplicate = SessionInfoImpl.duplicateCredentials(credentials); SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo); return new SessionInfoImpl(sInfo.getSession().impersonate(credentials), duplicate, getNameFactory(), getPathFactory()); }
/** * {@inheritDoc} */ public SessionInfo impersonate(SessionInfo sessionInfo, Credentials credentials) throws LoginException, RepositoryException { Credentials duplicate = SessionInfoImpl.duplicateCredentials(credentials); SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo); return new SessionInfoImpl(sInfo.getSession().impersonate(credentials), duplicate, getNameFactory(), getPathFactory()); }
@Test public void testImpersonateDisabledUser() throws Exception { user.disable("readonly user is disabled!"); superuser.save(); // -> impersonating this user must fail try { Session ss = superuser.impersonate(new SimpleCredentials(user.getID(), new char[0])); ss.logout(); fail("A disabled user cannot be impersonated any more."); } catch (LoginException e) { // success } }
public void testAdminCanImpersonateEveryone() throws RepositoryException { // EXERCISE: walk through this impersonation. does it work? if it does: why? Session impersonated = superuser.impersonate(new SimpleCredentials(anotherUser.getID(), new char[0])); sessionList.add(impersonated); assertEquals(anotherUser.getID(), impersonated.getUserID()); }
public void testImpersonateTestUser() throws RepositoryException { Principal principal = null; // EXERCISE: fill in the correct principal such that the test passes. Impersonation impersonation = anotherUser.getImpersonation(); impersonation.grantImpersonation(principal); superuser.save(); Session testSession = superuser.getRepository().login(ExerciseUtility.getTestCredentials(testUser.getID())); sessionList.add(testSession); Session impersonated = testSession.impersonate(new SimpleCredentials(anotherUser.getID(), new char[0])); sessionList.add(impersonated); assertEquals(anotherUser.getID(), impersonated.getUserID()); }
public void testImpersonateOneSelf() throws RepositoryException { // EXERCISE: walk through this impersonation. does it work? if it does: why? Session testSession = superuser.getRepository().login(ExerciseUtility.getTestCredentials(testUser.getID())); sessionList.add(testSession); Session impersonated = testSession.impersonate(new SimpleCredentials(testUser.getID(), new char[0])); sessionList.add(impersonated); assertEquals(testUser.getID(), impersonated.getUserID()); }