You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by di...@apache.org on 2020/04/07 09:25:41 UTC
[syncope] branch SYNCOPE-163-1 updated: add WA check and remove
unused entitlement
This is an automated email from the ASF dual-hosted git repository.
dimaayash pushed a commit to branch SYNCOPE-163-1
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/SYNCOPE-163-1 by this push:
new 066a03c add WA check and remove unused entitlement
066a03c is described below
commit 066a03c681d5c505a6f9dac8ef1799dce3f6252f
Author: dima.ayash <di...@tirasa.net>
AuthorDate: Tue Apr 7 11:25:12 2020 +0200
add WA check and remove unused entitlement
---
.../syncope/common/lib/types/AMEntitlement.java | 8 ---
.../wa/starter/rest/SyncopeServiceRegistry.java | 77 ++++++++++++++--------
2 files changed, 51 insertions(+), 34 deletions(-)
diff --git a/common/am/lib/src/main/java/org/apache/syncope/common/lib/types/AMEntitlement.java b/common/am/lib/src/main/java/org/apache/syncope/common/lib/types/AMEntitlement.java
index cb661b3..5938dd9 100644
--- a/common/am/lib/src/main/java/org/apache/syncope/common/lib/types/AMEntitlement.java
+++ b/common/am/lib/src/main/java/org/apache/syncope/common/lib/types/AMEntitlement.java
@@ -56,14 +56,6 @@ public final class AMEntitlement {
private static final Set<String> VALUES;
- public static final String REGISTERED_CLIENT_APP_READ = "REGISTERED_CLIENT_APP_READ";
-
- public static final String REGISTERED_CLIENT_APP_LIST = "REGISTERED_CLIENT_APP_LIST";
-
- public static final String REGISTERED_CLIENT_APP_CREATE = "REGISTERED_CLIENT_APP_CREATE";
-
- public static final String REGISTERED_CLIENT_APP_DELETE = "REGISTERED_CLIENT_APP_DELETE";
-
static {
Set<String> values = new TreeSet<>();
for (Field field : AMEntitlement.class.getDeclaredFields()) {
diff --git a/wa/starter/src/main/java/org/apache/syncope/wa/starter/rest/SyncopeServiceRegistry.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/rest/SyncopeServiceRegistry.java
index 7622f70..b042262 100644
--- a/wa/starter/src/main/java/org/apache/syncope/wa/starter/rest/SyncopeServiceRegistry.java
+++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/rest/SyncopeServiceRegistry.java
@@ -54,19 +54,28 @@ public class SyncopeServiceRegistry extends AbstractServiceRegistry {
@Override
public RegisteredService save(final RegisteredService registeredService) {
- Response response =
- restClient.getSyncopeClient().getService(RegisteredClientAppService.class).create(mapper.
- fromRegisteredService(registeredService));
- if (response.getStatusInfo().getStatusCode() == Response.Status.CREATED.getStatusCode()) {
- return registeredService;
+ if (WARestClient.isReady()) {
+ LOG.info("Create application definitions");
+ Response response =
+ restClient.getSyncopeClient().getService(RegisteredClientAppService.class).create(mapper.
+ fromRegisteredService(registeredService));
+ if (response.getStatusInfo().getStatusCode() == Response.Status.CREATED.getStatusCode()) {
+ return registeredService;
+ }
}
+ LOG.debug("Syncope client is not yet ready to fetch application definitions");
return null;
}
@Override
public boolean delete(final RegisteredService registeredService) {
- return restClient.getSyncopeClient().getService(RegisteredClientAppService.class).
- delete(registeredService.getName());
+ if (WARestClient.isReady()) {
+ LOG.info("Delete application definitions");
+ return restClient.getSyncopeClient().getService(RegisteredClientAppService.class).
+ delete(registeredService.getName());
+ }
+ LOG.debug("Syncope client is not yet ready to fetch application definitions");
+ return false;
}
@Override
@@ -74,7 +83,7 @@ public class SyncopeServiceRegistry extends AbstractServiceRegistry {
if (WARestClient.isReady()) {
LOG.info("Loading application definitions");
return restClient.getSyncopeClient().getService(RegisteredClientAppService.class).list().stream().
- map(clientApp -> mapper.toRegisteredService(clientApp)).collect(Collectors.toList());
+ map(clientApp -> mapper.toRegisteredService(clientApp)).collect(Collectors.toList());
}
LOG.debug("Syncope client is not yet ready to fetch application definitions");
return List.of();
@@ -82,41 +91,57 @@ public class SyncopeServiceRegistry extends AbstractServiceRegistry {
@Override
public RegisteredService findServiceById(final long id) {
- LOG.info("Searching for application definition by id {}", id);
- return mapper.toRegisteredService(restClient.getSyncopeClient().
- getService(RegisteredClientAppService.class).read(id));
+ if (WARestClient.isReady()) {
+ LOG.info("Searching for application definition by id {}", id);
+ return mapper.toRegisteredService(restClient.getSyncopeClient().
+ getService(RegisteredClientAppService.class).read(id));
+ }
+ LOG.debug("Syncope client is not yet ready to fetch application definitions");
+ return null;
}
@Override
@SuppressWarnings("unchecked")
public <T extends RegisteredService> T findServiceByExactServiceName(final String name, final Class<T> clazz) {
- if (clazz.isInstance(OidcRegisteredService.class)) {
- return (T) mapper.toRegisteredService(restClient.getSyncopeClient().
- getService(RegisteredClientAppService.class).read(name, ClientAppType.OIDCRP));
- } else if (clazz.isInstance(SamlRegisteredService.class)) {
- return (T) mapper.toRegisteredService(restClient.getSyncopeClient().
- getService(RegisteredClientAppService.class).read(name, ClientAppType.SAML2SP));
+ if (WARestClient.isReady()) {
+ LOG.info("Searching for application definition by name {} and type {}", name, clazz);
+ if (clazz.isInstance(OidcRegisteredService.class)) {
+ return (T) mapper.toRegisteredService(restClient.getSyncopeClient().
+ getService(RegisteredClientAppService.class).read(name, ClientAppType.OIDCRP));
+ } else if (clazz.isInstance(SamlRegisteredService.class)) {
+ return (T) mapper.toRegisteredService(restClient.getSyncopeClient().
+ getService(RegisteredClientAppService.class).read(name, ClientAppType.SAML2SP));
+ }
}
+ LOG.debug("Syncope client is not yet ready to fetch application definitions");
return null;
}
@Override
public RegisteredService findServiceByExactServiceName(final String name) {
- LOG.info("Searching for application definition by name {}", name);
- return mapper.toRegisteredService(restClient.getSyncopeClient().
- getService(RegisteredClientAppService.class).read(name));
+ if (WARestClient.isReady()) {
+ LOG.info("Searching for application definition by name {}", name);
+ return mapper.toRegisteredService(restClient.getSyncopeClient().
+ getService(RegisteredClientAppService.class).read(name));
+ }
+ LOG.debug("Syncope client is not yet ready to fetch application definitions");
+ return null;
}
@Override
@SuppressWarnings("unchecked")
public <T extends RegisteredService> T findServiceById(final long id, final Class<T> clazz) {
- if (clazz.isInstance(OidcRegisteredService.class)) {
- return (T) mapper.toRegisteredService(restClient.getSyncopeClient().
- getService(RegisteredClientAppService.class).read(id, ClientAppType.OIDCRP));
- } else if (clazz.isInstance(SamlRegisteredService.class)) {
- return (T) mapper.toRegisteredService(restClient.getSyncopeClient().
- getService(RegisteredClientAppService.class).read(id, ClientAppType.SAML2SP));
+ if (WARestClient.isReady()) {
+ LOG.info("Searching for application definition by id {} and type {}", id, clazz);
+ if (clazz.isInstance(OidcRegisteredService.class)) {
+ return (T) mapper.toRegisteredService(restClient.getSyncopeClient().
+ getService(RegisteredClientAppService.class).read(id, ClientAppType.OIDCRP));
+ } else if (clazz.isInstance(SamlRegisteredService.class)) {
+ return (T) mapper.toRegisteredService(restClient.getSyncopeClient().
+ getService(RegisteredClientAppService.class).read(id, ClientAppType.SAML2SP));
+ }
}
+ LOG.debug("Syncope client is not yet ready to fetch application definitions");
return null;
}