/** * Always returns the name of the <code>SystemPrincipal</code>. * * @return the name of <code>SystemPrincipal</code>. */ @Override protected String retrieveUserId(Subject subject, String workspaceName) throws RepositoryException { return new SystemPrincipal().getName(); }
@Override public void beforeSuite() throws Exception { super.beforeSuite(); if (getRepository() instanceof RepositoryImpl) { subject = SystemSubject.INSTANCE; } else { subject = new Subject(true, ImmutableSet.of(new SystemPrincipal()), Collections.emptySet(), Collections.emptySet()); } }
/** * Always returns the name of the <code>SystemPrincipal</code>. * * @return the name of <code>SystemPrincipal</code>. */ @Override protected String retrieveUserId(Subject subject, String workspaceName) throws RepositoryException { return new SystemPrincipal().getName(); }
/** * Package private factory method * * @param repositoryContext The repository context * @param wspConfig The workspace configuration * @return A new instance of <code>SystemSession</code> * @throws RepositoryException If an error occurs */ static SystemSession create( RepositoryContext repositoryContext, WorkspaceConfig wspConfig) throws RepositoryException { // create subject with SystemPrincipal Set<SystemPrincipal> principals = Collections.singleton(new SystemPrincipal()); Subject subject = new Subject(true, principals, Collections.emptySet(), Collections.emptySet()); return new SystemSession(repositoryContext, subject, wspConfig); }
/** * Package private factory method * * @param repositoryContext The repository context * @param wspConfig The workspace configuration * @return A new instance of <code>SystemSession</code> * @throws RepositoryException If an error occurs */ static SystemSession create( RepositoryContext repositoryContext, WorkspaceConfig wspConfig) throws RepositoryException { // create subject with SystemPrincipal Set<SystemPrincipal> principals = Collections.singleton(new SystemPrincipal()); Subject subject = new Subject(true, principals, Collections.emptySet(), Collections.emptySet()); return new SystemSession(repositoryContext, subject, wspConfig); }
throw new LoginException("Anonymous user is not allowed to impersonate"); } else if (!impersonator.getPrincipals(SystemPrincipal.class).isEmpty()) { principals.add(new SystemPrincipal()); validLogin = true; return true;
principals.add(new SystemPrincipal());
public void testSystemPrincipalAsImpersonator() throws RepositoryException { Principal systemPrincipal = new SystemPrincipal(); assertNull(userMgr.getAuthorizable(systemPrincipal)); // system cannot be add/remove to set of impersonators of 'u' nor // should it be allowed to impersonate a given user... User u = (User) userMgr.getAuthorizable(uID); Impersonation impersonation = u.getImpersonation(); assertFalse(impersonation.grantImpersonation(systemPrincipal)); assertFalse(impersonation.revokeImpersonation(systemPrincipal)); assertFalse(impersonation.allows(buildSubject(systemPrincipal))); } }