use of games.strategy.util.Version in project triplea by triplea-game.
the class GameParser method parseInfo.
private void parseInfo(final Node info) {
final String gameName = ((Element) info).getAttribute("name");
data.setGameName(gameName);
final String version = ((Element) info).getAttribute("version");
data.setGameVersion(new Version(version));
}
use of games.strategy.util.Version in project triplea by triplea-game.
the class LobbyLoginValidator method authenticateUser.
@Nullable
private String authenticateUser(final Map<String, String> response, final User user) {
if (response == null) {
return "No Client Properties";
}
final String clientVersionString = response.get(LOBBY_VERSION);
if (clientVersionString == null) {
return "No Client Version";
}
final Version clientVersion = new Version(clientVersionString);
if (!clientVersion.equals(LobbyServer.LOBBY_VERSION)) {
return "Wrong version, we require " + LobbyServer.LOBBY_VERSION.toString() + " but trying to log in with " + clientVersionString;
}
for (final String s : getBadWords()) {
if (user.getUsername().toLowerCase().contains(s.toLowerCase())) {
return ErrorMessages.THATS_NOT_A_NICE_NAME;
}
}
if (!MacFinder.isValidHashedMacAddress(user.getHashedMacAddress())) {
// Must have been tampered with
return ErrorMessages.INVALID_MAC;
}
final Tuple<Boolean, Timestamp> macBanned = bannedMacDao.isMacBanned(user.getHashedMacAddress());
if (macBanned.getFirst()) {
return ErrorMessages.YOU_HAVE_BEEN_BANNED + " " + getBanDurationBreakdown(macBanned.getSecond());
}
// test for username ban after testing normal bans, because if it is only a username ban then the user should know
// they can change their name
final Tuple<Boolean, Timestamp> usernameBanned = bannedUsernameDao.isUsernameBanned(user.getUsername());
if (usernameBanned.getFirst()) {
return ErrorMessages.USERNAME_HAS_BEEN_BANNED + " " + getBanDurationBreakdown(usernameBanned.getSecond());
}
if (response.containsKey(REGISTER_NEW_USER_KEY)) {
return createUser(response, user);
}
final UserType userType = getUserTypeFor(response);
switch(userType) {
case ANONYMOUS:
return authenticateAnonymousUser(response, user);
case REGISTERED:
return authenticateRegisteredUser(response, user);
default:
throw new AssertionError("unknown user type: " + userType);
}
}
use of games.strategy.util.Version in project triplea by triplea-game.
the class ClientLoginValidator method verifyConnection.
@Override
public String verifyConnection(final Map<String, String> propertiesSentToClient, final Map<String, String> propertiesReadFromClient, final String clientName, final String hashedMac, final SocketAddress remoteAddress) {
final String versionString = propertiesReadFromClient.get(ClientLogin.ENGINE_VERSION_PROPERTY);
if (versionString == null || versionString.length() > 20 || versionString.trim().length() == 0) {
return "Invalid version " + versionString;
}
// check for version
final Version clientVersion = new Version(versionString);
if (!GameEngineVersion.of(ClientContext.engineVersion()).isCompatibleWithEngineVersion(clientVersion)) {
return String.format("Client is using %s but the server requires a version compatible with version %s", clientVersion, ClientContext.engineVersion());
}
final String realName = clientName.split(" ")[0];
if (serverMessenger.isUsernameMiniBanned(realName)) {
return ErrorMessages.YOU_HAVE_BEEN_BANNED;
}
final String remoteIp = ((InetSocketAddress) remoteAddress).getAddress().getHostAddress();
if (serverMessenger.isIpMiniBanned(remoteIp)) {
return ErrorMessages.YOU_HAVE_BEEN_BANNED;
}
if (hashedMac == null) {
return ErrorMessages.UNABLE_TO_OBTAIN_MAC;
} else if (!MacFinder.isValidHashedMacAddress(hashedMac)) {
return ErrorMessages.INVALID_MAC;
} else if (serverMessenger.isMacMiniBanned(hashedMac)) {
return ErrorMessages.YOU_HAVE_BEEN_BANNED;
}
if (Boolean.TRUE.toString().equals(propertiesSentToClient.get(PASSWORD_REQUIRED_PROPERTY))) {
final String errorMessage = authenticate(propertiesSentToClient, propertiesReadFromClient);
if (!Objects.equals(errorMessage, ErrorMessages.NO_ERROR)) {
// sleep on average 2 seconds
// try to prevent flooding to guess the password
Interruptibles.sleep((long) (4_000 * Math.random()));
return errorMessage;
}
}
return ErrorMessages.NO_ERROR;
}
use of games.strategy.util.Version in project triplea by triplea-game.
the class GameRunner method main.
/**
* Launches the "main" TripleA gui enabled game client.
* No args will launch a client, additional args can be supplied to specify additional behavior.
* Warning: game engine code invokes this method to spawn new game clients.
*/
public static void main(final String[] args) throws InterruptedException {
LoggingConfiguration.initialize();
ClientSetting.initialize();
if (!ClientSetting.USE_EXPERIMENTAL_JAVAFX_UI.booleanValue()) {
SwingAction.invokeAndWait(() -> {
LookAndFeel.setupLookAndFeel();
ErrorConsole.createConsole();
ErrorMessage.INSTANCE.init();
});
}
if (!new ArgParser(COMMAND_LINE_ARGS).handleCommandLineArgs(args)) {
usage();
return;
}
if (HttpProxy.isUsingSystemProxy()) {
HttpProxy.updateSystemProxy();
}
final Version engineVersion = ClientContext.engineVersion();
System.out.println("TripleA engine version " + engineVersion.getExactVersion());
if (ClientSetting.USE_EXPERIMENTAL_JAVAFX_UI.booleanValue()) {
Application.launch(TripleA.class, args);
} else {
SwingUtilities.invokeLater(() -> {
setupPanelModel.showSelectType();
mainFrame = newMainFrame();
});
showMainFrame();
LocalSystemChecker.launch();
UpdateChecks.launch();
}
}
use of games.strategy.util.Version in project triplea by triplea-game.
the class DownloadFileDescriptionTest method testIsTool.
@Test
public void testIsTool() {
final DownloadFileDescription testObj = new DownloadFileDescription("", "", "", new Version(0, 0), DownloadFileDescription.DownloadType.MAP_TOOL, DownloadFileDescription.MapCategory.EXPERIMENTAL);
assertThat(testObj.isMapTool(), is(true));
}
Aggregations