aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-auth
diff options
context:
space:
mode:
authorMatteo Mara <matteo.mara@sonarsource.com>2023-01-09 10:21:46 +0100
committersonartech <sonartech@sonarsource.com>2023-01-10 20:03:01 +0000
commit295a87208f8c9898fbdc733a438587dc03a16877 (patch)
tree9771ee3245ab6e978b20b9d8b800450947fc7199 /server/sonar-webserver-auth
parent8868a5ff310c74f44f2c94e46ba31065017f50b4 (diff)
downloadsonarqube-295a87208f8c9898fbdc733a438587dc03a16877.tar.gz
sonarqube-295a87208f8c9898fbdc733a438587dc03a16877.zip
[NO-JIRA] Remove reported code smells about usage of instanceof
Diffstat (limited to 'server/sonar-webserver-auth')
-rw-r--r--server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/InitFilter.java8
-rw-r--r--server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/OAuth2CallbackFilter.java4
-rw-r--r--server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/UserSessionInitializer.java4
3 files changed, 8 insertions, 8 deletions
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/InitFilter.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/InitFilter.java
index faa28b4783d..fe35388cc5b 100644
--- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/InitFilter.java
+++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/InitFilter.java
@@ -73,11 +73,11 @@ public class InitFilter extends AuthenticationFilter {
private void handleProvider(HttpServletRequest request, HttpServletResponse response, IdentityProvider provider) {
try {
- if (provider instanceof BaseIdentityProvider) {
- handleBaseIdentityProvider(request, response, (BaseIdentityProvider) provider);
- } else if (provider instanceof OAuth2IdentityProvider) {
+ if (provider instanceof BaseIdentityProvider baseIdentityProvider) {
+ handleBaseIdentityProvider(request, response, baseIdentityProvider);
+ } else if (provider instanceof OAuth2IdentityProvider oAuth2IdentityProvider) {
oAuthOAuth2AuthenticationParameters.init(request, response);
- handleOAuth2IdentityProvider(request, response, (OAuth2IdentityProvider) provider);
+ handleOAuth2IdentityProvider(request, response, oAuth2IdentityProvider);
} else {
handleError(request, response, format("Unsupported IdentityProvider class: %s", provider.getClass()));
}
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/OAuth2CallbackFilter.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/OAuth2CallbackFilter.java
index 389436e5636..c3b5a664073 100644
--- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/OAuth2CallbackFilter.java
+++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/OAuth2CallbackFilter.java
@@ -71,8 +71,8 @@ public class OAuth2CallbackFilter extends AuthenticationFilter {
private void handleProvider(HttpServletRequest request, HttpServletResponse response, IdentityProvider provider) {
try {
- if (provider instanceof OAuth2IdentityProvider) {
- handleOAuth2Provider(response, request, (OAuth2IdentityProvider) provider);
+ if (provider instanceof OAuth2IdentityProvider oAuth2IdentityProvider) {
+ handleOAuth2Provider(response, request, oAuth2IdentityProvider);
} else {
handleError(request, response, format("Not an OAuth2IdentityProvider: %s", provider.getClass()));
}
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/UserSessionInitializer.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/UserSessionInitializer.java
index 66376c77170..fa6be146e7e 100644
--- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/UserSessionInitializer.java
+++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/UserSessionInitializer.java
@@ -141,8 +141,8 @@ public class UserSessionInitializer {
}
private static void checkTokenUserSession(HttpServletResponse response, UserSession session) {
- if (session instanceof TokenUserSession) {
- UserTokenDto userTokenDto = ((TokenUserSession) session).getUserToken();
+ if (session instanceof TokenUserSession tokenUserSession) {
+ UserTokenDto userTokenDto = tokenUserSession.getUserToken();
Optional.ofNullable(userTokenDto.getExpirationDate()).ifPresent(expirationDate -> response.addHeader(SQ_AUTHENTICATION_TOKEN_EXPIRATION, formatDateTime(expirationDate)));
}
}