Search in sources :

Example 6 with ClientConnection

use of com.faforever.server.client.ClientConnection in project faf-java-server by FAForever.

the class GameServiceActivatorsTest method setUp.

@Before
public void setUp() throws Exception {
    clientConnection = new ClientConnection("1", Protocol.V1_LEGACY_UTF_16, mock(InetAddress.class));
    player = new Player();
    User user = (User) new User().setPlayer(player).setPassword("password").setLogin("JUnit");
    clientConnection.setAuthentication(new TestingAuthenticationToken(new FafUserDetails(user), null));
    instance = new GameServiceActivators(gameService);
}
Also used : Player(com.faforever.server.entity.Player) User(com.faforever.server.entity.User) ClientConnection(com.faforever.server.client.ClientConnection) FafUserDetails(com.faforever.server.security.FafUserDetails) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Before(org.junit.Before)

Example 7 with ClientConnection

use of com.faforever.server.client.ClientConnection in project faf-java-server by FAForever.

the class ClientConnectionChannelInterceptor method preSend.

@Override
public Message<?> preSend(Message<?> message, MessageChannel channel) {
    org.springframework.messaging.MessageHeaders messageHeaders = message.getHeaders();
    String connectionId = (String) messageHeaders.get(CORRELATION_ID);
    ClientConnection clientConnection = clientConnectionService.getClientConnection(connectionId).orElseThrow(() -> new IllegalStateException("There is no connection with ID: " + connectionId));
    SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.wrap(message);
    accessor.setUser(clientConnection.getAuthentication());
    return MessageBuilder.fromMessage(message).setHeader(CLIENT_CONNECTION, clientConnection).copyHeaders(accessor.getMessageHeaders()).build();
}
Also used : ClientConnection(com.faforever.server.client.ClientConnection) SimpMessageHeaderAccessor(org.springframework.messaging.simp.SimpMessageHeaderAccessor)

Example 8 with ClientConnection

use of com.faforever.server.client.ClientConnection in project faf-java-server by FAForever.

the class LegacyAdapterConfigTest method onCloseConnection.

@Test
public void onCloseConnection() throws Exception {
    ClientConnection clientConnection = new ClientConnection("1", Protocol.V1_LEGACY_UTF_16, mock(InetAddress.class));
    instance.onCloseConnection(new CloseConnectionEvent(this, clientConnection));
// Not much to assert here
}
Also used : CloseConnectionEvent(com.faforever.server.client.CloseConnectionEvent) ClientConnection(com.faforever.server.client.ClientConnection) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 9 with ClientConnection

use of com.faforever.server.client.ClientConnection in project faf-java-server by FAForever.

the class IceServiceActivatorsTest method setUp.

@Before
public void setUp() throws Exception {
    player = new Player();
    player.setClientConnection(clientConnection);
    clientConnection = new ClientConnection("1", Protocol.V1_LEGACY_UTF_16, mock(InetAddress.class)).setAuthentication(new TestingAuthenticationToken(new FafUserDetails((User) new User().setPlayer(player).setPassword("pw").setLogin("JUnit")), null));
    instance = new IceServiceActivators(iceService);
}
Also used : Player(com.faforever.server.entity.Player) User(com.faforever.server.entity.User) ClientConnection(com.faforever.server.client.ClientConnection) FafUserDetails(com.faforever.server.security.FafUserDetails) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) InetAddress(java.net.InetAddress) Before(org.junit.Before)

Aggregations

ClientConnection (com.faforever.server.client.ClientConnection)9 User (com.faforever.server.entity.User)6 FafUserDetails (com.faforever.server.security.FafUserDetails)6 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)5 Player (com.faforever.server.entity.Player)4 InetAddress (java.net.InetAddress)4 Before (org.junit.Before)4 Test (org.junit.Test)3 Game (com.faforever.server.entity.Game)2 CloseConnectionEvent (com.faforever.server.client.CloseConnectionEvent)1 SimpMessageHeaderAccessor (org.springframework.messaging.simp.SimpMessageHeaderAccessor)1