All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aoindustries.aoserv.master.MasterConfiguration Maven / Gradle / Ivy

There is a newer version: 1.91.8
Show newest version
/*
 * aoserv-master - Master server for the AOServ Platform.
 * Copyright (C) 2001-2013, 2015, 2017, 2018, 2019, 2020  AO Industries, Inc.
 *     [email protected]
 *     7262 Bull Pen Cir
 *     Mobile, AL 36695
 *
 * This file is part of aoserv-master.
 *
 * aoserv-master is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * aoserv-master is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with aoserv-master.  If not, see .
 */
package com.aoindustries.aoserv.master;

import com.aoindustries.aoserv.client.account.Account;
import com.aoindustries.dbc.DatabaseAccess;
import com.aoindustries.io.AOPool;
import com.aoindustries.lang.Strings;
import com.aoindustries.net.InetAddress;
import com.aoindustries.util.PropertiesUtils;
import com.aoindustries.validation.ValidationException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

/**
 * The configuration for all AOServ processes is stored in a properties file.
 *
 * @author  AO Industries, Inc.
 */
public final class MasterConfiguration {

	private static Properties props;

	private MasterConfiguration() {
	}

	private static String getProperty(String name) throws IOException {
		synchronized (MasterConfiguration.class) {
			if (props == null) props = PropertiesUtils.loadFromResource(MasterConfiguration.class, "aoserv-master.properties");
			return props.getProperty(name);
		}
	}

	public static String getSSLKeystorePassword() throws IOException {
		return getProperty("aoserv.master.ssl.keystore.password");
	}

	public static String getSSLKeystorePath() throws IOException {
		return getProperty("aoserv.master.ssl.keystore.path");
	}

	public static String getSSLTruststorePassword() throws IOException {
		return getProperty("aoserv.daemon.client.ssl.truststore.password");
	}

	public static String getSSLTruststorePath() throws IOException {
		return getProperty("aoserv.daemon.client.ssl.truststore.path");
	}

	public static List getProtocols() throws IOException {
		return Strings.splitCommaSpace(getProperty("aoserv.master.protocols"));
	}

	/**
	 * Gets the local IP address used for outgoing connections to the daemons.
	 */
	public static InetAddress getLocalIp() throws IOException {
		try {
			return InetAddress.valueOf(getProperty("aoserv.master.local_ip"));
		} catch(ValidationException e) {
			throw new IOException(e.getLocalizedMessage(), e);
		}
	}

	public static List getBinds(String protocol) throws IOException {
		return Strings.splitCommaSpace(getProperty("aoserv.master."+protocol+".bind"));
	}

	public static List getPorts(String protocol) throws IOException {
		String ports = getProperty("aoserv.master."+protocol+".ports");
		List strings = Strings.splitCommaSpace(ports);
		List ints = new ArrayList<>(strings.size());
		for(int c=0,len=strings.size();c




© 2015 - 2025 Weber Informatics LLC | Privacy Policy