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


Java KdcServer类代码示例

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


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

示例1: initKdcServer

import org.apache.directory.server.kerberos.kdc.KdcServer; //导入依赖的package包/类
private void initKdcServer() throws KerberosException {
    KerberosConfig kdcConfig = new KerberosConfig();
    kdcConfig.setSearchBaseDn(USERS_DN);
    kdcConfig.setServicePrincipal(getPrincipal("krbtgt/" + realm));
    kdcConfig.setPrimaryRealm(realm);
    kdcConfig.setMaximumTicketLifetime(TimeUnit.DAYS.toMillis(1));
    kdcConfig.setMaximumRenewableLifetime(TimeUnit.DAYS.toMillis(1));
    kdcConfig.setForwardableAllowed(true);
    kdcConfig.setPostdatedAllowed(true);
    kdcConfig.setProxiableAllowed(true);
    kdcConfig.setRenewableAllowed(true);
    kdcConfig.setEmptyAddressesAllowed(true);
    kdcConfig.setPaEncTimestampRequired(false);
    kdcServer = new KdcServer(kdcConfig);
    try {
        host = InetAddress.getLocalHost().getCanonicalHostName();
    } catch (UnknownHostException e) {
        LOGGER.warn("Failed to get canonical host name. Using default: " + host);
    }
    TcpTransport defaultTransport = new TcpTransport(host, port);
    kdcServer.addTransports(defaultTransport);
    kdcServer.setDirectoryService(directoryService);
    addUserEntry("krbtgt/" + realm, "pass");
}
 
开发者ID:intropro,项目名称:prairie,代码行数:25,代码来源:KerberosServer.java

示例2: ApacheDS

import org.apache.directory.server.kerberos.kdc.KdcServer; //导入依赖的package包/类
private ApacheDS(String realm, String baseDn) {
  this.realm = realm;
  this.baseDn = baseDn;
  directoryService = new DefaultDirectoryService();
  ldapServer = new LdapServer();
  kdcServer = new KdcServer();
}
 
开发者ID:SonarQubeCommunity,项目名称:sonar-activedirectory,代码行数:8,代码来源:ApacheDS.java

示例3: start

import org.apache.directory.server.kerberos.kdc.KdcServer; //导入依赖的package包/类
/**
 * @throws IOException if we cannot bind to the sockets
 */
public void start() throws IOException, LdapInvalidDnException {
    super.start();

    try {

        // override initialized replay cache with a dummy implementation
        Field replayCacheField = KdcServer.class.getDeclaredField("replayCache");
        replayCacheField.setAccessible(true);
        replayCacheField.set(this, new DummyReplayCache());
    } catch (Exception e) {
        LOGGER.warn("Unable to override replay cache.", e);
    }

}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:KDCServerAnnotationProcessor.java

示例4: ApacheKDCServer

import org.apache.directory.server.kerberos.kdc.KdcServer; //导入依赖的package包/类
public ApacheKDCServer() {
    this.kdcServer = new KdcServer();
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:4,代码来源:ApacheKDCServer.java

示例5: initKDCServer

import org.apache.directory.server.kerberos.kdc.KdcServer; //导入依赖的package包/类
private void initKDCServer() throws Exception {
  String orgName= conf.getProperty(ORG_NAME);
  String orgDomain = conf.getProperty(ORG_DOMAIN);
  String bindAddress = conf.getProperty(KDC_BIND_ADDRESS);
  final Map<String, String> map = new HashMap<String, String>();
  map.put("0", orgName.toLowerCase());
  map.put("1", orgDomain.toLowerCase());
  map.put("2", orgName.toUpperCase());
  map.put("3", orgDomain.toUpperCase());
  map.put("4", bindAddress);

  ClassLoader cl = Thread.currentThread().getContextClassLoader();
  InputStream is = cl.getResourceAsStream("minikdc.ldiff");

  SchemaManager schemaManager = ds.getSchemaManager();
  final String content = StrSubstitutor.replace(IOUtils.toString(is), map);
  LdifReader reader = new LdifReader(new StringReader(content));
  try {
    for (LdifEntry ldifEntry : reader) {
      ds.getAdminSession().add(new DefaultEntry(schemaManager,
              ldifEntry.getEntry()));
    }
  } finally {
    reader.close();
  }

  kdc = new KdcServer();
  kdc.setDirectoryService(ds);

  // transport
  String transport = conf.getProperty(TRANSPORT);
  if (transport.trim().equals("TCP")) {
    kdc.addTransports(new TcpTransport(bindAddress, port, 3, 50));
  } else if (transport.trim().equals("UDP")) {
    kdc.addTransports(new UdpTransport(port));
  } else {
    throw new IllegalArgumentException("Invalid transport: " + transport);
  }
  kdc.setServiceName(conf.getProperty(INSTANCE));
  kdc.getConfig().setMaximumRenewableLifetime(
          Long.parseLong(conf.getProperty(MAX_RENEWABLE_LIFETIME)));
  kdc.getConfig().setMaximumTicketLifetime(
          Long.parseLong(conf.getProperty(MAX_TICKET_LIFETIME)));

  kdc.getConfig().setPaEncTimestampRequired(false);
  kdc.start();

  StringBuilder sb = new StringBuilder();
  is = cl.getResourceAsStream("minikdc-krb5.conf");
  BufferedReader r = new BufferedReader(new InputStreamReader(is));
  String line = r.readLine();
  while (line != null) {
    sb.append(line).append("{3}");
    line = r.readLine();
  }
  r.close();
  krb5conf = new File(workDir, "krb5.conf").getAbsoluteFile();
  FileUtils.writeStringToFile(krb5conf,
          MessageFormat.format(sb.toString(), getRealm(), getHost(),
                  Integer.toString(getPort()), System.getProperty("line.separator")));
  System.setProperty("java.security.krb5.conf", krb5conf.getAbsolutePath());

  System.setProperty("sun.security.krb5.debug", conf.getProperty(DEBUG,
          "false"));

  // refresh the config
  Class<?> classRef;
  if (System.getProperty("java.vendor").contains("IBM")) {
    classRef = Class.forName("com.ibm.security.krb5.internal.Config");
  } else {
    classRef = Class.forName("sun.security.krb5.Config");
  }
  Method refreshMethod = classRef.getMethod("refresh", new Class[0]);
  refreshMethod.invoke(classRef, new Object[0]);

  LOG.info("MiniKdc listening at port: {}", getPort());
  LOG.info("MiniKdc setting JVM krb5.conf to: {}",
          krb5conf.getAbsolutePath());
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:80,代码来源:MiniKdc.java

示例6: getKdcServer

import org.apache.directory.server.kerberos.kdc.KdcServer; //导入依赖的package包/类
/**
 * Creates and starts KdcServer based on configuration from {@link ExtCreateKdcServer} annotation.
 *
 * @param directoryService
 * @param startPort start port number used for searching free ports in case the transport has no port number preconfigured.
 * @return
 * @throws Exception
 */
public static KdcServer getKdcServer(DirectoryService directoryService, int startPort, String address) throws Exception {
    final CreateKdcServer createKdcServer = (CreateKdcServer) AnnotationUtils.getInstance(CreateKdcServer.class);
    return createKdcServer(createKdcServer, directoryService, startPort, address);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:13,代码来源:KDCServerAnnotationProcessor.java


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