Search in sources :

Example 1 with DocumentStoreConfiguration

use of org.gluu.service.document.store.conf.DocumentStoreConfiguration in project oxAuth by GluuFederation.

the class ApplicationFactory method getDocumentStoreConfiguration.

@Produces
@ApplicationScoped
public DocumentStoreConfiguration getDocumentStoreConfiguration() {
    DocumentStoreConfiguration documentStoreConfiguration = configurationService.getConfiguration().getDocumentStoreConfiguration();
    if ((documentStoreConfiguration == null) || (documentStoreConfiguration.getDocumentStoreType() == null)) {
        log.error("Failed to read document store configuration from DB. Please check configuration oxDocumentStoreConfiguration attribute " + "that must contain document store configuration JSON represented by DocumentStoreConfiguration.class. Appliance DN: " + configurationService.getConfiguration().getDn());
        log.info("Creating fallback LOCAL document store configuration ... ");
        documentStoreConfiguration = new DocumentStoreConfiguration();
        documentStoreConfiguration.setLocalConfiguration(new LocalDocumentStoreConfiguration());
        log.info("LOCAL document store configuration is created.");
    }
    log.info("Document store configuration: " + documentStoreConfiguration);
    return documentStoreConfiguration;
}
Also used : LocalDocumentStoreConfiguration(org.gluu.service.document.store.conf.LocalDocumentStoreConfiguration) DocumentStoreConfiguration(org.gluu.service.document.store.conf.DocumentStoreConfiguration) LocalDocumentStoreConfiguration(org.gluu.service.document.store.conf.LocalDocumentStoreConfiguration) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 2 with DocumentStoreConfiguration

use of org.gluu.service.document.store.conf.DocumentStoreConfiguration in project oxTrust by GluuFederation.

the class ApplicationFactory method getDocumentStoreConfiguration.

@Produces
@ApplicationScoped
public DocumentStoreConfiguration getDocumentStoreConfiguration() {
    DocumentStoreConfiguration documentStoreConfiguration = configurationService.getConfiguration().getDocumentStoreConfiguration();
    if ((documentStoreConfiguration == null) || (documentStoreConfiguration.getDocumentStoreType() == null)) {
        log.error("Failed to read document store configuration from DB. Please check configuration oxDocumentStoreConfiguration attribute " + "that must contain document store configuration JSON represented by DocumentStoreConfiguration.class. Appliance DN: " + configurationService.getConfiguration().getDn());
        log.info("Creating fallback LOCAL document store configuration ... ");
        documentStoreConfiguration = new DocumentStoreConfiguration();
        documentStoreConfiguration.setLocalConfiguration(new LocalDocumentStoreConfiguration());
        log.info("LOCAL document store configuration is created.");
    }
    log.info("Document store configuration: " + documentStoreConfiguration);
    return documentStoreConfiguration;
}
Also used : LocalDocumentStoreConfiguration(org.gluu.service.document.store.conf.LocalDocumentStoreConfiguration) DocumentStoreConfiguration(org.gluu.service.document.store.conf.DocumentStoreConfiguration) LocalDocumentStoreConfiguration(org.gluu.service.document.store.conf.LocalDocumentStoreConfiguration) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 3 with DocumentStoreConfiguration

use of org.gluu.service.document.store.conf.DocumentStoreConfiguration in project oxTrust by GluuFederation.

the class JsonConfigurationAction method convertToStoreConfiguration.

private DocumentStoreConfiguration convertToStoreConfiguration(String storeConfigurationJson) {
    try {
        DocumentStoreConfiguration storeConfiguration = jsonService.jsonToObject(storeConfigurationJson, DocumentStoreConfiguration.class);
        processPasswordProperty(storeConfiguration.getJcaConfiguration(), "password");
        return storeConfiguration;
    } catch (Exception ex) {
        log.error("Failed to prepare DocumentStoreConfiguration from JSON: '{}'", storeConfigurationJson, ex);
    }
    return null;
}
Also used : JcaDocumentStoreConfiguration(org.gluu.service.document.store.conf.JcaDocumentStoreConfiguration) DocumentStoreConfiguration(org.gluu.service.document.store.conf.DocumentStoreConfiguration) EncryptionException(org.gluu.util.security.StringEncrypter.EncryptionException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 4 with DocumentStoreConfiguration

use of org.gluu.service.document.store.conf.DocumentStoreConfiguration in project oxCore by GluuFederation.

the class JcaDocumentStoreManualTest method main.

public static void main(String[] args) throws RepositoryException, IOException, EncryptionException {
    StringEncrypter se = new StringEncrypter(StringEncrypter.DESEDE_ENCRYPTION_SCHEME, "Zqvw62DEFdhxoL4csi9hpVI4");
    DocumentStoreConfiguration dsc = new DocumentStoreConfiguration();
    dsc.setDocumentStoreType(DocumentStoreType.JCA);
    JcaDocumentStoreConfiguration jca = new JcaDocumentStoreConfiguration();
    jca.setServerUrl("http://localhost:8080/rmi");
    jca.setWorkspaceName("default");
    jca.setUserId("admin");
    jca.setPassword(se.encrypt("admin"));
    jca.setConnectionTimeout(15);
    dsc.setJcaConfiguration(jca);
    LocalDocumentStoreConfiguration lca = new LocalDocumentStoreConfiguration();
    dsc.setLocalConfiguration(lca);
    ObjectMapper om = new ObjectMapper();
    System.out.println(om.writeValueAsString(dsc));
    StandaloneDocumentStoreProviderFactory pf = new StandaloneDocumentStoreProviderFactory(se);
    DocumentStoreProvider dsp = pf.getDocumentStoreProvider(dsc);
    String doc1 = FileUtils.readFileToString(new File("V:/authorization_code.jmx"), "UTF-8");
    byte[] doc2 = FileUtils.readFileToByteArray(new File("V:/scim_requests.zip"));
    System.out.print("Has document: " + "/test2/test2/test.jmx: ");
    System.out.println(dsp.hasDocument("/test2/test2/test.jmx"));
    System.out.print("Has document: " + "/test2/test3/test3.jmx: ");
    System.out.println(dsp.hasDocument("/test2/test3/test3.jmx"));
    System.out.print("Write document: " + "/test2/test3/test4/test5.jmx: ");
    System.out.println(dsp.saveDocumentStream("/test2/test3/test4/test5.jmx", new ByteArrayInputStream(doc2)));
    System.out.print("Has document: " + "/test2/test3/test4/test5.jmx: ");
    System.out.println(dsp.hasDocument("/test2/test3/test4/test5.jmx"));
    System.out.print("Write document: " + "/test2/test3/test4/test5.jmx: ");
    System.out.println(dsp.saveDocument("/test2/test3/test4/test5.jmx", doc1, StandardCharsets.UTF_8));
    System.out.print("Has document: " + "/test2/test3/test4/test5.jmx: ");
    System.out.println(dsp.hasDocument("/test2/test3/test4/test5.jmx"));
    System.out.print("Read document: " + "/test2/test3/test4/test5.jmx: ");
    System.out.println(dsp.readDocument("/test2/test3/test4/test5.jmx", StandardCharsets.UTF_8));
    System.out.print("Read document: " + "/test2/test3/test4/test5.jmx: ");
    System.out.println(IOUtils.toString(dsp.readDocumentAsStream("/test2/test3/test4/test5.jmx"), StandardCharsets.UTF_8));
    System.out.print("Rename document: " + "/test2/test3/test4/test5.jmx: ");
    System.out.println(dsp.renameDocument("/test2/test3/test4/test5.jmx", "/test2/test4/test5.jmx"));
    System.out.print("Has document: " + "/test2/test3/test4/test5.jmx: ");
    System.out.println(dsp.hasDocument("/test2/test3/test4/test5.jmx"));
    System.out.print("Has document: " + "/test2/test4/test5.jmx: ");
    System.out.println(dsp.hasDocument("/test2/test4/test5.jmx"));
    System.out.print("Remove document: " + "test2/test4/test5.jmx: ");
    System.out.println(dsp.removeDocument("/test2/test4/test5.jmx"));
    System.out.print("Has document: " + "/test2/test4/test5.jmx: ");
    System.out.println(dsp.hasDocument("/test2/test4/test5.jmx"));
}
Also used : LocalDocumentStoreConfiguration(org.gluu.service.document.store.conf.LocalDocumentStoreConfiguration) JcaDocumentStoreConfiguration(org.gluu.service.document.store.conf.JcaDocumentStoreConfiguration) StandaloneDocumentStoreProviderFactory(org.gluu.service.document.store.StandaloneDocumentStoreProviderFactory) DocumentStoreConfiguration(org.gluu.service.document.store.conf.DocumentStoreConfiguration) LocalDocumentStoreConfiguration(org.gluu.service.document.store.conf.LocalDocumentStoreConfiguration) JcaDocumentStoreConfiguration(org.gluu.service.document.store.conf.JcaDocumentStoreConfiguration) ByteArrayInputStream(java.io.ByteArrayInputStream) StringEncrypter(org.gluu.util.security.StringEncrypter) DocumentStoreProvider(org.gluu.service.document.store.provider.DocumentStoreProvider) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with DocumentStoreConfiguration

use of org.gluu.service.document.store.conf.DocumentStoreConfiguration in project oxCore by GluuFederation.

the class WebDavDocumentStoreManualTest method main.

public static void main(String[] args) throws RepositoryException, IOException, EncryptionException {
    StringEncrypter se = new StringEncrypter(StringEncrypter.DESEDE_ENCRYPTION_SCHEME, "Zqvw62DEFdhxoL4csi9hpVI4");
    DocumentStoreConfiguration dsc = new DocumentStoreConfiguration();
    dsc.setDocumentStoreType(DocumentStoreType.WEB_DAV);
    WebDavDocumentStoreConfiguration jca = new WebDavDocumentStoreConfiguration();
    jca.setServerUrl("http://localhost:8080/repository");
    jca.setWorkspaceName("default");
    jca.setUserId("admin");
    jca.setPassword(se.encrypt("admin"));
    jca.setConnectionTimeout(15);
    dsc.setWebDavConfiguration(jca);
    LocalDocumentStoreConfiguration lca = new LocalDocumentStoreConfiguration();
    dsc.setLocalConfiguration(lca);
    ObjectMapper om = new ObjectMapper();
    System.out.println(om.writeValueAsString(dsc));
    StandaloneDocumentStoreProviderFactory pf = new StandaloneDocumentStoreProviderFactory(se);
    DocumentStoreProvider dsp = pf.getDocumentStoreProvider(dsc);
    String doc1 = FileUtils.readFileToString(new File("V:/test.log"), "UTF-8");
    byte[] doc2 = FileUtils.readFileToByteArray(new File("V:/test.zip"));
    /*		
		System.out.print("Has document: " + "/test2/test2/test.jmx: ");
		System.out.println(dsp.hasDocument("/test2/test2/test.jmx"));
*/
    System.out.print("Has document: " + "/test2/test3/test3.jmx: ");
    System.out.println(dsp.hasDocument("/test2/test3/test3.jmx"));
    System.out.print("Write document: " + "/test2/test3/test4/test5.jmx: ");
    System.out.println(dsp.saveDocumentStream("/test-1.jmx", new ByteArrayInputStream(doc2)));
    /*
		System.out.print("Has document: " + "/test2/test3/test4/test5.jmx: ");
		System.out.println(dsp.hasDocument("/test2/test3/test4/test5.jmx"));
*/
    System.out.print("Write document: " + "/test2/test3/test4/test5.jmx: ");
    System.out.println(dsp.saveDocument("/test7.jmx", doc1, StandardCharsets.UTF_8));
/*
		System.out.print("Has document: " + "/test2/test3/test4/test5.jmx: ");
		System.out.println(dsp.hasDocument("/test2/test3/test4/test5.jmx"));

		System.out.print("Read document: " + "/test2/test3/test4/test5.jmx: ");
		System.out.println(dsp.readDocument("/test2/test3/test4/test5.jmx", StandardCharsets.UTF_8));

		System.out.print("Read document: " + "/test2/test3/test4/test5.jmx: ");
		System.out.println(IOUtils.toString(dsp.readDocumentAsStream("/test2/test3/test4/test5.jmx"), StandardCharsets.UTF_8));

		System.out.print("Rename document: " + "/test2/test3/test4/test5.jmx: ");
		System.out.println(dsp.renameDocument("/test2/test3/test4/test5.jmx", "/test2/test4/test5.jmx"));

		System.out.print("Has document: " + "/test2/test3/test4/test5.jmx: ");
		System.out.println(dsp.hasDocument("/test2/test3/test4/test5.jmx"));

		System.out.print("Has document: " + "/test2/test4/test5.jmx: ");
		System.out.println(dsp.hasDocument("/test2/test4/test5.jmx"));

		System.out.print("Remove document: " + "test2/test4/test5.jmx: ");
		System.out.println(dsp.removeDocument("/test2/test4/test5.jmx"));

		System.out.print("Has document: " + "/test2/test4/test5.jmx: ");
		System.out.println(dsp.hasDocument("/test2/test4/test5.jmx"));
*/
}
Also used : WebDavDocumentStoreConfiguration(org.gluu.service.document.store.conf.WebDavDocumentStoreConfiguration) LocalDocumentStoreConfiguration(org.gluu.service.document.store.conf.LocalDocumentStoreConfiguration) StandaloneDocumentStoreProviderFactory(org.gluu.service.document.store.StandaloneDocumentStoreProviderFactory) DocumentStoreConfiguration(org.gluu.service.document.store.conf.DocumentStoreConfiguration) WebDavDocumentStoreConfiguration(org.gluu.service.document.store.conf.WebDavDocumentStoreConfiguration) LocalDocumentStoreConfiguration(org.gluu.service.document.store.conf.LocalDocumentStoreConfiguration) ByteArrayInputStream(java.io.ByteArrayInputStream) StringEncrypter(org.gluu.util.security.StringEncrypter) DocumentStoreProvider(org.gluu.service.document.store.provider.DocumentStoreProvider) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

DocumentStoreConfiguration (org.gluu.service.document.store.conf.DocumentStoreConfiguration)5 LocalDocumentStoreConfiguration (org.gluu.service.document.store.conf.LocalDocumentStoreConfiguration)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 File (java.io.File)2 ApplicationScoped (javax.enterprise.context.ApplicationScoped)2 Produces (javax.enterprise.inject.Produces)2 StandaloneDocumentStoreProviderFactory (org.gluu.service.document.store.StandaloneDocumentStoreProviderFactory)2 JcaDocumentStoreConfiguration (org.gluu.service.document.store.conf.JcaDocumentStoreConfiguration)2 DocumentStoreProvider (org.gluu.service.document.store.provider.DocumentStoreProvider)2 StringEncrypter (org.gluu.util.security.StringEncrypter)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 WebDavDocumentStoreConfiguration (org.gluu.service.document.store.conf.WebDavDocumentStoreConfiguration)1 EncryptionException (org.gluu.util.security.StringEncrypter.EncryptionException)1