Search in sources :

Example 1 with AbstractBootstrapSchema

use of org.apache.directory.server.core.schema.bootstrap.AbstractBootstrapSchema in project nhin-d by DirectProject.

the class WSSmtpAgentConfigFunctional_Test method setUp.

/**
     * Initialize the servers- LDAP and HTTP.
     */
@SuppressWarnings("unchecked")
@Override
public void setUp() throws Exception {
    // check for Windows... it doens't like file://<drive>... turns it into FTP
    File file = new File("./src/test/resources/bundles/testBundle.p7b");
    if (file.getAbsolutePath().contains(":/"))
        filePrefix = "file:///";
    else
        filePrefix = "file:///";
    CertCacheFactory.getInstance().flushAll();
    /*
		 * Setup the LDAP Server
		 */
    MutablePartitionConfiguration pcfg = new MutablePartitionConfiguration();
    pcfg.setName("lookupTest");
    pcfg.setSuffix("cn=lookupTest");
    // Create some indices
    Set<String> indexedAttrs = new HashSet<String>();
    indexedAttrs.add("objectClass");
    indexedAttrs.add("cn");
    pcfg.setIndexedAttributes(indexedAttrs);
    // Create a first entry associated to the partition
    Attributes attrs = new BasicAttributes(true);
    // First, the objectClass attribute
    Attribute attr = new BasicAttribute("objectClass");
    attr.add("top");
    attrs.put(attr);
    // Associate this entry to the partition
    pcfg.setContextEntry(attrs);
    // As we can create more than one partition, we must store
    // each created partition in a Set before initialization
    Set<MutablePartitionConfiguration> pcfgs = new HashSet<MutablePartitionConfiguration>();
    pcfgs.add(pcfg);
    //
    //
    //
    // add the lookupTestPublic
    //
    //
    pcfg = new MutablePartitionConfiguration();
    pcfg.setName("lookupTestPublic");
    pcfg.setSuffix("cn=lookupTestPublic");
    // Create some indices
    indexedAttrs = new HashSet<String>();
    indexedAttrs.add("objectClass");
    indexedAttrs.add("cn");
    pcfg.setIndexedAttributes(indexedAttrs);
    // Create a first entry associated to the partition
    attrs = new BasicAttributes(true);
    // First, the objectClass attribute
    attr = new BasicAttribute("objectClass");
    attr.add("top");
    attrs.put(attr);
    // Associate this entry to the partition
    pcfg.setContextEntry(attrs);
    // As we can create more than one partition, we must store
    // each created partition in a Set before initialization
    pcfgs.add(pcfg);
    configuration.setContextPartitionConfigurations(pcfgs);
    this.configuration.setWorkingDirectory(new File("LDAP-TEST"));
    // add the private key schema
    ///
    Set<AbstractBootstrapSchema> schemas = configuration.getBootstrapSchemas();
    schemas.add(new PrivkeySchema());
    configuration.setBootstrapSchemas(schemas);
    super.setUp();
    // import the ldif file
    InputStream stream = TestUtils.class.getResourceAsStream("/ldifs/privCertsOnly.ldif");
    if (stream == null)
        throw new IOException("Failed to load ldif file");
    importLdif(stream);
    // setup the mock DNS SRV adapter
    mockLookup = mock(Lookup.class);
    LookupFactory.getFactory().addOverrideImplementation(mockLookup);
    SRVRecord srvRecord = new SRVRecord(new Name("_ldap._tcp.example.com."), DClass.IN, 3600, 0, 1, port, new Name("localhost."));
    when(mockLookup.run()).thenReturn(new Record[] { srvRecord });
    // create the web service and proxy
    ConfigServiceRunner.startConfigService();
    proxy = new ConfigurationServiceProxy(ConfigServiceRunner.getConfigServiceURL());
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) BasicAttributes(javax.naming.directory.BasicAttributes) Attribute(javax.naming.directory.Attribute) BasicAttribute(javax.naming.directory.BasicAttribute) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) BasicAttributes(javax.naming.directory.BasicAttributes) Attributes(javax.naming.directory.Attributes) IOException(java.io.IOException) PrivkeySchema(org.nhindirect.ldap.PrivkeySchema) Name(org.xbill.DNS.Name) AbstractBootstrapSchema(org.apache.directory.server.core.schema.bootstrap.AbstractBootstrapSchema) MutablePartitionConfiguration(org.apache.directory.server.core.configuration.MutablePartitionConfiguration) Lookup(org.nhindirect.stagent.cert.impl.util.Lookup) SRVRecord(org.xbill.DNS.SRVRecord) File(java.io.File) ConfigurationServiceProxy(org.nhind.config.ConfigurationServiceProxy) HashSet(java.util.HashSet)

Example 2 with AbstractBootstrapSchema

use of org.apache.directory.server.core.schema.bootstrap.AbstractBootstrapSchema in project nhin-d by DirectProject.

the class XMLSmtpAgentConfigFunctional_Test method setUp.

/**
     * Initialize the server.
     */
@SuppressWarnings("unchecked")
@Override
public void setUp() throws Exception {
    CertCacheFactory.getInstance().flushAll();
    MutablePartitionConfiguration pcfg = new MutablePartitionConfiguration();
    pcfg.setName("lookupTest");
    pcfg.setSuffix("cn=lookupTest");
    // Create some indices
    Set<String> indexedAttrs = new HashSet<String>();
    indexedAttrs.add("objectClass");
    indexedAttrs.add("cn");
    pcfg.setIndexedAttributes(indexedAttrs);
    // Create a first entry associated to the partition
    Attributes attrs = new BasicAttributes(true);
    // First, the objectClass attribute
    Attribute attr = new BasicAttribute("objectClass");
    attr.add("top");
    attrs.put(attr);
    // Associate this entry to the partition
    pcfg.setContextEntry(attrs);
    // As we can create more than one partition, we must store
    // each created partition in a Set before initialization
    Set<MutablePartitionConfiguration> pcfgs = new HashSet<MutablePartitionConfiguration>();
    pcfgs.add(pcfg);
    configuration.setContextPartitionConfigurations(pcfgs);
    this.configuration.setWorkingDirectory(new File("LDAP-TEST"));
    // add the private key schema
    ///
    Set<AbstractBootstrapSchema> schemas = configuration.getBootstrapSchemas();
    schemas.add(new PrivkeySchema());
    configuration.setBootstrapSchemas(schemas);
    super.setUp();
    // import the ldif file
    InputStream stream = TestUtils.class.getResourceAsStream("/ldifs/privCertsOnly.ldif");
    if (stream == null)
        throw new IOException("Failed to load ldif file");
    importLdif(stream);
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) BasicAttributes(javax.naming.directory.BasicAttributes) BasicAttribute(javax.naming.directory.BasicAttribute) Attribute(javax.naming.directory.Attribute) InputStream(java.io.InputStream) BasicAttributes(javax.naming.directory.BasicAttributes) Attributes(javax.naming.directory.Attributes) IOException(java.io.IOException) PrivkeySchema(org.nhindirect.ldap.PrivkeySchema) AbstractBootstrapSchema(org.apache.directory.server.core.schema.bootstrap.AbstractBootstrapSchema) MutablePartitionConfiguration(org.apache.directory.server.core.configuration.MutablePartitionConfiguration) File(java.io.File) HashSet(java.util.HashSet)

Example 3 with AbstractBootstrapSchema

use of org.apache.directory.server.core.schema.bootstrap.AbstractBootstrapSchema in project nhin-d by DirectProject.

the class LDAPResearchTest method setUp.

@SuppressWarnings("unchecked")
@Override
public void setUp() throws Exception {
    MutablePartitionConfiguration pcfg = new MutablePartitionConfiguration();
    pcfg.setName("lookupTest");
    pcfg.setSuffix("cn=lookupTest");
    // Create some indices
    Set<String> indexedAttrs = new HashSet<String>();
    indexedAttrs.add("objectClass");
    indexedAttrs.add("cn");
    pcfg.setIndexedAttributes(indexedAttrs);
    // Create a first entry associated to the partition
    Attributes attrs = new BasicAttributes(true);
    // First, the objectClass attribute
    Attribute attr = new BasicAttribute("objectClass");
    attr.add("top");
    attrs.put(attr);
    // Associate this entry to the partition
    pcfg.setContextEntry(attrs);
    // As we can create more than one partition, we must store
    // each created partition in a Set before initialization
    Set<MutablePartitionConfiguration> pcfgs = new HashSet<MutablePartitionConfiguration>();
    pcfgs.add(pcfg);
    configuration.setContextPartitionConfigurations(pcfgs);
    this.configuration.setWorkingDirectory(new File("LDAP-TEST"));
    // add the private key schema
    ///
    Set<AbstractBootstrapSchema> schemas = configuration.getBootstrapSchemas();
    schemas.add(new PrivkeySchema());
    configuration.setBootstrapSchemas(schemas);
    super.setUp();
    // import the ldif file
    InputStream stream = LDAPResearchTest.class.getClassLoader().getResourceAsStream("ldifs/privCertsOnly.ldif");
    if (stream == null)
        throw new IOException("Failed to load ldif file");
    importLdif(stream);
    createLdapEntries();
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) BasicAttributes(javax.naming.directory.BasicAttributes) BasicAttribute(javax.naming.directory.BasicAttribute) Attribute(javax.naming.directory.Attribute) InputStream(java.io.InputStream) BasicAttributes(javax.naming.directory.BasicAttributes) Attributes(javax.naming.directory.Attributes) IOException(java.io.IOException) AbstractBootstrapSchema(org.apache.directory.server.core.schema.bootstrap.AbstractBootstrapSchema) MutablePartitionConfiguration(org.apache.directory.server.core.configuration.MutablePartitionConfiguration) File(java.io.File) HashSet(java.util.HashSet)

Example 4 with AbstractBootstrapSchema

use of org.apache.directory.server.core.schema.bootstrap.AbstractBootstrapSchema in project nhin-d by DirectProject.

the class LDAPPublicCertUtil_ldapSearch_Test method setUp.

@SuppressWarnings("unchecked")
@Override
public void setUp() throws Exception {
    // create the LDAP server
    MutablePartitionConfiguration pcfg = new MutablePartitionConfiguration();
    pcfg.setName("lookupTestPublic");
    pcfg.setSuffix("cn=lookupTestPublic");
    // Create some indices
    Set<String> indexedAttrs = new HashSet<String>();
    indexedAttrs.add("objectClass");
    indexedAttrs.add("cn");
    pcfg.setIndexedAttributes(indexedAttrs);
    // Create a first entry associated to the partition
    Attributes attrs = new BasicAttributes(true);
    // First, the objectClass attribute
    Attribute attr = new BasicAttribute("objectClass");
    attr.add("top");
    attrs.put(attr);
    // Associate this entry to the partition
    pcfg.setContextEntry(attrs);
    // As we can create more than one partition, we must store
    // each created partition in a Set before initialization
    Set<MutablePartitionConfiguration> pcfgs = new HashSet<MutablePartitionConfiguration>();
    pcfgs.add(pcfg);
    configuration.setContextPartitionConfigurations(pcfgs);
    configuration.setWorkingDirectory(new File("LDAP-TEST"));
    Set<AbstractBootstrapSchema> schemas = configuration.getBootstrapSchemas();
    configuration.setBootstrapSchemas(schemas);
    mockLookup = mock(Lookup.class);
    LookupFactory.getFactory().addOverrideImplementation(mockLookup);
    super.setUp();
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) BasicAttributes(javax.naming.directory.BasicAttributes) BasicAttribute(javax.naming.directory.BasicAttribute) Attribute(javax.naming.directory.Attribute) BasicAttributes(javax.naming.directory.BasicAttributes) Attributes(javax.naming.directory.Attributes) AbstractBootstrapSchema(org.apache.directory.server.core.schema.bootstrap.AbstractBootstrapSchema) MutablePartitionConfiguration(org.apache.directory.server.core.configuration.MutablePartitionConfiguration) Lookup(org.nhindirect.stagent.cert.impl.util.Lookup) File(java.io.File) HashSet(java.util.HashSet)

Example 5 with AbstractBootstrapSchema

use of org.apache.directory.server.core.schema.bootstrap.AbstractBootstrapSchema in project nhin-d by DirectProject.

the class RESTSmtpAgentConfigFunctional_Test method setUp.

/**
     * Initialize the servers- LDAP and HTTP.
     */
@SuppressWarnings("unchecked")
@Override
public void setUp() throws Exception {
    // check for Windows... it doens't like file://<drive>... turns it into FTP
    File file = new File("./src/test/resources/bundles/testBundle.p7b");
    if (file.getAbsolutePath().contains(":/"))
        filePrefix = "file:///";
    else
        filePrefix = "file:///";
    CertCacheFactory.getInstance().flushAll();
    /*
		 * Setup the LDAP Server
		 */
    MutablePartitionConfiguration pcfg = new MutablePartitionConfiguration();
    pcfg.setName("lookupTest");
    pcfg.setSuffix("cn=lookupTest");
    // Create some indices
    Set<String> indexedAttrs = new HashSet<String>();
    indexedAttrs.add("objectClass");
    indexedAttrs.add("cn");
    pcfg.setIndexedAttributes(indexedAttrs);
    // Create a first entry associated to the partition
    Attributes attrs = new BasicAttributes(true);
    // First, the objectClass attribute
    Attribute attr = new BasicAttribute("objectClass");
    attr.add("top");
    attrs.put(attr);
    // Associate this entry to the partition
    pcfg.setContextEntry(attrs);
    // As we can create more than one partition, we must store
    // each created partition in a Set before initialization
    Set<MutablePartitionConfiguration> pcfgs = new HashSet<MutablePartitionConfiguration>();
    pcfgs.add(pcfg);
    //
    //
    //
    // add the lookupTestPublic
    //
    //
    pcfg = new MutablePartitionConfiguration();
    pcfg.setName("lookupTestPublic");
    pcfg.setSuffix("cn=lookupTestPublic");
    // Create some indices
    indexedAttrs = new HashSet<String>();
    indexedAttrs.add("objectClass");
    indexedAttrs.add("cn");
    pcfg.setIndexedAttributes(indexedAttrs);
    // Create a first entry associated to the partition
    attrs = new BasicAttributes(true);
    // First, the objectClass attribute
    attr = new BasicAttribute("objectClass");
    attr.add("top");
    attrs.put(attr);
    // Associate this entry to the partition
    pcfg.setContextEntry(attrs);
    // As we can create more than one partition, we must store
    // each created partition in a Set before initialization
    pcfgs.add(pcfg);
    configuration.setContextPartitionConfigurations(pcfgs);
    this.configuration.setWorkingDirectory(new File("LDAP-TEST"));
    // add the private key schema
    ///
    Set<AbstractBootstrapSchema> schemas = configuration.getBootstrapSchemas();
    schemas.add(new PrivkeySchema());
    configuration.setBootstrapSchemas(schemas);
    super.setUp();
    // import the ldif file
    InputStream stream = TestUtils.class.getResourceAsStream("/ldifs/privCertsOnly.ldif");
    if (stream == null)
        throw new IOException("Failed to load ldif file");
    importLdif(stream);
    // setup the mock DNS SRV adapter
    mockLookup = mock(Lookup.class);
    LookupFactory.getFactory().addOverrideImplementation(mockLookup);
    SRVRecord srvRecord = new SRVRecord(new Name("_ldap._tcp.example.com."), DClass.IN, 3600, 0, 1, port, new Name("localhost."));
    when(mockLookup.run()).thenReturn(new Record[] { srvRecord });
    // create the web service and proxy
    ConfigServiceRunner.startConfigService();
    proxy = new ConfigurationServiceProxy(ConfigServiceRunner.getConfigServiceURL());
    certService = new DefaultCertificateService(ConfigServiceRunner.getRestAPIBaseURL(), HttpClientFactory.createHttpClient(), new OpenServiceSecurityManager());
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) BasicAttributes(javax.naming.directory.BasicAttributes) Attribute(javax.naming.directory.Attribute) BasicAttribute(javax.naming.directory.BasicAttribute) DefaultCertificateService(org.nhind.config.rest.impl.DefaultCertificateService) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) BasicAttributes(javax.naming.directory.BasicAttributes) Attributes(javax.naming.directory.Attributes) OpenServiceSecurityManager(org.nhindirect.common.rest.OpenServiceSecurityManager) IOException(java.io.IOException) PrivkeySchema(org.nhindirect.ldap.PrivkeySchema) Name(org.xbill.DNS.Name) AbstractBootstrapSchema(org.apache.directory.server.core.schema.bootstrap.AbstractBootstrapSchema) MutablePartitionConfiguration(org.apache.directory.server.core.configuration.MutablePartitionConfiguration) Lookup(org.nhindirect.stagent.cert.impl.util.Lookup) SRVRecord(org.xbill.DNS.SRVRecord) File(java.io.File) ConfigurationServiceProxy(org.nhind.config.ConfigurationServiceProxy) HashSet(java.util.HashSet)

Aggregations

File (java.io.File)7 HashSet (java.util.HashSet)7 Attribute (javax.naming.directory.Attribute)7 Attributes (javax.naming.directory.Attributes)7 BasicAttribute (javax.naming.directory.BasicAttribute)7 BasicAttributes (javax.naming.directory.BasicAttributes)7 MutablePartitionConfiguration (org.apache.directory.server.core.configuration.MutablePartitionConfiguration)7 AbstractBootstrapSchema (org.apache.directory.server.core.schema.bootstrap.AbstractBootstrapSchema)7 IOException (java.io.IOException)5 InputStream (java.io.InputStream)5 PrivkeySchema (org.nhindirect.ldap.PrivkeySchema)5 Lookup (org.nhindirect.stagent.cert.impl.util.Lookup)4 Name (org.xbill.DNS.Name)3 SRVRecord (org.xbill.DNS.SRVRecord)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ConfigurationServiceProxy (org.nhind.config.ConfigurationServiceProxy)2 DefaultCertificateService (org.nhind.config.rest.impl.DefaultCertificateService)1 OpenServiceSecurityManager (org.nhindirect.common.rest.OpenServiceSecurityManager)1 LDAPResearchTest (org.nhindirect.ldap.LDAPResearchTest)1