本文整理汇总了Java中org.apache.directory.server.protocol.shared.transport.UdpTransport类的典型用法代码示例。如果您正苦于以下问题:Java UdpTransport类的具体用法?Java UdpTransport怎么用?Java UdpTransport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UdpTransport类属于org.apache.directory.server.protocol.shared.transport包,在下文中一共展示了UdpTransport类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPort
import org.apache.directory.server.protocol.shared.transport.UdpTransport; //导入依赖的package包/类
/**
* @return The underlying TCP transport port, or -1 if no transport has been
* initialized
*/
public int getPort()
{
if ( transports == null )
{
return -1;
}
for ( Transport transport : transports )
{
if ( transport instanceof UdpTransport )
{
continue;
}
if ( !transport.isSSLEnabled() )
{
return transport.getPort();
}
}
return -1;
}
示例2: getPortSSL
import org.apache.directory.server.protocol.shared.transport.UdpTransport; //导入依赖的package包/类
/**
* @return The underlying SSL enabled TCP transport port, or -1 if no transport has been
* initialized
*/
public int getPortSSL()
{
if ( transports == null )
{
return -1;
}
for ( Transport transport : transports )
{
if ( transport instanceof UdpTransport )
{
continue;
}
if ( transport.isSSLEnabled() )
{
return transport.getPort();
}
}
return -1;
}
示例3: configureTransportHandlers
import org.apache.directory.server.protocol.shared.transport.UdpTransport; //导入依赖的package包/类
private void configureTransportHandlers(KdcConfiguration configuration) {
int port = getServerPort(configuration);
if (configuration.getKdcCommunicationProtocol() ==
KdcConfiguration.ProtocolType.UDP_PROTOCOL) {
logger.info("Starting KDC on UDP mode at port - " + port + " at host - " +
configuration.getKdcHostAddress());
UdpTransport defaultTransport = new UdpTransport(port);
this.kdcServer.addTransports(defaultTransport);
} else {
logger.info("Starting KDC on a TCP port " + port + " at host " +
configuration.getKdcHostAddress());
Transport tcp =
new TcpTransport(configuration.getKdcHostAddress(), port,
configuration.getNumberOfThreads(),
configuration.getBackLogCount());
this.kdcServer.addTransports(tcp);
}
}
示例4: startKerberos
import org.apache.directory.server.protocol.shared.transport.UdpTransport; //导入依赖的package包/类
@SuppressWarnings("unused")
private ApacheDS startKerberos() throws Exception {
Preconditions.checkState(ldapServer.isStarted());
kdcServer.setDirectoryService(directoryService);
// FIXME hard-coded ports
kdcServer.setTransports(new TcpTransport(6088), new UdpTransport(6088));
kdcServer.setEnabled(true);
kdcServer.setPrimaryRealm(realm);
kdcServer.setSearchBaseDn(baseDn);
kdcServer.setKdcPrincipal("krbtgt/" + realm + "@" + baseDn);
kdcServer.start();
// -------------------------------------------------------------------
// Enable the krb5kdc schema
// -------------------------------------------------------------------
Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(DirectoryService.JNDI_KEY, directoryService);
env.put(Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName());
env.put(Context.PROVIDER_URL, ServerDNConstants.OU_SCHEMA_DN);
InitialLdapContext schemaRoot = new InitialLdapContext(env, null);
// check if krb5kdc is disabled
Attributes krb5kdcAttrs = schemaRoot.getAttributes("cn=Krb5kdc");
boolean isKrb5KdcDisabled = false;
if (krb5kdcAttrs.get("m-disabled") != null) {
isKrb5KdcDisabled = ((String) krb5kdcAttrs.get("m-disabled").get()).equalsIgnoreCase("TRUE");
}
// if krb5kdc is disabled then enable it
if (isKrb5KdcDisabled) {
Attribute disabled = new BasicAttribute("m-disabled");
ModificationItem[] mods = new ModificationItem[] {new ModificationItem(DirContext.REMOVE_ATTRIBUTE, disabled)};
schemaRoot.modifyAttributes("cn=Krb5kdc", mods);
}
return this;
}
示例5: createTransport
import org.apache.directory.server.protocol.shared.transport.UdpTransport; //导入依赖的package包/类
private static Transport createTransport( CreateTransport transportBuilder, int startPort )
{
String protocol = transportBuilder.protocol();
int port = transportBuilder.port();
int nbThreads = transportBuilder.nbThreads();
int backlog = transportBuilder.backlog();
String address = transportBuilder.address();
if ( port == -1 )
{
port = AvailablePortFinder.getNextAvailable( startPort );
startPort = port + 1;
}
if ( protocol.equalsIgnoreCase( "TCP" ) )
{
Transport tcp = new TcpTransport( address, port, nbThreads, backlog );
return tcp;
}
else if ( protocol.equalsIgnoreCase( "UDP" ) )
{
UdpTransport udp = new UdpTransport( address, port );
return udp;
}
else
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_689, protocol ) );
}
}
示例6: initKDCServer
import org.apache.directory.server.protocol.shared.transport.UdpTransport; //导入依赖的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());
}