@Override protected Root getWriteRoot() { return sessionDelegate.getContentSession().getLatestRoot(); } @Override
@Test(expected = IllegalStateException.class) public void throwOnClosedSession() throws LoginException, NoSuchWorkspaceException, IOException { ContentSession session = repository.login(null, null); session.close(); session.getLatestRoot(); }
private PermissionProvider createPermissionProvider(ContentSession session) { return config.getPermissionProvider(session.getLatestRoot(), session.getWorkspaceName(), session.getAuthInfo().getPrincipals()); }
@Override public ContentRemoteRevision readLastRevision() { Root root = contentSession.getLatestRoot(); String revisionId = contentRemoteRevisions.put(contentSession.getAuthInfo(), root); return new ContentRemoteRevision(revisionId, root); }
@Test public void testGuest() throws Exception { ContentSession cs = null; try { cs = login(new GuestCredentials()); assertEquals(UserConstants.DEFAULT_ANONYMOUS_ID, cs.getAuthInfo().getUserID()); } finally { if (cs != null) { cs.close(); } } }
@Override protected void afterSuite() throws Exception { super.afterSuite(); cs.close(); }
@Override public boolean init(@NotNull Session session, @NotNull Root root, @NotNull NamePathMapper namePathMapper, boolean isWorkspaceImport, int uuidBehavior, @NotNull ReferenceChangeTracker referenceTracker, @NotNull SecurityProvider securityProvider) { isSystemSession = root.getContentSession().getAuthInfo().getPrincipals().contains(SystemPrincipal.INSTANCE); return true; }
@NotNull public String getWorkspaceName() { return contentSession.getWorkspaceName(); }
private PermissionProvider getPermissionProvider(ContentSession session) { return getSecurityProvider() .getConfiguration(AuthorizationConfiguration.class) .getPermissionProvider(root, session.getWorkspaceName(), session.getAuthInfo().getPrincipals()); }
@Test public void testImpersonateSystemUser() throws Exception { createUser(null); ContentSession cs = login(new ImpersonationCredentials(new SimpleCredentials(uid, new char[0]), adminSession.getAuthInfo())); cs.close(); }
@Override public void after() throws Exception { try { if (systemSession != null) { systemSession.close(); } } finally { super.after(); } }
private static <T> void logOperationDetails(ContentSession session, SessionOperation<T> ops) { if (readOperationLogger.isTraceEnabled() || writeOperationLogger.isTraceEnabled() || auditLogger.isDebugEnabled()) { Logger log = ops.isUpdate() ? writeOperationLogger : readOperationLogger; log.trace("[{}] {}", session, ops); //For a logout operation the auth info is not accessible if (!ops.isLogout() && !ops.isRefresh() && !ops.isSave() && ops.isUpdate()) { auditLogger.debug("[{}] [{}] {}", session.getAuthInfo().getUserID(), session, ops); } } }
private Delegatee(@NotNull SyncHandler handler, @NotNull ExternalIdentityProvider idp, @NotNull ContentSession systemSession, @NotNull SecurityProvider securityProvider, int batchSize) { this.handler = handler; this.idp = idp; this.systemSession = systemSession; this.batchSize = batchSize; root = systemSession.getLatestRoot(); userMgr = securityProvider.getConfiguration(UserConfiguration.class).getUserManager(root, NamePathMapper.DEFAULT); context = handler.createContext(idp, userMgr, new ValueFactoryImpl(root, NamePathMapper.DEFAULT)); log.info("Created delegatee for SyncMBean with session: {} {}", systemSession, systemSession.getAuthInfo().getUserID()); }
@Override protected PermissionProvider createValue() { return getAcConfig().getPermissionProvider( MutableRoot.this, getContentSession().getWorkspaceName(), subject.getPrincipals()); } };
private PermissionProvider getPermissionProvider(ContentSession session) { return getSecurityProvider() .getConfiguration(AuthorizationConfiguration.class) .getPermissionProvider(root, session.getWorkspaceName(), session.getAuthInfo().getPrincipals()); }
@Override protected Root getWriteRoot() { return sessionDelegate.getContentSession().getLatestRoot(); } @Override
@Test(expected = IllegalStateException.class) public void throwOnClosedRoot() throws LoginException, NoSuchWorkspaceException, IOException { ContentSession session = repository.login(null, null); Root root = session.getLatestRoot(); session.close(); root.getTree("/"); }
private TreePermission getTreePermission(String path) throws Exception { ContentSession testSession = createTestSession(); PermissionProvider pp = config.getPermissionProvider(testSession.getLatestRoot(), testSession.getWorkspaceName(), testSession.getAuthInfo().getPrincipals()); return pp.getTreePermission(root.getTree(path), TreePermission.EMPTY); }
@Test public void testNullLogin() throws Exception { ContentSession cs = login(null); try { AuthInfo authInfo = cs.getAuthInfo(); String anonymousID = UserUtil.getAnonymousId(getUserConfiguration().getParameters()); assertEquals(anonymousID, authInfo.getUserID()); } finally { cs.close(); } }
@After public void close() throws Exception { session.close(); executorService.shutdown(); executorService.awaitTermination(1, TimeUnit.SECONDS); }