use of games.strategy.net.IConnectionLogin in project triplea by triplea-game.
the class ClientLoginIntegrationTest method login_ShouldSucceedUsingMd5CryptAuthenticatorWhenPasswordMatches.
@Test
public void login_ShouldSucceedUsingMd5CryptAuthenticatorWhenPasswordMatches() {
final IConnectionLogin connectionLogin = new TestConnectionLogin() {
@Override
public Map<String, String> getProperties(final Map<String, String> challenge) {
return filterMd5CryptAuthenticatorResponseProperties(super.getProperties(challenge));
}
};
assertNotThrows(() -> newClientMessenger(connectionLogin).shutDown());
}
use of games.strategy.net.IConnectionLogin in project triplea by triplea-game.
the class ClientLoginIntegrationTest method login_ShouldSucceedUsingHmacSha512AuthenticatorWhenPasswordMatches.
@Test
public void login_ShouldSucceedUsingHmacSha512AuthenticatorWhenPasswordMatches() {
final IConnectionLogin connectionLogin = new TestConnectionLogin();
assertNotThrows(() -> newClientMessenger(connectionLogin).shutDown());
}
use of games.strategy.net.IConnectionLogin in project triplea by triplea-game.
the class InGameLobbyWatcher method newInGameLobbyWatcher.
/**
* Reads SystemProperties to see if we should connect to a lobby server
*
* <p>
* After creation, those properties are cleared, since we should watch the first start game.
* </p>
*
* @return null if no watcher should be created
*/
public static InGameLobbyWatcher newInGameLobbyWatcher(final IServerMessenger gameMessenger, final JComponent parent, final InGameLobbyWatcher oldWatcher) {
final String host = System.getProperty(LOBBY_HOST);
final String port = System.getProperty(LOBBY_PORT);
final String hostedBy = System.getProperty(LOBBY_GAME_HOSTED_BY);
if (host == null || port == null) {
return null;
}
// clear the properties
System.clearProperty(LOBBY_HOST);
System.clearProperty(LOBBY_PORT);
System.clearProperty(LOBBY_GAME_HOSTED_BY);
// add them as temporary properties (in case we load an old savegame and need them again)
System.setProperty(LOBBY_HOST + GameRunner.OLD_EXTENSION, host);
System.setProperty(LOBBY_PORT + GameRunner.OLD_EXTENSION, port);
System.setProperty(LOBBY_GAME_HOSTED_BY + GameRunner.OLD_EXTENSION, hostedBy);
final IConnectionLogin login = challengeProperties -> {
final Map<String, String> properties = new HashMap<>();
properties.put(LobbyLoginValidator.ANONYMOUS_LOGIN, Boolean.TRUE.toString());
properties.put(LobbyLoginValidator.LOBBY_VERSION, LobbyServer.LOBBY_VERSION.toString());
properties.put(LobbyLoginValidator.LOBBY_WATCHER_LOGIN, Boolean.TRUE.toString());
return properties;
};
try {
System.out.println("host:" + host + " port:" + port);
final String mac = MacFinder.getHashedMacAddress();
final ClientMessenger messenger = new ClientMessenger(host, Integer.parseInt(port), getRealName(hostedBy) + "_" + LOBBY_WATCHER_NAME, mac, login);
final UnifiedMessenger um = new UnifiedMessenger(messenger);
final RemoteMessenger rm = new RemoteMessenger(um);
final RemoteHostUtils rhu = new RemoteHostUtils(messenger.getServerNode(), gameMessenger);
rm.registerRemote(rhu, RemoteHostUtils.getRemoteHostUtilsName(um.getLocalNode()));
return new InGameLobbyWatcher(messenger, rm, gameMessenger, parent, oldWatcher);
} catch (final Exception e) {
ClientLogger.logQuietly("Failed to create in-game lobby watcher", e);
return null;
}
}
use of games.strategy.net.IConnectionLogin in project triplea by triplea-game.
the class ClientLoginIntegrationTest method login_ShouldFailUsingHmacSha512AuthenticatorWhenPasswordDoesNotMatch.
@Test
public void login_ShouldFailUsingHmacSha512AuthenticatorWhenPasswordDoesNotMatch() {
final IConnectionLogin connectionLogin = new TestConnectionLogin(OTHER_PASSWORD);
assertThrows(CouldNotLogInException.class, () -> newClientMessenger(connectionLogin).shutDown());
}
use of games.strategy.net.IConnectionLogin in project triplea by triplea-game.
the class ClientLoginIntegrationTest method login_ShouldFailUsingMd5CryptAuthenticatorWhenPasswordDoesNotMatch.
@Test
public void login_ShouldFailUsingMd5CryptAuthenticatorWhenPasswordDoesNotMatch() {
final IConnectionLogin connectionLogin = new TestConnectionLogin(OTHER_PASSWORD) {
@Override
public Map<String, String> getProperties(final Map<String, String> challenge) {
return filterMd5CryptAuthenticatorResponseProperties(super.getProperties(challenge));
}
};
assertThrows(CouldNotLogInException.class, () -> newClientMessenger(connectionLogin).shutDown());
}
Aggregations