下面列出了javax.websocket.server.HandshakeRequest#getHttpSession ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void modifyHandshake(ServerEndpointConfig config,
HandshakeRequest request,
HandshakeResponse response) {
HttpSession httpSession = (HttpSession)request.getHttpSession();
config.getUserProperties().put("webUserID", httpSession.getAttribute("webUserID"));
}
@Override
public void modifyHandshake(ServerEndpointConfig config, HandshakeRequest request, HandshakeResponse response) {
HttpSession httpSession = (HttpSession) request.getHttpSession();
if (null != httpSession) {
config.getUserProperties().put(HttpSession.class.getName(), httpSession);
}
}
@Override
public void modifyHandshake(ServerEndpointConfig config, HandshakeRequest request, HandshakeResponse response) {
HttpSession httpSession = (HttpSession) request.getHttpSession();
config.getUserProperties().put(MCRServlet.ATTR_MYCORE_SESSION,
httpSession.getAttribute(MCRServlet.ATTR_MYCORE_SESSION));
config.getUserProperties().put(HTTP_SESSION, httpSession);
}
@Override
public void modifyHandshake(final ServerEndpointConfig config,
final HandshakeRequest request, final HandshakeResponse response) {
final HttpSession httpSession = (HttpSession) request.getHttpSession();
config.getUserProperties().put(HttpSession.class.getName(), httpSession);
}
@Override
public void modifyHandshake(
ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
HttpSession httpSession = (HttpSession) request.getHttpSession();
if (httpSession != null) {
Object sessionSubject = httpSession.getAttribute("che_subject");
if (sessionSubject != null) {
sec.getUserProperties().put("che_subject", sessionSubject);
}
}
}
@Override
public void modifyHandshake(ServerEndpointConfig config,
HandshakeRequest request, HandshakeResponse response) {
HttpSession httpSession = (HttpSession) request.getHttpSession();
config.getUserProperties()
.put(HttpSession.class.getName(), httpSession);
}
@Override
public void modifyHandshake(ServerEndpointConfig config,
HandshakeRequest request,
HandshakeResponse response)
{
HttpSession httpSession = (HttpSession)request.getHttpSession();
if (httpSession == null) {
return;
}
config.getUserProperties().put(HttpSession.class.getName(), httpSession);
}
private Configurator createConfigurator() {
return new Configurator() {
@Override
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
super.modifyHandshake(sec, request, response);
final HttpSession httpSession = (HttpSession)request.getHttpSession();
if (httpSession != null) {
sec.getUserProperties().put(HTTP_SESSION_ATTRIBUTE, httpSession);
}
final SecurityContext securityContext = createSecurityContext(request);
sec.getUserProperties().put(SECURITY_CONTEXT, securityContext);
}
};
}
@Override
public void modifyHandshake(ServerEndpointConfig config, HandshakeRequest request, HandshakeResponse response) {
HttpSession httpSession = (HttpSession)request.getHttpSession();
config.getUserProperties().put(HttpSession.class.getName(),httpSession);
super.modifyHandshake(config, request, response);
}
@Override
public void modifyHandshake(ServerEndpointConfig config, HandshakeRequest request, HandshakeResponse response) {
HttpSession httpSession = (HttpSession)request.getHttpSession();
config.getUserProperties().put(HttpSession.class.getName(),httpSession);
super.modifyHandshake(config, request, response);
}
@Override
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
HttpSession httpSession = (HttpSession) request.getHttpSession();
sec.getUserProperties().put(HttpSession.class.getName(), httpSession);
}
@Override
public void modifyHandshake(ServerEndpointConfig config, HandshakeRequest request, HandshakeResponse response) {
HttpSession httpSession = (HttpSession) request.getHttpSession();
config.getUserProperties().put("ClientIP", httpSession.getAttribute("ClientIPadd"));//把HttpSession中保存的ClientIP放到ServerEndpointConfig中,关键字可以跟之前不同
}
@Override
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
HttpSession httpSession = (HttpSession) request.getHttpSession();
sec.getUserProperties().put(HttpSession.class.getName(), httpSession);
}