/** * @see org.modeshape.jcr.security.SecurityContext#getUserName() */ @Override public String getUserName() { return delegate.getUserName(); }
/** * Gets principal instance for the given name. This method uses feature of the security context to discover known principals. * * @param name the name of the principal. * @return principal instance. */ private Principal principal( String name ) { return SimplePrincipal.newInstance(name); } }
/** * Creates new instance of the principal. * * @param name the name of the user. * @return new user name principal. */ public static SimplePrincipal newInstance(String name) { return new SimplePrincipal(name); }
@Override public void logout() { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Logging out security context...."); } authenticationManager.logout(SimplePrincipal.newInstance(jaasSecurityContext.getUserName()), null); jaasSecurityContext.logout(); } }
/** * @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#logout() */ @Override public void logout() { delegate.logout(); }
/** * @see org.modeshape.jcr.security.SecurityContext#isAnonymous() */ @Override public boolean isAnonymous() { return delegate.isAnonymous(); }
/** * Creates a new anonymous provider. * * @param anonymousUsername the anonymous user name * @param userRoles the set of roles for the anonymous user */ public AnonymousProvider( final String anonymousUsername, final Set<String> userRoles ) { CheckArg.isNotEmpty(anonymousUsername, "anonymousUsername"); CheckArg.isNotNull(userRoles, "userRoles"); this.anonymousContext = new AnonymousSecurityContext(userRoles, anonymousUsername); }
@Test public void shouldAllowSetPolicy() throws RepositoryException { setPolicy("/Cars/Utility/Ford F-150", Privilege.JCR_ALL); }
@Override public boolean hasRole( String roleName ) { return jaasSecurityContext.hasRole(roleName); }
@Override protected RepositoryService environment() { return (RepositoryService)super.environment(); }
@Override public boolean isAnonymous() { return jaasSecurityContext.isAnonymous(); }
@Override public String getUserName() { return jaasSecurityContext.getUserName(); }
/** * Gets principal instance for the given name. This method uses feature of the security context to discover known principals. * * @param name the name of the principal. * @return principal instance. */ private Principal principal( String name ) { return SimplePrincipal.newInstance(name); } }
@Override public String getUserID() { return context.getSecurityContext().getUserName(); }
/** * 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); }
/** * Creates new instance of the principal. * * @param name the name of the user. * @return new user name principal. */ public static SimplePrincipal newInstance(String name) { return new SimplePrincipal(name); }
/** * Creates a new anonymous provider. * * @param anonymousUsername the anonymous user name * @param userRoles the set of roles for the anonymous user */ public AnonymousProvider( final String anonymousUsername, final Set<String> userRoles ) { CheckArg.isNotEmpty(anonymousUsername, "anonymousUsername"); CheckArg.isNotNull(userRoles, "userRoles"); this.anonymousContext = new AnonymousSecurityContext(userRoles, anonymousUsername); }
@Test public void shouldNotDependFromContentPermissions() throws Exception { setPolicy("/Cars/Luxury/Bentley Continental", Privilege.JCR_WRITE); }
@Override public Principal getUnknownPrincipal( Session session ) { return SimplePrincipal.newInstance("unknown"); }