<commit_before>/*  Package Jabber Server
 *  Copyright (C) 2001-2007
 *  "<NAME>" <<EMAIL>>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software Foundation,
 *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * $Rev$
 * Last modified by $Author$
 * $Date$
 */
package tigase.server.xmppsession;

import tigase.util.DNSResolver;
import java.util.Map;

/**
 * Describe class SessionManagerConfig here.
 *
 *
 * Created: Tue Oct 24 23:07:57 2006
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @version $Rev$
 */
public class SessionManagerConfig {

	public static final String USER_REPO_CLASS_PROP_KEY = "user-repo-class";
	public static final String XML_REPO_CLASS_PROP_VAL =
		"tigase.db.xml.XMLRepository";
	public static final String MYSQL_REPO_CLASS_PROP_VAL =
		"tigase.db.jdbc.JDBCRepository";
	public static final String PGSQL_REPO_CLASS_PROP_VAL =
		"tigase.db.jdbc.JDBCRepository";
	public static final String DRUPAL_REPO_CLASS_PROP_VAL =
		"tigase.db.jdbc.DrupalAuth";
	public static final String LIBRESOURCE_REPO_CLASS_PROP_VAL =
		"tigase.db.jdbc.LibreSourceAuth";
	public static final String USER_REPO_URL_PROP_KEY = "user-repo-url";
	public static final String XML_REPO_URL_PROP_VAL = "user-repository.xml";
	public static final String MYSQL_REPO_URL_PROP_VAL =
		"jdbc:mysql://localhost/tigase?user=root&password=<PASSWORD>";
	public static final String PGSQL_REPO_URL_PROP_VAL =
		"jdbc:postgresql://localhost/tigase?user=tigase";
	public static final String DRUPAL_REPO_URL_PROP_VAL =
		"jdbc:mysql://localhost/drupal?user=root&password=<PASSWORD>";
	public static final String LIBRESOURCE_REPO_URL_PROP_VAL =
		"jdbc:postgresql://localhost/libresource?user=demo";

	public static final String AUTH_REPO_CLASS_PROP_KEY = "auth-repo-class";
	public static final String AUTH_REPO_URL_PROP_KEY = "auth-repo-url";

	public static final String COMPONENTS_PROP_KEY = "components";
	/**
	 * List of default components loaded by the server. It can be changed later
	 * in config file or at runtime.
	 */
	public static final String[] COMPONENTS_PROP_VAL =
	{"jabber:iq:register", "jabber:iq:auth", "urn:ietf:params:xml:ns:xmpp-sasl",
	 "urn:ietf:params:xml:ns:xmpp-bind", "urn:ietf:params:xml:ns:xmpp-session",
	 "jabber:iq:roster", "jabber:iq:privacy", "presence", "msgoffline",
	 "jabber:iq:version", "http://jabber.org/protocol/stats", "starttls",
	 "vcard-temp", "http://jabber.org/protocol/commands", "jabber:iq:private"};
	/**
	 * List of components loaded when the server is loaded in test mode.
	 * Some components like off-line message storage is disabled during tests.
	 */
	public static final String[] COMPONENTS_TEST_PROP_VAL =
	{"jabber:iq:register", "jabber:iq:auth", "urn:ietf:params:xml:ns:xmpp-sasl",
	 "urn:ietf:params:xml:ns:xmpp-bind", "urn:ietf:params:xml:ns:xmpp-session",
	 "jabber:iq:roster", "jabber:iq:privacy", "presence", "jabber:iq:version",
	 "http://jabber.org/protocol/stats", "starttls", "msgoffline",
	 "vcard-temp", "http://jabber.org/protocol/commands", "jabber:iq:private"};

	public static final String HOSTNAMES_PROP_KEY = "hostnames";
	public static String[] HOSTNAMES_PROP_VAL =	{"localhost", "hostname"};

	public static final String ADMINS_PROP_KEY = "admins";
	public static String[] ADMINS_PROP_VAL =	{"admin@localhost", "admin@hostname"};

	public static void getDefaults(Map<String, Object> props,
		Map<String, Object> params) {

		String user_repo_class = XML_REPO_CLASS_PROP_VAL;
		String user_repo_url = XML_REPO_URL_PROP_VAL;
		String auth_repo_class = XML_REPO_CLASS_PROP_VAL;
		String auth_repo_url = XML_REPO_URL_PROP_VAL;
		if (params.get("--user-db") != null) {
			if (params.get("--user-db").equals("mysql")) {
				user_repo_class = MYSQL_REPO_CLASS_PROP_VAL;
				user_repo_url = MYSQL_REPO_URL_PROP_VAL;
				auth_repo_class = MYSQL_REPO_CLASS_PROP_VAL;
				auth_repo_url = MYSQL_REPO_URL_PROP_VAL;
			}
			if (params.get("--user-db").equals("pgsql")) {
				user_repo_class = PGSQL_REPO_CLASS_PROP_VAL;
				user_repo_url = PGSQL_REPO_URL_PROP_VAL;
				auth_repo_class = PGSQL_REPO_CLASS_PROP_VAL;
				auth_repo_url = PGSQL_REPO_URL_PROP_VAL;
			}
		}
		if (params.get("--user-db-uri") != null) {
			user_repo_url = (String)params.get("--user-db-uri");
			auth_repo_url = user_repo_url;
		}
		if (params.get("--auth-db") != null) {
			if (params.get("--auth-db").equals("mysql")) {
				auth_repo_class = MYSQL_REPO_CLASS_PROP_VAL;
				auth_repo_url = MYSQL_REPO_URL_PROP_VAL;
			}
			if (params.get("--auth-db").equals("pgsql")) {
				auth_repo_class = PGSQL_REPO_CLASS_PROP_VAL;
				auth_repo_url = PGSQL_REPO_URL_PROP_VAL;
			}
			if (params.get("--auth-db").equals("drupal")) {
				auth_repo_class = DRUPAL_REPO_CLASS_PROP_VAL;
				auth_repo_url = DRUPAL_REPO_URL_PROP_VAL;
			}
			if (params.get("--auth-db").equals("libresource")) {
				auth_repo_class = LIBRESOURCE_REPO_CLASS_PROP_VAL;
				auth_repo_url = LIBRESOURCE_REPO_URL_PROP_VAL;
			}
		}
		if (params.get("--auth-db-uri") != null) {
			auth_repo_url = (String)params.get("--auth-db-uri");
		}

		props.put(USER_REPO_CLASS_PROP_KEY, user_repo_class);
	  props.put(USER_REPO_URL_PROP_KEY, user_repo_url);

	  props.put(AUTH_REPO_CLASS_PROP_KEY, auth_repo_class);
	  props.put(AUTH_REPO_URL_PROP_KEY, auth_repo_url);

		if ((Boolean)params.get("--test")) {
			// Some components are not loaded during tests at least until proper
			// test cases are created for them. Sample case is off-line message
			// storage which may impact some test cases.
			props.put(COMPONENTS_PROP_KEY, COMPONENTS_TEST_PROP_VAL);
		} else {
			props.put(COMPONENTS_PROP_KEY, COMPONENTS_PROP_VAL);
		}

		if (params.get("--virt-hosts") != null) {
			HOSTNAMES_PROP_VAL = ((String)params.get("--virt-hosts")).split(",");
		} else {
			HOSTNAMES_PROP_VAL = DNSResolver.getDefHostNames();
		}
		props.put(HOSTNAMES_PROP_KEY, HOSTNAMES_PROP_VAL);
		if (params.get("--admins") != null) {
			ADMINS_PROP_VAL = ((String)params.get("--admins")).split(",");
		} else {
			ADMINS_PROP_VAL = new String[HOSTNAMES_PROP_VAL.length];
			for (int i = 0; i < ADMINS_PROP_VAL.length; i++) {
				ADMINS_PROP_VAL[i] = "admin@"+HOSTNAMES_PROP_VAL[i];
			} // end of for (int i = 0; i < ADMINS_PROP_VAL.length; i++)
		}
		props.put(ADMINS_PROP_KEY, ADMINS_PROP_VAL);
	}

} // SessionManagerConfig
<commit_msg>Added urn:xmpp:ping plugin for standard loaded plugins<commit_after>/*  Package Jabber Server
 *  Copyright (C) 2001-2007
 *  "<NAME>" <<EMAIL>>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software Foundation,
 *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * $Rev$
 * Last modified by $Author$
 * $Date$
 */
package tigase.server.xmppsession;

import tigase.util.DNSResolver;
import java.util.Map;

/**
 * Describe class SessionManagerConfig here.
 *
 *
 * Created: Tue Oct 24 23:07:57 2006
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @version $Rev$
 */
public class SessionManagerConfig {

	public static final String USER_REPO_CLASS_PROP_KEY = "user-repo-class";
	public static final String XML_REPO_CLASS_PROP_VAL =
		"tigase.db.xml.XMLRepository";
	public static final String MYSQL_REPO_CLASS_PROP_VAL =
		"tigase.db.jdbc.JDBCRepository";
	public static final String PGSQL_REPO_CLASS_PROP_VAL =
		"tigase.db.jdbc.JDBCRepository";
	public static final String DRUPAL_REPO_CLASS_PROP_VAL =
		"tigase.db.jdbc.DrupalAuth";
	public static final String LIBRESOURCE_REPO_CLASS_PROP_VAL =
		"tigase.db.jdbc.LibreSourceAuth";
	public static final String USER_REPO_URL_PROP_KEY = "user-repo-url";
	public static final String XML_REPO_URL_PROP_VAL = "user-repository.xml";
	public static final String MYSQL_REPO_URL_PROP_VAL =
		"jdbc:mysql://localhost/tigase?user=root&password=<PASSWORD>";
	public static final String PGSQL_REPO_URL_PROP_VAL =
		"jdbc:postgresql://localhost/tigase?user=tigase";
	public static final String DRUPAL_REPO_URL_PROP_VAL =
		"jdbc:mysql://localhost/drupal?user=root&password=<PASSWORD>";
	public static final String LIBRESOURCE_REPO_URL_PROP_VAL =
		"jdbc:postgresql://localhost/libresource?user=demo";

	public static final String AUTH_REPO_CLASS_PROP_KEY = "auth-repo-class";
	public static final String AUTH_REPO_URL_PROP_KEY = "auth-repo-url";

	public static final String COMPONENTS_PROP_KEY = "components";
	/**
	 * List of default components loaded by the server. It can be changed later
	 * in config file or at runtime.
	 */
	public static final String[] COMPONENTS_PROP_VAL =
	{"jabber:iq:register", "jabber:iq:auth", "urn:ietf:params:xml:ns:xmpp-sasl",
	 "urn:ietf:params:xml:ns:xmpp-bind", "urn:ietf:params:xml:ns:xmpp-session",
	 "jabber:iq:roster", "jabber:iq:privacy", "presence", "msgoffline",
	 "jabber:iq:version", "http://jabber.org/protocol/stats", "starttls",
	 "vcard-temp", "http://jabber.org/protocol/commands", "jabber:iq:private",
	 "urn:xmpp:ping"};
	/**
	 * List of components loaded when the server is loaded in test mode.
	 * Some components like off-line message storage is disabled during tests.
	 */
	public static final String[] COMPONENTS_TEST_PROP_VAL =
	{"jabber:iq:register", "jabber:iq:auth", "urn:ietf:params:xml:ns:xmpp-sasl",
	 "urn:ietf:params:xml:ns:xmpp-bind", "urn:ietf:params:xml:ns:xmpp-session",
	 "jabber:iq:roster", "jabber:iq:privacy", "presence", "jabber:iq:version",
	 "http://jabber.org/protocol/stats", "starttls", "msgoffline",
	 "vcard-temp", "http://jabber.org/protocol/commands", "jabber:iq:private",
	 "urn:xmpp:ping"};

	public static final String HOSTNAMES_PROP_KEY = "hostnames";
	public static String[] HOSTNAMES_PROP_VAL =	{"localhost", "hostname"};

	public static final String ADMINS_PROP_KEY = "admins";
	public static String[] ADMINS_PROP_VAL =	{"admin@localhost", "admin@hostname"};

	public static void getDefaults(Map<String, Object> props,
		Map<String, Object> params) {

		String user_repo_class = XML_REPO_CLASS_PROP_VAL;
		String user_repo_url = XML_REPO_URL_PROP_VAL;
		String auth_repo_class = XML_REPO_CLASS_PROP_VAL;
		String auth_repo_url = XML_REPO_URL_PROP_VAL;
		if (params.get("--user-db") != null) {
			if (params.get("--user-db").equals("mysql")) {
				user_repo_class = MYSQL_REPO_CLASS_PROP_VAL;
				user_repo_url = MYSQL_REPO_URL_PROP_VAL;
				auth_repo_class = MYSQL_REPO_CLASS_PROP_VAL;
				auth_repo_url = MYSQL_REPO_URL_PROP_VAL;
			}
			if (params.get("--user-db").equals("pgsql")) {
				user_repo_class = PGSQL_REPO_CLASS_PROP_VAL;
				user_repo_url = PGSQL_REPO_URL_PROP_VAL;
				auth_repo_class = PGSQL_REPO_CLASS_PROP_VAL;
				auth_repo_url = PGSQL_REPO_URL_PROP_VAL;
			}
		}
		if (params.get("--user-db-uri") != null) {
			user_repo_url = (String)params.get("--user-db-uri");
			auth_repo_url = user_repo_url;
		}
		if (params.get("--auth-db") != null) {
			if (params.get("--auth-db").equals("mysql")) {
				auth_repo_class = MYSQL_REPO_CLASS_PROP_VAL;
				auth_repo_url = MYSQL_REPO_URL_PROP_VAL;
			}
			if (params.get("--auth-db").equals("pgsql")) {
				auth_repo_class = PGSQL_REPO_CLASS_PROP_VAL;
				auth_repo_url = PGSQL_REPO_URL_PROP_VAL;
			}
			if (params.get("--auth-db").equals("drupal")) {
				auth_repo_class = DRUPAL_REPO_CLASS_PROP_VAL;
				auth_repo_url = DRUPAL_REPO_URL_PROP_VAL;
			}
			if (params.get("--auth-db").equals("libresource")) {
				auth_repo_class = LIBRESOURCE_REPO_CLASS_PROP_VAL;
				auth_repo_url = LIBRESOURCE_REPO_URL_PROP_VAL;
			}
		}
		if (params.get("--auth-db-uri") != null) {
			auth_repo_url = (String)params.get("--auth-db-uri");
		}

		props.put(USER_REPO_CLASS_PROP_KEY, user_repo_class);
	  props.put(USER_REPO_URL_PROP_KEY, user_repo_url);

	  props.put(AUTH_REPO_CLASS_PROP_KEY, auth_repo_class);
	  props.put(AUTH_REPO_URL_PROP_KEY, auth_repo_url);

		if ((Boolean)params.get("--test")) {
			// Some components are not loaded during tests at least until proper
			// test cases are created for them. Sample case is off-line message
			// storage which may impact some test cases.
			props.put(COMPONENTS_PROP_KEY, COMPONENTS_TEST_PROP_VAL);
		} else {
			props.put(COMPONENTS_PROP_KEY, COMPONENTS_PROP_VAL);
		}

		if (params.get("--virt-hosts") != null) {
			HOSTNAMES_PROP_VAL = ((String)params.get("--virt-hosts")).split(",");
		} else {
			HOSTNAMES_PROP_VAL = DNSResolver.getDefHostNames();
		}
		props.put(HOSTNAMES_PROP_KEY, HOSTNAMES_PROP_VAL);
		if (params.get("--admins") != null) {
			ADMINS_PROP_VAL = ((String)params.get("--admins")).split(",");
		} else {
			ADMINS_PROP_VAL = new String[HOSTNAMES_PROP_VAL.length];
			for (int i = 0; i < ADMINS_PROP_VAL.length; i++) {
				ADMINS_PROP_VAL[i] = "admin@"+HOSTNAMES_PROP_VAL[i];
			} // end of for (int i = 0; i < ADMINS_PROP_VAL.length; i++)
		}
		props.put(ADMINS_PROP_KEY, ADMINS_PROP_VAL);
	}

} // SessionManagerConfig

{'fraction_non_alphanumeric': 0.12815533980582525, 'fraction_numerical': 0.005321826681049982, 'mean_word_length': 4.825722664432342, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 16}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4264169', 'n_tokens_mistral': 5472, 'n_tokens_neox': 5017, 'n_words': 1036}