Java Examples for com.unboundid.ldap.sdk.schema.Schema
The following java examples will help you to understand the usage of com.unboundid.ldap.sdk.schema.Schema. These source code samples are taken from different open source projects.
Example 1
| Project: spring-boot-master File: EmbeddedLdapAutoConfiguration.java View source code |
private void setSchema(InMemoryDirectoryServerConfig config, Resource resource) {
try {
Schema defaultSchema = Schema.getDefaultStandardSchema();
Schema schema = Schema.getSchema(resource.getInputStream());
config.setSchema(Schema.mergeSchemas(defaultSchema, schema));
} catch (Exception ex) {
throw new IllegalStateException("Unable to load schema " + resource.getDescription(), ex);
}
}Example 2
| Project: adsync4j-master File: EmbeddedUnboundIDLdapServer.java View source code |
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; }
Example 3
| Project: ldap-in-memory-master File: LdapServerImpl.java View source code |
/**
* 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"));
//schema can be set on the rootDN too, per javadoc.
config.setSchema(schema);
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;
}
}Example 4
| Project: coprhd-controller-master File: LDAPServer.java View source code |
/**
* Stars the in memory ldap server by reading all the schema and config
* ldif files. Once all the configurations are loaded to the in memory
* ldap server, it starts listening for both ldap and ldaps connections
* from clients.
*
* @return true if the in memory ldap server is started and successfully
* listening for the client connections, false otherwise.
*
* @throws LDIFException
* @throws LDAPException
* @throws IOException
* @throws FileOperationFailedException
* @throws GeneralSecurityException
* @throws DirectoryOrFileNotFoundException
*/
public boolean start() throws LDIFException, LDAPException, IOException, FileOperationFailedException, GeneralSecurityException, DirectoryOrFileNotFoundException {
if (_isRunning) {
_log.info("LDAP Service is already running.");
return false;
}
_log.info("Starting LDAP Service.");
addLDAPBindCredentials();
_log.info("Importing Schema Ldifs");
importLDAPSchemaLdifs();
List<InMemoryListenerConfig> listenerConfigs = getInMemoryListenerConfigs();
_inMemoryDSConfig.setListenerConfigs(listenerConfigs);
_inMemoryDS = new InMemoryDirectoryServer(_inMemoryDSConfig);
_log.info("Importing Config Ldifs");
importLDAPConfigLdifs();
_log.info("Star listening...");
_inMemoryDS.startListening();
_isRunning = true;
return _isRunning;
}