protected Session createServiceSession()

in src/main/java/org/apache/sling/jcr/base/AbstractSlingRepository2.java [201:213]


    protected Session createServiceSession(final String serviceUserName, final String workspace) throws RepositoryException {
        Session admin = null;
        try {
            admin = this.createAdministrativeSession(workspace);
            Session result = admin.impersonate(new SimpleCredentials(serviceUserName, new char[0]));
            Repository repository = getRepository();
            return repository instanceof ProxyRepository ? ((ProxyRepository) repository).wrap(result) : result;
        } finally {
            if (admin != null) {
                admin.logout();
            }
        }
    }