Java Code Examples for javax.websocket.server.HandshakeRequest#getHttpSession()

The following examples show how to use javax.websocket.server.HandshakeRequest#getHttpSession() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebsocketSessionConfigurator.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void modifyHandshake(ServerEndpointConfig config,
        HandshakeRequest request,
        HandshakeResponse response) {
    HttpSession httpSession = (HttpSession)request.getHttpSession();
    config.getUserProperties().put("webUserID", httpSession.getAttribute("webUserID"));
}
 
Example 2
Source File: HttpChatSessionConfigurator.java    From belling-admin with Apache License 2.0 5 votes vote down vote up
@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);
	}
}
 
Example 3
Source File: MCRWebsocketDefaultConfigurator.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example 4
Source File: Channels.java    From symphonyx with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 5
Source File: GuiceInjectorEndpointConfigurator.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@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);
    }
  }
}
 
Example 6
Source File: GetHttpSessionConfigurator.java    From AngularBeans with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void modifyHandshake(ServerEndpointConfig config,
		HandshakeRequest request, HandshakeResponse response) {
	HttpSession httpSession = (HttpSession) request.getHttpSession();
	config.getUserProperties()
			.put(HttpSession.class.getName(), httpSession);
}
 
Example 7
Source File: ChatEndpointConfig.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
@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);
}
 
Example 8
Source File: ServerContainerInitializeListener.java    From everrest with Eclipse Public License 2.0 5 votes vote down vote up
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);
        }
    };
}
 
Example 9
Source File: WSSHSessionConfigurator.java    From mcg-helper with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example 10
Source File: GetHttpSessionConfigurator.java    From mcg-helper with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example 11
Source File: HttpSessionConfigurator.java    From realtime-log with Apache License 2.0 4 votes vote down vote up
@Override
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
    HttpSession httpSession = (HttpSession) request.getHttpSession();
    sec.getUserProperties().put(HttpSession.class.getName(), httpSession);
}
 
Example 12
Source File: SocketConfigurator.java    From webChat with Apache License 2.0 4 votes vote down vote up
@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中,关键字可以跟之前不同
}
 
Example 13
Source File: WebSocketServerConfigurator.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 4 votes vote down vote up
@Override
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
	HttpSession httpSession = (HttpSession) request.getHttpSession();
	sec.getUserProperties().put(HttpSession.class.getName(), httpSession);
}