mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
Some minor changes for user registration.
This commit is contained in:
parent
0af945633c
commit
bc822c9677
2 changed files with 64 additions and 68 deletions
|
@ -18,11 +18,11 @@ import com.google.api.services.gmail.model.Message;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import javax.mail.Session;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Collections;
|
||||
import java.util.Properties;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import mage.server.util.ConfigSettings;
|
||||
|
@ -76,7 +76,8 @@ public class GmailClient {
|
|||
Message message = new Message();
|
||||
message.setRaw(Base64.encodeBase64URLSafeString(baos.toByteArray()));
|
||||
|
||||
gmail.users().messages().send(ConfigSettings.getInstance().getGoogleAccount() + "@gmail.com", message).execute();
|
||||
gmail.users().messages().send(ConfigSettings.getInstance().getGoogleAccount()
|
||||
+ (ConfigSettings.getInstance().getGoogleAccount().endsWith("@gmail.com") ? "" : "@gmail.com"), message).execute();
|
||||
return true;
|
||||
} catch (MessagingException | IOException ex) {
|
||||
logger.error("Error sending message", ex);
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.server;
|
||||
|
||||
import mage.cards.repository.CardScanner;
|
||||
|
@ -58,14 +57,12 @@ import org.w3c.dom.Element;
|
|||
import javax.management.MBeanServer;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.jboss.remoting.transport.bisocket.BisocketServerInvoker;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -80,7 +77,6 @@ public class Main {
|
|||
private static final String adminPasswordArg = "-adminPassword=";
|
||||
private static final String pluginFolder = "plugins";
|
||||
|
||||
|
||||
public static PluginClassLoader classLoader = new PluginClassLoader();
|
||||
public static TransporterServer server;
|
||||
protected static boolean testMode;
|
||||
|
@ -95,15 +91,13 @@ public class Main {
|
|||
logger.info("Logging level: " + logger.getEffectiveLevel());
|
||||
|
||||
String adminPassword = "";
|
||||
for (String arg: args) {
|
||||
for (String arg : args) {
|
||||
if (arg.startsWith(testModeArg)) {
|
||||
testMode = Boolean.valueOf(arg.replace(testModeArg, ""));
|
||||
}
|
||||
else if (arg.startsWith(adminPasswordArg)) {
|
||||
} else if (arg.startsWith(adminPasswordArg)) {
|
||||
adminPassword = arg.replace(adminPasswordArg, "");
|
||||
adminPassword = SystemUtil.sanitize(adminPassword);
|
||||
}
|
||||
else if (arg.startsWith(fastDBModeArg)) {
|
||||
} else if (arg.startsWith(fastDBModeArg)) {
|
||||
fastDbMode = Boolean.valueOf(arg.replace(fastDBModeArg, ""));
|
||||
}
|
||||
}
|
||||
|
@ -128,19 +122,19 @@ public class Main {
|
|||
logger.info("Done.");
|
||||
|
||||
deleteSavedGames();
|
||||
for (GamePlugin plugin: config.getGameTypes()) {
|
||||
for (GamePlugin plugin : config.getGameTypes()) {
|
||||
GameFactory.getInstance().addGameType(plugin.getName(), loadGameType(plugin), loadPlugin(plugin));
|
||||
}
|
||||
for (GamePlugin plugin: config.getTournamentTypes()) {
|
||||
for (GamePlugin plugin : config.getTournamentTypes()) {
|
||||
TournamentFactory.getInstance().addTournamentType(plugin.getName(), loadTournamentType(plugin), loadPlugin(plugin));
|
||||
}
|
||||
for (Plugin plugin: config.getPlayerTypes()) {
|
||||
for (Plugin plugin : config.getPlayerTypes()) {
|
||||
PlayerFactory.getInstance().addPlayerType(plugin.getName(), loadPlugin(plugin));
|
||||
}
|
||||
for (Plugin plugin: config.getDraftCubes()) {
|
||||
for (Plugin plugin : config.getDraftCubes()) {
|
||||
CubeFactory.getInstance().addDraftCube(plugin.getName(), loadPlugin(plugin));
|
||||
}
|
||||
for (Plugin plugin: config.getDeckTypes()) {
|
||||
for (Plugin plugin : config.getDeckTypes()) {
|
||||
DeckValidatorFactory.getInstance().addDeckType(plugin.getName(), loadPlugin(plugin));
|
||||
}
|
||||
|
||||
|
@ -149,13 +143,15 @@ public class Main {
|
|||
logger.info("Config - max AI opponents: " + config.getMaxAiOpponents());
|
||||
logger.info("Config - min user name l.: " + config.getMinUserNameLength());
|
||||
logger.info("Config - max user name l.: " + config.getMaxUserNameLength());
|
||||
logger.info("Config - save game active: " + (config.isSaveGameActivated() ? "True":"false"));
|
||||
logger.info("Config - save game active: " + (config.isSaveGameActivated() ? "true" : "false"));
|
||||
|
||||
logger.info("Config - backlog size : " + config.getBacklogSize());
|
||||
logger.info("Config - lease period : " + config.getLeasePeriod());
|
||||
logger.info("Config - max pool size : " + config.getMaxPoolSize());
|
||||
logger.info("Config - num accp.threads: " + config.getNumAcceptThreads());
|
||||
logger.info("Config - second.bind port: " + config.getSecondaryBindPort());
|
||||
logger.info("Config - auth. activated : " + (config.isAuthenticationActivated() ? "true" : "false"));
|
||||
logger.info("Config - google account : " + config.getGoogleAccount());
|
||||
|
||||
Connection connection = new Connection("&maxPoolSize=" + config.getMaxPoolSize());
|
||||
connection.setHost(config.getServerAddress());
|
||||
|
@ -172,8 +168,7 @@ public class Main {
|
|||
logger.info("MAGE server running in test mode");
|
||||
}
|
||||
initStatistics();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
logger.fatal("Unable to start MAGE server - another server is already started");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
@ -202,6 +197,7 @@ public class Main {
|
|||
}
|
||||
|
||||
static class ClientConnectionListener implements ConnectionListener {
|
||||
|
||||
@Override
|
||||
public void handleConnectionException(Throwable throwable, Client client) {
|
||||
Session session = SessionManager.getInstance().getSession(client.getSessionId());
|
||||
|
@ -340,7 +336,7 @@ public class Main {
|
|||
logger.debug("Loading tournament type: " + plugin.getClassName());
|
||||
return (TournamentType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
logger.warn("Tournament type not found:" + plugin.getName() + " / "+ plugin.getJar() + " - check plugin folder", ex);
|
||||
logger.warn("Tournament type not found:" + plugin.getName() + " / " + plugin.getJar() + " - check plugin folder", ex);
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("Error loading game type " + plugin.getJar(), ex);
|
||||
}
|
||||
|
@ -360,8 +356,7 @@ public class Main {
|
|||
}
|
||||
}
|
||||
);
|
||||
for (File file : files)
|
||||
{
|
||||
for (File file : files) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue