Skip to content

Commit ff56a97

Browse files
committedMar 29, 2024·
Java 21 nonroot.
Gradle 8.5. New token-support. Div libs.
1 parent e7facbc commit ff56a97

File tree

9 files changed

+47
-35
lines changed

9 files changed

+47
-35
lines changed
 

‎.github/workflows/deploy-to-dev.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ jobs:
4343
restore-keys: |
4444
${{ runner.os }}-gradle-
4545
46-
- name: Install Java 17
46+
- name: Install Java 21
4747
uses: actions/setup-java@v4
4848
with:
49-
java-version: 17
49+
java-version: 21
5050
distribution: temurin
5151

5252
- name: Test and build

‎.github/workflows/pull-requests.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
1414
restore-keys: |
1515
${{ runner.os }}-gradle-
16-
- name: Sett opp Java 17
16+
- name: Sett opp Java 21
1717
uses: actions/setup-java@v4
1818
with:
19-
java-version: 17
19+
java-version: 21
2020
distribution: temurin
2121
- name: test and build
2222
run: ./gradlew test build

‎Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM gcr.io/distroless/java17-debian12:latest
1+
FROM gcr.io/distroless/java21-debian12:nonroot
22
ENV TZ="Europe/Oslo"
33

44
COPY build/libs/app.jar /app/app.jar

‎build.gradle.kts

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ val springDocVersion = "2.4.0"
99
val testContainersVersion = "1.19.7"
1010
val threeTenExtraVersion = "1.7.2"
1111
val archunitVersion = "1.2.1"
12-
val opensearchVersion = "2.12.0"
12+
val opensearchVersion = "2.11.1"
1313
val reactorSpringVersion = "1.0.1.RELEASE"
1414
val kodeverkVersion = "1.8.7"
1515
val ehcacheVersion = "3.10.8"
1616
val logbackSyslog4jVersion = "1.0.0"
1717

18-
java.sourceCompatibility = JavaVersion.VERSION_17
19-
20-
ext["elasticsearch.version"] = "7.10.2"
18+
java.sourceCompatibility = JavaVersion.VERSION_21
2119

2220
repositories {
2321
mavenCentral()
@@ -96,7 +94,7 @@ idea {
9694
tasks.withType<KotlinCompile> {
9795
kotlinOptions {
9896
freeCompilerArgs = listOf("-Xjsr305=strict")
99-
jvmTarget = "17"
97+
jvmTarget = "21"
10098
}
10199
}
102100

‎gradle/wrapper/gradle-wrapper.jar

1.99 KB
Binary file not shown.
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4+
networkTimeout=10000
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists

‎gradlew

+14-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
# Darwin, MinGW, and NonStop.
5656
#
5757
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
58+
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5959
# within the Gradle project.
6060
#
6161
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,10 +80,10 @@ do
8080
esac
8181
done
8282

83-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84-
85-
APP_NAME="Gradle"
83+
# This is normally unused
84+
# shellcheck disable=SC2034
8685
APP_BASE_NAME=${0##*/}
86+
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
8787

8888
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
8989
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
@@ -143,12 +143,16 @@ fi
143143
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144144
case $MAX_FD in #(
145145
max*)
146+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147+
# shellcheck disable=SC3045
146148
MAX_FD=$( ulimit -H -n ) ||
147149
warn "Could not query maximum file descriptor limit"
148150
esac
149151
case $MAX_FD in #(
150152
'' | soft) :;; #(
151153
*)
154+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155+
# shellcheck disable=SC3045
152156
ulimit -n "$MAX_FD" ||
153157
warn "Could not set maximum file descriptor limit to $MAX_FD"
154158
esac
@@ -205,6 +209,12 @@ set -- \
205209
org.gradle.wrapper.GradleWrapperMain \
206210
"$@"
207211

212+
# Stop when "xargs" is not available.
213+
if ! command -v xargs >/dev/null 2>&1
214+
then
215+
die "xargs is not available"
216+
fi
217+
208218
# Use "xargs" to parse quoted args.
209219
#
210220
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

‎gradlew.bat

+9-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@rem limitations under the License.
1515
@rem
1616

17-
@if "%DEBUG%" == "" @echo off
17+
@if "%DEBUG%"=="" @echo off
1818
@rem ##########################################################################
1919
@rem
2020
@rem Gradle startup script for Windows
@@ -25,7 +25,8 @@
2525
if "%OS%"=="Windows_NT" setlocal
2626

2727
set DIRNAME=%~dp0
28-
if "%DIRNAME%" == "" set DIRNAME=.
28+
if "%DIRNAME%"=="" set DIRNAME=.
29+
@rem This is normally unused
2930
set APP_BASE_NAME=%~n0
3031
set APP_HOME=%DIRNAME%
3132

@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
4041

4142
set JAVA_EXE=java.exe
4243
%JAVA_EXE% -version >NUL 2>&1
43-
if "%ERRORLEVEL%" == "0" goto execute
44+
if %ERRORLEVEL% equ 0 goto execute
4445

4546
echo.
4647
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
7576

7677
:end
7778
@rem End local scope for the variables with windows NT shell
78-
if "%ERRORLEVEL%"=="0" goto mainEnd
79+
if %ERRORLEVEL% equ 0 goto mainEnd
7980

8081
:fail
8182
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
8283
rem the _cmd.exe /c_ return code!
83-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84-
exit /b 1
84+
set EXIT_CODE=%ERRORLEVEL%
85+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
86+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87+
exit /b %EXIT_CODE%
8588

8689
:mainEnd
8790
if "%OS%"=="Windows_NT" endlocal

‎src/main/kotlin/no/nav/klage/search/util/TokenUtil.kt

+14-14
Original file line numberDiff line numberDiff line change
@@ -20,41 +20,41 @@ class TokenUtil(
2020
}
2121

2222
fun getSaksbehandlerAccessTokenWithPdlScope(): String {
23-
val clientProperties = clientConfigurationProperties.registration["pdl-onbehalfof"]
23+
val clientProperties = clientConfigurationProperties.registration["pdl-onbehalfof"]!!
2424
val response = oAuth2AccessTokenService.getAccessToken(clientProperties)
25-
return response.accessToken
25+
return response.accessToken!!
2626
}
2727

2828
fun getAppAccessTokenWithPdlScope(): String {
29-
val clientProperties = clientConfigurationProperties.registration["pdl-maskintilmaskin"]
29+
val clientProperties = clientConfigurationProperties.registration["pdl-maskintilmaskin"]!!
3030
val response = oAuth2AccessTokenService.getAccessToken(clientProperties)
31-
return response.accessToken
31+
return response.accessToken!!
3232
}
3333

3434
fun getUserAccessTokenWithKabalInnstillingerScope(): String {
35-
val clientProperties = clientConfigurationProperties.registration["kabal-innstillinger-onbehalfof"]
35+
val clientProperties = clientConfigurationProperties.registration["kabal-innstillinger-onbehalfof"]!!
3636
val response = oAuth2AccessTokenService.getAccessToken(clientProperties)
37-
return response.accessToken
37+
return response.accessToken!!
3838
}
3939

4040
fun getSaksbehandlerAccessTokenWithGraphScope(): String {
41-
val clientProperties = clientConfigurationProperties.registration["azure-onbehalfof"]
41+
val clientProperties = clientConfigurationProperties.registration["azure-onbehalfof"]!!
4242
val response = oAuth2AccessTokenService.getAccessToken(clientProperties)
43-
return response.accessToken
43+
return response.accessToken!!
4444
}
4545

4646
fun getAppAccessTokenWithGraphScope(): String {
47-
val clientProperties = clientConfigurationProperties.registration["app"]
47+
val clientProperties = clientConfigurationProperties.registration["app"]!!
4848
val response = oAuth2AccessTokenService.getAccessToken(clientProperties)
49-
return response.accessToken
49+
return response.accessToken!!
5050
}
5151

5252
fun getIdent(): String =
53-
tokenValidationContextHolder.tokenValidationContext.getJwtToken(SecurityConfiguration.ISSUER_AAD)
54-
.jwtTokenClaims?.get("NAVident")?.toString()
53+
tokenValidationContextHolder.getTokenValidationContext().getJwtToken(SecurityConfiguration.ISSUER_AAD)
54+
?.jwtTokenClaims?.get("NAVident")?.toString()
5555
?: throw RuntimeException("Ident not found in token")
5656

5757
fun getRoleIdsFromToken(): List<String> =
58-
tokenValidationContextHolder.tokenValidationContext.getJwtToken(SecurityConfiguration.ISSUER_AAD)
59-
.jwtTokenClaims?.getAsList("groups").orEmpty().toList()
58+
tokenValidationContextHolder.getTokenValidationContext().getJwtToken(SecurityConfiguration.ISSUER_AAD)
59+
?.jwtTokenClaims?.getAsList("groups").orEmpty().toList()
6060
}

0 commit comments

Comments
 (0)
Please sign in to comment.