Skip to content

Commit 782bf8c

Browse files
committed
Add WS Next OIDC quickstart
1 parent 1bd3f6c commit 782bf8c

File tree

12 files changed

+1028
-0
lines changed

12 files changed

+1028
-0
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
<module>security-openid-connect-client-quickstart</module>
9595
<module>security-openid-connect-web-authentication-quickstart</module>
9696
<module>security-openid-connect-multi-tenancy-quickstart</module>
97+
<module>security-openid-connect-websockets-next-quickstart</module>
9798
<module>security-webauthn-quickstart</module>
9899
<module>security-webauthn-reactive-quickstart</module>
99100
<module>software-transactional-memory-quickstart</module>
Binary file not shown.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
wrapperVersion=3.3.2
18+
distributionType=bin
19+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
20+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Quarkus guide: https://quarkus.io/guides/websockets-next-reference
2+
3+
This quickstart shows how `SecurityIdentity` can be updated using an access token obtained with Keycloak JavaScript adapter.
4+
First, start Quarkus application in DEV mode using `quarkus dev` command, and then navigate to the `http://localhost:8080/` page.
5+
You will be redirected to Keycloak where you can log in using well-known user `alice` or `bob`.
6+
Once the Web socket connection is opened, the Keycloak JavaScript adapter will update current access token when necessary and new token can be propagated to the WebSocket server as message.
Lines changed: 332 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,332 @@
1+
#!/bin/sh
2+
# ----------------------------------------------------------------------------
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
# ----------------------------------------------------------------------------
20+
21+
# ----------------------------------------------------------------------------
22+
# Apache Maven Wrapper startup batch script, version 3.3.2
23+
#
24+
# Required ENV vars:
25+
# ------------------
26+
# JAVA_HOME - location of a JDK home dir
27+
#
28+
# Optional ENV vars
29+
# -----------------
30+
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
31+
# e.g. to debug Maven itself, use
32+
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33+
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34+
# ----------------------------------------------------------------------------
35+
36+
if [ -z "$MAVEN_SKIP_RC" ]; then
37+
38+
if [ -f /usr/local/etc/mavenrc ]; then
39+
. /usr/local/etc/mavenrc
40+
fi
41+
42+
if [ -f /etc/mavenrc ]; then
43+
. /etc/mavenrc
44+
fi
45+
46+
if [ -f "$HOME/.mavenrc" ]; then
47+
. "$HOME/.mavenrc"
48+
fi
49+
50+
fi
51+
52+
# OS specific support. $var _must_ be set to either true or false.
53+
cygwin=false
54+
darwin=false
55+
mingw=false
56+
case "$(uname)" in
57+
CYGWIN*) cygwin=true ;;
58+
MINGW*) mingw=true ;;
59+
Darwin*)
60+
darwin=true
61+
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
62+
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
63+
if [ -z "$JAVA_HOME" ]; then
64+
if [ -x "/usr/libexec/java_home" ]; then
65+
JAVA_HOME="$(/usr/libexec/java_home)"
66+
export JAVA_HOME
67+
else
68+
JAVA_HOME="/Library/Java/Home"
69+
export JAVA_HOME
70+
fi
71+
fi
72+
;;
73+
esac
74+
75+
if [ -z "$JAVA_HOME" ]; then
76+
if [ -r /etc/gentoo-release ]; then
77+
JAVA_HOME=$(java-config --jre-home)
78+
fi
79+
fi
80+
81+
# For Cygwin, ensure paths are in UNIX format before anything is touched
82+
if $cygwin; then
83+
[ -n "$JAVA_HOME" ] \
84+
&& JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
85+
[ -n "$CLASSPATH" ] \
86+
&& CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
87+
fi
88+
89+
# For Mingw, ensure paths are in UNIX format before anything is touched
90+
if $mingw; then
91+
[ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] \
92+
&& JAVA_HOME="$(
93+
cd "$JAVA_HOME" || (
94+
echo "cannot cd into $JAVA_HOME." >&2
95+
exit 1
96+
)
97+
pwd
98+
)"
99+
fi
100+
101+
if [ -z "$JAVA_HOME" ]; then
102+
javaExecutable="$(which javac)"
103+
if [ -n "$javaExecutable" ] && ! [ "$(expr "$javaExecutable" : '\([^ ]*\)')" = "no" ]; then
104+
# readlink(1) is not available as standard on Solaris 10.
105+
readLink=$(which readlink)
106+
if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
107+
if $darwin; then
108+
javaHome="$(dirname "$javaExecutable")"
109+
javaExecutable="$(cd "$javaHome" && pwd -P)/javac"
110+
else
111+
javaExecutable="$(readlink -f "$javaExecutable")"
112+
fi
113+
javaHome="$(dirname "$javaExecutable")"
114+
javaHome=$(expr "$javaHome" : '\(.*\)/bin')
115+
JAVA_HOME="$javaHome"
116+
export JAVA_HOME
117+
fi
118+
fi
119+
fi
120+
121+
if [ -z "$JAVACMD" ]; then
122+
if [ -n "$JAVA_HOME" ]; then
123+
if [ -x "$JAVA_HOME/jre/sh/java" ]; then
124+
# IBM's JDK on AIX uses strange locations for the executables
125+
JAVACMD="$JAVA_HOME/jre/sh/java"
126+
else
127+
JAVACMD="$JAVA_HOME/bin/java"
128+
fi
129+
else
130+
JAVACMD="$(
131+
\unset -f command 2>/dev/null
132+
\command -v java
133+
)"
134+
fi
135+
fi
136+
137+
if [ ! -x "$JAVACMD" ]; then
138+
echo "Error: JAVA_HOME is not defined correctly." >&2
139+
echo " We cannot execute $JAVACMD" >&2
140+
exit 1
141+
fi
142+
143+
if [ -z "$JAVA_HOME" ]; then
144+
echo "Warning: JAVA_HOME environment variable is not set." >&2
145+
fi
146+
147+
# traverses directory structure from process work directory to filesystem root
148+
# first directory with .mvn subdirectory is considered project base directory
149+
find_maven_basedir() {
150+
if [ -z "$1" ]; then
151+
echo "Path not specified to find_maven_basedir" >&2
152+
return 1
153+
fi
154+
155+
basedir="$1"
156+
wdir="$1"
157+
while [ "$wdir" != '/' ]; do
158+
if [ -d "$wdir"/.mvn ]; then
159+
basedir=$wdir
160+
break
161+
fi
162+
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
163+
if [ -d "${wdir}" ]; then
164+
wdir=$(
165+
cd "$wdir/.." || exit 1
166+
pwd
167+
)
168+
fi
169+
# end of workaround
170+
done
171+
printf '%s' "$(
172+
cd "$basedir" || exit 1
173+
pwd
174+
)"
175+
}
176+
177+
# concatenates all lines of a file
178+
concat_lines() {
179+
if [ -f "$1" ]; then
180+
# Remove \r in case we run on Windows within Git Bash
181+
# and check out the repository with auto CRLF management
182+
# enabled. Otherwise, we may read lines that are delimited with
183+
# \r\n and produce $'-Xarg\r' rather than -Xarg due to word
184+
# splitting rules.
185+
tr -s '\r\n' ' ' <"$1"
186+
fi
187+
}
188+
189+
log() {
190+
if [ "$MVNW_VERBOSE" = true ]; then
191+
printf '%s\n' "$1"
192+
fi
193+
}
194+
195+
BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
196+
if [ -z "$BASE_DIR" ]; then
197+
exit 1
198+
fi
199+
200+
MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
201+
export MAVEN_PROJECTBASEDIR
202+
log "$MAVEN_PROJECTBASEDIR"
203+
204+
##########################################################################################
205+
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
206+
# This allows using the maven wrapper in projects that prohibit checking in binary data.
207+
##########################################################################################
208+
wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
209+
if [ -r "$wrapperJarPath" ]; then
210+
log "Found $wrapperJarPath"
211+
else
212+
log "Couldn't find $wrapperJarPath, downloading it ..."
213+
214+
if [ -n "$MVNW_REPOURL" ]; then
215+
wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar"
216+
else
217+
wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar"
218+
fi
219+
while IFS="=" read -r key value; do
220+
# Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
221+
safeValue=$(echo "$value" | tr -d '\r')
222+
case "$key" in wrapperUrl)
223+
wrapperUrl="$safeValue"
224+
break
225+
;;
226+
esac
227+
done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
228+
log "Downloading from: $wrapperUrl"
229+
230+
if $cygwin; then
231+
wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
232+
fi
233+
234+
if command -v wget >/dev/null; then
235+
log "Found wget ... using wget"
236+
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
237+
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
238+
wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
239+
else
240+
wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
241+
fi
242+
elif command -v curl >/dev/null; then
243+
log "Found curl ... using curl"
244+
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
245+
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
246+
curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
247+
else
248+
curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
249+
fi
250+
else
251+
log "Falling back to using Java to download"
252+
javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
253+
javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
254+
# For Cygwin, switch paths to Windows format before running javac
255+
if $cygwin; then
256+
javaSource=$(cygpath --path --windows "$javaSource")
257+
javaClass=$(cygpath --path --windows "$javaClass")
258+
fi
259+
if [ -e "$javaSource" ]; then
260+
if [ ! -e "$javaClass" ]; then
261+
log " - Compiling MavenWrapperDownloader.java ..."
262+
("$JAVA_HOME/bin/javac" "$javaSource")
263+
fi
264+
if [ -e "$javaClass" ]; then
265+
log " - Running MavenWrapperDownloader.java ..."
266+
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
267+
fi
268+
fi
269+
fi
270+
fi
271+
##########################################################################################
272+
# End of extension
273+
##########################################################################################
274+
275+
# If specified, validate the SHA-256 sum of the Maven wrapper jar file
276+
wrapperSha256Sum=""
277+
while IFS="=" read -r key value; do
278+
case "$key" in wrapperSha256Sum)
279+
wrapperSha256Sum=$value
280+
break
281+
;;
282+
esac
283+
done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
284+
if [ -n "$wrapperSha256Sum" ]; then
285+
wrapperSha256Result=false
286+
if command -v sha256sum >/dev/null; then
287+
if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c >/dev/null 2>&1; then
288+
wrapperSha256Result=true
289+
fi
290+
elif command -v shasum >/dev/null; then
291+
if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c >/dev/null 2>&1; then
292+
wrapperSha256Result=true
293+
fi
294+
else
295+
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
296+
echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." >&2
297+
exit 1
298+
fi
299+
if [ $wrapperSha256Result = false ]; then
300+
echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
301+
echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
302+
echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
303+
exit 1
304+
fi
305+
fi
306+
307+
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
308+
309+
# For Cygwin, switch paths to Windows format before running java
310+
if $cygwin; then
311+
[ -n "$JAVA_HOME" ] \
312+
&& JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
313+
[ -n "$CLASSPATH" ] \
314+
&& CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
315+
[ -n "$MAVEN_PROJECTBASEDIR" ] \
316+
&& MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
317+
fi
318+
319+
# Provide a "standardized" way to retrieve the CLI args that will
320+
# work with both Windows and non-Windows executions.
321+
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
322+
export MAVEN_CMD_LINE_ARGS
323+
324+
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
325+
326+
# shellcheck disable=SC2086 # safe args
327+
exec "$JAVACMD" \
328+
$MAVEN_OPTS \
329+
$MAVEN_DEBUG_OPTS \
330+
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
331+
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
332+
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

0 commit comments

Comments
 (0)