Remove useless "final" keywords
This commit is contained in:
@@ -13,19 +13,19 @@ import org.springframework.stereotype.Service;
|
|||||||
public class CustomUserDetailsService implements UserDetailsService {
|
public class CustomUserDetailsService implements UserDetailsService {
|
||||||
private final UserUseCases userUseCases;
|
private final UserUseCases userUseCases;
|
||||||
|
|
||||||
public CustomUserDetailsService(final UserUseCases userUseCases) {
|
public CustomUserDetailsService(UserUseCases userUseCases) {
|
||||||
this.userUseCases = userUseCases;
|
this.userUseCases = userUseCases;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDetails loadUserByUsername(final String userIdAsString) throws UsernameNotFoundException {
|
public UserDetails loadUserByUsername(String userIdAsString) throws UsernameNotFoundException {
|
||||||
UUID userId = parseUserId(userIdAsString);
|
UUID userId = parseUserId(userIdAsString);
|
||||||
return userUseCases.findById(userId)
|
return userUseCases.findById(userId)
|
||||||
.map(CustomUserDetails::new)
|
.map(CustomUserDetails::new)
|
||||||
.orElseThrow(() -> new UsernameNotFoundException(userIdAsString));
|
.orElseThrow(() -> new UsernameNotFoundException(userIdAsString));
|
||||||
}
|
}
|
||||||
|
|
||||||
private UUID parseUserId(final String userIdAsString) {
|
private UUID parseUserId(String userIdAsString) {
|
||||||
try {
|
try {
|
||||||
return UUID.fromString(userIdAsString);
|
return UUID.fromString(userIdAsString);
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
|||||||
@Component
|
@Component
|
||||||
public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
||||||
private static final String BEARER_PREFIX = "Bearer ";
|
private static final String BEARER_PREFIX = "Bearer ";
|
||||||
|
|
||||||
private final JwtService jwtService;
|
private final JwtService jwtService;
|
||||||
private final UserDetailsService userDetailsService;
|
private final UserDetailsService userDetailsService;
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import org.springframework.security.core.userdetails.UserDetails;
|
|||||||
public class CustomUserDetails implements UserDetails {
|
public class CustomUserDetails implements UserDetails {
|
||||||
private final User user;
|
private final User user;
|
||||||
|
|
||||||
public CustomUserDetails(final User user) {
|
public CustomUserDetails(User user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import org.sportshub.application.security.JwtService;
|
|||||||
import org.sportshub.application.security.annotation.AllowedToAdmins;
|
import org.sportshub.application.security.annotation.AllowedToAdmins;
|
||||||
import org.sportshub.domain.exception.LoginFailureException;
|
import org.sportshub.domain.exception.LoginFailureException;
|
||||||
import org.sportshub.domain.exception.RefreshTokenDoesNotExistException;
|
import org.sportshub.domain.exception.RefreshTokenDoesNotExistException;
|
||||||
import org.sportshub.domain.exception.RefreshTokenExpiredException;
|
|
||||||
import org.sportshub.domain.exception.UserDoesNotExistException;
|
import org.sportshub.domain.exception.UserDoesNotExistException;
|
||||||
import org.sportshub.domain.user.model.RefreshToken;
|
import org.sportshub.domain.user.model.RefreshToken;
|
||||||
import org.sportshub.domain.user.model.User;
|
import org.sportshub.domain.user.model.User;
|
||||||
@@ -86,7 +85,7 @@ public class UserUseCases {
|
|||||||
.flatMap(userPort::findById);
|
.flatMap(userPort::findById);
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserAuthenticationData generateAuthenticationData(final User user) {
|
private UserAuthenticationData generateAuthenticationData(User user) {
|
||||||
String accessToken = jwtService.createJwt(user);
|
String accessToken = jwtService.createJwt(user);
|
||||||
|
|
||||||
RefreshToken newRefreshToken = createNewRefreshToken(user);
|
RefreshToken newRefreshToken = createNewRefreshToken(user);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.sportshub.domain.exception;
|
package org.sportshub.domain.exception;
|
||||||
|
|
||||||
public abstract class FunctionnalException extends RuntimeException {
|
public abstract class FunctionnalException extends RuntimeException {
|
||||||
public FunctionnalException(final String message) {
|
public FunctionnalException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
public class UserController {
|
public class UserController {
|
||||||
private final UserUseCases userUseCases;
|
private final UserUseCases userUseCases;
|
||||||
|
|
||||||
public UserController(final UserUseCases userUseCases) {
|
public UserController(UserUseCases userUseCases) {
|
||||||
this.userUseCases = userUseCases;
|
this.userUseCases = userUseCases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class UserJpaAdapter implements UserPort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean existsById(final UUID userId) {
|
public boolean existsById(UUID userId) {
|
||||||
return userJpaRepository.existsById(userId);
|
return userJpaRepository.existsById(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user