Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
keycloak-scim
Manage
Activity
Members
Labels
Plan
Issues
13
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
libre.sh
scim
keycloak-scim
Commits
3ef6c81e
Commit
3ef6c81e
authored
1 year ago
by
Alex Morel
Browse files
Options
Downloads
Patches
Plain Diff
Wire local sonar and extract method for findById
parent
154bb349
No related branches found
No related tags found
1 merge request
!3
Sonar refactoring
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
build.gradle
+1
-0
1 addition, 0 deletions
build.gradle
src/main/java/sh/libre/scim/core/Adapter.java
+6
-0
6 additions, 0 deletions
src/main/java/sh/libre/scim/core/Adapter.java
src/main/java/sh/libre/scim/core/ScimClient.java
+8
-3
8 additions, 3 deletions
src/main/java/sh/libre/scim/core/ScimClient.java
with
15 additions
and
3 deletions
build.gradle
+
1
−
0
View file @
3ef6c81e
plugins
{
plugins
{
id
'java'
id
'java'
id
'com.github.johnrengelman.shadow'
version
'8.1.1'
id
'com.github.johnrengelman.shadow'
version
'8.1.1'
id
"org.sonarqube"
version
"5.0.0.4638"
}
}
group
=
'sh.libre.scim'
group
=
'sh.libre.scim'
...
...
This diff is collapsed.
Click to expand it.
src/main/java/sh/libre/scim/core/Adapter.java
+
6
−
0
View file @
3ef6c81e
...
@@ -13,6 +13,12 @@ import sh.libre.scim.jpa.ScimResource;
...
@@ -13,6 +13,12 @@ import sh.libre.scim.jpa.ScimResource;
import
java.util.stream.Stream
;
import
java.util.stream.Stream
;
/**
* Abstract class for converting a Keycloack {@link RoleMapperModel} into a SCIM {@link ResourceNode}.
*
* @param <M> The Keycloack {@link RoleMapperModel} (e.g. GroupModel, UserModel)
* @param <S> the SCIM {@link ResourceNode} (e.g. Group, User)
*/
public
abstract
class
Adapter
<
M
extends
RoleMapperModel
,
S
extends
ResourceNode
>
{
public
abstract
class
Adapter
<
M
extends
RoleMapperModel
,
S
extends
ResourceNode
>
{
protected
final
Logger
logger
;
protected
final
Logger
logger
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/sh/libre/scim/core/ScimClient.java
+
8
−
3
View file @
3ef6c81e
...
@@ -14,6 +14,7 @@ import io.github.resilience4j.retry.RetryConfig;
...
@@ -14,6 +14,7 @@ import io.github.resilience4j.retry.RetryConfig;
import
io.github.resilience4j.retry.RetryRegistry
;
import
io.github.resilience4j.retry.RetryRegistry
;
import
jakarta.persistence.EntityManager
;
import
jakarta.persistence.EntityManager
;
import
jakarta.persistence.NoResultException
;
import
jakarta.persistence.NoResultException
;
import
jakarta.persistence.TypedQuery
;
import
jakarta.ws.rs.ProcessingException
;
import
jakarta.ws.rs.ProcessingException
;
import
org.jboss.logging.Logger
;
import
org.jboss.logging.Logger
;
import
org.keycloak.component.ComponentModel
;
import
org.keycloak.component.ComponentModel
;
...
@@ -91,6 +92,10 @@ public class ScimClient implements AutoCloseable {
...
@@ -91,6 +92,10 @@ public class ScimClient implements AutoCloseable {
return
new
ScimClient
(
scimRequestBuilder
,
retryRegistry
,
session
,
model
);
return
new
ScimClient
(
scimRequestBuilder
,
retryRegistry
,
session
,
model
);
}
}
private
static
<
M
extends
RoleMapperModel
,
S
extends
ResourceNode
,
A
extends
Adapter
<
M
,
S
>>
TypedQuery
<
ScimResource
>
findById
(
A
adapter
)
{
return
adapter
.
query
(
"findById"
,
adapter
.
getId
());
}
protected
EntityManager
getEntityManager
()
{
protected
EntityManager
getEntityManager
()
{
return
session
.
getProvider
(
JpaConnectionProvider
.
class
).
getEntityManager
();
return
session
.
getProvider
(
JpaConnectionProvider
.
class
).
getEntityManager
();
}
}
...
@@ -116,7 +121,7 @@ public class ScimClient implements AutoCloseable {
...
@@ -116,7 +121,7 @@ public class ScimClient implements AutoCloseable {
if
(
adapter
.
skip
)
if
(
adapter
.
skip
)
return
;
return
;
// If mapping exist then it was created by import so skip.
// If mapping exist then it was created by import so skip.
if
(!
adapter
.
query
(
"
findById
"
,
adapter
.
getId
()
).
getResultList
().
isEmpty
())
{
if
(!
findById
(
adapter
).
getResultList
().
isEmpty
())
{
return
;
return
;
}
}
Retry
retry
=
registry
.
retry
(
"create-"
+
adapter
.
getId
());
Retry
retry
=
registry
.
retry
(
"create-"
+
adapter
.
getId
());
...
@@ -148,7 +153,7 @@ public class ScimClient implements AutoCloseable {
...
@@ -148,7 +153,7 @@ public class ScimClient implements AutoCloseable {
adapter
.
apply
(
kcModel
);
adapter
.
apply
(
kcModel
);
if
(
adapter
.
skip
)
if
(
adapter
.
skip
)
return
;
return
;
ScimResource
resource
=
adapter
.
query
(
"
findById
"
,
adapter
.
getId
()
).
getSingleResult
();
ScimResource
resource
=
findById
(
adapter
).
getSingleResult
();
adapter
.
apply
(
resource
);
adapter
.
apply
(
resource
);
Retry
retry
=
registry
.
retry
(
"replace-"
+
adapter
.
getId
());
Retry
retry
=
registry
.
retry
(
"replace-"
+
adapter
.
getId
());
ServerResponse
<
S
>
response
=
retry
.
executeSupplier
(()
->
{
ServerResponse
<
S
>
response
=
retry
.
executeSupplier
(()
->
{
...
@@ -178,7 +183,7 @@ public class ScimClient implements AutoCloseable {
...
@@ -178,7 +183,7 @@ public class ScimClient implements AutoCloseable {
adapter
.
setId
(
id
);
adapter
.
setId
(
id
);
try
{
try
{
ScimResource
resource
=
adapter
.
query
(
"
findById
"
,
adapter
.
getId
()
).
getSingleResult
();
ScimResource
resource
=
findById
(
adapter
).
getSingleResult
();
adapter
.
apply
(
resource
);
adapter
.
apply
(
resource
);
Retry
retry
=
registry
.
retry
(
"delete-"
+
id
);
Retry
retry
=
registry
.
retry
(
"delete-"
+
id
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment