Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
moqui
/
moqui-keycloak
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
37f2f2df
authored
2023-03-15 18:29:01 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Don't use a singleton instance of keycloak, but create one each time
getInstance() is called.
1 parent
89286c2a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
src/main/groovy/org/moqui/keycloak/KeycloakToolFactory.groovy
src/main/groovy/org/moqui/keycloak/KeycloakToolFactory.groovy
View file @
37f2f2d
...
...
@@ -32,7 +32,7 @@ class KeycloakToolFactory implements ToolFactory<Keycloak> {
protected
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
KeycloakToolFactory
.
class
)
final
static
String
TOOL_NAME
=
"Keycloak"
protected
Keycloak
keycloak
=
null
protected
Keycloak
Builder
keycloakBuilder
=
null
KeycloakToolFactory
()
{
}
...
...
@@ -44,34 +44,33 @@ class KeycloakToolFactory implements ToolFactory<Keycloak> {
@Override
void
init
(
ExecutionContextFactory
ecf
)
{
logger
.
info
(
"Starting Keycloak"
)
Keycloak
keycloak
=
getInstance
()
try
{
ServerInfoRepresentation
serverInfo
=
keycloak
.
serverInfo
().
getInfo
()
}
catch
(
Exception
e
)
{
logger
.
error
(
"Could not connect to keycloak server"
)
throw
e
}
finally
{
keycloak
.
close
()
}
}
@Override
void
preFacadeInit
(
ExecutionContextFactory
ecf
)
{
this
.
keycloak
=
KeycloakBuilder
.
builder
()
this
.
keycloak
Builder
=
KeycloakBuilder
.
builder
()
.
serverUrl
((
String
)
System
.
getProperty
(
"moqui_keycloak_server_url"
))
.
realm
((
String
)
System
.
getProperty
(
"moqui_keycloak_realm"
))
.
grantType
((
String
)
OAuth2Constants
.
CLIENT_CREDENTIALS
)
.
clientId
((
String
)
System
.
getProperty
(
"moqui_keycloak_client_id"
))
.
clientSecret
((
String
)
System
.
getProperty
(
"moqui_keycloak_client_secret"
))
.
build
()
}
@Override
Keycloak
getInstance
(
Object
...
parameters
)
{
return
keycloak
return
keycloak
Builder
.
build
()
}
@Override
void
destroy
()
{
if
(
keycloak
!=
null
)
{
keycloak
.
close
()
}
}
}
...
...
Please
register
or
sign in
to post a comment