Search in sources :

Example 1 with IConnectionLogin

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());
}
Also used : Map(java.util.Map) IConnectionLogin(games.strategy.net.IConnectionLogin) Test(org.junit.jupiter.api.Test)

Example 2 with IConnectionLogin

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());
}
Also used : IConnectionLogin(games.strategy.net.IConnectionLogin) Test(org.junit.jupiter.api.Test)

Example 3 with IConnectionLogin

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;
    }
}
Also used : Observer(java.util.Observer) ClientMessenger(games.strategy.net.ClientMessenger) LOBBY_GAME_COMMENTS(games.strategy.engine.framework.CliProperties.LOBBY_GAME_COMMENTS) GUID(games.strategy.net.GUID) SERVER_PASSWORD(games.strategy.engine.framework.CliProperties.SERVER_PASSWORD) HashMap(java.util.HashMap) HeadlessGameServer(games.strategy.engine.framework.headlessGameServer.HeadlessGameServer) IConnectionLogin(games.strategy.net.IConnectionLogin) LobbyServer(games.strategy.engine.lobby.server.LobbyServer) MacFinder(games.strategy.net.MacFinder) IMessengerErrorListener(games.strategy.net.IMessengerErrorListener) SwingUtilities(javax.swing.SwingUtilities) Map(java.util.Map) IMessenger(games.strategy.net.IMessenger) GameDescription(games.strategy.engine.lobby.server.GameDescription) IConnectionChangeListener(games.strategy.net.IConnectionChangeListener) RemoteMessenger(games.strategy.engine.message.RemoteMessenger) ClientContext(games.strategy.engine.ClientContext) JComponent(javax.swing.JComponent) LobbyLoginValidator(games.strategy.engine.lobby.server.login.LobbyLoginValidator) INode(games.strategy.net.INode) Frame(java.awt.Frame) ILobbyGameController(games.strategy.engine.lobby.server.ILobbyGameController) LOBBY_HOST(games.strategy.engine.framework.CliProperties.LOBBY_HOST) GameStepListener(games.strategy.engine.data.events.GameStepListener) GameStatus(games.strategy.engine.lobby.server.GameDescription.GameStatus) Instant(java.time.Instant) JOptionPane(javax.swing.JOptionPane) GameRunner(games.strategy.engine.framework.GameRunner) RemoteHostUtils(games.strategy.engine.lobby.server.RemoteHostUtils) TRIPLEA_PORT(games.strategy.engine.framework.CliProperties.TRIPLEA_PORT) UnifiedMessenger(games.strategy.engine.message.unifiedmessenger.UnifiedMessenger) ClientLogger(games.strategy.debug.ClientLogger) GameSelectorModel(games.strategy.engine.framework.startup.mc.GameSelectorModel) IRemoteMessenger(games.strategy.engine.message.IRemoteMessenger) LOBBY_PORT(games.strategy.engine.framework.CliProperties.LOBBY_PORT) OpenFileUtility(games.strategy.net.OpenFileUtility) IServerMessenger(games.strategy.net.IServerMessenger) UrlConstants(games.strategy.triplea.UrlConstants) IGame(games.strategy.engine.framework.IGame) LOBBY_GAME_HOSTED_BY(games.strategy.engine.framework.CliProperties.LOBBY_GAME_HOSTED_BY) RemoteMessenger(games.strategy.engine.message.RemoteMessenger) IRemoteMessenger(games.strategy.engine.message.IRemoteMessenger) UnifiedMessenger(games.strategy.engine.message.unifiedmessenger.UnifiedMessenger) RemoteHostUtils(games.strategy.engine.lobby.server.RemoteHostUtils) HashMap(java.util.HashMap) Map(java.util.Map) IConnectionLogin(games.strategy.net.IConnectionLogin) ClientMessenger(games.strategy.net.ClientMessenger)

Example 4 with IConnectionLogin

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());
}
Also used : IConnectionLogin(games.strategy.net.IConnectionLogin) Test(org.junit.jupiter.api.Test)

Example 5 with IConnectionLogin

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());
}
Also used : Map(java.util.Map) IConnectionLogin(games.strategy.net.IConnectionLogin) Test(org.junit.jupiter.api.Test)

Aggregations

IConnectionLogin (games.strategy.net.IConnectionLogin)5 Test (org.junit.jupiter.api.Test)4 Map (java.util.Map)3 ClientLogger (games.strategy.debug.ClientLogger)1 ClientContext (games.strategy.engine.ClientContext)1 GameStepListener (games.strategy.engine.data.events.GameStepListener)1 LOBBY_GAME_COMMENTS (games.strategy.engine.framework.CliProperties.LOBBY_GAME_COMMENTS)1 LOBBY_GAME_HOSTED_BY (games.strategy.engine.framework.CliProperties.LOBBY_GAME_HOSTED_BY)1 LOBBY_HOST (games.strategy.engine.framework.CliProperties.LOBBY_HOST)1 LOBBY_PORT (games.strategy.engine.framework.CliProperties.LOBBY_PORT)1 SERVER_PASSWORD (games.strategy.engine.framework.CliProperties.SERVER_PASSWORD)1 TRIPLEA_PORT (games.strategy.engine.framework.CliProperties.TRIPLEA_PORT)1 GameRunner (games.strategy.engine.framework.GameRunner)1 IGame (games.strategy.engine.framework.IGame)1 HeadlessGameServer (games.strategy.engine.framework.headlessGameServer.HeadlessGameServer)1 GameSelectorModel (games.strategy.engine.framework.startup.mc.GameSelectorModel)1 GameDescription (games.strategy.engine.lobby.server.GameDescription)1 GameStatus (games.strategy.engine.lobby.server.GameDescription.GameStatus)1 ILobbyGameController (games.strategy.engine.lobby.server.ILobbyGameController)1 LobbyServer (games.strategy.engine.lobby.server.LobbyServer)1