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


Java DirectoryService类代码示例

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


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

示例1: DefaultCoreSession

import org.apache.directory.server.core.api.DirectoryService; //导入依赖的package包/类
/**
 * Creates a new instance of a DefaultCoreSession
 * @param principal The principal to use to process operation for this session
 * @param directoryService The DirectoryService to which we will send requests
 */
public DefaultCoreSession( LdapPrincipal principal, DirectoryService directoryService )
{
    this.directoryService = directoryService;
    authenticatedPrincipal = principal;

    if ( principal.getAuthenticationLevel() == AuthenticationLevel.NONE )
    {
        anonymousPrincipal = principal;
    }
    else
    {
        anonymousPrincipal = new LdapPrincipal( directoryService.getSchemaManager() );
    }

    // setup attribute type value
    OBJECT_CLASS_AT = directoryService.getSchemaManager().getAttributeType( SchemaConstants.OBJECT_CLASS_AT );
    
    // initalize the user session
    this.userSession = new HashMap<Object,Object>();
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:26,代码来源:DefaultCoreSession.java

示例2: createPrincipal

import org.apache.directory.server.core.api.DirectoryService; //导入依赖的package包/类
private void createPrincipal(String principal, String password)
    throws Exception {
  DirectoryService ds = getService();
  String baseDn = "ou=users,ou=system";
  String content = "dn: uid=" + principal + "," + baseDn + "\n" +
      "objectClass: top\n" +
      "objectClass: person\n" +
      "objectClass: inetOrgPerson\n" +
      "cn: " + principal + "\n" +
      "sn: " + principal + "\n" +
      "uid: " + principal + "\n" +
      "userPassword: " + password;

  for (LdifEntry ldifEntry : new LdifReader(new StringReader(content))) {
    ds.getAdminSession().add(new DefaultEntry(ds.getSchemaManager(),
        ldifEntry.getEntry()));
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:19,代码来源:TestLDAPAuthentication.java

示例3: importLdif

import org.apache.directory.server.core.api.DirectoryService; //导入依赖的package包/类
private void importLdif(DirectoryService directoryService,
                        final SchemaManager schemaManager,
                        LdifReader ldifReader) throws Exception {
   try {
      for (LdifEntry ldifEntry : ldifReader) {
         checkPartition(ldifEntry);
         directoryService.getAdminSession().add(new DefaultEntry(schemaManager, ldifEntry.getEntry()));
      }
   } finally {
      try {
         ldifReader.close();
      } catch (IOException ioe) {
         // ignore
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:17,代码来源:LdapServer.java

示例4: createEnv

import org.apache.directory.server.core.api.DirectoryService; //导入依赖的package包/类
/**
 * Creates an environment configuration for JNDI access.
 */
private Properties createEnv() {
    // Fetch directory service from servlet context
    ServletContext servletContext = this.getServletContext();
    DirectoryService directoryService = (DirectoryService) servletContext.getAttribute(DirectoryService.JNDI_KEY);

    Properties env = new Properties();
    env.put(DirectoryService.JNDI_KEY, directoryService);
    env.put(Context.PROVIDER_URL, "");
    env.put(Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName());

    env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
    env.put(Context.SECURITY_CREDENTIALS, "secret");
    env.put(Context.SECURITY_AUTHENTICATION, "simple");

    return env;
}
 
开发者ID:apache,项目名称:syncope,代码行数:20,代码来源:ApacheDSRootDseServlet.java

示例5: setDirectoryService

import org.apache.directory.server.core.api.DirectoryService; //导入依赖的package包/类
public void setDirectoryService( DirectoryService directoryService )
{
    super.setDirectoryService( directoryService );
    Iterator<String> itr = directoryService.getLdapCodecService().registeredControls();
    while ( itr.hasNext() )
    {
        supportedControls.add( itr.next() );
    }
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:10,代码来源:LdapServer.java

示例6: init

import org.apache.directory.server.core.api.DirectoryService; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void init( DirectoryService directoryService ) throws LdapException
{
    super.init( directoryService );
    nexus = directoryService.getPartitionNexus();
    Value<?> attr = nexus.getRootDse( null ).get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get();
    subschemSubentryDn = directoryService.getDnFactory().create( attr.getString() );
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:11,代码来源:ExceptionInterceptor.java

示例7: init

import org.apache.directory.server.core.api.DirectoryService; //导入依赖的package包/类
/**
 * Initialize the Schema Service
 *
 * @param directoryService the directory service core
 * @throws Exception if there are problems during initialization
 */
public void init( DirectoryService directoryService ) throws LdapException
{
    if ( IS_DEBUG )
    {
        LOG.debug( "Initializing SchemaInterceptor..." );
    }

    super.init( directoryService );

    nexus = directoryService.getPartitionNexus();
    topFilter = new TopFilter();
    filters.add( topFilter );

    schemaBaseDn = directoryService.getDnFactory().create( SchemaConstants.OU_SCHEMA );

    // stuff for dealing with subentries (garbage for now)
    Value<?> subschemaSubentry = nexus.getRootDse( null ).get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get();
    subschemaSubentryDn = directoryService.getDnFactory().create( subschemaSubentry.getString() );
    subschemaSubentryDn.apply( schemaManager );
    subschemaSubentryDnNorm = subschemaSubentryDn.getNormName();

    schemaModificationAttributesDn = directoryService.getDnFactory().create(
        SchemaConstants.SCHEMA_MODIFICATIONS_DN );
    schemaModificationAttributesDn.apply( schemaManager );

    computeSuperiors();

    // Initialize the schema manager
    SchemaLoader loader = directoryService.getSchemaManager().getLoader();
    schemaSubEntryManager = new SchemaSubentryManager( schemaManager, loader, directoryService.getDnFactory() );

    if ( IS_DEBUG )
    {
        LOG.debug( "SchemaInterceptor Initialized !" );
    }
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:43,代码来源:SchemaInterceptor.java

示例8: init

import org.apache.directory.server.core.api.DirectoryService; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void init( DirectoryService directoryService ) throws LdapException
{
    super.init( directoryService );
    nexus = directoryService.getPartitionNexus();
    Value<?> attr = nexus.getRootDseValue( SUBSCHEMA_SUBENTRY_AT );
    subschemSubentryDn = dnFactory.create( attr.getString() );
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:11,代码来源:ExceptionInterceptor.java

示例9: init

import org.apache.directory.server.core.api.DirectoryService; //导入依赖的package包/类
/**
 * Initialize the Schema Service
 *
 * @param directoryService the directory service core
 * @throws Exception if there are problems during initialization
 */
public void init( DirectoryService directoryService ) throws LdapException
{
    if ( IS_DEBUG )
    {
        LOG.debug( "Initializing SchemaInterceptor..." );
    }

    super.init( directoryService );

    nexus = directoryService.getPartitionNexus();
    topFilter = new TopFilter();
    filters.add( topFilter );

    schemaBaseDn = dnFactory.create( SchemaConstants.OU_SCHEMA );

    // stuff for dealing with subentries (garbage for now)
    Value<?> subschemaSubentry = nexus.getRootDseValue( SUBSCHEMA_SUBENTRY_AT );
    subschemaSubentryDn = dnFactory.create( subschemaSubentry.getString() );
    subschemaSubentryDnNorm = subschemaSubentryDn.getNormName();

    schemaModificationAttributesDn = dnFactory.create(
        SchemaConstants.SCHEMA_MODIFICATIONS_DN );

    computeSuperiors();

    // Initialize the schema manager
    SchemaLoader loader = directoryService.getSchemaManager().getLoader();
    schemaSubEntryManager = new SchemaSubentryManager( schemaManager, loader, dnFactory );

    if ( IS_DEBUG )
    {
        LOG.debug( "SchemaInterceptor Initialized !" );
    }
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:41,代码来源:SchemaInterceptor.java

示例10: createGroup

import org.apache.directory.server.core.api.DirectoryService; //导入依赖的package包/类
private void createGroup(String groupName, String memberDn) throws Exception {
  DirectoryService ds = getService();
  String baseDn = "ou=groups,ou=system";
  String content = "dn: cn=" + groupName + "," + baseDn + "\n" +
      "objectClass: top\n" +
      "objectClass: groupofnames\n" +
      "cn: " + groupName + "\n" +
      "description: " + groupName + "\n" +
      "member: " + memberDn;

  for (LdifEntry ldifEntry : new LdifReader(new StringReader(content))) {
    ds.getAdminSession().add(new DefaultEntry(ds.getSchemaManager(),
        ldifEntry.getEntry()));
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:16,代码来源:TestLDAPAuthentication.java

示例11: contextInitialized

import org.apache.directory.server.core.api.DirectoryService; //导入依赖的package包/类
/**
 * Startup ApacheDS embedded.
 *
 * @param sce ServletContext event
 */
@Override
public void contextInitialized(final ServletContextEvent sce) {
    File workDir = (File) sce.getServletContext().getAttribute("javax.servlet.context.tempdir");
    workDir = new File(workDir, "server-work");

    final boolean loadDefaultContent = !workDir.exists();

    if (loadDefaultContent && !workDir.mkdirs()) {
        throw new RuntimeException("Could not create " + workDir.getAbsolutePath());
    }

    Entry result;
    try {
        initDirectoryService(sce.getServletContext(), workDir, loadDefaultContent);

        server = new LdapServer();
        server.setTransports(new TcpTransport(Integer.parseInt(
                WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext()).
                getBean("testds.port", String.class))));
        server.setDirectoryService(service);

        server.start();

        // store directoryService in context to provide it to servlets etc.
        sce.getServletContext().setAttribute(DirectoryService.JNDI_KEY, service);

        result = service.getAdminSession().lookup(new Dn("o=isp"));
    } catch (Exception e) {
        LOG.error("Fatal error in context init", e);
        throw new RuntimeException(e);
    }

    if (result == null) {
        throw new RuntimeException("Base DN not found");
    } else {
        LOG.info("ApacheDS startup completed succesfully");
    }
}
 
开发者ID:apache,项目名称:syncope,代码行数:44,代码来源:ApacheDSStartStopListener.java

示例12: createPartition

import org.apache.directory.server.core.api.DirectoryService; //导入依赖的package包/类
private static void createPartition(final DirectoryServiceFactory dsf, final SchemaManager schemaManager, final String id,
        final String suffix, final DirectoryService directoryService, final File workingDir) throws Exception {
    PartitionFactory pf = dsf.getPartitionFactory();
    Partition p = pf.createPartition(schemaManager, id, suffix, 1000, workingDir);
    pf.addIndex(p, "uid", 10);
    pf.addIndex(p, "departmentNumber", 10);
    pf.addIndex(p, "member", 10);
    pf.addIndex(p, "memberOf", 10);
    p.initialize();
    directoryService.addPartition(p);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:12,代码来源:LdapTestSuite.java

示例13: shutdownDirectoryService

import org.apache.directory.server.core.api.DirectoryService; //导入依赖的package包/类
public static void shutdownDirectoryService(DirectoryService service) throws Exception {
    if (service != null) {
        LOG.debug("Shuting down DS for {}", service.getInstanceId());
        service.shutdown();
        FileUtils.deleteDirectory(service.getInstanceLayout().getInstanceDirectory());
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:8,代码来源:DirectoryServiceBuilder.java

示例14: getCurrentRevision

import org.apache.directory.server.core.api.DirectoryService; //导入依赖的package包/类
public static long getCurrentRevision(DirectoryService dirService) throws Exception {
    if ((dirService != null) && (dirService.getChangeLog().isEnabled())) {
        long revision = dirService.getChangeLog().getCurrentRevision();
        LOG.debug("Create revision {}", revision);
        return revision;
    }
    return 0;
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:9,代码来源:DirectoryServiceBuilder.java

示例15: revert

import org.apache.directory.server.core.api.DirectoryService; //导入依赖的package包/类
public static void revert(DirectoryService dirService, long revision) throws Exception {
    ChangeLog cl = dirService.getChangeLog();
    if (cl.isEnabled() && (revision < cl.getCurrentRevision())) {
        LOG.debug("Revert revision {}", revision);
        dirService.revert(revision);
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:8,代码来源:DirectoryServiceBuilder.java


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