当前位置: 首页>>代码示例>>Java>>正文


Java Schema类代码示例

本文整理汇总了Java中com.unboundid.ldap.sdk.schema.Schema的典型用法代码示例。如果您正苦于以下问题:Java Schema类的具体用法?Java Schema怎么用?Java Schema使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Schema类属于com.unboundid.ldap.sdk.schema包,在下文中一共展示了Schema类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSchemasInArray

import com.unboundid.ldap.sdk.schema.Schema; //导入依赖的package包/类
private Schema[] getSchemasInArray() throws LDAPSDKException, IOException {
    Schema[] schemaArray;
    int i = 0;

    if (_includeStandardSchema) {
        schemaArray = new Schema[_schemas.size() + 1];
        schemaArray[i++] = Schema.getDefaultStandardSchema();
    } else {
        schemaArray = new Schema[_schemas.size()];
    }

    for (SchemaFileSupplier schemaFileSupplier : _schemas) {
        File schemaFile = schemaFileSupplier.getFile();
        try {
            Schema schema = Schema.getSchema(schemaFile);
            schemaArray[i++] = schema;
            if (schemaFileSupplier.isBackedByTempFile()) {
                schemaFile.deleteOnExit();
            }
        } catch (LDIFException e) {
            throw new RuntimeException("Could not load schema file: " + schemaFile.getAbsolutePath(), e);
        }
    }

    return schemaArray;
}
 
开发者ID:zagyi,项目名称:adsync4j,代码行数:27,代码来源:EmbeddedUnboundIDLdapServer.java

示例2: setup

import com.unboundid.ldap.sdk.schema.Schema; //导入依赖的package包/类
/**
 * Starts an in-memory DS.
 */
@BeforeClass
public void setup() throws Exception
{
  InMemoryDirectoryServerConfig config =
          new InMemoryDirectoryServerConfig(BASE_DN);
  config.setBaseDNs("cn=monitor");
  config.setEnforceSingleStructuralObjectClass(false);
  config.setEnforceAttributeSyntaxCompliance(false);
  config.setSchema(Schema.mergeSchemas(
          Schema.getDefaultStandardSchema(),
          Schema.getSchema(getSystemResourceAsFile("monitor-schema.ldif"))));
  ds = new InMemoryDirectoryServer(config);
  ds.startListening();
}
 
开发者ID:pingidentity,项目名称:status-servlet,代码行数:18,代码来源:StatusClientTest.java

示例3: setupClass

import com.unboundid.ldap.sdk.schema.Schema; //导入依赖的package包/类
@Before
public void setupClass() throws Exception {		

	InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=example,dc=com");
	config.addAdditionalBindCredentials("cn=Directory Manager", "password");
	config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("LDAP", 389));
	config.setSchema(
			Schema.getSchema(
					"src/test/resources/schema.ldif"
	));

	ds = new InMemoryDirectoryServer(config);
	ds.importFromLDIF(true, "src/test/resources/data.ldif");
	ds.startListening();
}
 
开发者ID:lgangloff,项目名称:ldap2rest,代码行数:16,代码来源:BaseLDAPUnitTest.java

示例4: InMemoryTestLdapDirectoryServer

import com.unboundid.ldap.sdk.schema.Schema; //导入依赖的package包/类
/**
 * Instantiates a new Ldap directory server.
 * Parameters need to be streams so they can be read from JARs.
 */
public InMemoryTestLdapDirectoryServer(final InputStream properties,
                                       final InputStream ldifFile,
                                       final InputStream schemaFile) {
    try {
        final Properties p = new Properties();
        p.load(properties);

        final InMemoryDirectoryServerConfig config =
                new InMemoryDirectoryServerConfig(p.getProperty("ldap.rootDn"));
        config.addAdditionalBindCredentials(p.getProperty("ldap.managerDn"), p.getProperty("ldap.managerPassword"));

        final File keystoreFile = File.createTempFile("key", "store");
        try (OutputStream outputStream = new FileOutputStream(keystoreFile)) {
            IOUtils.copy(new ClassPathResource("/ldapServerTrustStore").getInputStream(), outputStream);
        }

        final String serverKeyStorePath = keystoreFile.getCanonicalPath();
        final SSLUtil serverSSLUtil = new SSLUtil(
                new KeyStoreKeyManager(serverKeyStorePath, "changeit".toCharArray()), new TrustStoreTrustManager(serverKeyStorePath));
        final SSLUtil clientSSLUtil = new SSLUtil(new TrustStoreTrustManager(serverKeyStorePath));
        config.setListenerConfigs(
                InMemoryListenerConfig.createLDAPConfig("LDAP", // Listener name
                        null, // Listen address. (null = listen on all interfaces)
                        1389, // Listen port (0 = automatically choose an available port)
                        serverSSLUtil.createSSLSocketFactory()), // StartTLS factory
                InMemoryListenerConfig.createLDAPSConfig("LDAPS", // Listener name
                        null, // Listen address. (null = listen on all interfaces)
                        1636, // Listen port (0 = automatically choose an available port)
                        serverSSLUtil.createSSLServerSocketFactory(), // Server factory
                        clientSSLUtil.createSSLSocketFactory())); // Client factory

        config.setEnforceSingleStructuralObjectClass(false);
        config.setEnforceAttributeSyntaxCompliance(true);


        final File file = File.createTempFile("ldap", "schema");
        try (OutputStream outputStream = new FileOutputStream(file)) {
            IOUtils.copy(schemaFile, outputStream);
        }

        final Schema s = Schema.mergeSchemas(Schema.getSchema(file));
        config.setSchema(s);


        this.directoryServer = new InMemoryDirectoryServer(config);
        LOGGER.debug("Populating directory...");

        final File ldif = File.createTempFile("ldiff", "file");
        try (OutputStream outputStream = new FileOutputStream(ldif)) {
            IOUtils.copy(ldifFile, outputStream);
        }

        this.directoryServer.importFromLDIF(true, ldif.getCanonicalPath());
        this.directoryServer.restartServer();

        final LDAPConnection c = getConnection();
        LOGGER.debug("Connected to {}:{}", c.getConnectedAddress(), c.getConnectedPort());

        populateDefaultEntries(c);

        c.close();
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:70,代码来源:InMemoryTestLdapDirectoryServer.java

示例5: InMemoryTestLdapDirectoryServer

import com.unboundid.ldap.sdk.schema.Schema; //导入依赖的package包/类
/**
 * Instantiates a new Ldap directory server.
 * Parameters need to be streams so they can be read from JARs.
 */
public InMemoryTestLdapDirectoryServer(final InputStream properties,
                                       final InputStream ldifFile,
                                       final InputStream schemaFile) {
    try {
        final Properties p = new Properties();
        p.load(properties);

        final InMemoryDirectoryServerConfig config =
                new InMemoryDirectoryServerConfig(p.getProperty("ldap.rootDn"));
        config.addAdditionalBindCredentials(p.getProperty("ldap.managerDn"), p.getProperty("ldap.managerPassword"));

        final File keystoreFile = File.createTempFile("key", "store");
        try (final OutputStream outputStream = new FileOutputStream(keystoreFile)) {
            IOUtils.copy(new ClassPathResource("/ldapServerTrustStore").getInputStream(), outputStream);
        }

        final String serverKeyStorePath = keystoreFile.getCanonicalPath();
        final SSLUtil serverSSLUtil = new SSLUtil(
                new KeyStoreKeyManager(serverKeyStorePath, "changeit".toCharArray()), new TrustStoreTrustManager(serverKeyStorePath));
        final SSLUtil clientSSLUtil = new SSLUtil(new TrustStoreTrustManager(serverKeyStorePath));
        config.setListenerConfigs(
                InMemoryListenerConfig.createLDAPConfig("LDAP", // Listener name
                        null, // Listen address. (null = listen on all interfaces)
                        1389, // Listen port (0 = automatically choose an available port)
                        serverSSLUtil.createSSLSocketFactory()), // StartTLS factory
                InMemoryListenerConfig.createLDAPSConfig("LDAPS", // Listener name
                        null, // Listen address. (null = listen on all interfaces)
                        1636, // Listen port (0 = automatically choose an available port)
                        serverSSLUtil.createSSLServerSocketFactory(), // Server factory
                        clientSSLUtil.createSSLSocketFactory())); // Client factory

        config.setEnforceSingleStructuralObjectClass(false);
        config.setEnforceAttributeSyntaxCompliance(true);


        final File file = File.createTempFile("ldap", "schema");
        try (final OutputStream outputStream = new FileOutputStream(file)) {
            IOUtils.copy(schemaFile, outputStream);
        }

        final Schema s = Schema.mergeSchemas(Schema.getSchema(file));
        config.setSchema(s);


        this.directoryServer = new InMemoryDirectoryServer(config);
        LOGGER.debug("Populating directory...");

        final File ldif = File.createTempFile("ldiff", "file");
        try (final OutputStream outputStream = new FileOutputStream(ldif)) {
            IOUtils.copy(ldifFile, outputStream);
        }

        this.directoryServer.importFromLDIF(true, ldif.getCanonicalPath());
        this.directoryServer.restartServer();

        final LDAPConnection c = getConnection();
        LOGGER.debug("Connected to {}:{}", c.getConnectedAddress(), c.getConnectedPort());

        populateDefaultEntries(c);

        c.close();
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:70,代码来源:InMemoryTestLdapDirectoryServer.java

示例6: LdapServer

import com.unboundid.ldap.sdk.schema.Schema; //导入依赖的package包/类
/**
 * Instantiates a new Ldap directory server.
 * Parameters need to be streams so they can be read from JARs.
 */
public LdapServer(final InputStream properties,
                  final InputStream ldifFile,
                  final InputStream schemaFile) {
    try {
        final Properties p = new Properties();
        p.load(properties);

        final InMemoryDirectoryServerConfig config =
                new InMemoryDirectoryServerConfig(p.getProperty("ldap.rootDn"));
        config.addAdditionalBindCredentials(p.getProperty("ldap.managerDn"), p.getProperty("ldap.managerPassword"));

        final File keystoreFile = File.createTempFile("key", "store");
        try (final OutputStream outputStream = new FileOutputStream(keystoreFile)) {
            IOUtils.copy(new ClassPathResource("/ldapServerTrustStore").getInputStream(), outputStream);
        }

        final String serverKeyStorePath = keystoreFile.getCanonicalPath();
        final SSLUtil serverSSLUtil = new SSLUtil(
                new KeyStoreKeyManager(serverKeyStorePath, "changeit".toCharArray()), new TrustStoreTrustManager(serverKeyStorePath));
        final SSLUtil clientSSLUtil = new SSLUtil(new TrustStoreTrustManager(serverKeyStorePath));
        config.setListenerConfigs(
                InMemoryListenerConfig.createLDAPConfig("LDAP", // Listener name
                        null, // Listen address. (null = listen on all interfaces)
                        1389, // Listen port (0 = automatically choose an available port)
                        serverSSLUtil.createSSLSocketFactory()), // StartTLS factory
                InMemoryListenerConfig.createLDAPSConfig("LDAPS", // Listener name
                        null, // Listen address. (null = listen on all interfaces)
                        1636, // Listen port (0 = automatically choose an available port)
                        serverSSLUtil.createSSLServerSocketFactory(), // Server factory
                        clientSSLUtil.createSSLSocketFactory())); // Client factory

        config.setEnforceSingleStructuralObjectClass(false);
        config.setEnforceAttributeSyntaxCompliance(true);
        config.setMaxConnections(-1);

        final File file = File.createTempFile("ldap", "schema");
        try (final OutputStream outputStream = new FileOutputStream(file)) {
            IOUtils.copy(schemaFile, outputStream);
        }

        final Schema s = Schema.mergeSchemas(Schema.getSchema(file));
        config.setSchema(s);


        this.directoryServer = new InMemoryDirectoryServer(config);
        LOGGER.debug("Populating directory...");

        final File ldif = File.createTempFile("ldiff", "file");
        try (final OutputStream outputStream = new FileOutputStream(ldif)) {
            IOUtils.copy(ldifFile, outputStream);
        }

        this.directoryServer.importFromLDIF(true, ldif.getCanonicalPath());
        this.directoryServer.restartServer();

        final LDAPConnection c = getConnection();
        LOGGER.debug("Connected to {}:{}", c.getConnectedAddress(), c.getConnectedPort());

        LOGGER.debug("Bind DN: {}",  p.getProperty("ldap.managerDn"));
        LOGGER.debug("Bind credential: {}", p.getProperty("ldap.managerPassword"));

        populateDefaultEntries(c);

        c.close();
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:UniconLabs,项目名称:unboundid-ldap-server,代码行数:73,代码来源:LdapServer.java

示例7: configureAndStartServer

import com.unboundid.ldap.sdk.schema.Schema; //导入依赖的package包/类
/**
 * Configures and starts the local LDAP server.  This method is invoked by start().
 *
 * @throws Exception
 */
protected synchronized void configureAndStartServer() throws Exception {
    LOG.info(">>>LdapServerImpl.configureServer()");

    Collection<InMemoryListenerConfig> listenerConfigs = getInMemoryListenerConfigs();

    Schema schema = null;
    if (configuration.getSchema() == null || StringUtils.isEmpty(configuration.getSchema().getName())) {
        schema = Schema.getDefaultStandardSchema();
    } else {
        final String schemaName = configuration.getSchema().getName();
        URL schemaUrl = this.getClass().getClassLoader().getResource(schemaName);
        File schemaFile = new File(schemaUrl.toURI());
        schema = Schema.getSchema(schemaFile);
    }

    final String rootObjectDN = configuration.getRoot().getObjectDn();
    InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(new DN(rootObjectDN));
    //LOG.debug(System.getProperty("java.class.path"));

    config.setSchema(schema);  //schema can be set on the rootDN too, per javadoc.
    config.setListenerConfigs(listenerConfigs);

    LOG.info(config.getSchema().toString());

    /* Add handlers for debug and acccess log events.  These classes can be extended or dependency injected in a future version for more robust behavior. */
    config.setLDAPDebugLogHandler(new LDAPDebugLogHandler());
    config.setAccessLogHandler(new AccessLogHandler());
    config.addAdditionalBindCredentials(configuration.getBindDn(), configuration.getPassword());

    server = new InMemoryDirectoryServer(config);

    try {
        /* Clear entries from server. */
        server.clear();
        server.startListening();

        loadRootEntry();
        loadEntries();
        loadLdifFiles();
        resetPersonPasswords();

        LOG.info("   Total entry count: {}", server.countEntries());
        LOG.info("<<<LdapServerImpl.configureServer()");
    } catch (LDAPException ldape) {
        if (ldape.getMessage().contains("java.net.BindException")) {
            throw new BindException(ldape.getMessage());
        }
        throw ldape;
    }

}
 
开发者ID:inbloom,项目名称:ldap-in-memory,代码行数:57,代码来源:LdapServerImpl.java

示例8: LdapServerExternalResource

import com.unboundid.ldap.sdk.schema.Schema; //导入依赖的package包/类
public LdapServerExternalResource(Schema schema, LinkedHashMap<String, Attribute[]> preload) {
    this.schema = schema;
    preloadDnData = preload;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:5,代码来源:LdapServerExternalResource.java

示例9: getSchema

import com.unboundid.ldap.sdk.schema.Schema; //导入依赖的package包/类
@Override
public Schema getSchema() throws LDAPException {return _delegateConnection.getSchema();}
 
开发者ID:zagyi,项目名称:adsync4j,代码行数:3,代码来源:AbstractUnboundIDLdapConnectionDecorator.java

示例10: initSchema

import com.unboundid.ldap.sdk.schema.Schema; //导入依赖的package包/类
private void initSchema(InMemoryDirectoryServerConfig config) throws LDAPSDKException, IOException {
    if (_schemas.size() > 0) {
        config.setSchema(Schema.mergeSchemas(getSchemasInArray()));
    }
}
 
开发者ID:zagyi,项目名称:adsync4j,代码行数:6,代码来源:EmbeddedUnboundIDLdapServer.java

示例11: getSchema

import com.unboundid.ldap.sdk.schema.Schema; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <BR><BR>
 * This method may be used regardless of whether the server is listening for
 * client connections.
 */
public Schema getSchema()
       throws LDAPException
{
  return inMemoryHandler.getSchema();
}
 
开发者ID:zagyi,项目名称:adsync4j,代码行数:12,代码来源:InMemoryDirectoryServer.java


注:本文中的com.unboundid.ldap.sdk.schema.Schema类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。