Search in sources :

Example 1 with RepositoryImpl

use of org.apache.jackrabbit.core.RepositoryImpl in project jackrabbit by apache.

the class StopJackrabbit method execute.

/**
     * {@inheritDoc}
     */
public boolean execute(Context ctx) throws Exception {
    if (log.isDebugEnabled()) {
        log.debug("stopping jackrabbit");
    }
    RepositoryImpl repo = (RepositoryImpl) CommandHelper.getRepository(ctx);
    if (repo == null) {
        throw new IllegalStateException("No current working repository");
    }
    repo.shutdown();
    CommandHelper.setRepository(ctx, null, null);
    return false;
}
Also used : RepositoryImpl(org.apache.jackrabbit.core.RepositoryImpl)

Example 2 with RepositoryImpl

use of org.apache.jackrabbit.core.RepositoryImpl in project jackrabbit by apache.

the class SimpleSecurityManager method init.

//------------------------------------------< JackrabbitSecurityManager >---
/**
     * @see JackrabbitSecurityManager#init(Repository, Session)
     */
public void init(Repository repository, Session systemSession) throws RepositoryException {
    if (initialized) {
        throw new IllegalStateException("already initialized");
    }
    if (!(repository instanceof RepositoryImpl)) {
        throw new RepositoryException("RepositoryImpl expected");
    }
    this.systemSession = systemSession;
    config = ((RepositoryImpl) repository).getConfig().getSecurityConfig();
    // read the LoginModule configuration
    LoginModuleConfig loginModConf = config.getLoginModuleConfig();
    authCtxProvider = new AuthContextProvider(config.getAppName(), loginModConf);
    if (authCtxProvider.isLocal()) {
        log.info("init: using Repository LoginModule configuration for " + config.getAppName());
    } else if (authCtxProvider.isJAAS()) {
        log.info("init: using JAAS LoginModule configuration for " + config.getAppName());
    } else {
        String msg = "No valid LoginModule configuriation for " + config.getAppName();
        log.error(msg);
        throw new RepositoryException(msg);
    }
    Properties[] moduleConfig = authCtxProvider.getModuleConfig();
    // retrieve default-ids (admin and anonymous) from login-module-configuration.
    for (Properties aModuleConfig1 : moduleConfig) {
        if (aModuleConfig1.containsKey(LoginModuleConfig.PARAM_ADMIN_ID)) {
            adminID = aModuleConfig1.getProperty(LoginModuleConfig.PARAM_ADMIN_ID);
        }
        if (aModuleConfig1.containsKey(LoginModuleConfig.PARAM_ANONYMOUS_ID)) {
            anonymID = aModuleConfig1.getProperty(LoginModuleConfig.PARAM_ANONYMOUS_ID);
        }
    }
    // fallback:
    if (adminID == null) {
        log.debug("No adminID defined in LoginModule/JAAS config -> using default.");
        adminID = SecurityConstants.ADMIN_ID;
    }
    if (anonymID == null) {
        log.debug("No anonymousID defined in LoginModule/JAAS config -> using default.");
        anonymID = SecurityConstants.ANONYMOUS_ID;
    }
    // most simple principal provider registry, that does not read anything
    // from configuration
    PrincipalProvider principalProvider = new SimplePrincipalProvider();
    // skip init of provider (nop)
    principalProviderRegistry = new ProviderRegistryImpl(principalProvider);
    // register all configured principal providers.
    for (Properties aModuleConfig : moduleConfig) {
        principalProviderRegistry.registerProvider(aModuleConfig);
    }
    SecurityManagerConfig smc = config.getSecurityManagerConfig();
    if (smc != null && smc.getWorkspaceAccessConfig() != null) {
        workspaceAccessManager = smc.getWorkspaceAccessConfig().newInstance(WorkspaceAccessManager.class);
    } else {
        // fallback -> the default simple implementation
        log.debug("No WorkspaceAccessManager configured; using default.");
        workspaceAccessManager = new SimpleWorkspaceAccessManager();
    }
    workspaceAccessManager.init(systemSession);
    initialized = true;
}
Also used : PrincipalProvider(org.apache.jackrabbit.core.security.principal.PrincipalProvider) RepositoryException(javax.jcr.RepositoryException) Properties(java.util.Properties) AuthContextProvider(org.apache.jackrabbit.core.security.authentication.AuthContextProvider) LoginModuleConfig(org.apache.jackrabbit.core.config.LoginModuleConfig) RepositoryImpl(org.apache.jackrabbit.core.RepositoryImpl) SecurityManagerConfig(org.apache.jackrabbit.core.config.SecurityManagerConfig) WorkspaceAccessManager(org.apache.jackrabbit.core.security.authorization.WorkspaceAccessManager) ProviderRegistryImpl(org.apache.jackrabbit.core.security.principal.ProviderRegistryImpl)

Example 3 with RepositoryImpl

use of org.apache.jackrabbit.core.RepositoryImpl in project jackrabbit by apache.

the class IndexingQueueTest method testReaderUpToDate.

/*
     * Test case for JCR-2082
     */
public void testReaderUpToDate() throws Exception {
    BlockingParser.block();
    SearchIndex index = getSearchIndex();
    File indexDir = new File(index.getPath());
    // shutdown workspace
    RepositoryImpl repo = (RepositoryImpl) session.getRepository();
    session.logout();
    session = null;
    superuser.logout();
    superuser = null;
    TestHelper.shutdownWorkspace(getWorkspaceName(), repo);
    // delete index
    try {
        FileUtil.delete(indexDir);
    } catch (IOException e) {
        fail("Unable to delete index directory");
    }
    BlockingParser.unblock();
    // start workspace again by getting a session
    session = getHelper().getSuperuserSession(getWorkspaceName());
    qm = session.getWorkspace().getQueryManager();
    Query q = qm.createQuery(testPath, Query.XPATH);
    assertEquals(1, getSize(q.execute().getNodes()));
}
Also used : Query(javax.jcr.query.Query) RepositoryImpl(org.apache.jackrabbit.core.RepositoryImpl) IOException(java.io.IOException) File(java.io.File)

Example 4 with RepositoryImpl

use of org.apache.jackrabbit.core.RepositoryImpl in project jackrabbit by apache.

the class CustomPrivilegeTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    resolver = ((SessionImpl) superuser);
    // setup the custom privilege file with cyclic references
    fs = ((RepositoryImpl) superuser.getRepository()).getConfig().getFileSystem();
    FileSystemResource resource = new FileSystemResource(fs, "/privileges/custom_privileges.xml");
    if (!resource.exists()) {
        resource.makeParentDirs();
    }
    privilegeRegistry = new PrivilegeRegistry(superuser.getWorkspace().getNamespaceRegistry(), fs);
}
Also used : RepositoryImpl(org.apache.jackrabbit.core.RepositoryImpl) SessionImpl(org.apache.jackrabbit.core.SessionImpl) FileSystemResource(org.apache.jackrabbit.core.fs.FileSystemResource)

Example 5 with RepositoryImpl

use of org.apache.jackrabbit.core.RepositoryImpl in project jackrabbit by apache.

the class AbstractPerformanceTest method runTest.

private void runTest(AbstractTest test, String name, byte[] conf) {
    if (repoPattern.matcher(name).matches() && testPattern.matcher(test.toString()).matches()) {
        // Create the repository directory
        File dir = new File(new File("target", "repository"), name + "-" + test);
        dir.mkdirs();
        try {
            // Copy the configuration file into the repository directory
            File xml = new File(dir, "repository.xml");
            OutputStream output = FileUtils.openOutputStream(xml);
            try {
                output.write(conf, 0, conf.length);
            } finally {
                output.close();
            }
            // Create the repository
            RepositoryImpl repository = createRepository(dir, xml);
            try {
                // Run the test
                DescriptiveStatistics statistics = runTest(test, repository);
                if (statistics.getN() > 0) {
                    writeReport(test.toString(), name, statistics);
                }
            } finally {
                repository.shutdown();
            }
        } catch (Throwable t) {
            System.out.println("Unable to run " + test + ": " + t.getMessage());
        } finally {
            FileUtils.deleteQuietly(dir);
        }
    }
}
Also used : DescriptiveStatistics(org.apache.commons.math.stat.descriptive.DescriptiveStatistics) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RepositoryImpl(org.apache.jackrabbit.core.RepositoryImpl) File(java.io.File)

Aggregations

RepositoryImpl (org.apache.jackrabbit.core.RepositoryImpl)20 File (java.io.File)12 Session (javax.jcr.Session)9 RepositoryConfig (org.apache.jackrabbit.core.config.RepositoryConfig)6 RepositoryException (javax.jcr.RepositoryException)4 Node (javax.jcr.Node)3 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)3 Before (org.junit.Before)3 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 Properties (java.util.Properties)2 Repository (javax.jcr.Repository)2 SimpleCredentials (javax.jcr.SimpleCredentials)2 Query (javax.jcr.query.Query)2 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)2 RepositoryContext (org.apache.jackrabbit.core.RepositoryContext)2 SessionImpl (org.apache.jackrabbit.core.SessionImpl)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 Method (java.lang.reflect.Method)1