summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle1
-rw-r--r--src/main/java/org/luxons/sevenwonders/config/AnonymousUsersHandshakeHandler.java7
2 files changed, 4 insertions, 4 deletions
diff --git a/build.gradle b/build.gradle
index 9b5cee41..082673dd 100644
--- a/build.gradle
+++ b/build.gradle
@@ -25,6 +25,7 @@ dependencies {
compile 'ch.qos.logback:logback-classic:1.1.8'
compile 'org.springframework.boot:spring-boot-starter-websocket'
+ compile 'org.springframework.security:spring-security-core:4.2.0.RELEASE'
compile 'org.webjars:webjars-locator'
compile 'org.webjars:sockjs-client:1.0.2'
compile 'org.webjars:stomp-websocket:2.3.3'
diff --git a/src/main/java/org/luxons/sevenwonders/config/AnonymousUsersHandshakeHandler.java b/src/main/java/org/luxons/sevenwonders/config/AnonymousUsersHandshakeHandler.java
index 1132197d..bebbd477 100644
--- a/src/main/java/org/luxons/sevenwonders/config/AnonymousUsersHandshakeHandler.java
+++ b/src/main/java/org/luxons/sevenwonders/config/AnonymousUsersHandshakeHandler.java
@@ -4,11 +4,10 @@ import java.security.Principal;
import java.util.Map;
import org.springframework.http.server.ServerHttpRequest;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.server.support.DefaultHandshakeHandler;
-import sun.security.acl.PrincipalImpl;
-
class AnonymousUsersHandshakeHandler extends DefaultHandshakeHandler {
private int playerId = 0;
@@ -16,9 +15,9 @@ class AnonymousUsersHandshakeHandler extends DefaultHandshakeHandler {
@Override
public Principal determineUser(ServerHttpRequest request, WebSocketHandler wsHandler,
Map<String, Object> attributes) {
- Principal p = request.getPrincipal();
+ Principal p = super.determineUser(request, wsHandler, attributes);
if (p == null) {
- p = new PrincipalImpl("player" + playerId++);
+ p = new UsernamePasswordAuthenticationToken("player" + playerId++, null);
}
return p;
}
bgstack15