// Path: src/main/java/com/scheible/risingempire/web/join/message/server/PlayerEntry.java
// public class PlayerEntry {
// 	
// 	public enum State {
// 		ACTIVE, DETACHED, AI, NON_PARTICIPATING;
// 	}
// 	
// 	private final String leaderName;
// 	private final String nation;
// 	private final String username;
// 	private final State state;
// 	private final String color;
// 
// 	private PlayerEntry(String leaderName, String nation, State state, Color color) {
// 		this.leaderName = leaderName;
// 		this.nation = nation;
// 		this.username = PlayerHelper.generateUsername(leaderName, nation);
// 		this.state = state;
// 		this.color = new BrowserColor(color).getHex();
// 	}
// 	
// 	public static PlayerEntry create(String username, PlayerEntry.State state) {
// 		Player player = resolvePlayer(username);
// 		return create(player.getName(), player.getNation(), state);
// 	}
// 	
// 	public static PlayerEntry create(String leaderName, String nation, PlayerEntry.State state) {
// 		return new PlayerEntry(leaderName, nation, state,
// 				AvailablePlayer.find(leaderName, nation).getColor());
// 	}	
// }
// 
// Path: src/main/java/com/scheible/risingempire/web/security/ConnectedPlayer.java
// public final class ConnectedPlayer implements UserDetails {
// 	
// 	public final static PasswordEncoder PASSWORD_ENCODER = NoOpPasswordEncoder.getInstance();
// 	public final static String DEFAULT_PASSWORD = "yyy";
// 	
// 	private final String username;
// 
// 	/* package */ ConnectedPlayer(String username) {
// 		this.username = username;
// 	}
// 
// 	@Override
// 	public Collection<? extends GrantedAuthority> getAuthorities() {
// 		return AuthorityUtils.createAuthorityList("ROLE_USER");
// 	}
// 
// 	@Override
// 	public String getUsername() {
// 		return username;
// 	}
// 
// 	@Override
// 	public boolean isAccountNonExpired() {
// 		return true;
// 	}
// 
// 	@Override
// 	public boolean isAccountNonLocked() {
// 		return true;
// 	}
// 
// 	@Override
// 	public boolean isCredentialsNonExpired() {
// 		return true;
// 	}
// 
// 	@Override
// 	public boolean isEnabled() {
// 		return true;
// 	}
// 
// 	@Override
// 	public String getPassword() {
// 		return DEFAULT_PASSWORD;
// 	}	
// }


import com.scheible.risingempire.web.join.message.server.PlayerEntry;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.scheible.risingempire.web.security.ConnectedPlayer;
import java.security.Principal;
import org.springframework.context.ApplicationListener;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.socket.messaging.AbstractSubProtocolEvent;
import org.springframework.web.socket.messaging.SessionConnectEvent;
import org.springframework.web.socket.messaging.SessionDisconnectEvent;
package com.scheible.risingempire.web.join;


/**
 *
 * @author sj
 */
@Controller
public class JoinController implements ApplicationListener<AbstractSubProtocolEvent> {

	@Autowired
	SimpMessagingTemplate messagingTemplate;

	@Autowired
	PlayerManager playerManager;

	@RequestMapping("/join.html")
	public String join(Map<String, Object> model) {
		model.put("defaultPassword", ConnectedPlayer.DEFAULT_PASSWORD);
		return "join";
	}

	@RequestMapping("/players")
// Path: src/main/java/com/scheible/risingempire/web/join/message/server/PlayerEntry.java
// public class PlayerEntry {
// 	
// 	public enum State {
// 		ACTIVE, DETACHED, AI, NON_PARTICIPATING;
// 	}
// 	
// 	private final String leaderName;
// 	private final String nation;
// 	private final String username;
// 	private final State state;
// 	private final String color;
// 
// 	private PlayerEntry(String leaderName, String nation, State state, Color color) {
// 		this.leaderName = leaderName;
// 		this.nation = nation;
// 		this.username = PlayerHelper.generateUsername(leaderName, nation);
// 		this.state = state;
// 		this.color = new BrowserColor(color).getHex();
// 	}
// 	
// 	public static PlayerEntry create(String username, PlayerEntry.State state) {
// 		Player player = resolvePlayer(username);
// 		return create(player.getName(), player.getNation(), state);
// 	}
// 	
// 	public static PlayerEntry create(String leaderName, String nation, PlayerEntry.State state) {
// 		return new PlayerEntry(leaderName, nation, state,
// 				AvailablePlayer.find(leaderName, nation).getColor());
// 	}	
// }
// 
// Path: src/main/java/com/scheible/risingempire/web/security/ConnectedPlayer.java
// public final class ConnectedPlayer implements UserDetails {
// 	
// 	public final static PasswordEncoder PASSWORD_ENCODER = NoOpPasswordEncoder.getInstance();
// 	public final static String DEFAULT_PASSWORD = "yyy";
// 	
// 	private final String username;
// 
// 	/* package */ ConnectedPlayer(String username) {
// 		this.username = username;
// 	}
// 
// 	@Override
// 	public Collection<? extends GrantedAuthority> getAuthorities() {
// 		return AuthorityUtils.createAuthorityList("ROLE_USER");
// 	}
// 
// 	@Override
// 	public String getUsername() {
// 		return username;
// 	}
// 
// 	@Override
// 	public boolean isAccountNonExpired() {
// 		return true;
// 	}
// 
// 	@Override
// 	public boolean isAccountNonLocked() {
// 		return true;
// 	}
// 
// 	@Override
// 	public boolean isCredentialsNonExpired() {
// 		return true;
// 	}
// 
// 	@Override
// 	public boolean isEnabled() {
// 		return true;
// 	}
// 
// 	@Override
// 	public String getPassword() {
// 		return DEFAULT_PASSWORD;
// 	}	
// }


// Path: src/main/java/com/scheible/risingempire/web/join/JoinController.java
import com.scheible.risingempire.web.join.message.server.PlayerEntry;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.scheible.risingempire.web.security.ConnectedPlayer;
import java.security.Principal;
import org.springframework.context.ApplicationListener;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.socket.messaging.AbstractSubProtocolEvent;
import org.springframework.web.socket.messaging.SessionConnectEvent;
import org.springframework.web.socket.messaging.SessionDisconnectEvent;

package com.scheible.risingempire.web.join;


/**
 *
 * @author sj
 */
@Controller
public class JoinController implements ApplicationListener<AbstractSubProtocolEvent> {

	@Autowired
	SimpMessagingTemplate messagingTemplate;

	@Autowired
	PlayerManager playerManager;

	@RequestMapping("/join.html")
	public String join(Map<String, Object> model) {
		model.put("defaultPassword", ConnectedPlayer.DEFAULT_PASSWORD);
		return "join";
	}

	@RequestMapping("/players")
	public @ResponseBody List<PlayerEntry> players() {