/** * @see org.modeshape.jcr.security.SecurityContext#getUserName() */ @Override public String getUserName() { return delegate.getUserName(); }
/** * @see org.modeshape.jcr.security.SecurityContext#hasRole(java.lang.String) */ @Override public boolean hasRole(String roleName) { return delegate.hasRole(roleName); }
/** * @see org.modeshape.jcr.security.SecurityContext#isAnonymous() */ @Override public boolean isAnonymous() { return delegate.isAnonymous(); }
/** * Lists all privileges defined by this access list for the given user. * * @param context the security context of the user; never null * @return list of privilege objects. */ public Privilege[] getPrivileges( SecurityContext context ) { ArrayList<Privilege> privs = new ArrayList<Privilege>(); for (AccessControlEntryImpl ace : principals.values()) { // add privileges granted for everyone if (ace.getPrincipal().equals(SimplePrincipal.EVERYONE)) { privs.addAll(Arrays.asList(ace.getPrivileges())); } // add privileges granted for given user if (ace.getPrincipal().getName().equals(username(context.getUserName()))) { privs.addAll(Arrays.asList(ace.getPrivileges())); } // add privileges granted for given role if (context.hasRole(ace.getPrincipal().getName())) { privs.addAll(Arrays.asList(ace.getPrivileges())); } } Privilege[] res = new Privilege[privs.size()]; privs.toArray(res); return res; }
/** * @see org.modeshape.jcr.security.SecurityContext#logout() */ @Override public void logout() { delegate.logout(); }
/** * Lists all privileges defined by this access list for the given user. * * @param context the security context of the user; never null * @return list of privilege objects. */ public Privilege[] getPrivileges( SecurityContext context ) { ArrayList<Privilege> privs = new ArrayList<Privilege>(); for (AccessControlEntryImpl ace : principals.values()) { // add privileges granted for everyone if (ace.getPrincipal().equals(SimplePrincipal.EVERYONE)) { privs.addAll(Arrays.asList(ace.getPrivileges())); } // add privileges granted for given user if (ace.getPrincipal().getName().equals(username(context.getUserName()))) { privs.addAll(Arrays.asList(ace.getPrivileges())); } // add privileges granted for given role if (context.hasRole(ace.getPrincipal().getName())) { privs.addAll(Arrays.asList(ace.getPrivileges())); } } Privilege[] res = new Privilege[privs.size()]; privs.toArray(res); return res; }
/** * 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(); }
@Override public String getUserID() { return context.getSecurityContext().getUserName(); }
if (ace.getPrincipal().getName().equals(username(sc.getUserName()))) { if (ace.hasPrivileges(privileges)) { return true; if (sc.hasRole(ace.getPrincipal().getName())) { if (ace.hasPrivileges(privileges)) { return true;
/** * 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(); }
/** * Returns whether the authenticated user has the given role. * * @param context the security context * @param roleName the name of the role to check * @param repositoryName the name of the repository * @param workspaceName the workspace under which the user must have the role. This may be different from the current * workspace. * @return true if the user has the role and is logged in; false otherwise */ static boolean hasRole( SecurityContext context, String roleName, String repositoryName, String workspaceName ) { if (context.hasRole(roleName)) return true; roleName = roleName + "." + repositoryName; if (context.hasRole(roleName)) return true; roleName = roleName + "." + workspaceName; return context.hasRole(roleName); }
public boolean isAnonymous() { return context.getSecurityContext().isAnonymous(); }
@Override public String getUserID() { return context.getSecurityContext().getUserName(); }
if (ace.getPrincipal().getName().equals(username(sc.getUserName()))) { if (ace.hasPrivileges(privileges)) { return true; if (sc.hasRole(ace.getPrincipal().getName())) { if (ace.hasPrivileges(privileges)) { return true;
/** * Returns whether the authenticated user has the given role. * * @param context the security context * @param roleName the name of the role to check * @param repositoryName the name of the repository * @param workspaceName the workspace under which the user must have the role. This may be different from the current * workspace. * @return true if the user has the role and is logged in; false otherwise */ static boolean hasRole( SecurityContext context, String roleName, String repositoryName, String workspaceName ) { if (context.hasRole(roleName)) return true; roleName = roleName + "." + repositoryName; if (context.hasRole(roleName)) return true; roleName = roleName + "." + workspaceName; return context.hasRole(roleName); }
public boolean isAnonymous() { return context.getSecurityContext().isAnonymous(); }
@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(); }
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(); }