Add WebSocketSession attributes + initialization
In addition to adding the attributes, there is now mechanism for initializing WebSocketSession instances from attributes of the handshake request.
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.http.server;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
import org.springframework.http.HttpInputMessage;
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@@ -33,4 +35,21 @@ public interface ServerHttpRequest extends HttpRequest, HttpInputMessage {
|
||||
*/
|
||||
MultiValueMap<String, String> getQueryParams();
|
||||
|
||||
/**
|
||||
* Return a {@link java.security.Principal} instance containing the name of the
|
||||
* authenticated user. If the user has not been authenticated, the method returns
|
||||
* <code>null</code>.
|
||||
*/
|
||||
Principal getPrincipal();
|
||||
|
||||
/**
|
||||
* Return the host name of the endpoint on the other end.
|
||||
*/
|
||||
String getRemoteHostName();
|
||||
|
||||
/**
|
||||
* Return the IP address of the endpoint on the other end.
|
||||
*/
|
||||
String getRemoteAddress();
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.Principal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
@@ -131,6 +132,21 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
|
||||
return this.headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Principal getPrincipal() {
|
||||
return this.servletRequest.getUserPrincipal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteHostName() {
|
||||
return this.servletRequest.getRemoteHost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteAddress() {
|
||||
return this.servletRequest.getRemoteAddr();
|
||||
}
|
||||
|
||||
public Cookies getCookies() {
|
||||
if (this.cookies == null) {
|
||||
this.cookies = new Cookies();
|
||||
|
||||
Reference in New Issue
Block a user