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


Java UtilSSLSocketFactory类代码示例

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


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

示例1: main

import org.pircbotx.UtilSSLSocketFactory; //导入依赖的package包/类
public static void main(final String[] args) throws IOException, IrcException {
    if(args.length != 1) {
        System.out.println("Usage: java -jar internet-on-a-stick.jar <configfile>");
        System.exit(0);
    }

    final ObjectMapper mapper = new ObjectMapper()
            .registerModule(new AutoMatterModule());

    final IrcConfig config = mapper.readValue(new File(args[0]), IrcConfig.class);
    final Configuration configuration = new Configuration.Builder()
        .setName(config.name())
        .setRealName(config.realname())
        .addServer(config.server(), config.port())
        .setSocketFactory(new UtilSSLSocketFactory().trustAllCertificates())
        .addAutoJoinChannels(config.autoJoinChannels())
        .addListener(new IrcBot(config))
        .buildConfiguration();

    //Create our bot with the configuration
    final PircBotX bot = new PircBotX(configuration);
    //Connect to the server
    bot.startBot();
}
 
开发者ID:Unarmed,项目名称:internet-on-a-stick,代码行数:25,代码来源:IrcBot.java

示例2: getBotConfig

import org.pircbotx.UtilSSLSocketFactory; //导入依赖的package包/类
private static Configuration<AgarBot> getBotConfig(Config config) {
    Configuration.Builder<AgarBot> builder =
            new Configuration.Builder<AgarBot>().setAutoReconnect(true)
                    .setMaxLineLength(400).setMessageDelay(0L)
                    .setVersion("A`Gario by likcoras")
                    .setListenerManager(new AgarManager())
                    .setName(config.getNick()).setLogin(config.getUser())
                    .setRealName(config.getGecos())
                    .setServer(config.getHost(), config.getPort());
    if (!config.getPassword().isEmpty()) {
        builder.setNickservPassword(config.getPassword());
    }
    if (config.isSsl()) {
        builder.setSocketFactory(
                new UtilSSLSocketFactory().trustAllCertificates());
    }
    config.getChannels().forEach(builder::addAutoJoinChannel);
    Hooks.LIST.forEach(builder::addListener);
    return builder.buildConfiguration();
}
 
开发者ID:likcoras,项目名称:A-Gario,代码行数:21,代码来源:AgarBot.java

示例3: generateConfiguration

import org.pircbotx.UtilSSLSocketFactory; //导入依赖的package包/类
/**
 * Generates bot {@link Configuration}.
 * @return This bots configuration based on its {@link Properties}.
 */
private static Configuration generateConfiguration() {
    // Building configuration
    Configuration.Builder configBuilder = new Configuration.Builder()
            .setName(Properties.getValue("bot.nick"))
            .setLogin(Properties.getValue("bot.username"))
            .setVersion(TitanBot.VERSION)
            .setRealName(Properties.getValue("bot.real_name"))
            .setSocketFactory(new UtilSSLSocketFactory().trustAllCertificates())
            .setAutoNickChange(true)
            .setAutoReconnect(true)
            .setAutoSplitMessage(false)
            .addListener(new IRCListener())
            .addCapHandler(new TLSCapHandler((SSLSocketFactory) SSLSocketFactory.getDefault(), true))
            .addServer(Properties.getValue("irc.server"), Properties.getValueAsInt("irc.port"));

    // Conditional parameters
    String pass = Properties.getValue("bot.password");

    if (!pass.equalsIgnoreCase("NONE")) {
        configBuilder.setNickservPassword(pass);
    }

    String autojoinChannel = Properties.getValue("irc.autojoin_channel");

    if (!autojoinChannel.equalsIgnoreCase("NONE")) {
        configBuilder.addAutoJoinChannel(autojoinChannel);
    }

    // Now build and return the configuration
    return configBuilder.buildConfiguration();
}
 
开发者ID:MITBorg,项目名称:TitanBot,代码行数:36,代码来源:TitanBot.java

示例4: createBot

import org.pircbotx.UtilSSLSocketFactory; //导入依赖的package包/类
/**
 * Creates the bot and starts it
 * @param wip Wether or not the bot should be started as a development version
 */
public static void createBot(boolean wip) throws Exception
{
	Module.Builder builder = (Module.Builder)new Module.Builder()
			.setVersion(version + (wip ? "_WIP" : ""))
			.setName(botName)
			.setLogin(botName)
			.addServer("irc.esper.net", 6697)
			.setSocketFactory(new UtilSSLSocketFactory().trustAllCertificates())
			.setNickservPassword(Passwords.NICKSERV.getPassword())
			.setAutoNickChange(true)
			.setAutoReconnect(true)
			.setMessageDelay(0)
			.addListener(new Listener())
			.addListener(new Logging());
	Logging.info("Created PircBotX config");
	Logging.info("Setting up external information");
	Startup.callMethods();
	Logging.info("Starting to load modules");
	modules = new Modules(builder);
	Logging.info("Loading private modules");
	builder = modules.initPrivate();
	Logging.info("Loading public modules");
	builder = modules.initPublic();
	Logging.info("All modules loaded");
	bot = new Bot(builder.buildConfiguration(), "-");
	l10n = new L10N();
	Logging.info("Completed last setup steps");
	Logging.info("Starting bot");
	bot.startBot();
}
 
开发者ID:bl4ckscor3,项目名称:bl4ckb0t,代码行数:35,代码来源:Core.java

示例5: createNetwork

import org.pircbotx.UtilSSLSocketFactory; //导入依赖的package包/类
public static PircBotX createNetwork(String serverpass, String nick, String server, int port, String bindhost, String networkname, boolean SSL) {
    if (nick.isEmpty() || server.isEmpty()) {
        DatabaseUtils.removeNetwork(networkname);
        System.out.println("Removing Server " + networkname);
        return null;
    } else if (IRCUtils.getNetworkByNetworkName(networkname) != null) {
        DatabaseUtils.removeNetwork(networkname);
        System.out.println("Removing Server " + networkname);
        return null;
    }

    Configuration.Builder Net = new Configuration.Builder();
    Net.setName(nick);
    Net.setLogin(nick);
    Net.setEncoding(Charset.isSupported("UTF-8") ? Charset.forName("UTF-8") : Charset.defaultCharset());
    if (bindhost != null) {
        try {
            Net.setLocalAddress(InetAddress.getByName(bindhost));
        } catch (UnknownHostException e) {
            System.out.println("Failed to resolve bindhost on " + networkname);
            System.exit(0);
        }
    }
    Net.addServer(server, port);
    Net.setRealName(nick);
    Net.getListenerManager().addListener(new ConnectListener());
    Net.setAutoReconnect(true);
    if (serverpass != null) {
        Net.setServerPassword(serverpass);
    }
    Net.setAutoReconnectAttempts(5);
    Net.setAutoReconnectDelay(20000);
    Net.setChannelPrefixes("#");
    Net.setUserLevelPrefixes("+%@&~!");
    Net.setVersion(Registry.VERSION);
    if(SSL)
    Net.setSocketFactory(new UtilSSLSocketFactory().trustAllCertificates());
    Net.setAutoReconnect(true);
    return new PircBotX(Net.buildConfiguration());
}
 
开发者ID:TechCavern,项目名称:WaveTact,代码行数:41,代码来源:ConfigUtils.java

示例6: connectToServer

import org.pircbotx.UtilSSLSocketFactory; //导入依赖的package包/类
private void connectToServer()
{
    configBuilder.setServer(config.getServerAddress(), config.getServerPort(), config.getServerPassword());

    if (config.getServerSsl())
    {
        configBuilder.setSocketFactory(config.getAcceptInvalidSsl() ? new UtilSSLSocketFactory().trustAllCertificates().disableDiffieHellman() : SSLSocketFactory.getDefault());
    }

    if (config.useNickserv())
    {
        configBuilder.setNickservPassword(config.getNickservPassword());
    }

    logger.info(String.format("Connecting to %s on port %s%s...", config.getServerAddress(), config.getServerPort(), config.getServerSsl() ? " with SSL" : " without SSL"));
    logger.info("Adding channels...");

    for (String channel : config.getChannels())
    {
        if (channel.contains(":"))
        {
            String[] parts = channel.split(":");
            configBuilder.addAutoJoinChannel(parts[0], parts[1]);
            continue;
        }

        configBuilder.addAutoJoinChannel(channel);
    }

    try
    {
        bot = new PircBotX(configBuilder.buildConfiguration());
        bot.startBot();
    }
    catch (IOException | IrcException ex)
    {
        logger.error("Error occurred while connecting", ex);
        shutdown();
    }
}
 
开发者ID:FoxDev,项目名称:FoxBot,代码行数:41,代码来源:FoxBot.java

示例7: IRCMediator

import org.pircbotx.UtilSSLSocketFactory; //导入依赖的package包/类
protected IRCMediator()
{
    Configuration.Builder confBuilder = new Configuration.Builder();

    // check if SSL is enabled, otherwise it won't use SSL connection.
    if (ConfReader.getInstance().isSSL())
    {
        confBuilder.setSocketFactory(new UtilSSLSocketFactory().trustAllCertificates());
    }

    // It tries to authenticate using SASL (it doesn't work on all networks)
    if (ConfReader.getInstance().isIdentifyEnabled())
    {
        confBuilder.addCapHandler(new SASLCapHandler(ConfReader.getInstance().getNick(),
                ConfReader.getInstance().getNickserv_passwd(), true));
    }

    confBuilder.setAutoReconnect(ConfReader.getInstance().isAutoreconnect());
    confBuilder.setAutoReconnectAttempts(ConfReader.getInstance().getReconnectattempts());
    confBuilder.setAutoReconnectDelay(ConfReader.getInstance().getDelaybetweenretries());
    confBuilder.setRealName(ConfReader.getInstance().getRealname());
    confBuilder.setName(ConfReader.getInstance().getNick());
    confBuilder.setLogin(ConfReader.getInstance().getLogin());
    confBuilder.setAutoNickChange(true);
    confBuilder.addServer(ConfReader.getInstance().getIrcserver(), ConfReader.getInstance().getPort());
    confBuilder.addAutoJoinChannel("#" + ConfReader.getInstance().getChannel());

    confBuilder.setVersion(
            ConfReader.getAppProperties().getString("application.name") +
            " v" + ConfReader.getAppProperties()
                    .getString("application.version") +
            " " + ConfReader.getAppProperties()
                    .getString("application.buildnumber")
    );
    confBuilder.addListener(new IRCListener(this) );
    confBuilder.buildConfiguration();

    this.bot = new PircBotX(confBuilder.buildConfiguration());
    this.newsReader = new NewsReader(new IRCOutputter());

    new NewsTimer(ConfReader.getInstance().getPollFrequency()).addTask(
                    new NewsTask(newsReader)
    );
}
 
开发者ID:MadCoderZ,项目名称:NewsBotIRC,代码行数:45,代码来源:IRCMediator.java

示例8: network_connect

import org.pircbotx.UtilSSLSocketFactory; //导入依赖的package包/类
private void network_connect(ActionEvent event)
	{
		final BotConfiguration cfg = new BotConfiguration(bl4ckChat.nameField.getText(), bl4ckChat.networkField.getText(), bl4ckChat.portField.getText(), bl4ckChat.serverPasswordField.getText(),
				bl4ckChat.nickservField.getText(), bl4ckChat.channelField.getText(), bl4ckChat.sslBox.isSelected());
		
		stage.close();
		new MainChatWindow(stage);
		
		SwingUtilities.invokeLater(() -> {
			boolean fail = false;
			
			if(cfg.getName().equals(""))
			{
				cfg.setName("bl4ckChat");
//				System.out.println("Please fill out the name field.");
//				fail = true;
			}

			if(cfg.getNetwork().equals(""))
			{
				cfg.setNetwork("irc.esper.net");
//				System.out.println("Please fill out the network field.");
//				fail = true;
			}

			if(cfg.getPort() == 0)
				cfg.setPort(6669);

			if(!fail)
			{
				try
				{
					Configuration.Builder<PircBotX> config = new Configuration.Builder<PircBotX>()
							.setName(cfg.getName())
							.setLogin(cfg.getName())
							.setServer(cfg.getNetwork(), cfg.getPort())
							.setAutoNickChange(false)
							.setMessageDelay(0);
					
					if(!cfg.getNickserv().equals(""))
						config.setNickservPassword(cfg.getNickserv());
					
					if(cfg.getChannels().length != 0)
					{
						for(String s : cfg.getChannels())
						{
							config.addAutoJoinChannel(s);
						}
					}
					
					if(!cfg.getServerPassword().equals(""))
						config.setServerPassword(cfg.getServerPassword());
						
					if(cfg.useSsl())
						config.setSocketFactory(new UtilSSLSocketFactory().trustAllCertificates()); //need to trust all certificates because else pircbotx will error out for some reason
					
					Reference.bot = new PircBotX(config.buildConfiguration());
					Reference.isBotStarted = true;
					Reference.bot.startBot();
				}
				catch(Exception e)
				{
					e.printStackTrace();
				}
			}
		});
	}
 
开发者ID:bl4ckscor3,项目名称:bl4ckChat,代码行数:68,代码来源:ButtonListener.java

示例9: getXMLConfig

import org.pircbotx.UtilSSLSocketFactory; //导入依赖的package包/类
/**
 * getXMLConfig will then take the settings from the XML, and then 
 * attach listeners to the new bot objects based on the XML settings.
 * @param botSettings
 * @return Configuration<? extends PircBotX> configuration file for PircBotX to create.
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
private Configuration<? extends PircBotX> getXMLConfig(Settings botSettings) {
	// Create builder
	Builder myBuilder = new Configuration.Builder();
	Settings mySettings = botSettings;
	// Add generics to builder
	myBuilder
			.setName(mySettings.getNick())
			.setLogin("RCbot")
			.setAutoNickChange(true)
			.setCapEnabled(true)
			.addCapHandler(
					new TLSCapHandler(new UtilSSLSocketFactory()
							.trustAllCertificates(), true))
			.setAutoReconnect(true)
			.setServerHostname(mySettings.getServer())
			.addAutoJoinChannel(mySettings.getChannel())
			.setNickservPassword(mySettings.getPassword());
	// Add necessary listeners
	myBuilder.addListener(new AdminListener());
	if (mySettings.getRedditPreview() == true) {
		myBuilder.addListener(new RedditPreviewListener());
	}
	if (mySettings.getNewUserGreeting() == true) {
		myBuilder.addListener(new NewUserGreetingListener());
	}
	if (mySettings.getCalendar() == true) {
		myBuilder.addListener(new CalendarListener());
	}
	if (mySettings.getDice() == true) {
		myBuilder.addListener(new DiceListener());
	}
	if (mySettings.getCatfacts() == true) {
		myBuilder.addListener(new CatFactListener());
	}
	if (mySettings.getDadjokes() == true) {
		myBuilder.addListener(new DadJokeListener());
	}
	if (mySettings.getLogger() == true) {
		myBuilder.addListener(new LogListener());
		myBuilder.addListener(new QueryListener());
		myBuilder.addListener(new AutobannerListener());
	}
	if (mySettings.getRcrover() == true){
		myBuilder.addListener(new RoverListener());
	}
	// Build configuration and return
	Configuration<PircBotX> myConfiguration = myBuilder
			.buildConfiguration();
	return myConfiguration;
}
 
开发者ID:AndrewBell,项目名称:RCbot,代码行数:58,代码来源:ConfigFactory.java

示例10: main

import org.pircbotx.UtilSSLSocketFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    config = new Config();
    config.load();

    registerCommands();

    //Setup Logger
    System.setProperty(SimpleLogger.SHOW_DATE_TIME_KEY, "true");
    System.setProperty(SimpleLogger.DATE_TIME_FORMAT_KEY, "[HH:mm:ss]");
    System.setProperty(SimpleLogger.SHOW_THREAD_NAME_KEY, "false");
    System.setProperty(SimpleLogger.LEVEL_IN_BRACKETS_KEY, "true");
    System.setProperty(SimpleLogger.SHOW_LOG_NAME_KEY, "true");
    System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "debug");
    Logger logger = new SimpleLoggerFactory().getLogger(Main.class.getName());
    System.out.println(logger.isDebugEnabled());

    //Setup this bot
    Configuration.Builder builder = new Configuration.Builder();
    builder.setName(config.getBotNickname());
    builder.setRealName(config.getBotRealname());
    builder.setLogin(config.getBotLogin());
    //builder.setNickservPassword(config.getBotPassword());
    builder.setAutoNickChange(true);
    builder.addListener(new BotListener());
    builder.setServer(config.getServerHostname(), config.getServerPort(), config.getServerPassword());
    builder.setSocketFactory(new UtilSSLSocketFactory().trustAllCertificates());
    for(String channel : config.getChannels()){
        builder.addAutoJoinChannel(channel);
    }
    PircBotX bot = new PircBotX(builder.buildConfiguration());

    minecraftLog = new LogTailer(bot, "/home/minecraft/1.7.2/logs/latest.log");
    //Connect to server
    try {
        logger.debug("staring bot");
        bot.startBot();
    } catch (Exception ex) {
        logger.error(null, ex);
        ex.printStackTrace();
    }
}
 
开发者ID:mimiKitsune,项目名称:MimiBot,代码行数:42,代码来源:Main.java


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