当前位置: 首页>>代码示例>>Java>>正文


Java HandshakeRequest.getHttpSession方法代码示例

本文整理汇总了Java中javax.websocket.server.HandshakeRequest.getHttpSession方法的典型用法代码示例。如果您正苦于以下问题:Java HandshakeRequest.getHttpSession方法的具体用法?Java HandshakeRequest.getHttpSession怎么用?Java HandshakeRequest.getHttpSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.websocket.server.HandshakeRequest的用法示例。


在下文中一共展示了HandshakeRequest.getHttpSession方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: modifyHandshake

import javax.websocket.server.HandshakeRequest; //导入方法依赖的package包/类
@Override
public void modifyHandshake(ServerEndpointConfig config,
        HandshakeRequest request, HandshakeResponse response) {

    HttpSession httpSession = (HttpSession) request.getHttpSession();

    super.modifyHandshake(config, request, response);

    if (httpSession == null) {
        LOGGER.info("httpSession == null after modifyHandshake");
        httpSession = (HttpSession) request.getHttpSession();
    }

    if (httpSession == null) {
        LOGGER.info("httpSession == null");
        return;
    }

    config.getUserProperties().put("httpSession", httpSession);

    httpSession = (HttpSession) request.getHttpSession();
    LOGGER.info("modifyHandshake " + httpSession.getId());

}
 
开发者ID:webfirmframework,项目名称:tomcat-8-wffweb-demo-apps,代码行数:25,代码来源:WSServerForIndexPage.java

示例2: modifyHandshake

import javax.websocket.server.HandshakeRequest; //导入方法依赖的package包/类
@Override
public void modifyHandshake(ServerEndpointConfig config,
        HandshakeRequest request, HandshakeResponse response) {

  Map<String, List<String>> headers = request.getHeaders();
  if (headers != null && headers.containsKey(WatcherSecurityKey.HTTP_HEADER)) {
    List<String> header = headers.get(WatcherSecurityKey.HTTP_HEADER);
    if (header.size() > 0) {
      config.getUserProperties().put(WatcherSecurityKey.HTTP_HEADER, header.
              get(0));
    }
  }
  HttpSession httpSession = (HttpSession) request.getHttpSession();
  String user = request.getUserPrincipal().getName();
  config.getUserProperties().put("httpSession", httpSession);
  config.getUserProperties().put("user", user);
  logger.log(Level.INFO, "Hand shake for upgrade to websocket by: {0}", user);
}
 
开发者ID:hopshadoop,项目名称:hopsworks,代码行数:19,代码来源:ZeppelinEndpointConfig.java

示例3: modifyHandshake

import javax.websocket.server.HandshakeRequest; //导入方法依赖的package包/类
/**
 * Intercept the handshake operation so that we can take a hold of the
 * ServletContext instance to be able to retrieve attributes stored to it
 * such as the database object and other similar class instances
 * <p/>
 * @param config
 * @param request
 * @param response
 */
@Override
public void modifyHandshake(ServerEndpointConfig config,
        HandshakeRequest request, HandshakeResponse response) {

  HttpSession httpSession = (HttpSession) request.getHttpSession();
  ServletContext context = (ServletContext) httpSession.getServletContext();

  config.getUserProperties().put("httpSession", httpSession);
  config.getUserProperties().put("user", request.getUserPrincipal().getName());

  /*
   * store these attributes to servletContext so that they are available to
   * every created user socket session
   */
  config.getUserProperties().put("protocol", context.getAttribute("protocol"));
}
 
开发者ID:hopshadoop,项目名称:hopsworks,代码行数:26,代码来源:ServletAwareConfig.java

示例4: modifyHandshake

import javax.websocket.server.HandshakeRequest; //导入方法依赖的package包/类
@Override
public void modifyHandshake(ServerEndpointConfig sec,
        HandshakeRequest request, HandshakeResponse response)
{
    HttpSession httpSession = (HttpSession) request.getHttpSession();
    sec.getUserProperties().put(HttpSession.class.getName(), httpSession);
}
 
开发者ID:gzxishan,项目名称:OftenPorter,代码行数:8,代码来源:HttpSessionConfigurator.java

示例5: modifyHandshake

import javax.websocket.server.HandshakeRequest; //导入方法依赖的package包/类
@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);
	}
}
 
开发者ID:butter-fly,项目名称:belling-admin,代码行数:8,代码来源:HttpChatSessionConfigurator.java

示例6: modifyHandshake

import javax.websocket.server.HandshakeRequest; //导入方法依赖的package包/类
@Override
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
	final HttpSession httpSession = (HttpSession) request.getHttpSession();
	if (request.getUserPrincipal() == null) {
		return;
	}

	final SecurityContext securityCtx = new WebSocketSecurityContext(request);
	sec.getUserProperties().put(key(httpSession.getId()), securityCtx);
}
 
开发者ID:dansiviter,项目名称:cito,代码行数:11,代码来源:WebSocketConfigurator.java

示例7: modifyHandshake

import javax.websocket.server.HandshakeRequest; //导入方法依赖的package包/类
@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);
}
 
开发者ID:FangStarNet,项目名称:symphonyx,代码行数:8,代码来源:Channels.java

示例8: modifyHandshake

import javax.websocket.server.HandshakeRequest; //导入方法依赖的package包/类
@Override
public void modifyHandshake(ServerEndpointConfig config, HandshakeRequest request, HandshakeResponse response) {
	HttpSession session = (HttpSession) request.getHttpSession();
	if (null != session) {
		config.getUserProperties().put("demo", 1L);
	}
}
 
开发者ID:meskobalazs,项目名称:bootstrap-quickstart,代码行数:8,代码来源:SessionConfigurator.java

示例9: createConfigurator

import javax.websocket.server.HandshakeRequest; //导入方法依赖的package包/类
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);
      }
      sec.getUserProperties().put(SECURITY_CONTEXT, createSecurityContext(request));
      sec.getUserProperties().put(ENVIRONMENT_CONTEXT, EnvironmentContext.getCurrent());
    }
  };
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:ServerContainerInitializeListener.java

示例10: modifyHandshake

import javax.websocket.server.HandshakeRequest; //导入方法依赖的package包/类
@Override
public void modifyHandshake(ServerEndpointConfig config,
		HandshakeRequest request, HandshakeResponse response) {
	HttpSession httpSession = (HttpSession) request.getHttpSession();
	config.getUserProperties()
			.put(HttpSession.class.getName(), httpSession);
}
 
开发者ID:bessemHmidi,项目名称:AngularBeans,代码行数:8,代码来源:GetHttpSessionConfigurator.java

示例11: setContext

import javax.websocket.server.HandshakeRequest; //导入方法依赖的package包/类
/**
 * 
 * @param request 
 */
void setContext(HandshakeRequest request) {
	HttpSession httpSession = (HttpSession) request.getHttpSession();
	ThreadLocalContextHolder.put(Constants.HTTPSESSION, httpSession);
	if(null == httpSession.getAttribute(Constants.LOCALE)) {
		httpSession.setAttribute(Constants.LOCALE, getLocale(request));
	}
}
 
开发者ID:ocelotds,项目名称:ocelot,代码行数:12,代码来源:WSController.java

示例12: modifyHandshake

import javax.websocket.server.HandshakeRequest; //导入方法依赖的package包/类
@Override
public void modifyHandshake(ServerEndpointConfig config,
                            HandshakeRequest request,
                            HandshakeResponse response)
{
    HttpSession httpSession = (HttpSession)request.getHttpSession();
    config.getUserProperties().put(HttpSession.class.getName(),httpSession);
}
 
开发者ID:skavanagh,项目名称:EC2Box,代码行数:9,代码来源:GetHttpSessionConfigurator.java

示例13: modifyHandshake

import javax.websocket.server.HandshakeRequest; //导入方法依赖的package包/类
@Override
public void modifyHandshake(final ServerEndpointConfig config,
                            final HandshakeRequest request,
                            final HandshakeResponse response) {

  final HttpSession httpSession = (HttpSession) request.getHttpSession();

  config.getUserProperties().put(HTTP_SESSION_KEY, httpSession);
}
 
开发者ID:jpschewe,项目名称:fll-sw,代码行数:10,代码来源:GetHttpSessionConfigurator.java

示例14: fromRequest

import javax.websocket.server.HandshakeRequest; //导入方法依赖的package包/类
public static HandshakeRequestData fromRequest(HandshakeRequest request) {
    HandshakeRequestData data = new HandshakeRequestData();
   
    data.setParameters(request.getParameterMap());
    data.setHeaders(request.getHeaders());
    data.setRequestUri(request.getRequestURI());
    if (request.getHttpSession() instanceof HttpSession) {
        data.setHttpSession((HttpSession) request.getHttpSession()); 
    }
    //data.initSession(request.getHttpSession());
    return data;
}
 
开发者ID:wigforss,项目名称:Ka-Websocket,代码行数:13,代码来源:HandshakeRequestData.java

示例15: modifyHandshake

import javax.websocket.server.HandshakeRequest; //导入方法依赖的package包/类
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
	HttpSession httpSession = (HttpSession) request.getHttpSession();
	sec.getUserProperties().put(HttpSession.class.getName(), httpSession);
}
 
开发者ID:zhiqiang94,项目名称:BasicsProject,代码行数:5,代码来源:HttpSessionConfigurator.java


注:本文中的javax.websocket.server.HandshakeRequest.getHttpSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。