From c12d25d45cde0ec0b72e955362846c2b3ca6c831 Mon Sep 17 00:00:00 2001 From: github-actions <> Date: Mon, 15 Jan 2024 16:22:50 +0000 Subject: [PATCH] Google Java Format --- .../backend/config/socket/StompConfig.java | 2 ++ .../backend/config/socket/StompHandler.java | 29 ++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/com/twtw/backend/config/socket/StompConfig.java b/backend/src/main/java/com/twtw/backend/config/socket/StompConfig.java index fafbd77f..b479852b 100644 --- a/backend/src/main/java/com/twtw/backend/config/socket/StompConfig.java +++ b/backend/src/main/java/com/twtw/backend/config/socket/StompConfig.java @@ -1,7 +1,9 @@ package com.twtw.backend.config.socket; import com.twtw.backend.global.properties.RabbitMQProperties; + import lombok.RequiredArgsConstructor; + import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.messaging.simp.config.ChannelRegistration; diff --git a/backend/src/main/java/com/twtw/backend/config/socket/StompHandler.java b/backend/src/main/java/com/twtw/backend/config/socket/StompHandler.java index 4d29ca69..aa46cdd6 100644 --- a/backend/src/main/java/com/twtw/backend/config/socket/StompHandler.java +++ b/backend/src/main/java/com/twtw/backend/config/socket/StompHandler.java @@ -1,7 +1,9 @@ package com.twtw.backend.config.socket; import com.twtw.backend.config.security.jwt.TokenProvider; + import lombok.RequiredArgsConstructor; + import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.messaging.Message; @@ -28,21 +30,26 @@ public Message preSend(final Message message, final MessageChannel channel final StompHeaderAccessor acessor = StompHeaderAccessor.wrap(message); if (StompCommand.CONNECT == acessor.getCommand()) { - final Optional headerValue = Optional.ofNullable(acessor.getFirstNativeHeader(AUTHORIZATION_HEADER)); - resolveToken(headerValue).ifPresent(header -> { - tokenProvider.validateToken(header); - SecurityContextHolder.getContext().setAuthentication(tokenProvider.getAuthentication(header)); - }); + final Optional headerValue = + Optional.ofNullable(acessor.getFirstNativeHeader(AUTHORIZATION_HEADER)); + resolveToken(headerValue) + .ifPresent( + header -> { + tokenProvider.validateToken(header); + SecurityContextHolder.getContext() + .setAuthentication(tokenProvider.getAuthentication(header)); + }); } return message; } private Optional resolveToken(final Optional headerValue) { - return headerValue.map(header -> { - if (header.startsWith(BEARER_PREFIX)) { - return header.substring(7); - } - return header; - }); + return headerValue.map( + header -> { + if (header.startsWith(BEARER_PREFIX)) { + return header.substring(7); + } + return header; + }); } }