@Override public String toString() { StringBuilder sb = new StringBuilder("Execution context for "); if (getSecurityContext() == null) sb.append("null"); else sb.append(getSecurityContext().getUserName()); sb.append(" (").append(id).append(')'); return sb.toString(); }
@Override public String toString() { StringBuilder sb = new StringBuilder("Execution context for "); if (getSecurityContext() == null) sb.append("null"); else sb.append(getSecurityContext().getUserName()); sb.append(" (").append(id).append(')'); return sb.toString(); }
@Override public String getUserID() { return context.getSecurityContext().getUserName(); }
@Override public String getUserID() { return context.getSecurityContext().getUserName(); }
private SecurityContext securityContext() { return session.context().getSecurityContext(); }
public boolean isAnonymous() { return context.getSecurityContext().isAnonymous(); }
private SecurityContext securityContext() { return session.context().getSecurityContext(); }
public boolean isAnonymous() { return context.getSecurityContext().isAnonymous(); }
/** * @see org.modeshape.jcr.security.JaasProvider#authenticate(javax.jcr.Credentials, java.lang.String, java.lang.String, org.modeshape.jcr.ExecutionContext, java.util.Map) */ @Override public ExecutionContext authenticate(Credentials credentials, String repositoryName, String workspaceName, ExecutionContext repositoryContext, Map<String, Object> sessionAttributes) { ExecutionContext ctx = super.authenticate(credentials, repositoryName, workspaceName, repositoryContext, sessionAttributes); if (ctx != null) { return repositoryContext.with(new SrampSecurityContext(ctx.getSecurityContext())); } return ctx; }
protected BasicSaveContext( ExecutionContext context ) { this.now = context.getValueFactories().getDateFactory().create(); this.userId = context.getSecurityContext().getUserName(); }
protected BasicSaveContext( ExecutionContext context ) { this.now = context.getValueFactories().getDateFactory().create(); this.userId = context.getSecurityContext().getUserName(); }
protected final void logChangesBeingSaved(Iterable<NodeKey> firstNodesInOrder, Iterable<NodeKey> secondNodesInOrder) { if (SAVE_LOGGER.isTraceEnabled()) { String txn = txns.currentTransactionId(); // // Determine if there are any changes to be made. Note that this number is generally between 1 and 100, // // though for high concurrency some numbers may go above 100. However, the 100th save will always reset // // the counter back down to 1. (Any thread that got a save number above 100 will simply use it.) final int s = SAVE_NUMBER.getAndIncrement(); if (s == MAX_SAVE_NUMBER) SAVE_NUMBER.set(1); // only the 100th final AtomicInteger changes = new AtomicInteger(0); // There are at least some changes ... ExecutionContext context = getContext(); String id = context.getId(); String username = context.getSecurityContext().getUserName(); NamespaceRegistry registry = context.getNamespaceRegistry(); if (username == null) username = "<anonymous>"; SAVE_LOGGER.trace("Save #{0} (part of transaction '{1}') by session {2}({3}) is persisting the following changes:", s, txn, username, id); UnionIterator<NodeKey> unionIterator = new UnionIterator<>(firstNodesInOrder.iterator(), secondNodesInOrder); unionIterator.forEachRemaining(key -> { SessionNode node = changedNodes.get(key); if (node != null && node.hasChanges()) { SAVE_LOGGER.trace(" #{0} {1}", s, node.getString(registry)); changes.incrementAndGet(); } }); SAVE_LOGGER.trace("Save #{0} (part of transaction '{1}') by session {2}({3}) completed persisting changes to {4} nodes", s, txn, username, id, changes.get()); } }
protected final void logChangesBeingSaved(Iterable<NodeKey> firstNodesInOrder, Iterable<NodeKey> secondNodesInOrder) { if (SAVE_LOGGER.isTraceEnabled()) { String txn = txns.currentTransactionId(); // // Determine if there are any changes to be made. Note that this number is generally between 1 and 100, // // though for high concurrency some numbers may go above 100. However, the 100th save will always reset // // the counter back down to 1. (Any thread that got a save number above 100 will simply use it.) final int s = SAVE_NUMBER.getAndIncrement(); if (s == MAX_SAVE_NUMBER) SAVE_NUMBER.set(1); // only the 100th final AtomicInteger changes = new AtomicInteger(0); // There are at least some changes ... ExecutionContext context = getContext(); String id = context.getId(); String username = context.getSecurityContext().getUserName(); NamespaceRegistry registry = context.getNamespaceRegistry(); if (username == null) username = "<anonymous>"; SAVE_LOGGER.trace("Save #{0} (part of transaction '{1}') by session {2}({3}) is persisting the following changes:", s, txn, username, id); UnionIterator<NodeKey> unionIterator = new UnionIterator<>(firstNodesInOrder.iterator(), secondNodesInOrder); unionIterator.forEachRemaining(key -> { SessionNode node = changedNodes.get(key); if (node != null && node.hasChanges()) { SAVE_LOGGER.trace(" #{0} {1}", s, node.getString(registry)); changes.incrementAndGet(); } }); SAVE_LOGGER.trace("Save #{0} (part of transaction '{1}') by session {2}({3}) completed persisting changes to {4} nodes", s, txn, username, id, changes.get()); } }
private void assertPermissionsCheckedWhenIteratingChildren() throws RepositoryException { session = repository.login(); Node testRoot = session.getNode("/testRoot"); NodeIterator children = testRoot.getNodes(); while (children.hasNext()) { children.nextNode(); } TestSecurityProvider provider = (TestSecurityProvider) session.context().getSecurityContext(); Map<String, String> actionsByNodePath = provider.getActionsByNodePath(); assertTrue("READ permission not checked for node", actionsByNodePath.containsKey("/testRoot")); assertTrue("READ permission not checked for node", actionsByNodePath.containsKey("/testRoot/node3")); assertTrue("READ permission not checked for node", actionsByNodePath.containsKey("/testRoot/node2")); assertTrue("READ permission not checked for node", actionsByNodePath.containsKey("/testRoot/node1")); }
/** * This method is called by {@link #logout()} and by {@link JcrRepository#shutdown()}. It should not be called from anywhere * else. * * @param removeFromActiveSession true if the session should be removed from the active session list */ void terminate( boolean removeFromActiveSession ) { if (!isLive()) { return; } isLive = false; JcrObservationManager jcrObservationManager = observationManager(); if (jcrObservationManager != null) { jcrObservationManager.removeAllEventListeners(); } cleanLocks(); if (removeFromActiveSession) this.repository.runningState().removeSession(this); this.context.getSecurityContext().logout(); }
/** * This method is called by {@link #logout()} and by {@link JcrRepository#shutdown()}. It should not be called from anywhere * else. * * @param removeFromActiveSession true if the session should be removed from the active session list */ void terminate( boolean removeFromActiveSession ) { if (!isLive()) { return; } isLive = false; JcrObservationManager jcrObservationManager = observationManager(); if (jcrObservationManager != null) { jcrObservationManager.removeAllEventListeners(); } cleanLocks(); if (removeFromActiveSession) this.repository.runningState().removeSession(this); this.context.getSecurityContext().logout(); }
public final void setAccessControlEnabled( boolean enabled ) { if (this.accessControlEnabled.compareAndSet(!enabled, enabled)) { refreshRepositoryMetadata(true); // And notify the others ... String userId = context.getSecurityContext().getUserName(); Map<String, String> userData = context.getData(); DateTime timestamp = context.getValueFactories().getDateFactory().create(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null, repositoryEnvironment.journalId()); changes.repositoryMetadataChanged(); changes.freeze(userId, userData, timestamp); this.changeBus.notify(changes); } }
public final void setAccessControlEnabled( boolean enabled ) { if (this.accessControlEnabled.compareAndSet(!enabled, enabled)) { refreshRepositoryMetadata(true); // And notify the others ... String userId = context.getSecurityContext().getUserName(); Map<String, String> userData = context.getData(); DateTime timestamp = context.getValueFactories().getDateFactory().create(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null, repositoryEnvironment.journalId()); changes.repositoryMetadataChanged(); changes.freeze(userId, userData, timestamp); this.changeBus.notify(changes); } }
String userId = context.getSecurityContext().getUserName(); Map<String, String> userData = context.getData(); DateTime timestamp = context.getValueFactories().getDateFactory().create();
SecurityContext securityContext = context.getSecurityContext(); this.hasCustomAuthorizationProvider = securityContext instanceof AuthorizationProvider || securityContext instanceof AdvancedAuthorizationProvider;