org.modeshape.jcr.ExecutionContext.getSecurityContext()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(80)

本文整理了Java中org.modeshape.jcr.ExecutionContext.getSecurityContext()方法的一些代码示例,展示了ExecutionContext.getSecurityContext()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExecutionContext.getSecurityContext()方法的具体详情如下:
包路径:org.modeshape.jcr.ExecutionContext
类名称:ExecutionContext
方法名:getSecurityContext

ExecutionContext.getSecurityContext介绍

[英]Get the SecurityContext for this context.
[中]获取此上下文的SecurityContext。

代码示例

代码示例来源:origin: org.fcrepo/modeshape-jcr

@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();
}

代码示例来源:origin: ModeShape/modeshape

@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();
}

代码示例来源:origin: ModeShape/modeshape

@Override
public String getUserID() {
  return context.getSecurityContext().getUserName();
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

@Override
public String getUserID() {
  return context.getSecurityContext().getUserName();
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

private SecurityContext securityContext() {
  return session.context().getSecurityContext();
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

public boolean isAnonymous() {
  return context.getSecurityContext().isAnonymous();
}

代码示例来源:origin: ModeShape/modeshape

private SecurityContext securityContext() {
  return session.context().getSecurityContext();
}

代码示例来源:origin: ModeShape/modeshape

public boolean isAnonymous() {
  return context.getSecurityContext().isAnonymous();
}

代码示例来源:origin: org.overlord.sramp/s-ramp-repository-jcr-modeshape

/**
 * @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;
}

代码示例来源:origin: ModeShape/modeshape

protected BasicSaveContext( ExecutionContext context ) {
  this.now = context.getValueFactories().getDateFactory().create();
  this.userId = context.getSecurityContext().getUserName();
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

protected BasicSaveContext( ExecutionContext context ) {
  this.now = context.getValueFactories().getDateFactory().create();
  this.userId = context.getSecurityContext().getUserName();
}

代码示例来源:origin: ModeShape/modeshape

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());
  }
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

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());
  }
}

代码示例来源:origin: ModeShape/modeshape

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"));
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

/**
 * 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();
}

代码示例来源:origin: ModeShape/modeshape

/**
 * 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();
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

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);
  }
}

代码示例来源:origin: ModeShape/modeshape

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);
  }
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

String userId = context.getSecurityContext().getUserName();
Map<String, String> userData = context.getData();
DateTime timestamp = context.getValueFactories().getDateFactory().create();

代码示例来源:origin: ModeShape/modeshape

SecurityContext securityContext = context.getSecurityContext();
this.hasCustomAuthorizationProvider = securityContext instanceof AuthorizationProvider
                   || securityContext instanceof AdvancedAuthorizationProvider;

相关文章