Example usage for org.springframework.web.socket WebSocketSession getHandshakeHeaders

List of usage examples for org.springframework.web.socket WebSocketSession getHandshakeHeaders

Introduction

In this page you can find the example usage for org.springframework.web.socket WebSocketSession getHandshakeHeaders.

Prototype

HttpHeaders getHandshakeHeaders();

Source Link

Document

Return the headers used in the handshake request (never null ).

Usage

From source file:com.devicehive.websockets.WebSocketAuthenticationManager.java

public HiveAuthentication.HiveAuthDetails getDetails(WebSocketSession session) {
    List<String> originList = session.getHandshakeHeaders().get(HttpHeaders.ORIGIN);
    List<String> authList = session.getHandshakeHeaders().get(HttpHeaders.AUTHORIZATION);
    String origin = originList == null || originList.isEmpty() ? null : originList.get(0);
    String auth = authList == null || authList.isEmpty() ? null : authList.get(0);

    return new HiveAuthentication.HiveAuthDetails(session.getRemoteAddress().getAddress(), origin, auth);
}

From source file:com.github.mthizo247.cloud.netflix.zuul.web.authentication.LoginCookieHeadersCallback.java

@Override
protected void applyHeadersInternal(WebSocketSession userAgentSession, WebSocketHttpHeaders headers) {
    List<String> sessionCookies = userAgentSession.getHandshakeHeaders().get(HttpHeaders.COOKIE);
    headers.put(HttpHeaders.COOKIE, sessionCookies);
    if (logger.isDebugEnabled()) {
        logger.debug("Added cookie authentication header to web sockets http headers");
    }//  w  w w  . j  ava 2  s . c o m
}

From source file:jp.co.ctc_g.rack.websocket.sharedmessage.SharedMessageHandler.java

private String getGroupId(WebSocketSession session) {

    HttpHeaders headers = session.getHandshakeHeaders();
    if (headers == null) {
        throw new InternalException(SharedMessageHandler.class, "E-SHARED#0001");
    }/*  w  ww  .j  a  va2  s  .  c o  m*/
    List<String> groupIds = headers.get("x-GroupId");
    if (groupIds == null || groupIds.size() != 1) {
        throw new InternalException(SharedMessageHandler.class, "E-SHARED#0001");
    }
    return groupIds.get(0);
}

From source file:com.github.mthizo247.cloud.netflix.zuul.web.authentication.LoginCookieHeadersCallback.java

@Override
protected boolean shouldApplyHeaders(WebSocketSession userAgentSession, WebSocketHttpHeaders headers) {
    return !headers.containsKey(HttpHeaders.COOKIE)
            && userAgentSession.getHandshakeHeaders().containsKey(HttpHeaders.COOKIE);
}

From source file:com.zb.app.websocket.server.wrapper.ClientWrapper.java

public ClientWrapper(WebSocketSession socketSession) {
    this.address = socketSession.getRemoteAddress().getAddress();
    this.ip = address.getHostAddress();

    this.cookieManager = new WebSocketCookieManager(socketSession.getHandshakeHeaders());
    // ?1?//ww  w  .  ja  v a2s.  c o  m
    long lastLoginTime = NumberParser.parseLong(cookieManager.get(CookieKeyEnum.last_login_time), 0);
    if (lastLoginTime <= 0 || System.currentTimeMillis() - lastLoginTime > MAX_LAST_ACCESS_TIME) {
        ZuobianWebUserBuilder.loginOut(cookieManager);
    } else {
        this.webUser = ZuobianWebUserBuilder.create(cookieManager);
        this.mId = webUser.getmId();
    }
}