public HttpAPILogic(Holder holder) { super(holder.tokenManager, holder.sessionDao, holder.stats, ""); this.blockingIOProcessor = holder.blockingIOProcessor; this.mailWrapper = holder.mailWrapper; this.gcmWrapper = holder.gcmWrapper; this.reportingDao = holder.reportingDiskDao; this.eventorProcessor = holder.eventorProcessor; this.dbManager = holder.dbManager; this.fileManager = holder.fileManager; this.host = holder.props.host; this.httpsPort = holder.props.getHttpsPortAsString(); }
public MobileLoginHandler(Holder holder) { this.holder = holder; this.asyncHttpClient = holder.asyncHttpClient; this.allowStoreIp = holder.props.getAllowStoreIp(); }
public HardwareLoginHandler(Holder holder, int listenPort) { this.holder = holder; this.dbManager = holder.dbManager; this.blockingIOProcessor = holder.blockingIOProcessor; boolean isForce80ForRedirect = holder.props.getBoolProperty("force.port.80.for.redirect"); this.listenPort = isForce80ForRedirect ? "80" : String.valueOf(listenPort); this.allowStoreIp = holder.props.getAllowStoreIp(); }
public static void main(String[] args) throws Exception { Map<String, String> cmdProperties = ArgumentsParser.parse(args); ServerProperties serverProperties = new ServerProperties(cmdProperties); LoggerUtil.configureLogging(serverProperties); //required for logging dynamic context System.setProperty("data.folder", serverProperties.getProperty("data.folder")); //required to avoid dependencies within model to server.properties setGlobalProperties(serverProperties); MailProperties mailProperties = new MailProperties(cmdProperties); SmsProperties smsProperties = new SmsProperties(cmdProperties); GCMProperties gcmProperties = new GCMProperties(cmdProperties); TwitterProperties twitterProperties = new TwitterProperties(cmdProperties); Security.addProvider(new BouncyCastleProvider()); boolean restore = Boolean.parseBoolean(cmdProperties.get(ArgumentsParser.RESTORE_OPTION)); start(serverProperties, mailProperties, smsProperties, gcmProperties, twitterProperties, restore); }
@GET @Path("/{name}") public Response getConfigByName(@PathParam("name") String name) { switch (name) { case TOKEN_MAIL_BODY : return ok(new Config(name, textHolder.tokenBody).toString()); case SERVER_PROPERTIES_FILENAME : return ok(new Config(name, serverProperties).toString()); case MAIL_PROPERTIES_FILENAME : return ok(new Config(name, new MailProperties(Collections.emptyMap())).toString()); case GCM_PROPERTIES_FILENAME : return ok(new Config(name, new GCMProperties(Collections.emptyMap())).toString()); case TWITTER_PROPERTIES_FILENAME : return ok(new Config(name, new TwitterProperties(Collections.emptyMap())).toString()); default : return badRequest(); } }
public OTAManager(ServerProperties props) { String port = props.getProperty("http.port", "8080"); this.serverHostUrl = "http://" + props.host + (port.equals("80") ? "" : (":" + port)); this.staticFilesFolder = props.jarPath; this.otaInfos = new ConcurrentHashMap<>(); }
private HikariConfig initConfig(BaseProperties serverProperties) { HikariConfig config = new HikariConfig(); config.setJdbcUrl(serverProperties.getProperty("jdbc.url")); config.setUsername(serverProperties.getProperty("user")); config.setPassword(serverProperties.getProperty("password")); config.setAutoCommit(false); config.setConnectionTimeout(serverProperties.getLongProperty("connection.timeout.millis")); config.setMaximumPoolSize(5); config.setMaxLifetime(0); config.setConnectionTestQuery("SELECT 1"); return config; }
public GCMWrapper(GCMProperties props, AsyncHttpClient httpclient, String productName) { this.apiKey = "key=" + props.getGCMApiKey(); this.httpclient = httpclient; this.gcmURI = props.getGCMServer(); String title = props.getNotificationTitle(); this.title = title.replace(Placeholders.PRODUCT_NAME, productName); }
public Limits(ServerProperties props) { this.webRequestMaxSize = props.getIntProperty("web.request.max.size", 512 * 1024); this.deviceLimit = props.getIntProperty("user.devices.limit", 50); this.tagsLimit = props.getIntProperty("user.tags.limit", 100); this.dashboardsLimit = props.getIntProperty("user.dashboard.max.limit", 100); this.widgetSizeLimitBytes = props.getIntProperty("user.widget.max.size.limit", 10) * 1024; this.profileSizeLimitBytes = props.getIntProperty("user.profile.max.size", 64) * 1024; this.notificationPeriodLimitSec = props.getLongProperty("notifications.frequency.user.quota.limit", 15L) * 1000L; this.userQuotaLimit = props.getIntProperty("user.message.quota.limit", 100); this.webhookPeriodLimitation = isUnlimited(props.getLongProperty("webhooks.frequency.user.quota.limit", 1000), -1L); this.webhookResponseSizeLimitBytes = props.getIntProperty("webhooks.response.size.limit", 64) * 1024; this.webhookFailureLimit = isUnlimited(props.getIntProperty("webhooks.failure.count.limit", 10), Integer.MAX_VALUE); this.hardwareIdleTimeout = props.getIntProperty("hard.socket.idle.timeout", 0); this.appIdleTimeout = props.getIntProperty("app.socket.idle.timeout", 300); this.hourlyRegistrationsLimit = props.getIntProperty("hourly.registrations.limit", 1000); this.storeMinuteRecordDays = props.getIntProperty("store.minute.record.days", 10); this.reportsLimit = 25; }
public BaseClient(String host, int port, Random messageIdGenerator, NioEventLoopGroup nioEventLoopGroup) { this.host = host; this.port = port; this.random = messageIdGenerator; this.props = new ServerProperties(Collections.emptyMap()); this.nioEventLoopGroup = nioEventLoopGroup; }
public TwitterWrapper(TwitterProperties twitterProperties, AsyncHttpClient asyncHttpClient) { this.consumerKey = new ConsumerKey( twitterProperties.getConsumerKey(), twitterProperties.getConsumerSecret() ); this.asyncHttpClient = asyncHttpClient; }
public TransportTypeHolder(ServerProperties serverProperties) { this(serverProperties.getIntProperty("server.worker.threads", Runtime.getRuntime().availableProcessors() * 2)); }
/** * - Sets async logger for all logs * - Defines logging folder * - Sets logging level based on properties */ public static void configureLogging(BaseProperties serverProperties) { //required to make all loggers async with LMAX disruptor System.setProperty("log4j2.contextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"); System.setProperty("AsyncLogger.RingBufferSize", serverProperties.getProperty("async.logger.ring.buffer.size", "2048")); //configurable folder for logs via property. if (serverProperties.getProperty("logs.folder") == null) { System.out.println("logs.folder property is empty."); System.exit(1); } System.setProperty("logs.folder", serverProperties.getProperty("logs.folder")); //changing log level based on properties file changeLogLevel(serverProperties.getProperty("log.level")); }
public MobileResetPasswordHandler(Holder holder) { this.tokensPool = holder.tokensPool; String productName = holder.props.productName; this.resetEmailSubj = "Password restoration for your " + productName + " account."; this.resetEmailBody = holder.textHolder.appResetEmailTemplate .replace(Placeholders.PRODUCT_NAME, productName); this.resetConfirmationSubj = "Your new password on " + productName; this.resetConfirmationBody = holder.textHolder.appResetEmailConfirmationTemplate .replace(Placeholders.PRODUCT_NAME, productName); this.mailWrapper = holder.mailWrapper; this.userDao = holder.userDao; this.blockingIOProcessor = holder.blockingIOProcessor; this.host = holder.props.getRestoreHost(); }
TextHolder(GCMProperties gcmProperties) { this.tokenBody = readTokenMailBody(); this.dynamicMailBody = readDynamicMailBody(); this.staticMailBody = readStaticMailBody(); this.templateIdMailBody = readTemplateIdMailBody(); this.pushNotificationBody = gcmProperties.getNotificationBody(); this.resetPassLandingTemplate = readResetPassLandingTemplateAsString(); this.appResetEmailTemplate = readAppResetEmailTemplateAsString(); this.appResetEmailConfirmationTemplate = readAppResetEmailConfirmationTemplateAsString(); this.registerEmailTemplate = readRegisterEmailTemplate(); } }
protected File makeCertificateFile(String propertyName) { String path = props.getProperty(propertyName); if (path == null || path.isEmpty()) { path = ""; } File file = new File(path); if (!file.exists()) { log.warn("{} file was not found at {} location", propertyName, path); } return file; }
private HikariConfig initConfig(BaseProperties serverProperties) { HikariConfig config = new HikariConfig(); config.setJdbcUrl(serverProperties.getProperty("reporting.jdbc.url")); config.setUsername(serverProperties.getProperty("reporting.user")); config.setPassword(serverProperties.getProperty("reporting.password")); config.setAutoCommit(false); config.setConnectionTimeout(serverProperties.getLongProperty("reporting.connection.timeout.millis")); config.setMaximumPoolSize(5); config.setMaxLifetime(0); config.setConnectionTestQuery("SELECT 1"); return config; }
public ResetPasswordHttpLogic(Holder holder) { super(holder, ""); this.userDao = holder.userDao; this.tokensPool = holder.tokensPool; String productName = holder.props.productName; this.emailSubj = "Password reset request for the " + productName + " app."; this.emailBody = FileLoaderUtil.readResetEmailTemplateAsString() .replace(Placeholders.PRODUCT_NAME, productName); this.newResetPage = holder.textHolder.appResetEmailTemplate .replace(Placeholders.PRODUCT_NAME, productName); this.mailWrapper = holder.mailWrapper; String host = holder.props.host; //using https for private servers as they have valid certificates. String protocol = host.endsWith(".blynk.cc") ? "https://" : "http://"; this.resetPassUrl = protocol + host + "/landing?token="; this.pageContent = holder.textHolder.resetPassLandingTemplate; this.blockingIOProcessor = holder.blockingIOProcessor; this.dbManager = holder.dbManager; this.fileManager = holder.fileManager; this.resetClickHost = holder.props.getRestoreHost(); }
public void generateInitialCertificates(ServerProperties props) { if (isAutoGenerationEnabled && isNeedInitializeOnStart) { System.out.println("Generating own initial certificates..."); try { regenerate(); System.out.println("Success! The certificate for your domain " + props.getProperty("server.host") + " has been generated!"); } catch (Exception e) { System.out.println("Error during certificate generation."); System.out.println(e.getMessage()); } } }
private static void setGlobalProperties(ServerProperties serverProperties) { Map<String, String> globalProps = new HashMap<>(4); globalProps.put("terminal.strings.pool.size", "25"); globalProps.put("initial.energy", "2000"); globalProps.put("table.rows.pool.size", "100"); globalProps.put("csv.export.data.points.max", "43200"); for (var entry : globalProps.entrySet()) { String name = entry.getKey(); String value = serverProperties.getProperty(name, entry.getValue()); System.setProperty(name, value); } }