/** * {@inheritDoc} * @see org.apache.sling.jcr.jackrabbit.server.impl.security.TrustedCredentials#getPrincipal(java.lang.String) */ @Override protected Principal getPrincipal(String userId) { return new AdminPrincipal(userId); }
public SessionImpl createAdminSession(String workspace) throws RepositoryException { Principal admin = new AdminPrincipal(SecurityConstants.ADMIN_ID); Subject subject = new Subject( true, Collections.singleton(admin), Collections.emptySet(), Collections.emptySet()); return context.getRepository().createSession(subject, workspace); }
public SessionImpl createAdminSession(String workspace) throws RepositoryException { Principal admin = new AdminPrincipal(SecurityConstants.ADMIN_ID); Subject subject = new Subject( true, Collections.singleton(admin), Collections.emptySet(), Collections.emptySet()); return context.getRepository().createSession(subject, workspace); }
private SimplePrincipalProvider() { if (adminID != null) { principals.put(adminID, new AdminPrincipal(adminID)); } if (anonymID != null) { principals.put(anonymID, new AnonymousPrincipal()); } EveryonePrincipal everyone = EveryonePrincipal.getInstance(); principals.put(everyone.getName(), everyone); }
private SimplePrincipalProvider() { if (adminID != null) { principals.put(adminID, new AdminPrincipal(adminID)); } if (anonymID != null) { principals.put(anonymID, new AnonymousPrincipal()); } EveryonePrincipal everyone = EveryonePrincipal.getInstance(); principals.put(everyone.getName(), everyone); }
/** * {@inheritDoc} */ @Override public void init( Properties options ) { adminId = options.getProperty( KEY_ADMIN_ID, SecurityConstants.ADMIN_ID ); adminPrincipal = new AdminPrincipal( adminId ); adminRole = options.getProperty( KEY_ADMIN_ROLE, SecurityConstants.ADMINISTRATORS_NAME ); adminRolePrincipal = new SpringSecurityRolePrincipal( adminRole ); anonymousId = options.getProperty( KEY_ANONYMOUS_ID, SecurityConstants.ANONYMOUS_ID ); principals.put( adminId, adminPrincipal ); principals.put( adminRole, adminRolePrincipal ); ArrayList<SpringSecurityRolePrincipal> assignedAdminRoles = new ArrayList<SpringSecurityRolePrincipal>(); assignedAdminRoles.add( adminRolePrincipal ); roleAssignments.put( adminId, assignedAdminRoles ); principals.put( anonymousId, anonymousPrincipal ); EveryonePrincipal everyone = EveryonePrincipal.getInstance(); principals.put( everyone.getName(), everyone ); }
adminPrincipal = new AdminPrincipal( adminId ); if ( logger.isTraceEnabled() ) { logger.trace( String.format( "using adminId [%s]", adminId ) ); //$NON-NLS-1$
public void testAdminPrincipalAsImpersonator() throws RepositoryException, NotExecutableException { String adminId = superuser.getUserID(); Authorizable a = userMgr.getAuthorizable(adminId); if (a == null || a.isGroup() || !((User) a).isAdmin()) { throw new NotExecutableException(adminId + " is not administators ID"); } Principal adminPrincipal = new AdminPrincipal(adminId); // admin cannot be add/remove to set of impersonators of 'u' but is // always allowed to impersonate that user. User u = (User) userMgr.getAuthorizable(uID); Impersonation impersonation = u.getImpersonation(); assertFalse(impersonation.grantImpersonation(adminPrincipal)); assertFalse(impersonation.revokeImpersonation(adminPrincipal)); assertTrue(impersonation.allows(buildSubject(adminPrincipal))); // same if the impersonation object of the admin itself is used. Impersonation adminImpersonation = ((User) a).getImpersonation(); assertFalse(adminImpersonation.grantImpersonation(adminPrincipal)); assertFalse(adminImpersonation.revokeImpersonation(adminPrincipal)); assertTrue(impersonation.allows(buildSubject(adminPrincipal))); }