Java Code Examples for org.springframework.web.socket.WebSocketHttpHeaders#put()
The following examples show how to use
org.springframework.web.socket.WebSocketHttpHeaders#put() .
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: BasicAuthPrincipalHeadersCallback.java From spring-cloud-netflix-zuul-websocket with Apache License 2.0 | 5 votes |
@Override protected void applyHeadersInternal(WebSocketSession userAgentSession, WebSocketHttpHeaders headers) { Authentication authentication = (Authentication) userAgentSession.getPrincipal(); String usernameColonPwd = authentication.getName() + ":" + authentication.getCredentials().toString(); String encodedCredentials = new String( Base64.encode(usernameColonPwd.getBytes())); headers.put(HttpHeaders.AUTHORIZATION, Collections.singletonList("Basic " + encodedCredentials)); if (logger.isDebugEnabled()) { logger.debug("Added basic authentication header for user " + authentication.getName() + " to web sockets http headers"); } }
Example 2
Source File: OAuth2BearerPrincipalHeadersCallback.java From spring-cloud-netflix-zuul-websocket with Apache License 2.0 | 5 votes |
@Override protected void applyHeadersInternal(WebSocketSession userAgentSession, WebSocketHttpHeaders headers) { OAuth2Authentication oAuth2Authentication = (OAuth2Authentication) userAgentSession.getPrincipal(); OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails) oAuth2Authentication.getDetails(); String accessToken = details.getTokenValue(); headers.put(HttpHeaders.AUTHORIZATION, Collections.singletonList("Bearer " + accessToken)); if (logger.isDebugEnabled()) { logger.debug("Added Oauth2 bearer token authentication header for user " + oAuth2Authentication.getName() + " to web sockets http headers"); } }
Example 3
Source File: LoginCookieHeadersCallback.java From spring-cloud-netflix-zuul-websocket with Apache License 2.0 | 5 votes |
@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"); } }