Skip to content

Commit

Permalink
update :: null 처리 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
4mjeo committed Feb 28, 2024
1 parent e2c50aa commit 85a23fd
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ class AuthenticationFilter(
var requestUserAuthority = request.getHeader("Request-User-Authorities") ?: "STU"
var requestUserRole = request.getHeader("Request-User-Role") ?: "STU"

val simpleGrantedAuthorities = requestUserAuthority.toList().let { authorities ->
buildRequestAuthoritiesAndRole(requestUserRole, authorities)
val authorityList = requestUserAuthority.toList()
val simpleGrantedAuthorities = if(authorityList.isNotEmpty()) {
buildRequestAuthoritiesAndRole(requestUserRole, authorityList)
.map { SimpleGrantedAuthority(it) }
} else {
listOf<SimpleGrantedAuthority>()
}

if (simpleGrantedAuthorities.isNotEmpty()) {
Expand All @@ -73,6 +76,15 @@ class AuthenticationFilter(
}
}

private fun buildRequestAuthoritiesAndRole(
requestUserRole: String,
requestUserAuthorities: List<String>
): List<String> {
val authoritiesAndRoles = mutableListOf("ROLE_$requestUserRole")
requestUserAuthorities.forEach { authoritiesAndRoles.add(it) }
return authoritiesAndRoles
}

private fun setAuthenticationByAccessToken(accessToken: String) {
val tokenEntity = accessTokenEntityRepository.findByTokenValue(accessToken)
?: throw AccessTokenNotFoundException(ACCESS_TOKEN_NOT_FOUND)
Expand All @@ -90,15 +102,6 @@ class AuthenticationFilter(
)
}

private fun buildRequestAuthoritiesAndRole(
requestUserRole: String,
requestUserAuthorities: List<String>
): List<String> {
val authoritiesAndRoles = mutableListOf("ROLE_$requestUserRole")
requestUserAuthorities.forEach { authoritiesAndRoles.add(it) }
return requestUserAuthorities
}

private fun String.toList(): List<String> {
return this.removeSurrounding("[", "]")
.replace(" ", "")
Expand Down

0 comments on commit 85a23fd

Please sign in to comment.