You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by mm...@apache.org on 2020/02/27 08:17:29 UTC

[syncope] branch SYNCOPE-163-1 created (now cc18286)

This is an automated email from the ASF dual-hosted git repository.

mmoayyed pushed a change to branch SYNCOPE-163-1
in repository https://gitbox.apache.org/repos/asf/syncope.git.


      at cc18286  continue with refactoring

This branch includes the following new commits:

     new b64480a  Merge branch 'master' into SYNCOPE-163
     new 193fba5  Merge branch 'master' into SYNCOPE-163
     new 92d026f7 resume on auth modules; clean up to base essentials
     new 3a2bce2  resume on auth modules; clean up to base essentials
     new 812ee37  resume on auth modules; clean up to base essentials
     new 068d5a2  resume on auth modules; clean up to base essentials
     new 4349207  complete binders, rest client and DAOs for authn client apps
     new 4a503ce  complete binders, rest client and DAOs for authn client apps
     new 6824226  allow policies to reference modules in a chain
     new 0be4842  allow policies to reference modules in a chain
     new ec7c18d  clean up service impls & data binders
     new cc18286  continue with refactoring

The 12 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[syncope] 01/12: Merge branch 'master' into SYNCOPE-163

Posted by mm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mmoayyed pushed a commit to branch SYNCOPE-163-1
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit b64480a117c6b11953210b4b1bae5c0bb63a0249
Merge: 86b770a 8556c3e
Author: Misagh Moayyed <mm...@gmail.com>
AuthorDate: Thu Feb 20 15:46:08 2020 +0400

    Merge branch 'master' into SYNCOPE-163
    
    * master: (40 commits)
      Upgrading OpenJPA
      Bump upgrading DBMS stuff
      Cleanup Realm REST endpoints
      Correct formatting for external links
      Adding sample about how to generated SSHA256 admin password + related test
      Upgrading parent POM
      Adding more indexes to Task-related tables
      Various cleanings
      [SYNCOPE-1502] Bring back actual result sorting
      Fix build
      Fixing Travis CI
      Upgrading Groovy
      Error message improvements
      Upgrading maven-checkstyle-plugin
      [SYNCOPE-1535] Provision Sorter Implementation (#166)
      [SYNCOPE-1542] Always lookup groups from root realm
      [SYNCOPE-1542] Cleanup and refactoring
      [SYNCOPE-1476] keep code aligned between 'membership' and 'own' plain attributes
      Upgrading Tomcat
      Upgrading Elasticsearch and asciidoctorj-pdf
      ...

 .travis.yml                                        |  25 +--
 ...irectoryPanelAdditionalActionLinksProvider.java |  34 +++-
 .../client/console/commons/IdMConstants.java       |   4 +-
 .../commons/IdMImplementationInfoProvider.java     |   8 +-
 .../client/console/commons/IdMStatusProvider.java  |  10 +
 .../console/panels/LinkedAccountModalPanel.java    | 150 +++++++++-----
 .../panels/MergeLinkedAccountsResourcesPanel.java  | 181 +++++++++++++++++
 .../panels/MergeLinkedAccountsReviewPanel.java     | 178 +++++++++++++++++
 .../panels/MergeLinkedAccountsSearchPanel.java     | 112 +++++++++++
 .../client/console/rest/ResourceRestClient.java    |  15 ++
 .../console/status/LinkedAccountStatusPanel.java   |  66 +++++++
 .../client/console/status/ReconStatusUtils.java    |  14 ++
 .../client/console/status/ReconTaskPanel.java      |  33 +++-
 .../syncope/client/console/topology/Topology.java  |  16 +-
 .../wizards/any/LinkedAccountDetailsPanel.java     |   3 +-
 .../wizards/any/LinkedAccountWizardBuilder.java    |   1 -
 .../any/MergeLinkedAccountsWizardBuilder.java      | 187 ++++++++++++++++++
 .../any/MergeLinkedAccountsWizardModel.java        |  58 ++++++
 .../wizards/any/ProvisioningReportsPanel.java      |   3 +
 .../wizards/resources/ConnectorDetailsPanel.java   |  52 ++---
 .../wizards/resources/ResourceDetailsPanel.java    |  16 ++
 .../console/panels/LinkedAccountModalPanel.html    |   0
 .../panels/LinkedAccountModalPanel.properties      |   1 +
 .../LinkedAccountModalPanel_fr_CA.properties       |   5 +-
 .../panels/LinkedAccountModalPanel_it.properties   |   1 +
 .../panels/LinkedAccountModalPanel_ja.properties   |   1 +
 .../LinkedAccountModalPanel_pt_BR.properties       |   1 +
 .../panels/LinkedAccountModalPanel_ru.properties   |   1 +
 .../panels/MergeLinkedAccountsResourcesPanel.html} |  10 +-
 .../MergeLinkedAccountsResourcesPanel.properties}  |   6 +-
 ...eLinkedAccountsResourcesPanel_fr_CA.properties} |   6 +-
 ...ergeLinkedAccountsResourcesPanel_it.properties} |   6 +-
 ...ergeLinkedAccountsResourcesPanel_ja.properties} |   6 +-
 ...eLinkedAccountsResourcesPanel_pt_BR.properties} |   6 +-
 ...ergeLinkedAccountsResourcesPanel_ru.properties} |   6 +-
 .../panels/MergeLinkedAccountsReviewPanel.html}    |  10 +-
 .../MergeLinkedAccountsReviewPanel.properties}     |   7 +-
 ...ergeLinkedAccountsReviewPanel_fr_CA.properties} |   7 +-
 .../MergeLinkedAccountsReviewPanel_it.properties}  |   7 +-
 .../MergeLinkedAccountsReviewPanel_ja.properties}  |   7 +-
 ...ergeLinkedAccountsReviewPanel_pt_BR.properties} |   7 +-
 .../MergeLinkedAccountsReviewPanel_ru.properties}  |   7 +-
 .../panels/MergeLinkedAccountsSearchPanel.html}    |  20 +-
 .../MergeLinkedAccountsSearchPanel.properties}     |   2 +-
 ...ergeLinkedAccountsSearchPanel_fr_CA.properties} |   2 +-
 .../MergeLinkedAccountsSearchPanel_it.properties}  |   2 +-
 .../MergeLinkedAccountsSearchPanel_ja.properties}  |   2 +-
 ...ergeLinkedAccountsSearchPanel_pt_BR.properties} |   2 +-
 .../MergeLinkedAccountsSearchPanel_ru.properties}  |   2 +-
 .../wizards/resources/ResourceDetailsPanel.html    |   4 +
 .../resources/ResourceDetailsPanel.properties      |   1 +
 .../ResourceDetailsPanel_fr_CA.properties          |   9 +-
 .../resources/ResourceDetailsPanel_it.properties   |   1 +
 .../resources/ResourceDetailsPanel_ja.properties   |   1 +
 .../ResourceDetailsPanel_pt_BR.properties          |   1 +
 .../resources/ResourceDetailsPanel_ru.properties   |   1 +
 .../syncope/client/ui/commons/Constants.java       |   6 +
 .../commons/markup/html/form/AjaxPalettePanel.java |  28 +--
 .../ui/commons/markup/html/form/FieldPanel.java    |   2 +-
 .../client/ui/commons/wizards/AjaxWizard.java      |   9 +-
 .../resources/ui-commons/css/syncopeUI.scss        |  20 +-
 .../commons/markup/html/form/AjaxPalettePanel.html |   8 +-
 .../client/console/SyncopeConsoleSession.java      |   8 +-
 .../client/console/audit/AuditHistoryDetails.java  |  16 +-
 .../console/audit/AuditHistoryDirectoryPanel.java  |  35 ++--
 .../client/console/commons/AnyDataProvider.java    |   1 -
 ...irectoryPanelAdditionalActionLinksProvider.java |   6 +
 ...irectoryPanelAdditionalActionLinksProvider.java |   6 +
 .../console/commons/IdRepoStatusProvider.java      |   9 +
 .../client/console/commons/RealmsUtils.java        |  51 +++++
 .../client/console/commons/StatusProvider.java     |   5 +
 .../console/panels/AnyObjectDirectoryPanel.java    |   1 +
 .../syncope/client/console/panels/AnyPanel.java    |  24 +--
 .../client/console/panels/DirectoryPanel.java      |  22 +--
 .../client/console/panels/GroupDirectoryPanel.java |   1 +
 .../client/console/panels/ListViewPanel.java       |  29 ++-
 .../client/console/panels/RealmChoicePanel.java    | 165 ++++++++++------
 .../client/console/panels/SchemaTypePanel.java     |  12 +-
 .../client/console/panels/SchemasPanel.java        |  69 ++-----
 .../client/console/panels/UserDirectoryPanel.java  | 109 +++++-----
 .../console/panels/search/AbstractSearchPanel.java |  10 +-
 .../panels/search/AnyObjectSearchPanel.java        |  14 +-
 .../console/panels/search/GroupSearchPanel.java    |   7 +-
 .../console/panels/search/SearchClausePanel.java   | 195 +++++++-----------
 .../client/console/panels/search/SearchUtils.java  |  22 ++-
 .../console/policies/PolicyDirectoryPanel.java     |   3 +-
 .../console/rest/AuditHistoryRestClient.java       |  72 -------
 .../client/console/rest/LoggerRestClient.java      |  45 +++++
 .../client/console/rest/RealmRestClient.java       |   6 +
 .../console/tasks/SchedTaskWizardBuilder.java      |  68 ++++---
 .../repeater/data/table/AjaxFallbackDataTable.java |   2 +-
 .../markup/html/WebMarkupContainerNoVeil.java      |  32 +--
 .../wicket/markup/html/form/ActionLink.java        |   1 +
 .../markup/html/form/ActionLinksTogglePanel.java   |   8 +-
 .../markup/html/form/AjaxSearchFieldPanel.java     | 133 +++++++++++++
 .../syncope/client/console/widgets/JobWidget.java  |   2 -
 .../console/widgets/ReconciliationWidget.java      |   3 +-
 .../client/console/wizards/any/AbstractAttrs.java  |   6 +-
 .../client/console/wizards/any/Details.java        |  48 +++--
 .../syncope/client/console/wizards/any/Groups.java |   6 +-
 .../client/console/wizards/any/PlainAttrs.java     |  29 +--
 .../client/console/wizards/any/Relationships.java  |   8 +-
 .../syncope/client/console/wizards/any/Roles.java  |   7 +-
 .../implementations/MyProvisionSorter.groovy       |  38 ++--
 .../client/console/panels/AnyPanel.properties      |   2 +-
 .../console/panels/AnyPanel_fr_CA.properties       |   2 +-
 .../client/console/panels/AnyPanel_it.properties   |   2 +-
 .../client/console/panels/AnyPanel_ja.properties   |   2 +-
 .../console/panels/AnyPanel_pt_BR.properties       |   2 +-
 .../client/console/panels/AnyPanel_ru.properties   |   3 +-
 .../client/console/panels/ListViewPanel.html       |   2 +-
 .../client/console/panels/RealmChoicePanel.html    |  11 +-
 ...t_BR.properties => RealmChoicePanel.properties} |   2 +-
 ...roperties => RealmChoicePanel_fr_CA.properties} |   2 +-
 ...R.properties => RealmChoicePanel_it.properties} |   2 +-
 ...R.properties => RealmChoicePanel_ja.properties} |   2 +-
 ...roperties => RealmChoicePanel_pt_BR.properties} |   2 +-
 ...a.properties => RealmChoicePanel_ru.properties} |   2 +-
 .../client/console/panels/SchemasPanel.html        |  10 +-
 .../console/panels/UserDirectoryPanel.properties   |   1 +
 .../panels/UserDirectoryPanel_fr_CA.properties     |   7 +-
 .../panels/UserDirectoryPanel_it.properties        |   1 +
 .../panels/UserDirectoryPanel_ja.properties        |   1 +
 .../panels/UserDirectoryPanel_pt_BR.properties     |   1 +
 .../panels/UserDirectoryPanel_ru.properties        |   1 +
 .../markup/html/form/ActionsPanel.properties       |   4 +
 .../markup/html/form/AjaxCharacterFieldPanel.html  |   1 -
 ...erFieldPanel.html => AjaxSearchFieldPanel.html} |   1 -
 .../client/console/wizards/any/Details.html        |   8 +-
 .../client/enduser/wizards/any/AbstractAttrs.java  |   3 +-
 .../client/enduser/wizards/any/PlainAttrs.java     |  26 ++-
 .../apache/syncope/common/lib/to/ResourceTO.java   |  10 +
 .../common/lib/types/IdMImplementationType.java    |   5 +-
 .../common/rest/api/service/ResourceService.java   |  25 +++
 .../apache/syncope/common/lib/log/AuditEntry.java  | 158 +++++++++++++++
 .../apache/syncope/common/lib/to/AuditEntryTO.java | 141 -------------
 .../syncope/common/lib/to/LinkedAccountTO.java     |   1 +
 .../org/apache/syncope/common/lib/to/RealmTO.java  |   3 +-
 .../syncope/common/lib/types/CipherAlgorithm.java  |   4 +
 .../syncope/common/rest/api/RESTHeaders.java       |   2 +
 .../syncope/common/rest/api/beans/RealmQuery.java  |  18 ++
 .../common/rest/api/service/AuditService.java      |  54 -----
 .../common/rest/api/service/LoggerService.java     |  15 ++
 .../common/rest/api/service/RealmService.java      |  15 +-
 .../apache/syncope/core/logic/ResourceLogic.java   |  25 +++
 .../core/rest/cxf/service/ResourceServiceImpl.java |   6 +
 .../syncope/core/logic/AbstractAuditAppender.java  |  72 -------
 .../org/apache/syncope/core/logic/AuditLogic.java  |  73 -------
 .../org/apache/syncope/core/logic/LoggerLogic.java |  50 +++--
 .../org/apache/syncope/core/logic/RealmLogic.java  |  34 +++-
 .../syncope/core/logic/audit/AuditAppender.java    |  20 +-
 .../core/logic/audit/DefaultAuditAppender.java     |  31 ++-
 .../logic/audit/DefaultRewriteAuditAppender.java   |  38 ++--
 .../core/logic/audit/JdbcAuditAppender.java        | 102 ++++++++++
 .../logic/audit/PassThroughAuditRewritePolicy.java |   1 -
 .../init/ClassPathScanImplementationLookup.java    |  12 +-
 .../syncope/core/logic/init/LoggerLoader.java      | 131 ++++--------
 .../logic/src/main/resources/logic.properties      |   1 +
 .../core/rest/cxf/service/AuditServiceImpl.java    |  52 -----
 .../core/rest/cxf/service/LoggerServiceImpl.java   |  40 +++-
 .../core/rest/cxf/service/RealmServiceImpl.java    |   8 +-
 .../core/persistence/api/dao/LoggerDAO.java        |  20 ++
 .../api/entity/resource/ExternalResource.java      |   4 +
 ...AuditDAO.java => AbstractJPAJSONLoggerDAO.java} |   2 +-
 ...PAJSONAuditDAO.java => MyJPAJSONLoggerDAO.java} |  10 +-
 ...PAJSONAuditDAO.java => PGJPAJSONLoggerDAO.java} |  14 +-
 .../src/main/resources/myjson/indexes.xml          |   3 +
 .../main/resources/myjson/persistence.properties   |   2 +-
 .../src/main/resources/pgjsonb/indexes.xml         |   3 +
 .../main/resources/pgjsonb/persistence.properties  |   2 +-
 .../core/persistence/jpa/PersistenceContext.java   |   8 +-
 .../jpa/content/XMLContentExporter.java            | 174 ++++++++++++++--
 .../persistence/jpa/dao/AbstractAnySearchDAO.java  |   7 +-
 .../core/persistence/jpa/dao/JPAAnySearchDAO.java  |  74 ++++---
 .../core/persistence/jpa/dao/JPAAuditDAO.java      | 163 ---------------
 .../core/persistence/jpa/dao/JPALoggerDAO.java     | 141 ++++++++++++-
 .../core/persistence/jpa/dao/JPARealmDAO.java      |  10 +-
 .../persistence/jpa/entity/AbstractEntity.java     |   3 +
 .../persistence/jpa/entity/JPAConnInstance.java    |   1 -
 .../jpa/entity/resource/JPAExternalResource.java   |  15 ++
 .../persistence-jpa/src/main/resources/indexes.xml |   3 +
 .../src/main/resources/persistence.properties      |   2 +-
 .../jpa/outer/XMLContentExporterTest.java          |  10 +-
 .../core/provisioning/api/AuditEntryImpl.java      | 219 ---------------------
 .../AuditDataBinder.java => ProvisionSorter.java}  |   9 +-
 .../provisioning/api/data/LoggerDataBinder.java}   |  22 +--
 .../provisioning/api/serialization/POJOHelper.java |  12 --
 .../core/provisioning/api/AuditEntryImplTest.java  |  93 ---------
 .../api/PropagationByResourceTest.java             |  75 ++++---
 .../api/cache/VirAttrCacheValueTest.java           |   6 +-
 .../serialization/AttributeDeserializerTest.java   |  14 +-
 .../api/serialization/AttributeSerializerTest.java |  16 +-
 .../api/serialization/POJOHelperTest.java          |   7 -
 .../provisioning/java/DefaultAuditManager.java     |  85 +++++---
 .../provisioning/java/DefaultProvisionSorter.java  |  45 +++++
 .../java/data/AnyObjectDataBinderImpl.java         |  26 +--
 .../java/data/AuditDataBinderImpl.java             |  66 -------
 .../java/data/ImplementationDataBinderImpl.java    |   5 +
 .../java/data/LoggerDataBinderImpl.java}           |  43 ++--
 .../java/data/ResourceDataBinderImpl.java          |  15 ++
 .../provisioning/java/data/UserDataBinderImpl.java |  26 +--
 .../java/job/report/AuditReportlet.java            |  18 +-
 .../java/pushpull/AbstractPullResultHandler.java   |   1 +
 .../pushpull/DefaultUserPullResultHandler.java     |   3 +-
 .../java/pushpull/PullJobDelegate.java             | 155 ++++++++-------
 core/spring/pom.xml                                |   1 -
 .../syncope/core/spring/security/Encryptor.java    |  40 ++--
 .../core/spring/security/EncryptorTest.java        |  51 ++---
 .../src/main/resources/persistence.properties.all  |   2 +-
 .../main/resources/persistence.properties.myjson   |   2 +-
 .../main/resources/persistence.properties.pgjsonb  |   2 +-
 .../src/main/resources/persistence.properties      |   2 +-
 .../panels/OIDCProvidersDirectoryPanel.java        |  46 +++--
 .../console/panels/SAML2IdPsDirectoryPanel.java    |  37 ++--
 .../fit/core/reference/ITImplementationLookup.java |   8 +
 .../core/reference/SyslogRewriteAuditAppender.java |  47 ++---
 .../fit/core/reference/TestFileAuditAppender.java  |  30 ++-
 .../reference/TestFileRewriteAuditAppender.java    |  23 +--
 .../fit/core/reference/TestRewritePolicy.java      |   7 +-
 .../resources/elasticsearch/persistence.properties |   2 +-
 .../src/main/resources/logic.properties            |   1 +
 .../org/apache/syncope/fit/AbstractITCase.java     |   4 -
 .../syncope/fit/console/LinkedAccountsITCase.java  | 201 +++++++++++++++++++
 .../apache/syncope/fit/console/PoliciesITCase.java |   7 +-
 .../apache/syncope/fit/console/UsersITCase.java    |  11 +-
 .../org/apache/syncope/fit/core/AuditITCase.java   |  36 ++--
 .../org/apache/syncope/fit/core/LoggerITCase.java  |   1 -
 .../syncope/fit/core/MultitenancyITCase.java       |  10 +-
 .../org/apache/syncope/fit/core/RealmITCase.java   |   5 +-
 .../org/apache/syncope/fit/core/UserITCase.java    |   2 +-
 .../apache/syncope/fit/core/UserIssuesITCase.java  |   4 +-
 .../view/ResourceExplorerTopComponent.java         |  10 +-
 pom.xml                                            |  38 ++--
 .../systemadministration/dbms.adoc                 |   4 +-
 .../systemadministration/setadmincredentials.adoc  |  25 +++
 235 files changed, 3753 insertions(+), 2519 deletions(-)



[syncope] 08/12: complete binders, rest client and DAOs for authn client apps

Posted by mm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mmoayyed pushed a commit to branch SYNCOPE-163-1
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 4a503ce0e1d5efe2595e3899a0f9f5669375fbf4
Author: Misagh Moayyed <mm...@gmail.com>
AuthorDate: Tue Feb 25 16:53:02 2020 +0330

    complete binders, rest client and DAOs for authn client apps
---
 .../common/lib/authentication/AuthenticationModuleConf.java        | 7 +++++--
 .../common/lib/authentication/JaasAuthenticationModuleConf.java    | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AuthenticationModuleConf.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AuthenticationModuleConf.java
index 69afddc..6211915 100644
--- a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AuthenticationModuleConf.java
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AuthenticationModuleConf.java
@@ -32,7 +32,10 @@ public interface AuthenticationModuleConf extends Serializable {
      */
     String getName();
 
+    /**
+     * Execution order of this authentication module in the policy chain.
+     *
+     * @return numeric order
+     */
     int getOrder();
-
-    
 }
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/JaasAuthenticationModuleConf.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/JaasAuthenticationModuleConf.java
index 24b785e..6ccafd4 100644
--- a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/JaasAuthenticationModuleConf.java
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/JaasAuthenticationModuleConf.java
@@ -22,7 +22,7 @@ package org.apache.syncope.common.lib.authentication;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
-@XmlRootElement(name = "predefinedAuthenticationModuleConf")
+@XmlRootElement(name = "jaasAuthenticationModuleConf")
 @XmlType
 public class JaasAuthenticationModuleConf extends AbstractAuthenticationModuleConf {
     private static final long serialVersionUID = -7775771400318503131L;


[syncope] 09/12: allow policies to reference modules in a chain

Posted by mm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mmoayyed pushed a commit to branch SYNCOPE-163-1
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 682422642418a2cd03d0209e7131e138b8a50f0a
Author: Misagh Moayyed <mm...@gmail.com>
AuthorDate: Tue Feb 25 19:01:42 2020 +0330

    allow policies to reference modules in a chain
---
 .../AbstractAuthenticationPolicyConf.java          | 36 ++++++++++---------
 .../authentication/AuthenticationPolicyConf.java   | 20 +++++++----
 .../DefaultAuthenticationPolicyConf.java           | 42 ++++++++++++++++++++++
 .../api/entity/policy/AuthenticationPolicy.java    |  9 +++++
 .../jpa/entity/policy/JPAAuthenticationPolicy.java | 34 ++++++++++++++++++
 .../jpa/inner/AuthenticationPolicyTest.java        | 22 +++++++++++-
 6 files changed, 140 insertions(+), 23 deletions(-)

diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAuthenticationPolicy.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AbstractAuthenticationPolicyConf.java
similarity index 54%
copy from core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAuthenticationPolicy.java
copy to common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AbstractAuthenticationPolicyConf.java
index f43fd7d..fc9352b 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAuthenticationPolicy.java
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AbstractAuthenticationPolicyConf.java
@@ -6,8 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -15,33 +14,38 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.syncope.core.persistence.jpa.entity.policy;
 
-import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
+package org.apache.syncope.common.lib.authentication;
 
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.annotation.XmlType;
 
-@Entity
-@Table(name = JPAAuthenticationPolicy.TABLE)
-public class JPAAuthenticationPolicy extends AbstractPolicy implements AuthenticationPolicy {
+import java.io.Serializable;
 
-    public static final String TABLE = "AuthenticationPolicy";
+@XmlType
+@XmlSeeAlso({DefaultAuthenticationPolicyConf.class})
+public abstract class AbstractAuthenticationPolicyConf implements Serializable, AuthenticationPolicyConf {
 
-    private static final long serialVersionUID = -4190607009908888884L;
+    private static final long serialVersionUID = 9185127128182430142L;
 
-    @Column(unique = true, nullable = false)
     private String name;
 
+    public AbstractAuthenticationPolicyConf() {
+        setName(getClass().getName());
+    }
+
+    public AbstractAuthenticationPolicyConf(final String name) {
+        setName(name);
+    }
+
     @Override
-    public String getName() {
+    public final String getName() {
         return name;
     }
 
-    @Override
-    public void setName(final String name) {
+    public final void setName(final String name) {
         this.name = name;
     }
 }
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AuthenticationPolicy.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AuthenticationPolicyConf.java
similarity index 61%
copy from core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AuthenticationPolicy.java
copy to common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AuthenticationPolicyConf.java
index 774e83c..c8e0557 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AuthenticationPolicy.java
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AuthenticationPolicyConf.java
@@ -6,8 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -15,12 +14,21 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.syncope.core.persistence.api.entity.policy;
+package org.apache.syncope.common.lib.authentication;
 
-public interface AuthenticationPolicy extends Policy {
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
 
-    String getName();
+import java.io.Serializable;
 
-    void setName(String name);
+@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
+public interface AuthenticationPolicyConf extends Serializable {
+
+    /**
+     * Give name of related authentication module instance.
+     *
+     * @return name of this authentication policy instance
+     */
+    String getName();
 }
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/DefaultAuthenticationPolicyConf.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/DefaultAuthenticationPolicyConf.java
new file mode 100644
index 0000000..467ecfb
--- /dev/null
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/DefaultAuthenticationPolicyConf.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.common.lib.authentication;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@XmlRootElement(name = "defaultAuthenticationModuleConf")
+@XmlType
+public class DefaultAuthenticationPolicyConf extends AbstractAuthenticationModuleConf {
+    private static final long serialVersionUID = -2969836600059025380L;
+
+    private List<String> authenticationModules = new ArrayList<>();
+
+    public List<String> getAuthenticationModules() {
+        return authenticationModules;
+    }
+
+    public void setAuthenticationModules(final List<String> authenticationModules) {
+        this.authenticationModules = authenticationModules;
+    }
+}
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AuthenticationPolicy.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AuthenticationPolicy.java
index 774e83c..d3e8399 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AuthenticationPolicy.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AuthenticationPolicy.java
@@ -18,9 +18,18 @@
  */
 package org.apache.syncope.core.persistence.api.entity.policy;
 
+import org.apache.syncope.core.persistence.api.entity.Implementation;
+
+import java.util.List;
+
 public interface AuthenticationPolicy extends Policy {
 
     String getName();
 
     void setName(String name);
+
+    List<? extends Implementation> getConfigurations();
+
+    boolean addConfiguration(Implementation configuration);
+
 }
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAuthenticationPolicy.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAuthenticationPolicy.java
index f43fd7d..f015063 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAuthenticationPolicy.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAuthenticationPolicy.java
@@ -18,11 +18,22 @@
  */
 package org.apache.syncope.core.persistence.jpa.entity.policy;
 
+import org.apache.syncope.common.lib.types.AMImplementationType;
+import org.apache.syncope.core.persistence.api.entity.Implementation;
 import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
+import org.apache.syncope.core.persistence.jpa.entity.JPAImplementation;
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
 import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+
+import java.util.ArrayList;
+import java.util.List;
 
 @Entity
 @Table(name = JPAAuthenticationPolicy.TABLE)
@@ -35,6 +46,16 @@ public class JPAAuthenticationPolicy extends AbstractPolicy implements Authentic
     @Column(unique = true, nullable = false)
     private String name;
 
+    @ManyToMany(fetch = FetchType.EAGER)
+    @JoinTable(name = TABLE + "Conf",
+        joinColumns =
+        @JoinColumn(name = "authentication_policy_id"),
+        inverseJoinColumns =
+        @JoinColumn(name = "implementation_id"),
+        uniqueConstraints =
+        @UniqueConstraint(columnNames = {"authentication_policy_id", "implementation_id"}))
+    private List<JPAImplementation> configurations = new ArrayList<>();
+
     @Override
     public String getName() {
         return name;
@@ -44,4 +65,17 @@ public class JPAAuthenticationPolicy extends AbstractPolicy implements Authentic
     public void setName(final String name) {
         this.name = name;
     }
+
+    @Override
+    public List<? extends Implementation> getConfigurations() {
+        return configurations;
+    }
+
+    @Override
+    public boolean addConfiguration(final Implementation configuration) {
+        checkType(configuration, JPAImplementation.class);
+        checkImplementationType(configuration, AMImplementationType.AUTH_POLICY_CONFIGURATIONS);
+        return configurations.contains((JPAImplementation) configuration)
+            || configurations.add((JPAImplementation) configuration);
+    }
 }
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationPolicyTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationPolicyTest.java
index be9e0de..af31ce9 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationPolicyTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationPolicyTest.java
@@ -18,9 +18,15 @@
  */
 package org.apache.syncope.core.persistence.jpa.inner;
 
+import org.apache.syncope.common.lib.authentication.DefaultAuthenticationPolicyConf;
+import org.apache.syncope.common.lib.types.AMImplementationType;
+import org.apache.syncope.common.lib.types.ImplementationEngine;
+import org.apache.syncope.core.persistence.api.dao.ImplementationDAO;
 import org.apache.syncope.core.persistence.api.dao.authentication.AuthenticationPolicyDAO;
+import org.apache.syncope.core.persistence.api.entity.Implementation;
 import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
 import org.apache.syncope.core.persistence.jpa.AbstractTest;
+import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -36,6 +42,9 @@ public class AuthenticationPolicyTest extends AbstractTest {
     @Autowired
     private AuthenticationPolicyDAO authenticationPolicyDAO;
 
+    @Autowired
+    private ImplementationDAO implementationDAO;
+
     @Test
     public void find() {
         AuthenticationPolicy authenticationPolicy = authenticationPolicyDAO.find("b912a0d4-a890-416f-9ab8-84ab077eb028");
@@ -53,11 +62,22 @@ public class AuthenticationPolicyTest extends AbstractTest {
 
     @Test
     public void save() {
-
         int beforeCount = authenticationPolicyDAO.findAll().size();
         AuthenticationPolicy authenticationPolicy = entityFactory.newEntity(AuthenticationPolicy.class);
         authenticationPolicy.setName("AuthenticationPolicyTest");
         authenticationPolicy.setDescription("This is a sample authentication policy");
+
+        DefaultAuthenticationPolicyConf conf = new DefaultAuthenticationPolicyConf();
+        conf.setAuthenticationModules(List.of("LdapAuthentication1", "DatabaseAuthentication2"));
+        
+        Implementation type = entityFactory.newEntity(Implementation.class);
+        type.setKey("AuthPolicyConfKey");
+        type.setEngine(ImplementationEngine.JAVA);
+        type.setType(AMImplementationType.AUTH_POLICY_CONFIGURATIONS);
+        type.setBody(POJOHelper.serialize(conf));
+        type = implementationDAO.save(type);
+
+        authenticationPolicy.addConfiguration(type);
         authenticationPolicyDAO.save(authenticationPolicy);
 
         assertNotNull(authenticationPolicy);


[syncope] 04/12: resume on auth modules; clean up to base essentials

Posted by mm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mmoayyed pushed a commit to branch SYNCOPE-163-1
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 3a2bce298cc52099d91145f1d86e1eaa1bba9016
Author: Misagh Moayyed <mm...@gmail.com>
AuthorDate: Mon Feb 24 13:42:09 2020 +0330

    resume on auth modules; clean up to base essentials
---
 .../authentication/JPAClientApplicationDAO.java    | 69 ----------------------
 .../JPAOpenIdConnectRelyingPartyDAO.java           | 11 ++--
 .../jpa/inner/OpenIdConnectRelyingPartyTest.java   | 63 ++++++++++++++++++++
 .../jpa/inner/SAML2ServiceProviderTest.java        | 64 ++++++++++++++++++++
 4 files changed, 134 insertions(+), 73 deletions(-)

diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAClientApplicationDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAClientApplicationDAO.java
deleted file mode 100644
index 7e8d1ce..0000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAClientApplicationDAO.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.syncope.core.persistence.jpa.dao.authentication;
-
-import org.apache.syncope.core.persistence.api.dao.authentication.AuthenticationPolicyDAO;
-import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
-import org.apache.syncope.core.persistence.jpa.dao.AbstractDAO;
-import org.apache.syncope.core.persistence.jpa.entity.policy.JPAAuthenticationPolicy;
-import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.persistence.TypedQuery;
-
-import java.util.List;
-
-@Repository
-public class JPAClientApplicationDAO extends AbstractDAO<AuthenticationPolicy> implements AuthenticationPolicyDAO {
-
-    @Override
-    public AuthenticationPolicy find(final String key) {
-        return entityManager().find(JPAAuthenticationPolicy.class, key);
-    }
-
-    @Transactional(readOnly = true)
-    @Override
-    public List<AuthenticationPolicy> findAll() {
-        TypedQuery<AuthenticationPolicy> query = entityManager().createQuery(
-            "SELECT e FROM " + JPAAuthenticationPolicy.class.getSimpleName() + " e", AuthenticationPolicy.class);
-
-        return query.getResultList();
-    }
-
-    @Override
-    public AuthenticationPolicy save(final AuthenticationPolicy policy) {
-        return entityManager().merge(policy);
-    }
-
-    @Override
-    public void delete(final String key) {
-        AuthenticationPolicy policy = find(key);
-        if (policy == null) {
-            return;
-        }
-
-        delete(policy);
-    }
-
-    @Override
-    public void delete(final AuthenticationPolicy policy) {
-        entityManager().remove(policy);
-    }
-
-}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAOpenIdConnectRelyingPartyDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAOpenIdConnectRelyingPartyDAO.java
index b6b3355..17a9ad7 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAOpenIdConnectRelyingPartyDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAOpenIdConnectRelyingPartyDAO.java
@@ -43,7 +43,8 @@ public class JPAOpenIdConnectRelyingPartyDAO extends AbstractDAO<OpenIdConnectRe
     @Override
     public OpenIdConnectRelyingParty findByName(final String name) {
         TypedQuery<OpenIdConnectRelyingParty> query = entityManager().createQuery(
-            "SELECT e FROM " + JPAOpenIdConnectRelyingParty.class.getSimpleName() + " e WHERE e.name=:name", OpenIdConnectRelyingParty.class);
+            "SELECT e FROM " + JPAOpenIdConnectRelyingParty.class.getSimpleName()
+                + " e WHERE e.name=:name", OpenIdConnectRelyingParty.class);
         query.setParameter("name", name);
 
         OpenIdConnectRelyingParty result = null;
@@ -59,8 +60,9 @@ public class JPAOpenIdConnectRelyingPartyDAO extends AbstractDAO<OpenIdConnectRe
     @Override
     public OpenIdConnectRelyingParty findByClientId(final String clientId) {
         TypedQuery<OpenIdConnectRelyingParty> query = entityManager().createQuery(
-            "SELECT e FROM " + JPAOpenIdConnectRelyingParty.class.getSimpleName() + " e WHERE e.clientId=:clientId", OpenIdConnectRelyingParty.class);
-        query.setParameter(clientId, clientId);
+            "SELECT e FROM " + JPAOpenIdConnectRelyingParty.class.getSimpleName()
+                + " e WHERE e.clientId=:clientId", OpenIdConnectRelyingParty.class);
+        query.setParameter("clientId", clientId);
 
         OpenIdConnectRelyingParty result = null;
         try {
@@ -76,7 +78,8 @@ public class JPAOpenIdConnectRelyingPartyDAO extends AbstractDAO<OpenIdConnectRe
     @Override
     public List<OpenIdConnectRelyingParty> findAll() {
         TypedQuery<OpenIdConnectRelyingParty> query = entityManager().createQuery(
-            "SELECT e FROM " + JPAOpenIdConnectRelyingParty.class.getSimpleName() + " e", OpenIdConnectRelyingParty.class);
+            "SELECT e FROM " + JPAOpenIdConnectRelyingParty.class.getSimpleName()
+                + " e", OpenIdConnectRelyingParty.class);
 
         return query.getResultList();
     }
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/OpenIdConnectRelyingPartyTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/OpenIdConnectRelyingPartyTest.java
new file mode 100644
index 0000000..d671e0b
--- /dev/null
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/OpenIdConnectRelyingPartyTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.core.persistence.jpa.inner;
+
+import org.apache.syncope.core.persistence.api.dao.authentication.OpenIdConnectRelyingPartyDAO;
+import org.apache.syncope.core.persistence.api.entity.authentication.OpenIdConnectRelyingParty;
+import org.apache.syncope.core.persistence.jpa.AbstractTest;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+@Transactional("Master")
+public class OpenIdConnectRelyingPartyTest extends AbstractTest {
+
+    @Autowired
+    private OpenIdConnectRelyingPartyDAO openIdConnectRelyingPartyDAO;
+
+    @Test
+    public void find() {
+        int beforeCount = openIdConnectRelyingPartyDAO.findAll().size();
+        OpenIdConnectRelyingParty rp = entityFactory.newEntity(OpenIdConnectRelyingParty.class);
+        rp.setName("OIDC");
+        rp.setDescription("This is a sample OIDC RP");
+        rp.setClientId("clientid");
+        rp.setClientSecret("secret");
+        openIdConnectRelyingPartyDAO.save(rp);
+
+        assertNotNull(rp);
+        assertNotNull(rp.getKey());
+
+        int afterCount = openIdConnectRelyingPartyDAO.findAll().size();
+        assertEquals(afterCount, beforeCount + 1);
+
+        rp = openIdConnectRelyingPartyDAO.findByClientId("clientid");
+        assertNotNull(rp);
+
+        rp = openIdConnectRelyingPartyDAO.findByName("OIDC");
+        assertNotNull(rp);
+
+        openIdConnectRelyingPartyDAO.deleteByClientId("clientid");
+        assertNull(openIdConnectRelyingPartyDAO.findByName("OIDC"));
+    }
+
+}
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/SAML2ServiceProviderTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/SAML2ServiceProviderTest.java
new file mode 100644
index 0000000..4eb988e
--- /dev/null
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/SAML2ServiceProviderTest.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.core.persistence.jpa.inner;
+
+import org.apache.syncope.core.persistence.api.dao.authentication.SAML2ServiceProviderDAO;
+import org.apache.syncope.core.persistence.api.entity.authentication.OpenIdConnectRelyingParty;
+import org.apache.syncope.core.persistence.api.entity.authentication.SAML2ServiceProvider;
+import org.apache.syncope.core.persistence.jpa.AbstractTest;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+@Transactional("Master")
+public class SAML2ServiceProviderTest extends AbstractTest {
+
+    @Autowired
+    private SAML2ServiceProviderDAO saml2ServiceProviderDAO;
+
+    @Test
+    public void find() {
+        int beforeCount = saml2ServiceProviderDAO.findAll().size();
+        SAML2ServiceProvider rp = entityFactory.newEntity(SAML2ServiceProvider.class);
+        rp.setName("OIDC");
+        rp.setDescription("This is a sample OIDC RP");
+        rp.setEntityId("urn:example:saml2:sp");
+        rp.setMetadataLocation("https://example.org/metadata.xml");
+        saml2ServiceProviderDAO.save(rp);
+
+        assertNotNull(rp);
+        assertNotNull(rp.getKey());
+
+        int afterCount = saml2ServiceProviderDAO.findAll().size();
+        assertEquals(afterCount, beforeCount + 1);
+
+        rp = saml2ServiceProviderDAO.findByEntityId(rp.getEntityId());
+        assertNotNull(rp);
+
+        rp = saml2ServiceProviderDAO.findByName("OIDC");
+        assertNotNull(rp);
+
+        saml2ServiceProviderDAO.deleteByEntityId(rp.getEntityId());
+        assertNull(saml2ServiceProviderDAO.findByName("OIDC"));
+    }
+
+}


[syncope] 10/12: allow policies to reference modules in a chain

Posted by mm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mmoayyed pushed a commit to branch SYNCOPE-163-1
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 0be484280ad9e70a5068e718c500417eb1573d22
Author: Misagh Moayyed <mm...@gmail.com>
AuthorDate: Tue Feb 25 19:14:10 2020 +0330

    allow policies to reference modules in a chain
---
 .../entity/authentication/ClientApplication.java   |  5 +++
 .../JPAOpenIdConnectRelyingParty.java              | 31 ++++++++++++----
 .../authentication/JPASAML2ServiceProvider.java    | 18 ++++++++++
 .../jpa/inner/OpenIdConnectRelyingPartyTest.java   | 42 +++++++++++++++++++++-
 4 files changed, 89 insertions(+), 7 deletions(-)

diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/ClientApplication.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/ClientApplication.java
index def140c..9f972b6 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/ClientApplication.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/ClientApplication.java
@@ -19,6 +19,7 @@
 package org.apache.syncope.core.persistence.api.entity.authentication;
 
 import org.apache.syncope.core.persistence.api.entity.Entity;
+import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
 
 public interface ClientApplication extends Entity {
 
@@ -29,4 +30,8 @@ public interface ClientApplication extends Entity {
     String getDescription();
 
     void setDescription(String description);
+
+    AuthenticationPolicy getAuthenticationPolicy();
+
+    void setAuthenticationPolicy(AuthenticationPolicy policy);
 }
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAOpenIdConnectRelyingParty.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAOpenIdConnectRelyingParty.java
index f07984d..39094ae 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAOpenIdConnectRelyingParty.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAOpenIdConnectRelyingParty.java
@@ -20,7 +20,9 @@
 package org.apache.syncope.core.persistence.jpa.entity.authentication;
 
 import org.apache.syncope.core.persistence.api.entity.authentication.OpenIdConnectRelyingParty;
+import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
 import org.apache.syncope.core.persistence.jpa.entity.AbstractGeneratedKeyEntity;
+import org.apache.syncope.core.persistence.jpa.entity.policy.JPAAuthenticationPolicy;
 
 import javax.persistence.CollectionTable;
 import javax.persistence.Column;
@@ -28,6 +30,7 @@ import javax.persistence.ElementCollection;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
 import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
 import javax.persistence.Table;
 
 import java.util.ArrayList;
@@ -53,6 +56,10 @@ public class JPAOpenIdConnectRelyingParty extends AbstractGeneratedKeyEntity imp
     @Column
     private String clientSecret;
 
+    @Column(nullable = false)
+    @OneToOne(fetch = FetchType.EAGER)
+    private JPAAuthenticationPolicy authenticationPolicy;
+
     @ElementCollection(fetch = FetchType.EAGER)
     @Column(name = "redirectUris")
     @CollectionTable(name = "OpenIdConnectRelyingParty_RedirectUris", joinColumns = @JoinColumn(name = "clientId"))
@@ -66,9 +73,6 @@ public class JPAOpenIdConnectRelyingParty extends AbstractGeneratedKeyEntity imp
     @Override
     public void setName(final String name) {
         this.name = name;
-    }    @Override
-    public List<String> getRedirectUris() {
-        return redirectUris;
     }
 
     @Override
@@ -79,20 +83,35 @@ public class JPAOpenIdConnectRelyingParty extends AbstractGeneratedKeyEntity imp
     @Override
     public void setDescription(final String description) {
         this.description = description;
-    }    @Override
+    }
+
+    @Override
+    public JPAAuthenticationPolicy getAuthenticationPolicy() {
+        return authenticationPolicy;
+    }
+
+    @Override
+    public void setAuthenticationPolicy(final AuthenticationPolicy authenticationPolicy) {
+        this.authenticationPolicy = (JPAAuthenticationPolicy) authenticationPolicy;
+    }
+
+    @Override
+    public List<String> getRedirectUris() {
+        return redirectUris;
+    }
+    
+    @Override
     public void setRedirectUris(final List<String> redirectUris) {
         this.redirectUris = redirectUris;
     }
 
 
-
     @Override
     public String getClientId() {
         return clientId;
     }
 
 
-
     @Override
     public void setClientId(final String clientId) {
         this.clientId = clientId;
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPASAML2ServiceProvider.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPASAML2ServiceProvider.java
index 79de4a2..fd167d4 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPASAML2ServiceProvider.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPASAML2ServiceProvider.java
@@ -20,10 +20,14 @@
 package org.apache.syncope.core.persistence.jpa.entity.authentication;
 
 import org.apache.syncope.core.persistence.api.entity.authentication.SAML2ServiceProvider;
+import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
 import org.apache.syncope.core.persistence.jpa.entity.AbstractGeneratedKeyEntity;
+import org.apache.syncope.core.persistence.jpa.entity.policy.JPAAuthenticationPolicy;
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.OneToOne;
 import javax.persistence.Table;
 
 @Entity
@@ -45,6 +49,20 @@ public class JPASAML2ServiceProvider extends AbstractGeneratedKeyEntity implemen
     @Column(nullable = false)
     private String metadataLocation;
 
+    @Column(nullable = false)
+    @OneToOne(fetch = FetchType.EAGER)
+    private JPAAuthenticationPolicy authenticationPolicy;
+
+    @Override
+    public JPAAuthenticationPolicy getAuthenticationPolicy() {
+        return authenticationPolicy;
+    }
+
+    @Override
+    public void setAuthenticationPolicy(final AuthenticationPolicy authenticationPolicy) {
+        this.authenticationPolicy = (JPAAuthenticationPolicy) authenticationPolicy;
+    }
+
     @Override
     public String getEntityId() {
         return entityId;
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/OpenIdConnectRelyingPartyTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/OpenIdConnectRelyingPartyTest.java
index d671e0b..cee841f 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/OpenIdConnectRelyingPartyTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/OpenIdConnectRelyingPartyTest.java
@@ -19,29 +19,50 @@
 
 package org.apache.syncope.core.persistence.jpa.inner;
 
+import org.apache.syncope.common.lib.authentication.DefaultAuthenticationPolicyConf;
+import org.apache.syncope.common.lib.types.AMImplementationType;
+import org.apache.syncope.common.lib.types.ImplementationEngine;
+import org.apache.syncope.core.persistence.api.dao.ImplementationDAO;
+import org.apache.syncope.core.persistence.api.dao.authentication.AuthenticationPolicyDAO;
 import org.apache.syncope.core.persistence.api.dao.authentication.OpenIdConnectRelyingPartyDAO;
+import org.apache.syncope.core.persistence.api.entity.Implementation;
 import org.apache.syncope.core.persistence.api.entity.authentication.OpenIdConnectRelyingParty;
+import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
 import org.apache.syncope.core.persistence.jpa.AbstractTest;
+import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.List;
+
 import static org.junit.jupiter.api.Assertions.*;
 
 @Transactional("Master")
 public class OpenIdConnectRelyingPartyTest extends AbstractTest {
 
     @Autowired
+    private AuthenticationPolicyDAO authenticationPolicyDAO;
+
+    @Autowired
+    private ImplementationDAO implementationDAO;
+
+    @Autowired
     private OpenIdConnectRelyingPartyDAO openIdConnectRelyingPartyDAO;
 
     @Test
     public void find() {
         int beforeCount = openIdConnectRelyingPartyDAO.findAll().size();
+        
         OpenIdConnectRelyingParty rp = entityFactory.newEntity(OpenIdConnectRelyingParty.class);
         rp.setName("OIDC");
         rp.setDescription("This is a sample OIDC RP");
         rp.setClientId("clientid");
         rp.setClientSecret("secret");
+
+        AuthenticationPolicy policy = buildAndSaveAuthenticationPolicy();
+        rp.setAuthenticationPolicy(policy);
+
         openIdConnectRelyingPartyDAO.save(rp);
 
         assertNotNull(rp);
@@ -52,7 +73,8 @@ public class OpenIdConnectRelyingPartyTest extends AbstractTest {
 
         rp = openIdConnectRelyingPartyDAO.findByClientId("clientid");
         assertNotNull(rp);
-
+        assertNotNull(rp.getAuthenticationPolicy());
+        
         rp = openIdConnectRelyingPartyDAO.findByName("OIDC");
         assertNotNull(rp);
 
@@ -60,4 +82,22 @@ public class OpenIdConnectRelyingPartyTest extends AbstractTest {
         assertNull(openIdConnectRelyingPartyDAO.findByName("OIDC"));
     }
 
+    private AuthenticationPolicy buildAndSaveAuthenticationPolicy() {
+        AuthenticationPolicy authenticationPolicy = entityFactory.newEntity(AuthenticationPolicy.class);
+        authenticationPolicy.setName("AuthenticationPolicyTest");
+        authenticationPolicy.setDescription("This is a sample authentication policy");
+
+        DefaultAuthenticationPolicyConf conf = new DefaultAuthenticationPolicyConf();
+        conf.setAuthenticationModules(List.of("LdapAuthentication1", "DatabaseAuthentication2"));
+
+        Implementation type = entityFactory.newEntity(Implementation.class);
+        type.setKey("AuthPolicyConfKey");
+        type.setEngine(ImplementationEngine.JAVA);
+        type.setType(AMImplementationType.AUTH_POLICY_CONFIGURATIONS);
+        type.setBody(POJOHelper.serialize(conf));
+        type = implementationDAO.save(type);
+
+        authenticationPolicy.addConfiguration(type);
+        return authenticationPolicyDAO.save(authenticationPolicy);
+    }
 }


[syncope] 05/12: resume on auth modules; clean up to base essentials

Posted by mm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mmoayyed pushed a commit to branch SYNCOPE-163-1
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 812ee377f68886575168d13a14fcb73fabc64abe
Author: Misagh Moayyed <mm...@gmail.com>
AuthorDate: Mon Feb 24 15:24:12 2020 +0330

    resume on auth modules; clean up to base essentials
---
 .../AbstractAuthenticationModuleConf.java          |  43 +++++----
 .../authentication/AuthenticationModuleConf.java   |  22 +++--
 .../JaasAuthenticationModuleConf.java              |  88 +++++++++++++++++
 .../PredefinedAuthenticationModuleConf.java        |  31 +++---
 .../authentication/AuthenticationModuleDAO.java    |   3 +
 .../authentication/AuthenticationModule.java       |   7 ++
 .../core/persistence/jpa/dao/AbstractDAO.java      |   1 +
 .../authentication/JPAAuthenticationModuleDAO.java |  11 +++
 .../authentication/JPAAuthenticationModule.java    |  31 ++++++
 .../jpa/inner/AuthenticationModuleTest.java        | 104 ++++++++++++++++-----
 10 files changed, 281 insertions(+), 60 deletions(-)

diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationModule.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AbstractAuthenticationModuleConf.java
similarity index 52%
copy from core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationModule.java
copy to common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AbstractAuthenticationModuleConf.java
index 3a3c523..94d9c90 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationModule.java
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AbstractAuthenticationModuleConf.java
@@ -6,8 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -15,34 +14,42 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.syncope.core.persistence.jpa.entity.authentication;
-
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationModule;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractGeneratedKeyEntity;
+package org.apache.syncope.common.lib.authentication;
 
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlType;
 
-@Entity
-@Table(name = JPAAuthenticationModule.TABLE)
-public class JPAAuthenticationModule extends AbstractGeneratedKeyEntity implements AuthenticationModule {
+import java.io.Serializable;
 
-    public static final String TABLE = "AuthenticationModule";
+@XmlType
+public abstract class AbstractAuthenticationModuleConf implements Serializable, AuthenticationModuleConf {
 
-    private static final long serialVersionUID = 7422422526695279794L;
+    private static final long serialVersionUID = 4153200197344709778L;
 
-    @Column(unique = true, nullable = false)
     private String name;
 
+    private int order;
+
+    public AbstractAuthenticationModuleConf() {
+        setName(getClass().getName());
+    }
+
     @Override
-    public String getName() {
+    public final String getName() {
         return name;
     }
 
-    @Override
-    public void setName(final String name) {
+    public final void setName(final String name) {
         this.name = name;
     }
+
+    @Override
+    public int getOrder() {
+        return order;
+    }
+
+    public void setOrder(final int order) {
+        this.order = order;
+    }
 }
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationModule.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AuthenticationModuleConf.java
similarity index 60%
copy from core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationModule.java
copy to common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AuthenticationModuleConf.java
index 505df4f..69afddc 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationModule.java
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AuthenticationModuleConf.java
@@ -6,8 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -15,14 +14,25 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.syncope.core.persistence.api.entity.authentication;
+package org.apache.syncope.common.lib.authentication;
 
-import org.apache.syncope.core.persistence.api.entity.Entity;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
 
-public interface AuthenticationModule extends Entity {
+import java.io.Serializable;
 
+@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
+public interface AuthenticationModuleConf extends Serializable {
+
+    /**
+     * Give name of related authentication module instance.
+     *
+     * @return name of this authentication module instance
+     */
     String getName();
 
-    void setName(String name);
+    int getOrder();
+
+    
 }
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/JaasAuthenticationModuleConf.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/JaasAuthenticationModuleConf.java
new file mode 100644
index 0000000..24b785e
--- /dev/null
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/JaasAuthenticationModuleConf.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.common.lib.authentication;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement(name = "predefinedAuthenticationModuleConf")
+@XmlType
+public class JaasAuthenticationModuleConf extends AbstractAuthenticationModuleConf {
+    private static final long serialVersionUID = -7775771400318503131L;
+
+    /**
+     * The realm that contains the login module information.
+     */
+    private String realm;
+
+    /**
+     * System property value to overwrite the realm in krb5 config.
+     */
+    private String kerberosRealmSystemProperty;
+
+    /**
+     * System property value to overwrite the kdc in krb5 config.
+     */
+    private String kerberosKdcSystemProperty;
+
+    private String loginConfigType;
+
+    private String loginConfigurationFile;
+
+    public String getRealm() {
+        return realm;
+    }
+
+    public void setRealm(final String realm) {
+        this.realm = realm;
+    }
+
+    public String getKerberosRealmSystemProperty() {
+        return kerberosRealmSystemProperty;
+    }
+
+    public void setKerberosRealmSystemProperty(final String kerberosRealmSystemProperty) {
+        this.kerberosRealmSystemProperty = kerberosRealmSystemProperty;
+    }
+
+    public String getKerberosKdcSystemProperty() {
+        return kerberosKdcSystemProperty;
+    }
+
+    public void setKerberosKdcSystemProperty(final String kerberosKdcSystemProperty) {
+        this.kerberosKdcSystemProperty = kerberosKdcSystemProperty;
+    }
+
+    public String getLoginConfigType() {
+        return loginConfigType;
+    }
+
+    public void setLoginConfigType(final String loginConfigType) {
+        this.loginConfigType = loginConfigType;
+    }
+
+    public String getLoginConfigurationFile() {
+        return loginConfigurationFile;
+    }
+
+    public void setLoginConfigurationFile(final String loginConfigurationFile) {
+        this.loginConfigurationFile = loginConfigurationFile;
+    }
+}
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/AuthenticationModuleDAO.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/PredefinedAuthenticationModuleConf.java
similarity index 50%
copy from core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/AuthenticationModuleDAO.java
copy to common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/PredefinedAuthenticationModuleConf.java
index f439da7..fb1df11 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/AuthenticationModuleDAO.java
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/PredefinedAuthenticationModuleConf.java
@@ -16,23 +16,32 @@
  * under the License.
  *
  */
-package org.apache.syncope.core.persistence.api.dao.authentication;
 
-import org.apache.syncope.core.persistence.api.dao.DAO;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationModule;
+package org.apache.syncope.common.lib.authentication;
 
-import java.util.List;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
 
-public interface AuthenticationModuleDAO extends DAO<AuthenticationModule> {
+import java.util.HashMap;
+import java.util.Map;
 
-    AuthenticationModule find(String key);
+@XmlRootElement(name = "predefinedAuthenticationModuleConf")
+@XmlType
+public class PredefinedAuthenticationModuleConf extends AbstractAuthenticationModuleConf {
+    private static final long serialVersionUID = -7775771400318503131L;
 
-    List<AuthenticationModule> findAll();
+    private Map<String, String> users = new HashMap<>();
 
-    AuthenticationModule save(AuthenticationModule authenticationModule);
+    public PredefinedAuthenticationModuleConf(final Map<String, String> users) {
+        setName(getClass().getSimpleName());
+        setUsers(users);
+    }
 
-    void delete(String key);
-
-    void delete(AuthenticationModule authenticationModule);
+    public Map<String, String> getUsers() {
+        return users;
+    }
 
+    public void setUsers(final Map<String, String> users) {
+        this.users = users;
+    }
 }
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/AuthenticationModuleDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/AuthenticationModuleDAO.java
index f439da7..fe84738 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/AuthenticationModuleDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/AuthenticationModuleDAO.java
@@ -19,6 +19,7 @@
 package org.apache.syncope.core.persistence.api.dao.authentication;
 
 import org.apache.syncope.core.persistence.api.dao.DAO;
+import org.apache.syncope.core.persistence.api.entity.Implementation;
 import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationModule;
 
 import java.util.List;
@@ -35,4 +36,6 @@ public interface AuthenticationModuleDAO extends DAO<AuthenticationModule> {
 
     void delete(AuthenticationModule authenticationModule);
 
+    List<AuthenticationModule> findByConfiguration(Implementation configuration);
+
 }
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationModule.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationModule.java
index 505df4f..8ebd7c0 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationModule.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationModule.java
@@ -19,10 +19,17 @@
 package org.apache.syncope.core.persistence.api.entity.authentication;
 
 import org.apache.syncope.core.persistence.api.entity.Entity;
+import org.apache.syncope.core.persistence.api.entity.Implementation;
+
+import java.util.List;
 
 public interface AuthenticationModule extends Entity {
 
     String getName();
 
     void setName(String name);
+
+    List<? extends Implementation> getConfigurations();
+
+    boolean add(Implementation configuration);
 }
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractDAO.java
index fd87b30..5810fc4 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractDAO.java
@@ -19,6 +19,7 @@
 package org.apache.syncope.core.persistence.jpa.dao;
 
 import javax.persistence.EntityManager;
+
 import org.apache.syncope.core.spring.security.AuthContextUtils;
 import org.apache.syncope.core.spring.ApplicationContextProvider;
 import org.apache.syncope.core.persistence.api.dao.DAO;
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAAuthenticationModuleDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAAuthenticationModuleDAO.java
index f298152..b505582 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAAuthenticationModuleDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAAuthenticationModuleDAO.java
@@ -19,6 +19,7 @@
 package org.apache.syncope.core.persistence.jpa.dao.authentication;
 
 import org.apache.syncope.core.persistence.api.dao.authentication.AuthenticationModuleDAO;
+import org.apache.syncope.core.persistence.api.entity.Implementation;
 import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationModule;
 import org.apache.syncope.core.persistence.jpa.dao.AbstractDAO;
 import org.apache.syncope.core.persistence.jpa.entity.authentication.JPAAuthenticationModule;
@@ -46,6 +47,16 @@ public class JPAAuthenticationModuleDAO extends AbstractDAO<AuthenticationModule
         return query.getResultList();
     }
 
+    @Transactional(readOnly = true)
+    @Override
+    public List<AuthenticationModule> findByConfiguration(final Implementation configuration) {
+        TypedQuery<AuthenticationModule> query = entityManager().createQuery(
+            "SELECT e FROM " + JPAAuthenticationModule.class.getSimpleName() + " e "
+                + "WHERE :configuration MEMBER OF e.configurations", AuthenticationModule.class);
+        query.setParameter("configuration", configuration);
+        return query.getResultList();
+    }
+
     @Override
     public AuthenticationModule save(final AuthenticationModule authenticationModule) {
         return entityManager().merge(authenticationModule);
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationModule.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationModule.java
index 3a3c523..33d0e98 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationModule.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationModule.java
@@ -18,13 +18,23 @@
  */
 package org.apache.syncope.core.persistence.jpa.entity.authentication;
 
+import org.apache.syncope.common.lib.types.AMImplementationType;
+import org.apache.syncope.core.persistence.api.entity.Implementation;
 import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationModule;
 import org.apache.syncope.core.persistence.jpa.entity.AbstractGeneratedKeyEntity;
+import org.apache.syncope.core.persistence.jpa.entity.JPAImplementation;
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
 import javax.persistence.Table;
 
+import java.util.ArrayList;
+import java.util.List;
+
 @Entity
 @Table(name = JPAAuthenticationModule.TABLE)
 public class JPAAuthenticationModule extends AbstractGeneratedKeyEntity implements AuthenticationModule {
@@ -36,6 +46,14 @@ public class JPAAuthenticationModule extends AbstractGeneratedKeyEntity implemen
     @Column(unique = true, nullable = false)
     private String name;
 
+    @ManyToMany(fetch = FetchType.EAGER)
+    @JoinTable(name = TABLE + "Conf",
+        joinColumns =
+        @JoinColumn(name = "authentication_module_id"),
+        inverseJoinColumns =
+        @JoinColumn(name = "implementation_id"))
+    private List<JPAImplementation> configurations = new ArrayList<>();
+
     @Override
     public String getName() {
         return name;
@@ -45,4 +63,17 @@ public class JPAAuthenticationModule extends AbstractGeneratedKeyEntity implemen
     public void setName(final String name) {
         this.name = name;
     }
+
+    @Override
+    public List<? extends Implementation> getConfigurations() {
+        return configurations;
+    }
+
+    @Override
+    public boolean add(final Implementation configuration) {
+        checkType(configuration, JPAImplementation.class);
+        checkImplementationType(configuration, AMImplementationType.AUTH_MODULE_CONFIGURATIONS);
+        return configurations.contains((JPAImplementation) configuration)
+            || configurations.add((JPAImplementation) configuration);
+    }
 }
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationModuleTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationModuleTest.java
index 294d7c1..9d17651 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationModuleTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationModuleTest.java
@@ -18,62 +18,116 @@
  */
 package org.apache.syncope.core.persistence.jpa.inner;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-import java.util.List;
-import java.util.UUID;
-
+import org.apache.syncope.common.lib.authentication.AuthenticationModuleConf;
+import org.apache.syncope.common.lib.authentication.JaasAuthenticationModuleConf;
+import org.apache.syncope.common.lib.authentication.PredefinedAuthenticationModuleConf;
+import org.apache.syncope.common.lib.types.AMImplementationType;
+import org.apache.syncope.common.lib.types.ImplementationEngine;
+import org.apache.syncope.core.persistence.api.dao.ImplementationDAO;
 import org.apache.syncope.core.persistence.api.dao.authentication.AuthenticationModuleDAO;
+import org.apache.syncope.core.persistence.api.entity.Implementation;
 import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationModule;
 import org.apache.syncope.core.persistence.jpa.AbstractTest;
+import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.*;
+
 @Transactional("Master")
 public class AuthenticationModuleTest extends AbstractTest {
 
     @Autowired
     private AuthenticationModuleDAO authenticationModuleDAO;
 
+    @Autowired
+    private ImplementationDAO implementationDAO;
+
     @Test
     public void find() {
-        AuthenticationModule athAuthenticationModule = authenticationModuleDAO.find(
-                "be456831-593d-4003-b273-4c3fb61700df");
-        assertNotNull(athAuthenticationModule);
+        AuthenticationModule module = authenticationModuleDAO.find(
+            "be456831-593d-4003-b273-4c3fb61700df");
+        assertNotNull(module);
 
-        athAuthenticationModule = authenticationModuleDAO.find(UUID.randomUUID().toString());
-        assertNull(athAuthenticationModule);
+        module = authenticationModuleDAO.find(UUID.randomUUID().toString());
+        assertNull(module);
     }
 
     @Test
     public void findAll() {
-        List<AuthenticationModule> athAuthenticationModules = authenticationModuleDAO.findAll();
-        assertNotNull(athAuthenticationModules);
-        assertEquals(1, athAuthenticationModules.size());
+        List<AuthenticationModule> modules = authenticationModuleDAO.findAll();
+        assertNotNull(modules);
+        assertEquals(1, modules.size());
     }
 
     @Test
-    public void save() {
+    public void saveWithPredefinedModule() {
+        PredefinedAuthenticationModuleConf conf =
+            new PredefinedAuthenticationModuleConf(Map.of("user", UUID.randomUUID().toString()));
+
+        Implementation config = getImplementation(conf);
 
-        int beforeCount = authenticationModuleDAO.findAll().size();
-        AuthenticationModule authenticationModule = entityFactory.newEntity(AuthenticationModule.class);
-        authenticationModule.setName("AuthenticationModuleTest");
-        authenticationModuleDAO.save(authenticationModule);
+        config = implementationDAO.save(config);
+
+        assertNotNull(config);
+        assertNotNull(config.getKey());
+
+        AuthenticationModule module = entityFactory.newEntity(AuthenticationModule.class);
+        module.setName("AuthenticationModuleTest");
+        module.add(config);
+        authenticationModuleDAO.save(module);
+
+        assertNotNull(module);
+        assertNotNull(module.getKey());
+
+        assertNotNull(authenticationModuleDAO.find(module.getKey()));
+    }
+
+    @Test
+    public void saveWithJaasModule() {
+        JaasAuthenticationModuleConf conf = new JaasAuthenticationModuleConf();
+        conf.setKerberosKdcSystemProperty("sample-value");
+        conf.setKerberosRealmSystemProperty("sample-value");
+        conf.setLoginConfigType("JavaLoginConfig");
+        conf.setRealm("SYNCOPE");
+        conf.setLoginConfigurationFile("/opt/jaas/login.conf");
+        Implementation config = getImplementation(conf);
+
+        config = implementationDAO.save(config);
+
+        assertNotNull(config);
+        assertNotNull(config.getKey());
+
+        AuthenticationModule module = entityFactory.newEntity(AuthenticationModule.class);
+        module.setName("AuthenticationModuleTest");
+        module.add(config);
+        authenticationModuleDAO.save(module);
+
+        assertNotNull(module);
+        assertNotNull(module.getKey());
+
+        assertNotNull(authenticationModuleDAO.find(module.getKey()));
+    }
 
-        assertNotNull(authenticationModule);
-        assertNotNull(authenticationModule.getKey());
 
-        int afterCount = authenticationModuleDAO.findAll().size();
-        assertEquals(afterCount, beforeCount + 1);
+    private Implementation getImplementation(final AuthenticationModuleConf conf) {
+        Implementation config = entityFactory.newEntity(Implementation.class);
+        config.setKey(UUID.randomUUID().toString());
+        config.setEngine(ImplementationEngine.JAVA);
+        config.setType(AMImplementationType.AUTH_MODULE_CONFIGURATIONS);
+        config.setBody(POJOHelper.serialize(conf));
+        return config;
     }
 
     @Test
     public void delete() {
         AuthenticationModule athAuthenticationModule = authenticationModuleDAO.find(
-                "be456831-593d-4003-b273-4c3fb61700df");
+            "be456831-593d-4003-b273-4c3fb61700df");
         assertNotNull(athAuthenticationModule);
 
         authenticationModuleDAO.delete("be456831-593d-4003-b273-4c3fb61700df");


[syncope] 07/12: complete binders, rest client and DAOs for authn client apps

Posted by mm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mmoayyed pushed a commit to branch SYNCOPE-163-1
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 4349207fc3536d7113c5141c181ec2e0e8d116a9
Author: Misagh Moayyed <mm...@gmail.com>
AuthorDate: Tue Feb 25 16:51:07 2020 +0330

    complete binders, rest client and DAOs for authn client apps
---
 .../console/rest/ClientApplicationRestClient.java  | 10 +--
 .../common/lib/types/IdRepoEntitlement.java        | 16 ++++
 .../core/logic/AbstractClientApplicationLogic.java | 24 +++++-
 .../core/logic/OpenIdConnectRelyingPartyLogic.java | 99 ++++++++++++++++++++++
 .../core/logic/SAML2ServiceProviderLogic.java      | 98 +++++++++++++++++++++
 .../OpenIdConnectRelyingPartyServiceImpl.java}     | 17 +++-
 .../service/SAML2ServiceProviderServiceImpl.java}  | 17 +++-
 .../data/OpenIdConnectRelyingPartyDataBinder.java} | 12 ++-
 .../api/data/SAML2ServiceProviderDataBinder.java}  | 16 ++--
 9 files changed, 288 insertions(+), 21 deletions(-)

diff --git a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/ClientApplicationRestClient.java b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/ClientApplicationRestClient.java
index 0dfb663..2f36947 100644
--- a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/ClientApplicationRestClient.java
+++ b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/ClientApplicationRestClient.java
@@ -18,7 +18,7 @@
  */
 package org.apache.syncope.client.console.rest;
 
-import org.apache.syncope.common.lib.to.ApplicationTO;
+import org.apache.syncope.common.lib.to.ClientApplicationTO;
 import org.apache.syncope.common.rest.api.service.ClientApplicationService;
 
 import java.util.List;
@@ -34,19 +34,19 @@ public class ClientApplicationRestClient extends BaseRestClient {
         getService(ClientApplicationService.class).delete(key);
     }
 
-    public static ApplicationTO read(final String key) {
+    public static ClientApplicationTO read(final String key) {
         return getService(ClientApplicationService.class).read(key);
     }
 
-    public static void update(final ApplicationTO applicationTO) {
+    public static void update(final ClientApplicationTO applicationTO) {
         getService(ClientApplicationService.class).update(applicationTO);
     }
 
-    public static void create(final ApplicationTO applicationTO) {
+    public static void create(final ClientApplicationTO applicationTO) {
         getService(ClientApplicationService.class).create(applicationTO);
     }
 
-    public static List<ApplicationTO> list() {
+    public static List<ClientApplicationTO> list() {
         return getService(ClientApplicationService.class).list();
     }
 
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/types/IdRepoEntitlement.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/types/IdRepoEntitlement.java
index 8ab42af..97746b2 100644
--- a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/types/IdRepoEntitlement.java
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/types/IdRepoEntitlement.java
@@ -238,6 +238,22 @@ public final class IdRepoEntitlement {
 
     public static final String IMPLEMENTATION_DELETE = "IMPLEMENTATION_DELETE";
 
+    public static final String OIDC_RELYING_PARTY_READ = "OIDC_RELYING_PARTY_READ";
+
+    public static final String OIDC_RELYING_PARTY_DELETE = "OIDC_RELYING_PARTY_DELETE";
+
+    public static final String OIDC_RELYING_PARTY_CREATE = "OIDC_RELYING_PARTY_CREATE";
+
+    public static final String OIDC_RELYING_PARTY_LIST = "OIDC_RELYING_PARTY_LIST";
+
+    public static final String SAML2_SERVICE_PROVIDER_READ = "OIDC_RELYING_PARTY_READ";
+
+    public static final String SAML2_SERVICE_PROVIDER_DELETE = "SAML2_SERVICE_PROVIDER_DELETE";
+
+    public static final String SAML2_SERVICE_PROVIDER_CREATE = "SAML2_SERVICE_PROVIDER_CREATE";
+
+    public static final String SAML2_SERVICE_PROVIDER_LIST = "SAML2_SERVICE_PROVIDER_LIST";
+
     private static final Set<String> VALUES;
 
     static {
diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java
index 79ccf62..24cd2f1 100644
--- a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java
+++ b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java
@@ -19,7 +19,27 @@
 
 package org.apache.syncope.core.logic;
 
-import org.apache.syncope.common.lib.to.DynRealmTO;
+import org.apache.syncope.common.lib.to.ClientApplicationTO;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+public abstract class AbstractClientApplicationLogic extends AbstractTransactionalLogic<ClientApplicationTO> {
+
+    @Override
+    protected ClientApplicationTO resolveReference(final Method method, final Object... args)
+        throws UnresolvedReferenceException {
+        throw new UnresolvedReferenceException();
+    }
+
+    public abstract ClientApplicationTO delete(String key);
+
+    public abstract List<ClientApplicationTO> list();
+
+    public abstract ClientApplicationTO read(String key);
+
+    public abstract ClientApplicationTO create(ClientApplicationTO applicationTO);
+
+    public abstract ClientApplicationTO update(ClientApplicationTO applicationTO);
 
-public abstract class AbstractClientApplicationLogic extends AbstractTransactionalLogic<DynRealmTO> {
 }
diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/OpenIdConnectRelyingPartyLogic.java b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/OpenIdConnectRelyingPartyLogic.java
new file mode 100644
index 0000000..f08bfdf
--- /dev/null
+++ b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/OpenIdConnectRelyingPartyLogic.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.core.logic;
+
+import org.apache.syncope.common.lib.to.ClientApplicationTO;
+import org.apache.syncope.common.lib.types.IdRepoEntitlement;
+import org.apache.syncope.core.persistence.api.dao.NotFoundException;
+import org.apache.syncope.core.persistence.api.dao.authentication.OpenIdConnectRelyingPartyDAO;
+import org.apache.syncope.core.persistence.api.entity.authentication.OpenIdConnectRelyingParty;
+import org.apache.syncope.core.provisioning.api.data.OpenIdConnectRelyingPartyDataBinder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Component
+public class OpenIdConnectRelyingPartyLogic extends AbstractClientApplicationLogic {
+    @Autowired
+    private OpenIdConnectRelyingPartyDAO openIdConnectRelyingPartyDAO;
+
+    @Autowired
+    private OpenIdConnectRelyingPartyDataBinder binder;
+
+    @PreAuthorize("hasRole('" + IdRepoEntitlement.OIDC_RELYING_PARTY_READ + "')")
+    @Transactional(readOnly = true)
+    @Override
+    public ClientApplicationTO read(final String key) {
+        OpenIdConnectRelyingParty application = openIdConnectRelyingPartyDAO.find(key);
+        if (application == null) {
+            LOG.error("Could not find application '" + key + '\'');
+
+            throw new NotFoundException(key);
+        }
+
+        return binder.getClientApplicationTO(application);
+    }
+
+    @PreAuthorize("hasRole('" + IdRepoEntitlement.OIDC_RELYING_PARTY_LIST + "')")
+    @Transactional(readOnly = true)
+    @Override
+    public List<ClientApplicationTO> list() {
+        return openIdConnectRelyingPartyDAO.findAll()
+            .stream().map(binder::getClientApplicationTO).collect(Collectors.toList());
+    }
+
+    @PreAuthorize("hasRole('" + IdRepoEntitlement.OIDC_RELYING_PARTY_CREATE + "')")
+    @Override
+    public ClientApplicationTO create(final ClientApplicationTO applicationTO) {
+        return binder.getClientApplicationTO(openIdConnectRelyingPartyDAO.save(binder.create(applicationTO)));
+    }
+
+    @Override
+    @PreAuthorize("hasRole('" + IdRepoEntitlement.APPLICATION_UPDATE + "')")
+    public ClientApplicationTO update(final ClientApplicationTO applicationTO) {
+        OpenIdConnectRelyingParty application = openIdConnectRelyingPartyDAO.find(applicationTO.getKey());
+        if (application == null) {
+            LOG.error("Could not find application '" + applicationTO.getKey() + '\'');
+            throw new NotFoundException(applicationTO.getKey());
+        }
+
+        return binder.getClientApplicationTO(openIdConnectRelyingPartyDAO.save(binder.update(application, applicationTO)));
+    }
+
+    @Override
+    @PreAuthorize("hasRole('" + IdRepoEntitlement.OIDC_RELYING_PARTY_DELETE + "')")
+    public ClientApplicationTO delete(final String key) {
+        OpenIdConnectRelyingParty application = openIdConnectRelyingPartyDAO.find(key);
+        if (application == null) {
+            LOG.error("Could not find application '" + key + '\'');
+
+            throw new NotFoundException(key);
+        }
+
+        ClientApplicationTO deleted = binder.getClientApplicationTO(application);
+        openIdConnectRelyingPartyDAO.delete(key);
+        return deleted;
+    }
+    
+}
diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/SAML2ServiceProviderLogic.java b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/SAML2ServiceProviderLogic.java
new file mode 100644
index 0000000..a2d5092
--- /dev/null
+++ b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/SAML2ServiceProviderLogic.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.core.logic;
+
+import org.apache.syncope.common.lib.to.ClientApplicationTO;
+import org.apache.syncope.common.lib.types.IdRepoEntitlement;
+import org.apache.syncope.core.persistence.api.dao.NotFoundException;
+import org.apache.syncope.core.persistence.api.dao.authentication.SAML2ServiceProviderDAO;
+import org.apache.syncope.core.persistence.api.entity.authentication.SAML2ServiceProvider;
+import org.apache.syncope.core.provisioning.api.data.SAML2ServiceProviderDataBinder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Component
+public class SAML2ServiceProviderLogic extends AbstractClientApplicationLogic {
+
+    @Autowired
+    private SAML2ServiceProviderDAO saml2ServiceProviderDAO;
+
+    @Autowired
+    private SAML2ServiceProviderDataBinder binder;
+
+    @Override
+    @PreAuthorize("hasRole('" + IdRepoEntitlement.SAML2_SERVICE_PROVIDER_DELETE + "')")
+    public ClientApplicationTO delete(final String key) {
+        SAML2ServiceProvider application = saml2ServiceProviderDAO.find(key);
+        if (application == null) {
+            LOG.error("Could not find application '" + key + '\'');
+
+            throw new NotFoundException(key);
+        }
+
+        ClientApplicationTO deleted = binder.getClientApplicationTO(application);
+        saml2ServiceProviderDAO.delete(key);
+        return deleted;
+    }
+
+    @Override
+    @PreAuthorize("hasRole('" + IdRepoEntitlement.SAML2_SERVICE_PROVIDER_LIST + "')")
+    @Transactional(readOnly = true)
+    public List<ClientApplicationTO> list() {
+        return saml2ServiceProviderDAO.findAll().stream().map(binder::getClientApplicationTO).collect(Collectors.toList());
+    }
+
+    @PreAuthorize("hasRole('" + IdRepoEntitlement.SAML2_SERVICE_PROVIDER_READ + "')")
+    @Transactional(readOnly = true)
+    @Override
+    public ClientApplicationTO read(final String key) {
+        SAML2ServiceProvider application = saml2ServiceProviderDAO.find(key);
+        if (application == null) {
+            LOG.error("Could not find application '" + key + '\'');
+
+            throw new NotFoundException(key);
+        }
+
+        return binder.getClientApplicationTO(application);
+    }
+
+    @Override
+    @PreAuthorize("hasRole('" + IdRepoEntitlement.SAML2_SERVICE_PROVIDER_CREATE + "')")
+    public ClientApplicationTO create(final ClientApplicationTO applicationTO) {
+        return binder.getClientApplicationTO(saml2ServiceProviderDAO.save(binder.create(applicationTO)));
+    }
+
+    @Override
+    @PreAuthorize("hasRole('" + IdRepoEntitlement.APPLICATION_UPDATE + "')")
+    public ClientApplicationTO update(final ClientApplicationTO applicationTO) {
+        SAML2ServiceProvider application = saml2ServiceProviderDAO.find(applicationTO.getKey());
+        if (application == null) {
+            LOG.error("Could not find application '" + applicationTO.getKey() + '\'');
+            throw new NotFoundException(applicationTO.getKey());
+        }
+
+        return binder.getClientApplicationTO(saml2ServiceProviderDAO.save(binder.update(application, applicationTO)));
+    }
+}
diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/OpenIdConnectRelyingPartyServiceImpl.java
similarity index 58%
copy from core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java
copy to core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/OpenIdConnectRelyingPartyServiceImpl.java
index 79ccf62..84f01de 100644
--- a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java
+++ b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/OpenIdConnectRelyingPartyServiceImpl.java
@@ -17,9 +17,20 @@
  *
  */
 
-package org.apache.syncope.core.logic;
+package org.apache.syncope.core.rest.cxf.service;
 
-import org.apache.syncope.common.lib.to.DynRealmTO;
+import org.apache.syncope.core.logic.AbstractClientApplicationLogic;
+import org.apache.syncope.core.logic.OpenIdConnectRelyingPartyLogic;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 
-public abstract class AbstractClientApplicationLogic extends AbstractTransactionalLogic<DynRealmTO> {
+@Service
+public class OpenIdConnectRelyingPartyServiceImpl extends AbstractClientApplicationServiceImpl {
+    @Autowired
+    private OpenIdConnectRelyingPartyLogic logic;
+
+    @Override
+    protected AbstractClientApplicationLogic getLogic() {
+        return this.logic;
+    }
 }
diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SAML2ServiceProviderServiceImpl.java
similarity index 59%
copy from core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java
copy to core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SAML2ServiceProviderServiceImpl.java
index 79ccf62..960a442 100644
--- a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java
+++ b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SAML2ServiceProviderServiceImpl.java
@@ -17,9 +17,20 @@
  *
  */
 
-package org.apache.syncope.core.logic;
+package org.apache.syncope.core.rest.cxf.service;
 
-import org.apache.syncope.common.lib.to.DynRealmTO;
+import org.apache.syncope.core.logic.AbstractClientApplicationLogic;
+import org.apache.syncope.core.logic.SAML2ServiceProviderLogic;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 
-public abstract class AbstractClientApplicationLogic extends AbstractTransactionalLogic<DynRealmTO> {
+@Service
+public class SAML2ServiceProviderServiceImpl extends AbstractClientApplicationServiceImpl {
+    @Autowired
+    private SAML2ServiceProviderLogic logic;
+
+    @Override
+    protected AbstractClientApplicationLogic getLogic() {
+        return this.logic;
+    }
 }
diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/OpenIdConnectRelyingPartyDataBinder.java
similarity index 60%
copy from core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java
copy to core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/OpenIdConnectRelyingPartyDataBinder.java
index 79ccf62..87a1f57 100644
--- a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java
+++ b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/OpenIdConnectRelyingPartyDataBinder.java
@@ -17,9 +17,15 @@
  *
  */
 
-package org.apache.syncope.core.logic;
+package org.apache.syncope.core.provisioning.api.data;
 
-import org.apache.syncope.common.lib.to.DynRealmTO;
+import org.apache.syncope.common.lib.to.ClientApplicationTO;
+import org.apache.syncope.core.persistence.api.entity.authentication.OpenIdConnectRelyingParty;
 
-public abstract class AbstractClientApplicationLogic extends AbstractTransactionalLogic<DynRealmTO> {
+public interface OpenIdConnectRelyingPartyDataBinder {
+    OpenIdConnectRelyingParty create(ClientApplicationTO applicationTO);
+
+    OpenIdConnectRelyingParty update(OpenIdConnectRelyingParty application, ClientApplicationTO applicationTO);
+
+    ClientApplicationTO getClientApplicationTO(OpenIdConnectRelyingParty application);
 }
diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/SAML2ServiceProviderDataBinder.java
similarity index 57%
copy from core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java
copy to core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/SAML2ServiceProviderDataBinder.java
index 79ccf62..9b3b2be 100644
--- a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java
+++ b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/SAML2ServiceProviderDataBinder.java
@@ -6,7 +6,8 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -14,12 +15,17 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
  */
+package org.apache.syncope.core.provisioning.api.data;
+
+import org.apache.syncope.common.lib.to.ClientApplicationTO;
+import org.apache.syncope.core.persistence.api.entity.authentication.SAML2ServiceProvider;
+
+public interface SAML2ServiceProviderDataBinder {
 
-package org.apache.syncope.core.logic;
+    SAML2ServiceProvider create(ClientApplicationTO applicationTO);
 
-import org.apache.syncope.common.lib.to.DynRealmTO;
+    SAML2ServiceProvider update(SAML2ServiceProvider application, ClientApplicationTO applicationTO);
 
-public abstract class AbstractClientApplicationLogic extends AbstractTransactionalLogic<DynRealmTO> {
+    ClientApplicationTO getClientApplicationTO(SAML2ServiceProvider application);
 }


[syncope] 02/12: Merge branch 'master' into SYNCOPE-163

Posted by mm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mmoayyed pushed a commit to branch SYNCOPE-163-1
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 193fba5d506f5ff96f213ffd2f9cd16e2545cee5
Merge: b64480a 1eb1f14
Author: Misagh Moayyed <mm...@gmail.com>
AuthorDate: Mon Feb 24 10:42:13 2020 +0330

    Merge branch 'master' into SYNCOPE-163

 .../syncope/core/logic/ReconciliationLogic.java    |   6 +-
 .../core/provisioning/api/MappingManager.java      |   8 +-
 .../core/provisioning/java/MappingManagerImpl.java |  64 ++++---
 .../java/job/report/ReconciliationReportlet.java   |   2 +-
 .../java/propagation/PropagationManagerImpl.java   |   7 +-
 .../stream/StreamAnyObjectPushResultHandler.java   |   3 +-
 .../stream/StreamGroupPushResultHandler.java       |   3 +-
 .../stream/StreamUserPushResultHandler.java        |   3 +-
 .../provisioning/java/ConnectorManagerTest.java    |   7 +-
 .../provisioning/java/MappingManagerImplTest.java  | 205 +++++++++++++++++++++
 pom.xml                                            |   4 +-
 11 files changed, 272 insertions(+), 40 deletions(-)


[syncope] 12/12: continue with refactoring

Posted by mm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mmoayyed pushed a commit to branch SYNCOPE-163-1
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit cc182864525b5fddbb8e6afb437782d60566e5aa
Author: Misagh Moayyed <mm...@gmail.com>
AuthorDate: Thu Feb 27 11:47:04 2020 +0330

    continue with refactoring
---
 ...va => OpenIdConnectRelyingPartyRestClient.java} | 24 +++++++++++-----------
 ...nt.java => SAML2ServiceProviderRestClient.java} | 24 +++++++++++-----------
 .../rest/api/service/ClientApplicationService.java | 10 ++++-----
 .../service/OpenIdConnectRelyingPartyService.java  |  3 ++-
 .../api/service/SAML2ServiceProviderService.java   |  3 ++-
 .../AbstractClientApplicationServiceImpl.java      | 16 +++++++--------
 .../OpenIdConnectRelyingPartyServiceImpl.java      |  5 ++++-
 .../service/SAML2ServiceProviderServiceImpl.java   |  4 +++-
 8 files changed, 48 insertions(+), 41 deletions(-)

diff --git a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/ClientApplicationRestClient.java b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/OpenIdConnectRelyingPartyRestClient.java
similarity index 55%
copy from client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/ClientApplicationRestClient.java
copy to client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/OpenIdConnectRelyingPartyRestClient.java
index 2f36947..d3d67c4 100644
--- a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/ClientApplicationRestClient.java
+++ b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/OpenIdConnectRelyingPartyRestClient.java
@@ -18,36 +18,36 @@
  */
 package org.apache.syncope.client.console.rest;
 
-import org.apache.syncope.common.lib.to.ClientApplicationTO;
-import org.apache.syncope.common.rest.api.service.ClientApplicationService;
+import org.apache.syncope.common.lib.to.OpenIdConnectRelyingPartyTO;
+import org.apache.syncope.common.rest.api.service.OpenIdConnectRelyingPartyService;
 
 import java.util.List;
 
 /**
  * Console client for invoking Rest Client Application's services.
  */
-public class ClientApplicationRestClient extends BaseRestClient {
+public class OpenIdConnectRelyingPartyRestClient extends BaseRestClient {
 
     private static final long serialVersionUID = -3161863874876938094L;
 
     public static void delete(final String key) {
-        getService(ClientApplicationService.class).delete(key);
+        getService(OpenIdConnectRelyingPartyService.class).delete(key);
     }
 
-    public static ClientApplicationTO read(final String key) {
-        return getService(ClientApplicationService.class).read(key);
+    public static OpenIdConnectRelyingPartyTO read(final String key) {
+        return getService(OpenIdConnectRelyingPartyService.class).read(key);
     }
 
-    public static void update(final ClientApplicationTO applicationTO) {
-        getService(ClientApplicationService.class).update(applicationTO);
+    public static void update(final OpenIdConnectRelyingPartyTO applicationTO) {
+        getService(OpenIdConnectRelyingPartyService.class).update(applicationTO);
     }
 
-    public static void create(final ClientApplicationTO applicationTO) {
-        getService(ClientApplicationService.class).create(applicationTO);
+    public static void create(final OpenIdConnectRelyingPartyTO applicationTO) {
+        getService(OpenIdConnectRelyingPartyService.class).create(applicationTO);
     }
 
-    public static List<ClientApplicationTO> list() {
-        return getService(ClientApplicationService.class).list();
+    public static List<OpenIdConnectRelyingPartyTO> list() {
+        return getService(OpenIdConnectRelyingPartyService.class).list();
     }
 
 }
diff --git a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/ClientApplicationRestClient.java b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/SAML2ServiceProviderRestClient.java
similarity index 56%
rename from client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/ClientApplicationRestClient.java
rename to client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/SAML2ServiceProviderRestClient.java
index 2f36947..d5d9088 100644
--- a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/ClientApplicationRestClient.java
+++ b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/SAML2ServiceProviderRestClient.java
@@ -18,36 +18,36 @@
  */
 package org.apache.syncope.client.console.rest;
 
-import org.apache.syncope.common.lib.to.ClientApplicationTO;
-import org.apache.syncope.common.rest.api.service.ClientApplicationService;
+import org.apache.syncope.common.lib.to.SAML2ServiceProviderTO;
+import org.apache.syncope.common.rest.api.service.SAML2ServiceProviderService;
 
 import java.util.List;
 
 /**
  * Console client for invoking Rest Client Application's services.
  */
-public class ClientApplicationRestClient extends BaseRestClient {
+public class SAML2ServiceProviderRestClient extends BaseRestClient {
 
     private static final long serialVersionUID = -3161863874876938094L;
 
     public static void delete(final String key) {
-        getService(ClientApplicationService.class).delete(key);
+        getService(SAML2ServiceProviderService.class).delete(key);
     }
 
-    public static ClientApplicationTO read(final String key) {
-        return getService(ClientApplicationService.class).read(key);
+    public static SAML2ServiceProviderTO read(final String key) {
+        return getService(SAML2ServiceProviderService.class).read(key);
     }
 
-    public static void update(final ClientApplicationTO applicationTO) {
-        getService(ClientApplicationService.class).update(applicationTO);
+    public static void update(final SAML2ServiceProviderTO applicationTO) {
+        getService(SAML2ServiceProviderService.class).update(applicationTO);
     }
 
-    public static void create(final ClientApplicationTO applicationTO) {
-        getService(ClientApplicationService.class).create(applicationTO);
+    public static void create(final SAML2ServiceProviderTO applicationTO) {
+        getService(SAML2ServiceProviderService.class).create(applicationTO);
     }
 
-    public static List<ClientApplicationTO> list() {
-        return getService(ClientApplicationService.class).list();
+    public static List<SAML2ServiceProviderTO> list() {
+        return getService(SAML2ServiceProviderService.class).list();
     }
 
 }
diff --git a/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ClientApplicationService.java b/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ClientApplicationService.java
index 56740ee..71c80b9 100644
--- a/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ClientApplicationService.java
+++ b/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ClientApplicationService.java
@@ -46,7 +46,7 @@ import java.util.List;
 /**
  * REST operations for applications.
  */
-public interface ClientApplicationService extends JAXRSService {
+public interface ClientApplicationService<T extends ClientApplicationTO> extends JAXRSService {
 
     /**
      * Returns a list of all applications.
@@ -55,7 +55,7 @@ public interface ClientApplicationService extends JAXRSService {
      */
     @GET
     @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
-    List<ClientApplicationTO> list();
+    List<T> list();
 
     /**
      * Returns application with matching key.
@@ -66,7 +66,7 @@ public interface ClientApplicationService extends JAXRSService {
     @GET
     @Path("{key}")
     @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
-    ClientApplicationTO read(@NotNull @PathParam("key") String key);
+    T read(@NotNull @PathParam("key") String key);
 
     /**
      * Creates a new application.
@@ -86,7 +86,7 @@ public interface ClientApplicationService extends JAXRSService {
     @POST
     @Consumes({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
     @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
-    Response create(@NotNull ClientApplicationTO applicationTO);
+    Response create(@NotNull T applicationTO);
 
     /**
      * Updates the application matching the provided key.
@@ -101,7 +101,7 @@ public interface ClientApplicationService extends JAXRSService {
     @Path("{key}")
     @Consumes({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
     @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
-    void update(@NotNull ClientApplicationTO applicationTO);
+    void update(@NotNull T applicationTO);
 
     /**
      * Deletes the application matching the provided key.
diff --git a/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/OpenIdConnectRelyingPartyService.java b/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/OpenIdConnectRelyingPartyService.java
index ce2f57c..e127bbca 100644
--- a/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/OpenIdConnectRelyingPartyService.java
+++ b/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/OpenIdConnectRelyingPartyService.java
@@ -22,6 +22,7 @@ package org.apache.syncope.common.rest.api.service;
 import io.swagger.v3.oas.annotations.security.SecurityRequirement;
 import io.swagger.v3.oas.annotations.security.SecurityRequirements;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import org.apache.syncope.common.lib.to.OpenIdConnectRelyingPartyTO;
 
 import javax.ws.rs.Path;
 
@@ -30,5 +31,5 @@ import javax.ws.rs.Path;
     @SecurityRequirement(name = "BasicAuthentication"),
     @SecurityRequirement(name = "Bearer")})
 @Path("openIdConnectRelyingParties")
-public interface OpenIdConnectRelyingPartyService extends ClientApplicationService {
+public interface OpenIdConnectRelyingPartyService extends ClientApplicationService<OpenIdConnectRelyingPartyTO> {
 }
diff --git a/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/SAML2ServiceProviderService.java b/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/SAML2ServiceProviderService.java
index 2373270..75912fe 100644
--- a/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/SAML2ServiceProviderService.java
+++ b/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/SAML2ServiceProviderService.java
@@ -22,6 +22,7 @@ package org.apache.syncope.common.rest.api.service;
 import io.swagger.v3.oas.annotations.security.SecurityRequirement;
 import io.swagger.v3.oas.annotations.security.SecurityRequirements;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import org.apache.syncope.common.lib.to.SAML2ServiceProviderTO;
 
 import javax.ws.rs.Path;
 
@@ -30,5 +31,5 @@ import javax.ws.rs.Path;
     @SecurityRequirement(name = "BasicAuthentication"),
     @SecurityRequirement(name = "Bearer")})
 @Path("saml2ServiceProviders")
-public interface SAML2ServiceProviderService extends ClientApplicationService {
+public interface SAML2ServiceProviderService extends ClientApplicationService<SAML2ServiceProviderTO> {
 }
diff --git a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractClientApplicationServiceImpl.java b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractClientApplicationServiceImpl.java
index f7c4295..088a3c0 100644
--- a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractClientApplicationServiceImpl.java
+++ b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractClientApplicationServiceImpl.java
@@ -28,25 +28,25 @@ import javax.ws.rs.core.Response;
 import java.net.URI;
 import java.util.List;
 
-public abstract class AbstractClientApplicationServiceImpl extends AbstractServiceImpl
-    implements ClientApplicationService {
+public abstract class AbstractClientApplicationServiceImpl<T extends ClientApplicationTO> extends AbstractServiceImpl
+    implements ClientApplicationService<T> {
 
-    protected abstract AbstractClientApplicationLogic getLogic();
+    protected abstract AbstractClientApplicationLogic<T> getLogic();
 
     @Override
-    public List<ClientApplicationTO> list() {
+    public List<T> list() {
         return getLogic().list();
     }
 
     @Override
-    public ClientApplicationTO read(final String key) {
+    public T read(final String key) {
         return getLogic().read(key);
     }
 
 
     @Override
-    public Response create(final ClientApplicationTO applicationTO) {
-        ClientApplicationTO created = getLogic().create(applicationTO);
+    public Response create(final T applicationTO) {
+        T created = getLogic().create(applicationTO);
         URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build();
         return Response.created(location).
             header(RESTHeaders.RESOURCE_KEY, created.getKey()).
@@ -54,7 +54,7 @@ public abstract class AbstractClientApplicationServiceImpl extends AbstractServi
     }
 
     @Override
-    public void update(final ClientApplicationTO applicationTO) {
+    public void update(final T applicationTO) {
         getLogic().update(applicationTO);
     }
 
diff --git a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/OpenIdConnectRelyingPartyServiceImpl.java b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/OpenIdConnectRelyingPartyServiceImpl.java
index 03ece06..cdb69b4 100644
--- a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/OpenIdConnectRelyingPartyServiceImpl.java
+++ b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/OpenIdConnectRelyingPartyServiceImpl.java
@@ -19,6 +19,7 @@
 
 package org.apache.syncope.core.rest.cxf.service;
 
+import org.apache.syncope.common.lib.to.OpenIdConnectRelyingPartyTO;
 import org.apache.syncope.common.rest.api.service.OpenIdConnectRelyingPartyService;
 import org.apache.syncope.core.logic.AbstractClientApplicationLogic;
 import org.apache.syncope.core.logic.OpenIdConnectRelyingPartyLogic;
@@ -26,8 +27,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 @Service
-public class OpenIdConnectRelyingPartyServiceImpl extends AbstractClientApplicationServiceImpl
+public class OpenIdConnectRelyingPartyServiceImpl
+    extends AbstractClientApplicationServiceImpl<OpenIdConnectRelyingPartyTO>
     implements OpenIdConnectRelyingPartyService {
+
     @Autowired
     private OpenIdConnectRelyingPartyLogic logic;
 
diff --git a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SAML2ServiceProviderServiceImpl.java b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SAML2ServiceProviderServiceImpl.java
index 69b41f1..03a2077 100644
--- a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SAML2ServiceProviderServiceImpl.java
+++ b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SAML2ServiceProviderServiceImpl.java
@@ -19,6 +19,7 @@
 
 package org.apache.syncope.core.rest.cxf.service;
 
+import org.apache.syncope.common.lib.to.SAML2ServiceProviderTO;
 import org.apache.syncope.common.rest.api.service.SAML2ServiceProviderService;
 import org.apache.syncope.core.logic.AbstractClientApplicationLogic;
 import org.apache.syncope.core.logic.SAML2ServiceProviderLogic;
@@ -26,7 +27,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 @Service
-public class SAML2ServiceProviderServiceImpl extends AbstractClientApplicationServiceImpl
+public class SAML2ServiceProviderServiceImpl
+    extends AbstractClientApplicationServiceImpl<SAML2ServiceProviderTO>
     implements SAML2ServiceProviderService {
     
     @Autowired


[syncope] 03/12: resume on auth modules; clean up to base essentials

Posted by mm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mmoayyed pushed a commit to branch SYNCOPE-163-1
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 92d026f76f2e9c652bf6d1be5e8d86304bf086ea
Author: Misagh Moayyed <mm...@gmail.com>
AuthorDate: Mon Feb 24 13:27:37 2020 +0330

    resume on auth modules; clean up to base essentials
---
 .../common/lib/types/AMImplementationType.java     |   8 +-
 .../AbstractAuthenticationModuleConf.java          |  63 ----------
 .../AbstractAuthenticationPolicyConf.java          |  53 --------
 .../authentication/AuthenticationModuleConf.java   |  40 ------
 .../authentication/AuthenticationPolicyConf.java   |  33 -----
 .../ChainAuthenticationPolicyConf.java             |  30 -----
 .../DefaultAuthenticationModuleConf.java           |  31 -----
 .../DefaultAuthenticationPolicyConf.java           |  59 ---------
 .../FlowableAuthenticationPolicyConf.java          |  30 -----
 .../api/dao/AuthenticationModuleRule.java          |  33 -----
 .../api/dao/AuthenticationModuleRuleConfClass.java |  32 -----
 .../api/dao/AuthenticationPolicyRule.java          |  33 -----
 .../api/dao/AuthenticationPolicyRuleConfClass.java |  32 -----
 .../api/dao/AuthenticationPostProcessorRule.java   |  23 ----
 .../AuthenticationPostProcessorRuleConfClass.java  |  23 ----
 .../api/dao/AuthenticationPreProcessorRule.java    |  30 -----
 .../AuthenticationPreProcessorRuleConfClass.java   |  23 ----
 .../core/persistence/api/dao/PolicyDAO.java        |   3 -
 .../AuthenticationModuleDAO.java                   |  13 +-
 .../authentication/AuthenticationPolicyDAO.java}   |  22 ++--
 .../OpenIdConnectRelyingPartyDAO.java}             |  29 +++--
 .../SAML2ServiceProviderDAO.java}                  |  27 ++--
 .../syncope/core/persistence/api/entity/Realm.java |  22 ++--
 .../authentication/AuthenticationModule.java       |  14 +--
 .../AuthenticationPostProcessor.java               |  37 ------
 ...enticationChain.java => ClientApplication.java} |   9 +-
 ...ocessor.java => OpenIdConnectRelyingParty.java} |  20 +--
 .../SAML2ServiceProvider.java}                     |  13 +-
 .../api/entity/policy/AuthenticationPolicy.java    |  37 ------
 .../jpa/dao/JPAAuthenticationChainDAO.java         |  76 ------------
 .../jpa/dao/JPAAuthenticationProcessorDAO.java     |  82 ------------
 .../core/persistence/jpa/dao/JPAPolicyDAO.java     |  12 --
 .../JPAAuthenticationModuleDAO.java                |  27 ++--
 .../authentication/JPAAuthenticationPolicyDAO.java |  69 +++++++++++
 .../authentication/JPAClientApplicationDAO.java    |  69 +++++++++++
 .../JPAOpenIdConnectRelyingPartyDAO.java           | 112 +++++++++++++++++
 .../authentication/JPASAML2ServiceProviderDAO.java | 112 +++++++++++++++++
 .../persistence/jpa/entity/JPAEntityFactory.java   | 114 ++++++++---------
 .../core/persistence/jpa/entity/JPARealm.java      |  54 +++-----
 .../authentication/JPAAuthenticationModule.java    |  57 +--------
 .../JPAAuthenticationPostProcessor.java            |  91 --------------
 .../JPAAuthenticationPreProcessor.java             |  64 ----------
 ...hain.java => JPAOpenIdConnectRelyingParty.java} |  93 ++++++++------
 ...Processor.java => JPASAML2ServiceProvider.java} |  69 +++++++----
 .../jpa/entity/policy/JPAAccessPolicy.java         |  33 -----
 .../jpa/entity/policy/JPAAuthenticationPolicy.java | 137 +--------------------
 .../jpa/inner/AuthenticationChainTest.java         | 104 ----------------
 .../jpa/inner/AuthenticationModuleTest.java        |  25 +---
 .../jpa/inner/AuthenticationPolicyTest.java        |  79 ++++++++++++
 .../jpa/inner/AuthenticationProcessorTest.java     | 130 -------------------
 .../persistence/jpa/inner/ImplementationTest.java  |  14 +--
 .../core/persistence/jpa/inner/PolicyTest.java     |  92 +++-----------
 .../src/test/resources/domains/MasterContent.xml   |  32 +----
 53 files changed, 746 insertions(+), 1823 deletions(-)

diff --git a/common/am/lib/src/main/java/org/apache/syncope/common/lib/types/AMImplementationType.java b/common/am/lib/src/main/java/org/apache/syncope/common/lib/types/AMImplementationType.java
index d54bc1b..e2efc2c 100644
--- a/common/am/lib/src/main/java/org/apache/syncope/common/lib/types/AMImplementationType.java
+++ b/common/am/lib/src/main/java/org/apache/syncope/common/lib/types/AMImplementationType.java
@@ -19,13 +19,7 @@
 package org.apache.syncope.common.lib.types;
 
 public final class AMImplementationType {
-
-    public static final String AUTH_CHAIN_RULES = "AUTH_CHAIN_RULES";
-
-    public static final String AUTH_POST_PROCESSING = "AUTH_POST_PROCESSING";
-
-    public static final String AUTH_PRE_PROCESSING = "AUTH_PRE_PROCESSING";
-
+    
     public static final String AUTH_MODULE_CONFIGURATIONS = "AUTH_MODULE_CONFIGURATIONS";
 
     public static final String AUTH_POLICY_CONFIGURATIONS = "AUTH_POLICY_CONFIGURATIONS";
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AbstractAuthenticationModuleConf.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AbstractAuthenticationModuleConf.java
deleted file mode 100644
index c8b8e5c..0000000
--- a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AbstractAuthenticationModuleConf.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.common.lib.authentication;
-
-import java.io.Serializable;
-import javax.xml.bind.annotation.XmlSeeAlso;
-import javax.xml.bind.annotation.XmlType;
-import org.apache.commons.lang3.StringUtils;
-
-@XmlType
-@XmlSeeAlso({ DefaultAuthenticationModuleConf.class })
-public abstract class AbstractAuthenticationModuleConf implements Serializable, AuthenticationModuleConf {
-
-    private static final long serialVersionUID = 4153200197344709778L;
-
-    private String name;
-    
-    private int authenticationLevel;
-
-    public AbstractAuthenticationModuleConf() {
-        this(StringUtils.EMPTY);
-        setName(getClass().getName());
-    }
-
-    public AbstractAuthenticationModuleConf(final String name) {
-        super();
-        this.name = name;
-    }
-
-    @Override
-    public final String getName() {
-        return name;
-    }
-
-    public final void setName(final String name) {
-        this.name = name;
-    }
-
-    @Override
-    public int getAuthenticationLevel() {
-        return authenticationLevel;
-    }
-
-    public void setAuthenticationLevel(final int authenticationLevel) {
-        this.authenticationLevel = authenticationLevel;
-    }
-}
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AbstractAuthenticationPolicyConf.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AbstractAuthenticationPolicyConf.java
deleted file mode 100644
index 9db030d..0000000
--- a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AbstractAuthenticationPolicyConf.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.common.lib.authentication;
-
-import java.io.Serializable;
-import javax.xml.bind.annotation.XmlSeeAlso;
-import javax.xml.bind.annotation.XmlType;
-import org.apache.commons.lang3.StringUtils;
-
-@XmlType
-@XmlSeeAlso({ DefaultAuthenticationPolicyConf.class, ChainAuthenticationPolicyConf.class,
-    FlowableAuthenticationPolicyConf.class })
-public abstract class AbstractAuthenticationPolicyConf implements Serializable, AuthenticationPolicyConf {
-
-    private static final long serialVersionUID = 9185127128182430142L;
-
-    private String name;
-
-    public AbstractAuthenticationPolicyConf() {
-        this(StringUtils.EMPTY);
-        setName(getClass().getName());
-    }
-
-    public AbstractAuthenticationPolicyConf(final String name) {
-        super();
-        this.name = name;
-    }
-
-    @Override
-    public final String getName() {
-        return name;
-    }
-
-    public final void setName(final String name) {
-        this.name = name;
-    }
-}
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AuthenticationModuleConf.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AuthenticationModuleConf.java
deleted file mode 100644
index 71348e1..0000000
--- a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AuthenticationModuleConf.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.common.lib.authentication;
-
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-import java.io.Serializable;
-
-@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
-public interface AuthenticationModuleConf extends Serializable {
-
-    /**
-     * Give name of related authentication module instance.
-     *
-     * @return name of this authentication module instance
-     */
-    String getName();
-
-    /**
-     * Give authentication level of related authentication module instance.
-     *
-     * @return authentication level of this authentication module instance
-     */
-    int getAuthenticationLevel();
-}
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AuthenticationPolicyConf.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AuthenticationPolicyConf.java
deleted file mode 100644
index d8d3e4b..0000000
--- a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/AuthenticationPolicyConf.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.common.lib.authentication;
-
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-import java.io.Serializable;
-
-@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
-public interface AuthenticationPolicyConf extends Serializable {
-
-    /**
-     * Give name of related authentication policy instance.
-     *
-     * @return name of this authentication policy instance
-     */
-    String getName();
-}
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/ChainAuthenticationPolicyConf.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/ChainAuthenticationPolicyConf.java
deleted file mode 100644
index 171f892..0000000
--- a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/ChainAuthenticationPolicyConf.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.common.lib.authentication;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-@XmlRootElement(name = "chainAuthenticationPolicyConf")
-@XmlType
-public class ChainAuthenticationPolicyConf extends AbstractAuthenticationPolicyConf {
-
-    private static final long serialVersionUID = -984521961849586727L;
-
-}
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/DefaultAuthenticationModuleConf.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/DefaultAuthenticationModuleConf.java
deleted file mode 100644
index 132a64b..0000000
--- a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/DefaultAuthenticationModuleConf.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.common.lib.authentication;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-@XmlRootElement(name = "defaultAuthenticationModuleConf")
-@XmlType
-public class DefaultAuthenticationModuleConf extends AbstractAuthenticationModuleConf {
-
-    private static final long serialVersionUID = -7775771400318503131L;
-    
-    
-}
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/DefaultAuthenticationPolicyConf.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/DefaultAuthenticationPolicyConf.java
deleted file mode 100644
index f4e4d3d..0000000
--- a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/DefaultAuthenticationPolicyConf.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.common.lib.authentication;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.ArrayList;
-import java.util.List;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-@XmlRootElement(name = "defaultAuthenticationPolicyConf")
-@XmlType
-public class DefaultAuthenticationPolicyConf extends AbstractAuthenticationPolicyConf {
-
-    private static final long serialVersionUID = 6021204813821798285L;
-
-    /**
-     * Authentication attribute.
-     */
-    private final List<String> authenticationAttributes = new ArrayList<>();
-
-    /**
-     * Case sensitive.
-     */
-    private boolean caseSensitiveAuthentication;
-
-    public boolean isCaseSensitiveAuthentication() {
-        return caseSensitiveAuthentication;
-    }
-
-    public void setCaseSensitiveAuthentication(final boolean caseSensitiveAuthentication) {
-        this.caseSensitiveAuthentication = caseSensitiveAuthentication;
-    }
-
-    @XmlElementWrapper(name = "authenticationAttributes")
-    @XmlElement(name = "attribute")
-    @JsonProperty("authenticationAttributes")
-    public List<String> getAuthenticationAttributes() {
-        return authenticationAttributes;
-    }
-}
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/FlowableAuthenticationPolicyConf.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/FlowableAuthenticationPolicyConf.java
deleted file mode 100644
index db7a14a..0000000
--- a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/authentication/FlowableAuthenticationPolicyConf.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.common.lib.authentication;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-@XmlRootElement(name = "flowableAuthenticationPolicyConf")
-@XmlType
-public class FlowableAuthenticationPolicyConf extends AbstractAuthenticationPolicyConf {
-
-    private static final long serialVersionUID = -984521961849586727L;
-
-}
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationModuleRule.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationModuleRule.java
deleted file mode 100644
index ca89010..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationModuleRule.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.api.dao;
-
-import org.apache.syncope.common.lib.authentication.AuthenticationPolicyConf;
-
-/**
- * Interface for authentication module rule to be evaluated during authentication.
- */
-public interface AuthenticationModuleRule {
-
-    default void setConf(AuthenticationPolicyConf conf) {
-    }
-    
-    void authenticate();
-
-}
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationModuleRuleConfClass.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationModuleRuleConfClass.java
deleted file mode 100644
index f920a9b..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationModuleRuleConfClass.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.api.dao;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.apache.syncope.common.lib.authentication.AuthenticationModuleConf;
-
-@Target({ ElementType.TYPE })
-@Retention(RetentionPolicy.RUNTIME)
-public @interface AuthenticationModuleRuleConfClass {
-
-    Class<? extends AuthenticationModuleConf> value();
-}
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPolicyRule.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPolicyRule.java
deleted file mode 100644
index 27bd7f6..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPolicyRule.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.api.dao;
-
-import org.apache.syncope.common.lib.authentication.AuthenticationPolicyConf;
-
-/**
- * Interface for authentication policy rule to be evaluated during authentication.
- */
-public interface AuthenticationPolicyRule {
-
-    default void setConf(AuthenticationPolicyConf conf) {
-    }
-
-    void authenticate();
-
-}
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPolicyRuleConfClass.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPolicyRuleConfClass.java
deleted file mode 100644
index a4bc2d3..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPolicyRuleConfClass.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.api.dao;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.apache.syncope.common.lib.authentication.AuthenticationPolicyConf;
-
-@Target({ ElementType.TYPE })
-@Retention(RetentionPolicy.RUNTIME)
-public @interface AuthenticationPolicyRuleConfClass {
-
-    Class<? extends AuthenticationPolicyConf> value();
-}
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPostProcessorRule.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPostProcessorRule.java
deleted file mode 100644
index 883a80d..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPostProcessorRule.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.api.dao;
-
-public class AuthenticationPostProcessorRule {
-    
-}
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPostProcessorRuleConfClass.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPostProcessorRuleConfClass.java
deleted file mode 100644
index b002d30..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPostProcessorRuleConfClass.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.api.dao;
-
-public class AuthenticationPostProcessorRuleConfClass {
-    
-}
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPreProcessorRule.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPreProcessorRule.java
deleted file mode 100644
index b097541..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPreProcessorRule.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.api.dao;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target({ ElementType.TYPE })
-@Retention(RetentionPolicy.RUNTIME)
-public @interface AuthenticationPreProcessorRule {
-    
-}
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPreProcessorRuleConfClass.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPreProcessorRuleConfClass.java
deleted file mode 100644
index 040054c..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationPreProcessorRuleConfClass.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.api.dao;
-
-public class AuthenticationPreProcessorRuleConfClass {
-    
-}
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PolicyDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PolicyDAO.java
index 8cedd32..6765030 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PolicyDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PolicyDAO.java
@@ -21,7 +21,6 @@ package org.apache.syncope.core.persistence.api.dao;
 import java.util.List;
 import org.apache.syncope.core.persistence.api.entity.Implementation;
 import org.apache.syncope.core.persistence.api.entity.policy.AccountPolicy;
-import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
 import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
 import org.apache.syncope.core.persistence.api.entity.policy.Policy;
 import org.apache.syncope.core.persistence.api.entity.policy.PullPolicy;
@@ -41,8 +40,6 @@ public interface PolicyDAO extends DAO<Policy> {
     List<PullPolicy> findByPullCorrelationRule(Implementation correlationRule);
 
     List<PushPolicy> findByPushCorrelationRule(Implementation correlationRule);
-    
-    List<AuthenticationPolicy> findByAuthenticationPolicy(Implementation authenticationPolicy);
 
     List<AccountPolicy> findByResource(ExternalResource resource);
 
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationModuleDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/AuthenticationModuleDAO.java
similarity index 82%
rename from core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationModuleDAO.java
rename to core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/AuthenticationModuleDAO.java
index 4d48214..f439da7 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationModuleDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/AuthenticationModuleDAO.java
@@ -6,8 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -15,19 +14,19 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.syncope.core.persistence.api.dao;
+package org.apache.syncope.core.persistence.api.dao.authentication;
 
-import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
+import org.apache.syncope.core.persistence.api.dao.DAO;
 import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationModule;
 
+import java.util.List;
+
 public interface AuthenticationModuleDAO extends DAO<AuthenticationModule> {
 
     AuthenticationModule find(String key);
 
-    List<AuthenticationModule> findByConfiguration(Implementation configuration);
-
     List<AuthenticationModule> findAll();
 
     AuthenticationModule save(AuthenticationModule authenticationModule);
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationProcessor.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/AuthenticationPolicyDAO.java
similarity index 61%
rename from core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationProcessor.java
rename to core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/AuthenticationPolicyDAO.java
index 197fd30..30f4276 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationProcessor.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/AuthenticationPolicyDAO.java
@@ -6,8 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -15,20 +14,25 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.syncope.core.persistence.api.entity.authentication;
+package org.apache.syncope.core.persistence.api.dao.authentication;
 
-import org.apache.syncope.core.persistence.api.entity.Entity;
+import org.apache.syncope.core.persistence.api.dao.DAO;
 import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
 
-public interface AuthenticationProcessor extends Entity {
+import java.util.List;
+
+public interface AuthenticationPolicyDAO extends DAO<AuthenticationPolicy> {
+
+    AuthenticationPolicy find(String key);
 
-    AuthenticationPolicy getAuthenticationPolicy();
+    List<AuthenticationPolicy> findAll();
 
-    String getName();
+    AuthenticationPolicy save(AuthenticationPolicy authenticationModule);
 
-    void setAuthenticationPolicy(AuthenticationPolicy authenticationPolicy);
+    void delete(String key);
 
-    void setName(String name);
+    void delete(AuthenticationPolicy authenticationModule);
 
 }
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationProcessorDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/OpenIdConnectRelyingPartyDAO.java
similarity index 54%
rename from core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationProcessorDAO.java
rename to core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/OpenIdConnectRelyingPartyDAO.java
index 92e40b9..51713eb 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationProcessorDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/OpenIdConnectRelyingPartyDAO.java
@@ -6,8 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -15,21 +14,31 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.syncope.core.persistence.api.dao;
+package org.apache.syncope.core.persistence.api.dao.authentication;
+
+import org.apache.syncope.core.persistence.api.dao.DAO;
+import org.apache.syncope.core.persistence.api.entity.authentication.OpenIdConnectRelyingParty;
 
 import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationProcessor;
 
-public interface AuthenticationProcessorDAO extends DAO<AuthenticationProcessor> {
+public interface OpenIdConnectRelyingPartyDAO extends DAO<OpenIdConnectRelyingParty> {
+
+    OpenIdConnectRelyingParty find(String key);
+
+    OpenIdConnectRelyingParty findByName(String name);
+
+    OpenIdConnectRelyingParty findByClientId(String clientId);
+
+    List<OpenIdConnectRelyingParty> findAll();
 
-    <T extends AuthenticationProcessor> T find(String key);
+    OpenIdConnectRelyingParty save(OpenIdConnectRelyingParty application);
 
-    <T extends AuthenticationProcessor> List<T> find(Class<T> reference);
+    void delete(String key);
 
-    List<AuthenticationProcessor> findAll();
+    void deleteByClientId(String clientId);
 
-    <T extends AuthenticationProcessor> T save(T authenticationProcessor);
+    void delete(OpenIdConnectRelyingParty application);
 
-    <T extends AuthenticationProcessor> void delete(T authenticationProcessor);
 }
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationChainDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/SAML2ServiceProviderDAO.java
similarity index 58%
rename from core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationChainDAO.java
rename to core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/SAML2ServiceProviderDAO.java
index a349844..8807cc5 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/AuthenticationChainDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/authentication/SAML2ServiceProviderDAO.java
@@ -6,8 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -15,25 +14,31 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.syncope.core.persistence.api.dao;
+package org.apache.syncope.core.persistence.api.dao.authentication;
+
+import org.apache.syncope.core.persistence.api.dao.DAO;
+import org.apache.syncope.core.persistence.api.entity.authentication.SAML2ServiceProvider;
 
 import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationChain;
 
-public interface AuthenticationChainDAO extends DAO<AuthenticationChain> {
+public interface SAML2ServiceProviderDAO extends DAO<SAML2ServiceProvider> {
 
-    AuthenticationChain find(String key);
+    SAML2ServiceProvider find(String key);
 
-    List<AuthenticationChain> findByRule(Implementation configuration);
+    SAML2ServiceProvider findByName(String name);
 
-    List<AuthenticationChain> findAll();
+    SAML2ServiceProvider findByEntityId(String clientId);
 
-    AuthenticationChain save(AuthenticationChain authenticationChain);
+    List<SAML2ServiceProvider> findAll();
+
+    SAML2ServiceProvider save(SAML2ServiceProvider application);
 
     void delete(String key);
 
-    void delete(AuthenticationChain authenticationChain);
+    void deleteByEntityId(String entityId);
+
+    void delete(SAML2ServiceProvider application);
 
 }
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Realm.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Realm.java
index 19c4e6c..f579702 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Realm.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Realm.java
@@ -18,36 +18,32 @@
  */
 package org.apache.syncope.core.persistence.api.entity;
 
-import java.util.List;
-import java.util.Optional;
 import org.apache.syncope.core.persistence.api.entity.policy.AccountPolicy;
-import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
 import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
 import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 
+import java.util.List;
+import java.util.Optional;
+
 public interface Realm extends Entity {
 
     String getName();
 
+    void setName(String name);
+
     Realm getParent();
 
+    void setParent(Realm parent);
+
     String getFullPath();
 
     AccountPolicy getAccountPolicy();
 
-    PasswordPolicy getPasswordPolicy();
-    
-    AuthenticationPolicy getAuthenticationPolicy();
-
-    void setName(String name);
-
-    void setParent(Realm parent);
-
     void setAccountPolicy(AccountPolicy accountPolicy);
 
+    PasswordPolicy getPasswordPolicy();
+
     void setPasswordPolicy(PasswordPolicy passwordPolicy);
-    
-    void setAuthenticationPolicy(AuthenticationPolicy authenticationPolicy);
 
     boolean add(Implementation action);
 
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationModule.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationModule.java
index d1bf6b3..505df4f 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationModule.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationModule.java
@@ -18,23 +18,11 @@
  */
 package org.apache.syncope.core.persistence.api.entity.authentication;
 
-import java.util.List;
-import org.apache.syncope.common.lib.types.TraceLevel;
 import org.apache.syncope.core.persistence.api.entity.Entity;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
 
 public interface AuthenticationModule extends Entity {
 
-    void setName(String displayName);
-
     String getName();
 
-    List<? extends Implementation> getConfigurations();
-    
-    boolean add(Implementation configuration);
-    
-    TraceLevel getTraceLevel();
-
-    void setTraceLevel(TraceLevel createTraceLevel);
-
+    void setName(String name);
 }
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationPostProcessor.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationPostProcessor.java
deleted file mode 100644
index 09e74cb..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationPostProcessor.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.api.entity.authentication;
-
-import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
-
-public interface AuthenticationPostProcessor extends AuthenticationProcessor {
-
-    String getDefaultSuccessLoginURL();
-
-    String getDefaultFailureLoginURL();
-
-    List<? extends Implementation> getAuthenticationPostProcessing();
-
-    void setDefaultSuccessLoginURL(String defaultSuccessLoginURL);
-
-    void setDefaultFailureLoginURL(String defaultFailureLoginURL);
-
-    boolean addAuthPostProcessing(Implementation authPostProcessing);
-}
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationChain.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/ClientApplication.java
similarity index 80%
rename from core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationChain.java
rename to core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/ClientApplication.java
index e2c5b2a..def140c 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationChain.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/ClientApplication.java
@@ -18,11 +18,9 @@
  */
 package org.apache.syncope.core.persistence.api.entity.authentication;
 
-import java.util.List;
 import org.apache.syncope.core.persistence.api.entity.Entity;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
 
-public interface AuthenticationChain extends Entity {
+public interface ClientApplication extends Entity {
 
     String getName();
 
@@ -31,9 +29,4 @@ public interface AuthenticationChain extends Entity {
     String getDescription();
 
     void setDescription(String description);
-
-    boolean add(Implementation configuration);
-
-    List<? extends Implementation> getConfigurations();
-
 }
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationPreProcessor.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/OpenIdConnectRelyingParty.java
similarity index 71%
rename from core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationPreProcessor.java
rename to core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/OpenIdConnectRelyingParty.java
index aa41d65..6ad2cc5 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/AuthenticationPreProcessor.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/OpenIdConnectRelyingParty.java
@@ -6,8 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -15,16 +14,23 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
+
 package org.apache.syncope.core.persistence.api.entity.authentication;
 
 import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
 
-public interface AuthenticationPreProcessor extends AuthenticationProcessor {
+public interface OpenIdConnectRelyingParty extends ClientApplication {
+    void setClientId(String id);
+
+    String getClientId();
+
+    void setClientSecret(String secret);
+
+    String getClientSecret();
 
-    List<? extends Implementation> getAuthenticationPreProcessing();
-    
-    boolean addAuthPreProcessing(Implementation authPreProcessing);
+    List<String> getRedirectUris();
 
+    void setRedirectUris(List<String> uris);
 }
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AccessPolicy.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/SAML2ServiceProvider.java
similarity index 70%
rename from core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AccessPolicy.java
rename to core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/SAML2ServiceProvider.java
index 2cb30d6..f42a30f 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AccessPolicy.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/authentication/SAML2ServiceProvider.java
@@ -6,8 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -15,11 +14,17 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.syncope.core.persistence.api.entity.policy;
 
-public interface AccessPolicy extends Policy {
+package org.apache.syncope.core.persistence.api.entity.authentication;
+
+public interface SAML2ServiceProvider extends ClientApplication {
+    String getEntityId();
 
+    void setEntityId(String id);
 
+    String getMetadataLocation();
 
+    void setMetadataLocation(String location);
 }
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AuthenticationPolicy.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AuthenticationPolicy.java
index 20df9a6..774e83c 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AuthenticationPolicy.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/policy/AuthenticationPolicy.java
@@ -18,46 +18,9 @@
  */
 package org.apache.syncope.core.persistence.api.entity.policy;
 
-import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationPostProcessor;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationPreProcessor;
-
 public interface AuthenticationPolicy extends Policy {
 
     String getName();
 
-    List<? extends Implementation> getConfigurations();
-
-    int getMaxAuthenticationAttempts();
-
-    int getAuthenticationAttemptsInterval();
-
-    int getAuthenticationFailureLockoutDuration();
-
-    String getLockoutAttributeName();
-
-    String getLockoutAttributeValue();
-
-    AuthenticationPostProcessor getAuthenticationPostProcessor();
-
-    AuthenticationPreProcessor getAuthenticationPreProcessor();
-
     void setName(String name);
-
-    boolean addConfiguration(Implementation configuration);
-
-    void setMaxAuthenticationAttempts(int maxAuthenticationAttempts);
-
-    void setAuthenticationAttemptsInterval(int authenticationAttemptsInterval);
-
-    void setAuthenticationFailureLockoutDuration(int authenticationFailureLockoutDuration);
-
-    void setLockoutAttributeName(String lockoutAttributeName);
-
-    void setLockoutAttributeValue(String lockoutAttributeValue);
-
-    void setAuthenticationPostProcessor(AuthenticationPostProcessor authenticationPostProcessor);
-
-    void setAuthenticationPreProcessor(AuthenticationPreProcessor authenticationPreProcessor);
 }
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAuthenticationChainDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAuthenticationChainDAO.java
deleted file mode 100644
index f50c1a5..0000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAuthenticationChainDAO.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.dao;
-
-import java.util.List;
-import javax.persistence.TypedQuery;
-import org.apache.syncope.core.persistence.api.dao.AuthenticationChainDAO;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationChain;
-import org.apache.syncope.core.persistence.jpa.entity.authentication.JPAAuthenticationChain;
-import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Transactional;
-
-@Repository
-public class JPAAuthenticationChainDAO extends AbstractDAO<AuthenticationChain> implements AuthenticationChainDAO {
-
-    @Override
-    public AuthenticationChain find(final String key) {
-        return entityManager().find(JPAAuthenticationChain.class, key);
-    }
-
-    @Override
-    public List<AuthenticationChain> findByRule(final Implementation configuration) {
-        TypedQuery<AuthenticationChain> query = entityManager().createQuery(
-                "SELECT e FROM " + JPAAuthenticationChain.class.getSimpleName() + " e "
-                + "WHERE :rule MEMBER OF e.rules", AuthenticationChain.class);
-        query.setParameter("rule", configuration);
-        return query.getResultList();
-    }
-
-    @Transactional(readOnly = true)
-    @Override
-    public List<AuthenticationChain> findAll() {
-        TypedQuery<AuthenticationChain> query = entityManager().createQuery(
-                "SELECT e FROM " + JPAAuthenticationChain.class.getSimpleName() + " e", AuthenticationChain.class);
-
-        return query.getResultList();
-    }
-
-    @Override
-    public AuthenticationChain save(final AuthenticationChain authenticationChain) {
-        return entityManager().merge(authenticationChain);
-    }
-
-    @Override
-    public void delete(final String key) {
-        AuthenticationChain authenticationChain = find(key);
-        if (authenticationChain == null) {
-            return;
-        }
-
-        delete(authenticationChain);
-    }
-
-    @Override
-    public void delete(final AuthenticationChain authenticationChain) {
-        entityManager().remove(authenticationChain);
-    }
-
-}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAuthenticationProcessorDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAuthenticationProcessorDAO.java
deleted file mode 100644
index 1ae4bac..0000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAuthenticationProcessorDAO.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.dao;
-
-import java.util.List;
-import javax.persistence.TypedQuery;
-import org.apache.syncope.core.persistence.api.dao.AuthenticationProcessorDAO;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationPostProcessor;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationPreProcessor;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationProcessor;
-import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
-import org.apache.syncope.core.persistence.jpa.entity.authentication.AbstractAuthenticationProcessor;
-import org.apache.syncope.core.persistence.jpa.entity.authentication.JPAAuthenticationPostProcessor;
-import org.apache.syncope.core.persistence.jpa.entity.authentication.JPAAuthenticationPreProcessor;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public class JPAAuthenticationProcessorDAO extends AbstractDAO<AuthenticationProcessor> implements
-        AuthenticationProcessorDAO {
-
-    private <T extends AuthenticationProcessor> Class<? extends AbstractAuthenticationProcessor> getEntityReference(
-            final Class<T> reference) {
-        return AuthenticationPreProcessor.class.isAssignableFrom(reference)
-                ? JPAAuthenticationPreProcessor.class
-                : AuthenticationPostProcessor.class.isAssignableFrom(reference)
-                ? JPAAuthenticationPostProcessor.class
-                : null;
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public <T extends AuthenticationProcessor> T find(final String key) {
-        return (T) entityManager().find(AbstractAuthenticationProcessor.class, key);
-    }
-
-    @Override
-    public <T extends AuthenticationProcessor> List<T> find(final Class<T> reference) {
-        TypedQuery<T> query = entityManager().createQuery(
-                "SELECT e FROM " + getEntityReference(reference).getSimpleName() + " e", reference);
-
-        return query.getResultList();
-    }
-
-    public List<AuthenticationProcessor> findAll() {
-        TypedQuery<AuthenticationProcessor> query = entityManager().createQuery(
-                "SELECT e FROM " + AbstractAuthenticationProcessor.class.getSimpleName()
-                + " e", AuthenticationProcessor.class);
-        return query.getResultList();
-    }
-
-    @Override
-    public <T extends AuthenticationProcessor> T save(final T authenticationProcessor) {
-        return entityManager().merge(authenticationProcessor);
-    }
-
-    @Override
-    public <T extends AuthenticationProcessor> void delete(final T authenticationProcessor) {
-        AuthenticationPolicy policy = authenticationProcessor.getAuthenticationPolicy();
-        if (authenticationProcessor instanceof AuthenticationPreProcessor) {
-            policy.setAuthenticationPreProcessor(null);
-        } else {
-            policy.setAuthenticationPostProcessor(null);
-        }
-        entityManager().remove(authenticationProcessor);
-    }
-}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPolicyDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPolicyDAO.java
index 4773ae9..2b26627 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPolicyDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPolicyDAO.java
@@ -123,16 +123,6 @@ public class JPAPolicyDAO extends AbstractDAO<Policy> implements PolicyDAO {
     }
 
     @Override
-    public List<AuthenticationPolicy> findByAuthenticationPolicy(final Implementation authenticationRule) {
-        TypedQuery<AuthenticationPolicy> query = entityManager().createQuery(
-                "SELECT e FROM " + JPAAuthenticationPolicy.class.getSimpleName() + " e "
-                + "WHERE :authenticationRule MEMBER OF e.configurations", AuthenticationPolicy.class);
-        query.setParameter("authenticationRule", authenticationRule);
-
-        return query.getResultList();
-    }
-
-    @Override
     public List<AccountPolicy> findByResource(final ExternalResource resource) {
         TypedQuery<AccountPolicy> query = entityManager().createQuery(
                 "SELECT e FROM " + JPAAccountPolicy.class.getSimpleName() + " e "
@@ -161,8 +151,6 @@ public class JPAPolicyDAO extends AbstractDAO<Policy> implements PolicyDAO {
                 realm.setAccountPolicy(null);
             } else if (policy instanceof PasswordPolicy) {
                 realm.setPasswordPolicy(null);
-            } else if (policy instanceof AuthenticationPolicy) {
-                realm.setAuthenticationPolicy(null);
             }
         });
 
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAuthenticationModuleDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAAuthenticationModuleDAO.java
similarity index 72%
rename from core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAuthenticationModuleDAO.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAAuthenticationModuleDAO.java
index 99d335d..f298152 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAuthenticationModuleDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAAuthenticationModuleDAO.java
@@ -6,8 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -15,18 +14,21 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.syncope.core.persistence.jpa.dao;
+package org.apache.syncope.core.persistence.jpa.dao.authentication;
 
-import java.util.List;
-import javax.persistence.TypedQuery;
-import org.apache.syncope.core.persistence.api.dao.AuthenticationModuleDAO;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
+import org.apache.syncope.core.persistence.api.dao.authentication.AuthenticationModuleDAO;
 import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationModule;
+import org.apache.syncope.core.persistence.jpa.dao.AbstractDAO;
 import org.apache.syncope.core.persistence.jpa.entity.authentication.JPAAuthenticationModule;
 import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.persistence.TypedQuery;
+
+import java.util.List;
+
 @Repository
 public class JPAAuthenticationModuleDAO extends AbstractDAO<AuthenticationModule> implements AuthenticationModuleDAO {
 
@@ -35,20 +37,11 @@ public class JPAAuthenticationModuleDAO extends AbstractDAO<AuthenticationModule
         return entityManager().find(JPAAuthenticationModule.class, key);
     }
 
-    @Override
-    public List<AuthenticationModule> findByConfiguration(final Implementation configuration) {
-        TypedQuery<AuthenticationModule> query = entityManager().createQuery(
-                "SELECT e FROM " + JPAAuthenticationModule.class.getSimpleName() + " e "
-                + "WHERE :configuration MEMBER OF e.configurations", AuthenticationModule.class);
-        query.setParameter("configuration", configuration);
-        return query.getResultList();
-    }
-
     @Transactional(readOnly = true)
     @Override
     public List<AuthenticationModule> findAll() {
         TypedQuery<AuthenticationModule> query = entityManager().createQuery(
-                "SELECT e FROM " + JPAAuthenticationModule.class.getSimpleName() + " e", AuthenticationModule.class);
+            "SELECT e FROM " + JPAAuthenticationModule.class.getSimpleName() + " e", AuthenticationModule.class);
 
         return query.getResultList();
     }
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAAuthenticationPolicyDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAAuthenticationPolicyDAO.java
new file mode 100644
index 0000000..388b7f2
--- /dev/null
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAAuthenticationPolicyDAO.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.syncope.core.persistence.jpa.dao.authentication;
+
+import org.apache.syncope.core.persistence.api.dao.authentication.AuthenticationPolicyDAO;
+import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
+import org.apache.syncope.core.persistence.jpa.dao.AbstractDAO;
+import org.apache.syncope.core.persistence.jpa.entity.policy.JPAAuthenticationPolicy;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.persistence.TypedQuery;
+
+import java.util.List;
+
+@Repository
+public class JPAAuthenticationPolicyDAO extends AbstractDAO<AuthenticationPolicy> implements AuthenticationPolicyDAO {
+
+    @Override
+    public AuthenticationPolicy find(final String key) {
+        return entityManager().find(JPAAuthenticationPolicy.class, key);
+    }
+
+    @Transactional(readOnly = true)
+    @Override
+    public List<AuthenticationPolicy> findAll() {
+        TypedQuery<AuthenticationPolicy> query = entityManager().createQuery(
+            "SELECT e FROM " + JPAAuthenticationPolicy.class.getSimpleName() + " e", AuthenticationPolicy.class);
+
+        return query.getResultList();
+    }
+
+    @Override
+    public AuthenticationPolicy save(final AuthenticationPolicy policy) {
+        return entityManager().merge(policy);
+    }
+
+    @Override
+    public void delete(final String key) {
+        AuthenticationPolicy policy = find(key);
+        if (policy == null) {
+            return;
+        }
+
+        delete(policy);
+    }
+
+    @Override
+    public void delete(final AuthenticationPolicy policy) {
+        entityManager().remove(policy);
+    }
+
+}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAClientApplicationDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAClientApplicationDAO.java
new file mode 100644
index 0000000..7e8d1ce
--- /dev/null
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAClientApplicationDAO.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.syncope.core.persistence.jpa.dao.authentication;
+
+import org.apache.syncope.core.persistence.api.dao.authentication.AuthenticationPolicyDAO;
+import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
+import org.apache.syncope.core.persistence.jpa.dao.AbstractDAO;
+import org.apache.syncope.core.persistence.jpa.entity.policy.JPAAuthenticationPolicy;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.persistence.TypedQuery;
+
+import java.util.List;
+
+@Repository
+public class JPAClientApplicationDAO extends AbstractDAO<AuthenticationPolicy> implements AuthenticationPolicyDAO {
+
+    @Override
+    public AuthenticationPolicy find(final String key) {
+        return entityManager().find(JPAAuthenticationPolicy.class, key);
+    }
+
+    @Transactional(readOnly = true)
+    @Override
+    public List<AuthenticationPolicy> findAll() {
+        TypedQuery<AuthenticationPolicy> query = entityManager().createQuery(
+            "SELECT e FROM " + JPAAuthenticationPolicy.class.getSimpleName() + " e", AuthenticationPolicy.class);
+
+        return query.getResultList();
+    }
+
+    @Override
+    public AuthenticationPolicy save(final AuthenticationPolicy policy) {
+        return entityManager().merge(policy);
+    }
+
+    @Override
+    public void delete(final String key) {
+        AuthenticationPolicy policy = find(key);
+        if (policy == null) {
+            return;
+        }
+
+        delete(policy);
+    }
+
+    @Override
+    public void delete(final AuthenticationPolicy policy) {
+        entityManager().remove(policy);
+    }
+
+}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAOpenIdConnectRelyingPartyDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAOpenIdConnectRelyingPartyDAO.java
new file mode 100644
index 0000000..b6b3355
--- /dev/null
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPAOpenIdConnectRelyingPartyDAO.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.core.persistence.jpa.dao.authentication;
+
+import org.apache.syncope.core.persistence.api.dao.authentication.OpenIdConnectRelyingPartyDAO;
+import org.apache.syncope.core.persistence.api.entity.authentication.OpenIdConnectRelyingParty;
+import org.apache.syncope.core.persistence.jpa.dao.AbstractDAO;
+import org.apache.syncope.core.persistence.jpa.entity.authentication.JPAOpenIdConnectRelyingParty;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.persistence.NoResultException;
+import javax.persistence.TypedQuery;
+
+import java.util.List;
+
+@Repository
+public class JPAOpenIdConnectRelyingPartyDAO extends AbstractDAO<OpenIdConnectRelyingParty>
+    implements OpenIdConnectRelyingPartyDAO {
+
+    @Override
+    public OpenIdConnectRelyingParty find(final String key) {
+        return entityManager().find(JPAOpenIdConnectRelyingParty.class, key);
+    }
+
+    @Override
+    public OpenIdConnectRelyingParty findByName(final String name) {
+        TypedQuery<OpenIdConnectRelyingParty> query = entityManager().createQuery(
+            "SELECT e FROM " + JPAOpenIdConnectRelyingParty.class.getSimpleName() + " e WHERE e.name=:name", OpenIdConnectRelyingParty.class);
+        query.setParameter("name", name);
+
+        OpenIdConnectRelyingParty result = null;
+        try {
+            result = query.getSingleResult();
+        } catch (NoResultException e) {
+            LOG.debug("No OpenIdConnectRelyingParty found with name {}", name, e);
+        }
+
+        return result;
+    }
+
+    @Override
+    public OpenIdConnectRelyingParty findByClientId(final String clientId) {
+        TypedQuery<OpenIdConnectRelyingParty> query = entityManager().createQuery(
+            "SELECT e FROM " + JPAOpenIdConnectRelyingParty.class.getSimpleName() + " e WHERE e.clientId=:clientId", OpenIdConnectRelyingParty.class);
+        query.setParameter(clientId, clientId);
+
+        OpenIdConnectRelyingParty result = null;
+        try {
+            result = query.getSingleResult();
+        } catch (NoResultException e) {
+            LOG.debug("No OpenIdConnectRelyingParty found with clientId {}", clientId, e);
+        }
+
+        return result;
+    }
+
+    @Transactional(readOnly = true)
+    @Override
+    public List<OpenIdConnectRelyingParty> findAll() {
+        TypedQuery<OpenIdConnectRelyingParty> query = entityManager().createQuery(
+            "SELECT e FROM " + JPAOpenIdConnectRelyingParty.class.getSimpleName() + " e", OpenIdConnectRelyingParty.class);
+
+        return query.getResultList();
+    }
+
+    @Override
+    public OpenIdConnectRelyingParty save(final OpenIdConnectRelyingParty policy) {
+        return entityManager().merge(policy);
+    }
+
+    @Override
+    public void delete(final String key) {
+        OpenIdConnectRelyingParty policy = find(key);
+        if (policy == null) {
+            return;
+        }
+
+        delete(policy);
+    }
+
+    @Override
+    public void deleteByClientId(final String clientId) {
+        OpenIdConnectRelyingParty policy = findByClientId(clientId);
+        if (policy == null) {
+            return;
+        }
+        delete(policy);
+    }
+
+    @Override
+    public void delete(final OpenIdConnectRelyingParty policy) {
+        entityManager().remove(policy);
+    }
+}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPASAML2ServiceProviderDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPASAML2ServiceProviderDAO.java
new file mode 100644
index 0000000..1254583
--- /dev/null
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/authentication/JPASAML2ServiceProviderDAO.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.core.persistence.jpa.dao.authentication;
+
+import org.apache.syncope.core.persistence.api.dao.authentication.SAML2ServiceProviderDAO;
+import org.apache.syncope.core.persistence.api.entity.authentication.SAML2ServiceProvider;
+import org.apache.syncope.core.persistence.jpa.dao.AbstractDAO;
+import org.apache.syncope.core.persistence.jpa.entity.authentication.JPASAML2ServiceProvider;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.persistence.NoResultException;
+import javax.persistence.TypedQuery;
+
+import java.util.List;
+
+@Repository
+public class JPASAML2ServiceProviderDAO extends AbstractDAO<SAML2ServiceProvider>
+    implements SAML2ServiceProviderDAO {
+
+    @Override
+    public SAML2ServiceProvider find(final String key) {
+        return entityManager().find(JPASAML2ServiceProvider.class, key);
+    }
+
+    @Override
+    public SAML2ServiceProvider findByName(final String name) {
+        final TypedQuery<SAML2ServiceProvider> query = entityManager().createQuery(
+            "SELECT e FROM " + JPASAML2ServiceProvider.class.getSimpleName() + " e WHERE e.name=:name", SAML2ServiceProvider.class);
+        query.setParameter("name", name);
+
+        SAML2ServiceProvider result = null;
+        try {
+            result = query.getSingleResult();
+        } catch (final NoResultException e) {
+            LOG.debug("No SAML2ServiceProvider found with name {}", name, e);
+        }
+
+        return result;
+    }
+
+    @Override
+    public SAML2ServiceProvider findByEntityId(final String entityId) {
+        final TypedQuery<SAML2ServiceProvider> query = entityManager().createQuery(
+            "SELECT e FROM " + JPASAML2ServiceProvider.class.getSimpleName() + " e WHERE e.entityId=:entityId", SAML2ServiceProvider.class);
+        query.setParameter("entityId", entityId);
+
+        SAML2ServiceProvider result = null;
+        try {
+            result = query.getSingleResult();
+        } catch (final NoResultException e) {
+            LOG.debug("No SAML2ServiceProvider found with clientId {}", entityId, e);
+        }
+
+        return result;
+    }
+
+    @Transactional(readOnly = true)
+    @Override
+    public List<SAML2ServiceProvider> findAll() {
+        final TypedQuery<SAML2ServiceProvider> query = entityManager().createQuery(
+            "SELECT e FROM " + JPASAML2ServiceProvider.class.getSimpleName() + " e", SAML2ServiceProvider.class);
+
+        return query.getResultList();
+    }
+
+    @Override
+    public SAML2ServiceProvider save(final SAML2ServiceProvider policy) {
+        return entityManager().merge(policy);
+    }
+
+    @Override
+    public void delete(final String key) {
+        final SAML2ServiceProvider policy = find(key);
+        if (policy == null) {
+            return;
+        }
+
+        delete(policy);
+    }
+
+    @Override
+    public void deleteByEntityId(final String entityId) {
+        final SAML2ServiceProvider app = findByEntityId(entityId);
+        if (app == null) {
+            return;
+        }
+        delete(app);
+    }
+
+    @Override
+    public void delete(final SAML2ServiceProvider policy) {
+        entityManager().remove(policy);
+    }
+}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java
index 25dc089..1f19263 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java
@@ -19,15 +19,7 @@
 package org.apache.syncope.core.persistence.jpa.entity;
 
 import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
-import org.apache.syncope.core.persistence.jpa.entity.user.JPASecurityQuestion;
 import org.apache.syncope.core.persistence.api.entity.AccessToken;
-import org.apache.syncope.core.persistence.jpa.entity.policy.JPAPasswordPolicy;
-import org.apache.syncope.core.persistence.jpa.entity.policy.JPAPullPolicy;
-import org.apache.syncope.core.persistence.jpa.entity.policy.JPAAccountPolicy;
-import org.apache.syncope.core.persistence.jpa.entity.policy.JPAPushPolicy;
-import org.apache.syncope.core.persistence.jpa.entity.user.JPADynRoleMembership;
-import org.apache.syncope.core.persistence.jpa.entity.resource.JPAExternalResource;
-import org.apache.syncope.core.persistence.api.entity.policy.AccountPolicy;
 import org.apache.syncope.core.persistence.api.entity.AnyAbout;
 import org.apache.syncope.core.persistence.api.entity.AnyTemplateRealm;
 import org.apache.syncope.core.persistence.api.entity.AnyType;
@@ -37,22 +29,25 @@ import org.apache.syncope.core.persistence.api.entity.Batch;
 import org.apache.syncope.core.persistence.api.entity.ConnInstance;
 import org.apache.syncope.core.persistence.api.entity.ConnPoolConf;
 import org.apache.syncope.core.persistence.api.entity.DerSchema;
-import org.apache.syncope.core.persistence.api.entity.user.DynRoleMembership;
+import org.apache.syncope.core.persistence.api.entity.DynRealm;
+import org.apache.syncope.core.persistence.api.entity.DynRealmMembership;
 import org.apache.syncope.core.persistence.api.entity.Entity;
 import org.apache.syncope.core.persistence.api.entity.EntityFactory;
-import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
+import org.apache.syncope.core.persistence.api.entity.GatewayRoute;
+import org.apache.syncope.core.persistence.api.entity.Implementation;
 import org.apache.syncope.core.persistence.api.entity.Logger;
 import org.apache.syncope.core.persistence.api.entity.MailTemplate;
 import org.apache.syncope.core.persistence.api.entity.Notification;
-import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
 import org.apache.syncope.core.persistence.api.entity.PlainSchema;
-import org.apache.syncope.core.persistence.api.entity.policy.PushPolicy;
+import org.apache.syncope.core.persistence.api.entity.Privilege;
 import org.apache.syncope.core.persistence.api.entity.Realm;
 import org.apache.syncope.core.persistence.api.entity.RelationshipType;
+import org.apache.syncope.core.persistence.api.entity.Remediation;
 import org.apache.syncope.core.persistence.api.entity.Report;
 import org.apache.syncope.core.persistence.api.entity.ReportExec;
 import org.apache.syncope.core.persistence.api.entity.ReportTemplate;
 import org.apache.syncope.core.persistence.api.entity.Role;
+import org.apache.syncope.core.persistence.api.entity.SchemaLabel;
 import org.apache.syncope.core.persistence.api.entity.VirSchema;
 import org.apache.syncope.core.persistence.api.entity.anyobject.ADynGroupMembership;
 import org.apache.syncope.core.persistence.api.entity.anyobject.AMembership;
@@ -61,20 +56,40 @@ import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttrUnique
 import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttrValue;
 import org.apache.syncope.core.persistence.api.entity.anyobject.ARelationship;
 import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
+import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationModule;
+import org.apache.syncope.core.persistence.api.entity.authentication.OpenIdConnectRelyingParty;
+import org.apache.syncope.core.persistence.api.entity.authentication.SAML2ServiceProvider;
 import org.apache.syncope.core.persistence.api.entity.group.GPlainAttr;
 import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrUniqueValue;
 import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrValue;
 import org.apache.syncope.core.persistence.api.entity.group.Group;
 import org.apache.syncope.core.persistence.api.entity.group.TypeExtension;
+import org.apache.syncope.core.persistence.api.entity.policy.AccountPolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.PullCorrelationRuleEntity;
+import org.apache.syncope.core.persistence.api.entity.policy.PullPolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.PushCorrelationRuleEntity;
+import org.apache.syncope.core.persistence.api.entity.policy.PushPolicy;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.persistence.api.entity.resource.Mapping;
 import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
+import org.apache.syncope.core.persistence.api.entity.resource.OrgUnit;
+import org.apache.syncope.core.persistence.api.entity.resource.OrgUnitItem;
 import org.apache.syncope.core.persistence.api.entity.resource.Provision;
+import org.apache.syncope.core.persistence.api.entity.task.AnyTemplatePullTask;
 import org.apache.syncope.core.persistence.api.entity.task.NotificationTask;
 import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
+import org.apache.syncope.core.persistence.api.entity.task.PullTask;
 import org.apache.syncope.core.persistence.api.entity.task.PushTask;
 import org.apache.syncope.core.persistence.api.entity.task.PushTaskAnyFilter;
 import org.apache.syncope.core.persistence.api.entity.task.SchedTask;
 import org.apache.syncope.core.persistence.api.entity.task.TaskExec;
+import org.apache.syncope.core.persistence.api.entity.user.DynRoleMembership;
+import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttr;
+import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttrUniqueValue;
+import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttrValue;
+import org.apache.syncope.core.persistence.api.entity.user.LinkedAccount;
 import org.apache.syncope.core.persistence.api.entity.user.SecurityQuestion;
 import org.apache.syncope.core.persistence.api.entity.user.UDynGroupMembership;
 import org.apache.syncope.core.persistence.api.entity.user.UMembership;
@@ -83,6 +98,7 @@ import org.apache.syncope.core.persistence.api.entity.user.UPlainAttrUniqueValue
 import org.apache.syncope.core.persistence.api.entity.user.UPlainAttrValue;
 import org.apache.syncope.core.persistence.api.entity.user.URelationship;
 import org.apache.syncope.core.persistence.api.entity.user.User;
+import org.apache.syncope.core.persistence.jpa.dao.JPAAnySearchDAO;
 import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAADynGroupMembership;
 import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAMembership;
 import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAPlainAttr;
@@ -90,22 +106,41 @@ import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAPlainAttrUni
 import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAPlainAttrValue;
 import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAARelationship;
 import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAnyObject;
+import org.apache.syncope.core.persistence.jpa.entity.authentication.JPAAuthenticationModule;
+import org.apache.syncope.core.persistence.jpa.entity.authentication.JPAOpenIdConnectRelyingParty;
+import org.apache.syncope.core.persistence.jpa.entity.authentication.JPASAML2ServiceProvider;
 import org.apache.syncope.core.persistence.jpa.entity.group.JPAGPlainAttr;
 import org.apache.syncope.core.persistence.jpa.entity.group.JPAGPlainAttrUniqueValue;
 import org.apache.syncope.core.persistence.jpa.entity.group.JPAGPlainAttrValue;
 import org.apache.syncope.core.persistence.jpa.entity.group.JPAGroup;
 import org.apache.syncope.core.persistence.jpa.entity.group.JPATypeExtension;
+import org.apache.syncope.core.persistence.jpa.entity.policy.JPAAccountPolicy;
+import org.apache.syncope.core.persistence.jpa.entity.policy.JPAAuthenticationPolicy;
+import org.apache.syncope.core.persistence.jpa.entity.policy.JPAPasswordPolicy;
+import org.apache.syncope.core.persistence.jpa.entity.policy.JPAPullCorrelationRuleEntity;
+import org.apache.syncope.core.persistence.jpa.entity.policy.JPAPullPolicy;
+import org.apache.syncope.core.persistence.jpa.entity.policy.JPAPushCorrelationRuleEntity;
+import org.apache.syncope.core.persistence.jpa.entity.policy.JPAPushPolicy;
+import org.apache.syncope.core.persistence.jpa.entity.resource.JPAExternalResource;
 import org.apache.syncope.core.persistence.jpa.entity.resource.JPAMapping;
 import org.apache.syncope.core.persistence.jpa.entity.resource.JPAMappingItem;
+import org.apache.syncope.core.persistence.jpa.entity.resource.JPAOrgUnit;
+import org.apache.syncope.core.persistence.jpa.entity.resource.JPAOrgUnitItem;
 import org.apache.syncope.core.persistence.jpa.entity.resource.JPAProvision;
-import org.apache.syncope.core.persistence.jpa.entity.task.JPAPushTaskAnyFilter;
 import org.apache.syncope.core.persistence.jpa.entity.task.JPAAnyTemplatePullTask;
 import org.apache.syncope.core.persistence.jpa.entity.task.JPANotificationTask;
 import org.apache.syncope.core.persistence.jpa.entity.task.JPAPropagationTask;
+import org.apache.syncope.core.persistence.jpa.entity.task.JPAPullTask;
 import org.apache.syncope.core.persistence.jpa.entity.task.JPAPushTask;
+import org.apache.syncope.core.persistence.jpa.entity.task.JPAPushTaskAnyFilter;
 import org.apache.syncope.core.persistence.jpa.entity.task.JPASchedTask;
-import org.apache.syncope.core.persistence.jpa.entity.task.JPAPullTask;
 import org.apache.syncope.core.persistence.jpa.entity.task.JPATaskExec;
+import org.apache.syncope.core.persistence.jpa.entity.user.JPADynRoleMembership;
+import org.apache.syncope.core.persistence.jpa.entity.user.JPALAPlainAttr;
+import org.apache.syncope.core.persistence.jpa.entity.user.JPALAPlainAttrUniqueValue;
+import org.apache.syncope.core.persistence.jpa.entity.user.JPALAPlainAttrValue;
+import org.apache.syncope.core.persistence.jpa.entity.user.JPALinkedAccount;
+import org.apache.syncope.core.persistence.jpa.entity.user.JPASecurityQuestion;
 import org.apache.syncope.core.persistence.jpa.entity.user.JPAUDynGroupMembership;
 import org.apache.syncope.core.persistence.jpa.entity.user.JPAUMembership;
 import org.apache.syncope.core.persistence.jpa.entity.user.JPAUPlainAttr;
@@ -113,45 +148,6 @@ import org.apache.syncope.core.persistence.jpa.entity.user.JPAUPlainAttrUniqueVa
 import org.apache.syncope.core.persistence.jpa.entity.user.JPAUPlainAttrValue;
 import org.apache.syncope.core.persistence.jpa.entity.user.JPAURelationship;
 import org.apache.syncope.core.persistence.jpa.entity.user.JPAUser;
-import org.apache.syncope.core.persistence.api.entity.task.PullTask;
-import org.apache.syncope.core.persistence.api.entity.task.AnyTemplatePullTask;
-import org.apache.syncope.core.persistence.api.entity.policy.PullPolicy;
-import org.apache.syncope.core.persistence.api.entity.resource.OrgUnit;
-import org.apache.syncope.core.persistence.jpa.entity.resource.JPAOrgUnit;
-import org.apache.syncope.core.persistence.api.entity.DynRealm;
-import org.apache.syncope.core.persistence.api.entity.DynRealmMembership;
-import org.apache.syncope.core.persistence.api.entity.GatewayRoute;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.api.entity.Privilege;
-import org.apache.syncope.core.persistence.api.entity.Remediation;
-import org.apache.syncope.core.persistence.api.entity.SchemaLabel;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationChain;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationModule;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationPostProcessor;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationPreProcessor;
-import org.apache.syncope.core.persistence.api.entity.policy.AccessPolicy;
-import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
-import org.apache.syncope.core.persistence.api.entity.resource.OrgUnitItem;
-import org.apache.syncope.core.persistence.jpa.entity.policy.JPAPullCorrelationRuleEntity;
-import org.apache.syncope.core.persistence.jpa.entity.resource.JPAOrgUnitItem;
-import org.apache.syncope.core.persistence.api.entity.policy.PullCorrelationRuleEntity;
-import org.apache.syncope.core.persistence.api.entity.policy.PushCorrelationRuleEntity;
-import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttr;
-import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttrUniqueValue;
-import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttrValue;
-import org.apache.syncope.core.persistence.api.entity.user.LinkedAccount;
-import org.apache.syncope.core.persistence.jpa.dao.JPAAnySearchDAO;
-import org.apache.syncope.core.persistence.jpa.entity.authentication.JPAAuthenticationChain;
-import org.apache.syncope.core.persistence.jpa.entity.authentication.JPAAuthenticationModule;
-import org.apache.syncope.core.persistence.jpa.entity.authentication.JPAAuthenticationPostProcessor;
-import org.apache.syncope.core.persistence.jpa.entity.authentication.JPAAuthenticationPreProcessor;
-import org.apache.syncope.core.persistence.jpa.entity.policy.JPAAccessPolicy;
-import org.apache.syncope.core.persistence.jpa.entity.policy.JPAAuthenticationPolicy;
-import org.apache.syncope.core.persistence.jpa.entity.policy.JPAPushCorrelationRuleEntity;
-import org.apache.syncope.core.persistence.jpa.entity.user.JPALAPlainAttr;
-import org.apache.syncope.core.persistence.jpa.entity.user.JPALAPlainAttrUniqueValue;
-import org.apache.syncope.core.persistence.jpa.entity.user.JPALAPlainAttrValue;
-import org.apache.syncope.core.persistence.jpa.entity.user.JPALinkedAccount;
 import org.apache.syncope.core.spring.security.SecureRandomUtils;
 
 public class JPAEntityFactory implements EntityFactory {
@@ -307,16 +303,12 @@ public class JPAEntityFactory implements EntityFactory {
             result = (E) new JPAGatewayRoute();
         } else if (reference.equals(AuthenticationModule.class)) {
             result = (E) new JPAAuthenticationModule();
-        } else if (reference.equals(AuthenticationChain.class)) {
-            result = (E) new JPAAuthenticationChain();
         } else if (reference.equals(AuthenticationPolicy.class)) {
             result = (E) new JPAAuthenticationPolicy();
-        } else if (reference.equals(AuthenticationPostProcessor.class)) {
-            result = (E) new JPAAuthenticationPostProcessor();
-        } else if (reference.equals(AuthenticationPreProcessor.class)) {
-            result = (E) new JPAAuthenticationPreProcessor();
-        } else if (reference.equals(AccessPolicy.class)) {
-            result = (E) new JPAAccessPolicy();
+        } else if (reference.equals(OpenIdConnectRelyingParty.class)) {
+            result = (E) new JPAOpenIdConnectRelyingParty();
+        } else if (reference.equals(SAML2ServiceProvider.class)) {
+            result = (E) new JPASAML2ServiceProvider();
         } else {
             throw new IllegalArgumentException("Could not find a JPA implementation of " + reference.getName());
         }
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARealm.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARealm.java
index e7b07ac..129fd1c 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARealm.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARealm.java
@@ -18,39 +18,39 @@
  */
 package org.apache.syncope.core.persistence.jpa.entity;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
-import javax.persistence.Cacheable;
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-import javax.persistence.UniqueConstraint;
-import javax.validation.constraints.Size;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.common.lib.types.IdRepoImplementationType;
 import org.apache.syncope.core.persistence.api.entity.AnyTemplateRealm;
 import org.apache.syncope.core.persistence.api.entity.AnyType;
 import org.apache.syncope.core.persistence.api.entity.Implementation;
+import org.apache.syncope.core.persistence.api.entity.Realm;
 import org.apache.syncope.core.persistence.api.entity.policy.AccountPolicy;
 import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
-import org.apache.syncope.core.persistence.api.entity.Realm;
-import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
 import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.persistence.jpa.entity.policy.JPAAccountPolicy;
-import org.apache.syncope.core.persistence.jpa.entity.policy.JPAAuthenticationPolicy;
 import org.apache.syncope.core.persistence.jpa.entity.policy.JPAPasswordPolicy;
 import org.apache.syncope.core.persistence.jpa.entity.resource.JPAExternalResource;
 import org.apache.syncope.core.persistence.jpa.validation.entity.RealmCheck;
 
+import javax.persistence.Cacheable;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+import javax.validation.constraints.Size;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
 @Entity
 @Table(name = JPARealm.TABLE, uniqueConstraints =
         @UniqueConstraint(columnNames = { "name", "parent_id" }))
@@ -74,9 +74,6 @@ public class JPARealm extends AbstractGeneratedKeyEntity implements Realm {
     @ManyToOne(fetch = FetchType.EAGER)
     private JPAAccountPolicy accountPolicy;
 
-    @ManyToOne(fetch = FetchType.EAGER)
-    private JPAAuthenticationPolicy authenticationPolicy;
-
     @ManyToMany(fetch = FetchType.EAGER)
     @JoinTable(name = TABLE + "Action",
             joinColumns =
@@ -127,13 +124,6 @@ public class JPARealm extends AbstractGeneratedKeyEntity implements Realm {
     }
 
     @Override
-    public AuthenticationPolicy getAuthenticationPolicy() {
-        return authenticationPolicy == null && getParent() != null
-                ? getParent().getAuthenticationPolicy() 
-                : authenticationPolicy;
-    }
-
-    @Override
     public void setName(final String name) {
         this.name = name;
     }
@@ -157,12 +147,6 @@ public class JPARealm extends AbstractGeneratedKeyEntity implements Realm {
     }
 
     @Override
-    public void setAuthenticationPolicy(final AuthenticationPolicy authenticationPolicy) {
-        checkType(authenticationPolicy, JPAAuthenticationPolicy.class);
-        this.authenticationPolicy = (JPAAuthenticationPolicy) authenticationPolicy;
-    }
-
-    @Override
     public boolean add(final Implementation action) {
         checkType(action, JPAImplementation.class);
         checkImplementationType(action, IdRepoImplementationType.LOGIC_ACTIONS);
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationModule.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationModule.java
index b772443..3a3c523 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationModule.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationModule.java
@@ -18,49 +18,24 @@
  */
 package org.apache.syncope.core.persistence.jpa.entity.authentication;
 
+import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationModule;
+import org.apache.syncope.core.persistence.jpa.entity.AbstractGeneratedKeyEntity;
 
-import java.util.ArrayList;
-import java.util.List;
 import javax.persistence.Column;
 import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
 import javax.persistence.Table;
-import javax.validation.constraints.NotNull;
-import org.apache.syncope.common.lib.types.AMImplementationType;
-import org.apache.syncope.common.lib.types.TraceLevel;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationModule;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractGeneratedKeyEntity;
-import org.apache.syncope.core.persistence.jpa.entity.JPAImplementation;
 
 @Entity
 @Table(name = JPAAuthenticationModule.TABLE)
 public class JPAAuthenticationModule extends AbstractGeneratedKeyEntity implements AuthenticationModule {
 
-    private static final long serialVersionUID = 7422422526695279794L;
-
     public static final String TABLE = "AuthenticationModule";
 
+    private static final long serialVersionUID = 7422422526695279794L;
+
     @Column(unique = true, nullable = false)
     private String name;
 
-    @Enumerated(EnumType.STRING)
-    @NotNull
-    private TraceLevel traceLevel = TraceLevel.FAILURES;
-
-    @ManyToMany(fetch = FetchType.EAGER)
-    @JoinTable(name = TABLE + "Conf",
-            joinColumns =
-            @JoinColumn(name = "authentication_module_id"),
-            inverseJoinColumns =
-            @JoinColumn(name = "implementation_id"))
-    private List<JPAImplementation> configurations = new ArrayList<>();
-
     @Override
     public String getName() {
         return name;
@@ -70,28 +45,4 @@ public class JPAAuthenticationModule extends AbstractGeneratedKeyEntity implemen
     public void setName(final String name) {
         this.name = name;
     }
-
-    @Override
-    public TraceLevel getTraceLevel() {
-        return traceLevel;
-    }
-
-    @Override
-    public List<? extends Implementation> getConfigurations() {
-        return configurations;
-    }
-
-    @Override
-    public void setTraceLevel(final TraceLevel createTraceLevel) {
-        this.traceLevel = createTraceLevel;
-    }
-
-    @Override
-    public boolean add(final Implementation configuration) {
-        checkType(configuration, JPAImplementation.class);
-        checkImplementationType(configuration, AMImplementationType.AUTH_MODULE_CONFIGURATIONS);
-        return configurations.contains((JPAImplementation) configuration)
-                || configurations.add((JPAImplementation) configuration);
-    }
-
 }
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationPostProcessor.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationPostProcessor.java
deleted file mode 100644
index 721194f..0000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationPostProcessor.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.entity.authentication;
-
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
-import javax.persistence.Table;
-import javax.validation.constraints.NotNull;
-import org.apache.syncope.common.lib.types.AMImplementationType;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationPostProcessor;
-import org.apache.syncope.core.persistence.jpa.entity.JPAImplementation;
-
-@Entity
-@Table(name = JPAAuthenticationPostProcessor.TABLE)
-public class JPAAuthenticationPostProcessor 
-        extends AbstractAuthenticationProcessor implements AuthenticationPostProcessor  {
-
-    private static final long serialVersionUID = 8759966056325625080L;
-
-    public static final String TABLE = "AuthenticationPostProcessor";
-
-    @NotNull
-    private String defaultSuccessLoginURL;
-
-    @NotNull
-    private String defaultFailureLoginURL;
-
-    @ManyToMany(fetch = FetchType.EAGER)
-    @JoinTable(name = TABLE + "Actions",
-            joinColumns =
-            @JoinColumn(name = "authentication_post_processor"),
-            inverseJoinColumns =
-            @JoinColumn(name = "implementation_id"))
-    private List<JPAImplementation> authenticationPostProcessing = new ArrayList<>();
-
-    @Override
-    public String getDefaultSuccessLoginURL() {
-        return defaultSuccessLoginURL;
-    }
-
-    @Override
-    public String getDefaultFailureLoginURL() {
-        return defaultFailureLoginURL;
-    }
-
-    @Override
-    public List<? extends Implementation> getAuthenticationPostProcessing() {
-        return authenticationPostProcessing;
-    }
-
-    @Override
-    public void setDefaultSuccessLoginURL(final String defaultSuccessLoginURL) {
-        this.defaultSuccessLoginURL = defaultSuccessLoginURL;
-    }
-
-    @Override
-    public void setDefaultFailureLoginURL(final String defaultFailureLoginURL) {
-        this.defaultFailureLoginURL = defaultFailureLoginURL;
-    }
-
-    @Override
-    public boolean addAuthPostProcessing(final Implementation authPreProcessing) {
-        checkType(authPreProcessing, JPAImplementation.class);
-        checkImplementationType(authPreProcessing, AMImplementationType.AUTH_POST_PROCESSING);
-        return authenticationPostProcessing.contains((JPAImplementation) authPreProcessing)
-                || authenticationPostProcessing.add((JPAImplementation) authPreProcessing);
-    }
-}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationPreProcessor.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationPreProcessor.java
deleted file mode 100644
index 9c36478..0000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationPreProcessor.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.entity.authentication;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
-import javax.persistence.Table;
-import org.apache.syncope.common.lib.types.AMImplementationType;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationPreProcessor;
-import org.apache.syncope.core.persistence.jpa.entity.JPAImplementation;
-
-@Entity
-@Table(name = JPAAuthenticationPreProcessor.TABLE)
-public class JPAAuthenticationPreProcessor 
-        extends AbstractAuthenticationProcessor implements AuthenticationPreProcessor  {
-
-    private static final long serialVersionUID = -3064505653663946579L;
-
-    public static final String TABLE = "AuthenticationPreProcessor";
-
-    @ManyToMany(fetch = FetchType.EAGER)
-    @JoinTable(name = TABLE + "Actions",
-            joinColumns =
-            @JoinColumn(name = "authentication_pre_processor"),
-            inverseJoinColumns =
-            @JoinColumn(name = "implementation_id"))
-    private List<JPAImplementation> authenticationPreProcessing = new ArrayList<>();
-
-    @Override
-    public List<? extends Implementation> getAuthenticationPreProcessing() {
-        return authenticationPreProcessing;
-    }
-
-    @Override
-    public boolean addAuthPreProcessing(final Implementation authPreProcessing) {
-        checkType(authPreProcessing, JPAImplementation.class);
-        checkImplementationType(authPreProcessing, AMImplementationType.AUTH_PRE_PROCESSING);
-        return authenticationPreProcessing.contains((JPAImplementation) authPreProcessing)
-                || authenticationPreProcessing.add((JPAImplementation) authPreProcessing);
-    }
-
-}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationChain.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAOpenIdConnectRelyingParty.java
similarity index 53%
rename from core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationChain.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAOpenIdConnectRelyingParty.java
index b3fffa0..6acd0ea 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAAuthenticationChain.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAOpenIdConnectRelyingParty.java
@@ -6,8 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -15,76 +14,98 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
+
 package org.apache.syncope.core.persistence.jpa.entity.authentication;
 
-import java.util.ArrayList;
-import java.util.List;
+import org.apache.syncope.core.persistence.api.entity.authentication.OpenIdConnectRelyingParty;
+import org.apache.syncope.core.persistence.jpa.entity.AbstractGeneratedKeyEntity;
+
+import javax.persistence.CollectionTable;
 import javax.persistence.Column;
+import javax.persistence.ElementCollection;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
 import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
 import javax.persistence.Table;
-import org.apache.syncope.common.lib.types.AMImplementationType;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationChain;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractGeneratedKeyEntity;
-import org.apache.syncope.core.persistence.jpa.entity.JPAImplementation;
+
+import java.util.ArrayList;
+import java.util.List;
 
 @Entity
-@Table(name = JPAAuthenticationChain.TABLE)
-public class JPAAuthenticationChain extends AbstractGeneratedKeyEntity implements AuthenticationChain {
+@Table(name = JPAOpenIdConnectRelyingParty.TABLE)
+public class JPAOpenIdConnectRelyingParty extends AbstractGeneratedKeyEntity implements OpenIdConnectRelyingParty {
 
-    private static final long serialVersionUID = -1169616553574108334L;
+    public static final String TABLE = "OpenIdConnectRelyingParty";
 
-    public static final String TABLE = "AuthenticationChain";
+    private static final long serialVersionUID = 7422422526695279794L;
 
     @Column(unique = true, nullable = false)
     private String name;
 
-    @Column(unique = false, nullable = true)
+    @Column(unique = true, nullable = false)
     private String description;
 
-    @ManyToMany(fetch = FetchType.EAGER)
-    @JoinTable(name = TABLE + "Conf",
-            joinColumns =
-            @JoinColumn(name = "authentication_chain_id"),
-            inverseJoinColumns =
-            @JoinColumn(name = "implementation_id"))
-    private List<JPAImplementation> configurations = new ArrayList<>();
+    @Column(unique = true, nullable = false)
+    private String clientId;
+
+    @Column
+    private String clientSecret;
+
+    @ElementCollection(fetch = FetchType.EAGER)
+    @Column(name = "redirectUris")
+    @CollectionTable(name = "OpenIdConnectRelyingParty_RedirectUris", joinColumns = @JoinColumn(name = "clientId"))
+    private List<String> redirectUris = new ArrayList<>();
 
     @Override
     public String getName() {
         return name;
+    }    @Override
+    public List<String> getRedirectUris() {
+        return redirectUris;
     }
 
     @Override
-    public String getDescription() {
-        return description;
+    public void setName(final String name) {
+        this.name = name;
+    }    @Override
+    public void setRedirectUris(final List<String> redirectUris) {
+        this.redirectUris = redirectUris;
     }
 
     @Override
-    public List<? extends Implementation> getConfigurations() {
-        return configurations;
+    public String getDescription() {
+        return description;
+    }    @Override
+    public String getClientId() {
+        return clientId;
     }
 
     @Override
-    public void setName(final String name) {
-        this.name = name;
+    public void setDescription(final String description) {
+        this.description = description;
+    }    @Override
+    public void setClientId(final String clientId) {
+        this.clientId = clientId;
     }
 
     @Override
-    public void setDescription(final String description) {
-        this.description = description;
+    public String getClientSecret() {
+        return clientSecret;
     }
 
     @Override
-    public boolean add(final Implementation configuration) {
-        checkType(configuration, JPAImplementation.class);
-        checkImplementationType(configuration, AMImplementationType.AUTH_CHAIN_RULES);
-        return configurations.contains((JPAImplementation) configuration)
-                || configurations.add((JPAImplementation) configuration);
+    public void setClientSecret(final String clientSecret) {
+        this.clientSecret = clientSecret;
     }
+
+
+
+
+
+
+
+
 }
+
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/AbstractAuthenticationProcessor.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPASAML2ServiceProvider.java
similarity index 51%
rename from core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/AbstractAuthenticationProcessor.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPASAML2ServiceProvider.java
index be02256..79de4a2 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/AbstractAuthenticationProcessor.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPASAML2ServiceProvider.java
@@ -6,8 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -15,48 +14,74 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
+
 package org.apache.syncope.core.persistence.jpa.entity.authentication;
 
+import org.apache.syncope.core.persistence.api.entity.authentication.SAML2ServiceProvider;
+import org.apache.syncope.core.persistence.jpa.entity.AbstractGeneratedKeyEntity;
+
 import javax.persistence.Column;
 import javax.persistence.Entity;
-import javax.persistence.Inheritance;
-import javax.persistence.InheritanceType;
-import javax.persistence.OneToOne;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationProcessor;
-import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractGeneratedKeyEntity;
-import org.apache.syncope.core.persistence.jpa.entity.policy.JPAAuthenticationPolicy;
+import javax.persistence.Table;
 
 @Entity
-@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
-public abstract class AbstractAuthenticationProcessor extends AbstractGeneratedKeyEntity
-        implements AuthenticationProcessor {
+@Table(name = JPASAML2ServiceProvider.TABLE)
+public class JPASAML2ServiceProvider extends AbstractGeneratedKeyEntity implements SAML2ServiceProvider {
+    public static final String TABLE = "SAML2ServiceProvider";
 
-    private static final long serialVersionUID = -1419270763197087924L;
+    private static final long serialVersionUID = 6422422526695279794L;
 
     @Column(unique = true, nullable = false)
     private String name;
 
+    @Column(unique = true, nullable = false)
+    private String description;
+
+    @Column(unique = true, nullable = false)
+    private String entityId;
+
+    @Column(nullable = false)
+    private String metadataLocation;
+
     @Override
-    public String getName() {
-        return name;
+    public String getEntityId() {
+        return entityId;
+    }
+
+    @Override
+    public void setEntityId(final String entityId) {
+        this.entityId = entityId;
     }
 
-    @OneToOne(optional = false)
-    private JPAAuthenticationPolicy authenticationPolicy;
+    @Override
+    public String getMetadataLocation() {
+        return metadataLocation;
+    }
 
-    public AuthenticationPolicy getAuthenticationPolicy() {
-        return authenticationPolicy;
+    @Override
+    public void setMetadataLocation(final String metadataLocation) {
+        this.metadataLocation = metadataLocation;
     }
 
-    public void setAuthenticationPolicy(final AuthenticationPolicy authenticationPolicy) {
-        checkType(authenticationPolicy, JPAAuthenticationPolicy.class);
-        this.authenticationPolicy = (JPAAuthenticationPolicy) authenticationPolicy;
+    @Override
+    public String getName() {
+        return name;
     }
 
     @Override
     public void setName(final String name) {
         this.name = name;
     }
+
+    @Override
+    public String getDescription() {
+        return description;
+    }
+
+    @Override
+    public void setDescription(final String description) {
+        this.description = description;
+    }
 }
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAccessPolicy.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAccessPolicy.java
deleted file mode 100644
index 4c6221e..0000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAccessPolicy.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.entity.policy;
-
-import javax.persistence.Entity;
-import javax.persistence.Table;
-import org.apache.syncope.core.persistence.api.entity.policy.AccessPolicy;
-
-@Entity
-@Table(name = JPAAccessPolicy.TABLE)
-public class JPAAccessPolicy extends AbstractPolicy implements AccessPolicy {
-
-    private static final long serialVersionUID = -6284704337579924774L;
-
-    public static final String TABLE = "AccessPolicy";
-
-}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAuthenticationPolicy.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAuthenticationPolicy.java
index 9ea9cea..f43fd7d 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAuthenticationPolicy.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAuthenticationPolicy.java
@@ -18,159 +18,30 @@
  */
 package org.apache.syncope.core.persistence.jpa.entity.policy;
 
-import java.util.ArrayList;
-import java.util.List;
-import javax.persistence.CascadeType;
+import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
+
 import javax.persistence.Column;
 import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
-import javax.persistence.OneToOne;
 import javax.persistence.Table;
-import javax.persistence.UniqueConstraint;
-import org.apache.syncope.common.lib.types.AMImplementationType;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationPostProcessor;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationPreProcessor;
-import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
-import org.apache.syncope.core.persistence.jpa.entity.JPAImplementation;
-import org.apache.syncope.core.persistence.jpa.entity.authentication.JPAAuthenticationPostProcessor;
-import org.apache.syncope.core.persistence.jpa.entity.authentication.JPAAuthenticationPreProcessor;
 
 @Entity
 @Table(name = JPAAuthenticationPolicy.TABLE)
 public class JPAAuthenticationPolicy extends AbstractPolicy implements AuthenticationPolicy {
 
-    private static final long serialVersionUID = -4190607009908888884L;
-
     public static final String TABLE = "AuthenticationPolicy";
 
+    private static final long serialVersionUID = -4190607009908888884L;
+
     @Column(unique = true, nullable = false)
     private String name;
 
-    @ManyToMany(fetch = FetchType.EAGER)
-    @JoinTable(name = TABLE + "Conf",
-            joinColumns =
-            @JoinColumn(name = "authentication_policy_id"),
-            inverseJoinColumns =
-            @JoinColumn(name = "implementation_id"),
-            uniqueConstraints =
-            @UniqueConstraint(columnNames = { "authentication_policy_id", "implementation_id" }))
-    private List<JPAImplementation> configurations = new ArrayList<>();
-
-    private int maxAuthenticationAttempts;
-
-    private int authenticationAttemptsInterval;
-
-    private int authenticationFailureLockoutDuration;
-
-    private String lockoutAttributeName;
-
-    private String lockoutAttributeValue;
-
-    @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy =
-            "authenticationPolicy")
-    private JPAAuthenticationPostProcessor authenticationPostProcessor;
-
-    @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy =
-            "authenticationPolicy")
-    private JPAAuthenticationPreProcessor authenticationPreProcessor;
-
     @Override
     public String getName() {
         return name;
     }
 
     @Override
-    public int getMaxAuthenticationAttempts() {
-        return maxAuthenticationAttempts;
-    }
-
-    @Override
-    public int getAuthenticationAttemptsInterval() {
-        return authenticationAttemptsInterval;
-    }
-
-    @Override
-    public int getAuthenticationFailureLockoutDuration() {
-        return authenticationFailureLockoutDuration;
-    }
-
-    @Override
-    public String getLockoutAttributeName() {
-        return lockoutAttributeName;
-    }
-
-    @Override
-    public String getLockoutAttributeValue() {
-        return lockoutAttributeValue;
-    }
-
-    @Override
-    public AuthenticationPostProcessor getAuthenticationPostProcessor() {
-        return authenticationPostProcessor;
-    }
-
-    @Override
-    public AuthenticationPreProcessor getAuthenticationPreProcessor() {
-        return authenticationPreProcessor;
-    }
-
-    @Override
-    public List<? extends Implementation> getConfigurations() {
-        return configurations;
-    }
-
-    @Override
     public void setName(final String name) {
         this.name = name;
     }
-
-    @Override
-    public void setMaxAuthenticationAttempts(final int maxAuthenticationAttempts) {
-        this.maxAuthenticationAttempts = maxAuthenticationAttempts;
-    }
-
-    @Override
-    public void setAuthenticationAttemptsInterval(final int authenticationAttemptsInterval) {
-        this.authenticationAttemptsInterval = authenticationAttemptsInterval;
-    }
-
-    @Override
-    public void setAuthenticationFailureLockoutDuration(final int authenticationFailureLockoutDuration) {
-        this.authenticationFailureLockoutDuration = authenticationFailureLockoutDuration;
-    }
-
-    @Override
-    public void setLockoutAttributeName(final String lockoutAttributeName) {
-        this.lockoutAttributeName = lockoutAttributeName;
-    }
-
-    @Override
-    public void setLockoutAttributeValue(final String lockoutAttributeValue) {
-        this.lockoutAttributeValue = lockoutAttributeValue;
-    }
-
-    @Override
-    public void setAuthenticationPostProcessor(final AuthenticationPostProcessor authenticationPostProcessor) {
-        checkType(authenticationPostProcessor, JPAAuthenticationPostProcessor.class);
-        this.authenticationPostProcessor = (JPAAuthenticationPostProcessor) authenticationPostProcessor;
-    }
-
-    @Override
-    public void setAuthenticationPreProcessor(final AuthenticationPreProcessor authenticationPreProcessor) {
-        checkType(authenticationPreProcessor, JPAAuthenticationPreProcessor.class);
-        this.authenticationPreProcessor = (JPAAuthenticationPreProcessor) authenticationPreProcessor;
-    }
-
-    @Override
-    public boolean addConfiguration(final Implementation configuration) {
-        checkType(configuration, JPAImplementation.class);
-        checkImplementationType(configuration, AMImplementationType.AUTH_POLICY_CONFIGURATIONS);
-        return configurations.contains((JPAImplementation) configuration)
-                || configurations.add((JPAImplementation) configuration);
-    }
-
 }
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationChainTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationChainTest.java
deleted file mode 100644
index 9ad6716..0000000
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationChainTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.inner;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-import java.util.List;
-import java.util.UUID;
-import org.apache.syncope.common.lib.types.AMImplementationType;
-import org.apache.syncope.common.lib.types.ImplementationEngine;
-import org.apache.syncope.core.persistence.api.dao.AuthenticationChainDAO;
-import org.apache.syncope.core.persistence.api.dao.ImplementationDAO;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationChain;
-import org.apache.syncope.core.persistence.jpa.AbstractTest;
-import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-@Transactional("Master")
-public class AuthenticationChainTest extends AbstractTest {
-
-    @Autowired
-    private AuthenticationChainDAO authenticationChainDAO;
-
-    @Autowired
-    private ImplementationDAO implementationDAO;
-
-    @Test
-    public void find() {
-        AuthenticationChain authenticationChain = authenticationChainDAO.find(
-                "4735ce66-aa3f-416b-b810-9b2c1d25ada7");
-        assertNotNull(authenticationChain);
-
-        authenticationChain = authenticationChainDAO.find(UUID.randomUUID().toString());
-        assertNull(authenticationChain);
-    }
-
-    @Test
-    public void findAll() {
-        List<AuthenticationChain> authenticationChains = authenticationChainDAO.findAll();
-        assertNotNull(authenticationChains);
-        assertEquals(1, authenticationChains.size());
-    }
-
-    @Test
-    public void save() {
-        Implementation authenticationChainRule = entityFactory.newEntity(Implementation.class);
-        authenticationChainRule.setKey(UUID.randomUUID().toString());
-        authenticationChainRule.setEngine(ImplementationEngine.JAVA);
-        authenticationChainRule.setType(AMImplementationType.AUTH_CHAIN_RULES);
-        authenticationChainRule.setBody(POJOHelper.serialize(""));
-
-        int beforeCount = authenticationChainDAO.findAll().size();
-
-        authenticationChainRule = implementationDAO.save(authenticationChainRule);
-
-        assertNotNull(authenticationChainRule);
-        assertNotNull(authenticationChainRule.getKey());
-
-        AuthenticationChain authenticationChain = entityFactory.newEntity(AuthenticationChain.class);
-        authenticationChain.setName("AuthenticationChainTest");
-        authenticationChain.add(authenticationChainRule);
-        authenticationChainDAO.save(authenticationChain);
-
-        assertNotNull(authenticationChain);
-        assertNotNull(authenticationChain.getKey());
-
-        int afterCount = authenticationChainDAO.findAll().size();
-        assertEquals(afterCount, beforeCount + 1);
-    }
-
-    @Test
-    public void delete() {
-        AuthenticationChain authenticationChain = authenticationChainDAO.find(
-                "4735ce66-aa3f-416b-b810-9b2c1d25ada7");
-        assertNotNull(authenticationChain);
-
-        authenticationChainDAO.delete("4735ce66-aa3f-416b-b810-9b2c1d25ada7");
-
-        authenticationChain = authenticationChainDAO.find("4735ce66-aa3f-416b-b810-9b2c1d25ada7");
-        assertNull(authenticationChain);
-    }
-
-}
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationModuleTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationModuleTest.java
index 8802aca..294d7c1 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationModuleTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationModuleTest.java
@@ -24,15 +24,10 @@ import static org.junit.jupiter.api.Assertions.assertNull;
 
 import java.util.List;
 import java.util.UUID;
-import org.apache.syncope.common.lib.types.AMImplementationType;
-import org.apache.syncope.common.lib.types.ImplementationEngine;
-import org.apache.syncope.common.lib.types.TraceLevel;
-import org.apache.syncope.core.persistence.api.dao.AuthenticationModuleDAO;
-import org.apache.syncope.core.persistence.api.dao.ImplementationDAO;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
+
+import org.apache.syncope.core.persistence.api.dao.authentication.AuthenticationModuleDAO;
 import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationModule;
 import org.apache.syncope.core.persistence.jpa.AbstractTest;
-import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -43,9 +38,6 @@ public class AuthenticationModuleTest extends AbstractTest {
     @Autowired
     private AuthenticationModuleDAO authenticationModuleDAO;
 
-    @Autowired
-    private ImplementationDAO implementationDAO;
-
     @Test
     public void find() {
         AuthenticationModule athAuthenticationModule = authenticationModuleDAO.find(
@@ -65,23 +57,10 @@ public class AuthenticationModuleTest extends AbstractTest {
 
     @Test
     public void save() {
-        Implementation authentificationModuleConf = entityFactory.newEntity(Implementation.class);
-        authentificationModuleConf.setKey(UUID.randomUUID().toString());
-        authentificationModuleConf.setEngine(ImplementationEngine.JAVA);
-        authentificationModuleConf.setType(AMImplementationType.AUTH_MODULE_CONFIGURATIONS);
-        authentificationModuleConf.setBody(POJOHelper.serialize(""));
 
         int beforeCount = authenticationModuleDAO.findAll().size();
-
-        authentificationModuleConf = implementationDAO.save(authentificationModuleConf);
-
-        assertNotNull(authentificationModuleConf);
-        assertNotNull(authentificationModuleConf.getKey());
-
         AuthenticationModule authenticationModule = entityFactory.newEntity(AuthenticationModule.class);
         authenticationModule.setName("AuthenticationModuleTest");
-        authenticationModule.setTraceLevel(TraceLevel.FAILURES);
-        authenticationModule.add(authentificationModuleConf);
         authenticationModuleDAO.save(authenticationModule);
 
         assertNotNull(authenticationModule);
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationPolicyTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationPolicyTest.java
new file mode 100644
index 0000000..be9e0de
--- /dev/null
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationPolicyTest.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa.inner;
+
+import org.apache.syncope.core.persistence.api.dao.authentication.AuthenticationPolicyDAO;
+import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
+import org.apache.syncope.core.persistence.jpa.AbstractTest;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+@Transactional("Master")
+public class AuthenticationPolicyTest extends AbstractTest {
+
+    @Autowired
+    private AuthenticationPolicyDAO authenticationPolicyDAO;
+
+    @Test
+    public void find() {
+        AuthenticationPolicy authenticationPolicy = authenticationPolicyDAO.find("b912a0d4-a890-416f-9ab8-84ab077eb028");
+        assertNotNull(authenticationPolicy);
+        authenticationPolicy = authenticationPolicyDAO.find(UUID.randomUUID().toString());
+        assertNull(authenticationPolicy);
+    }
+
+    @Test
+    public void findAll() {
+        List<AuthenticationPolicy> authenticationPolicies = authenticationPolicyDAO.findAll();
+        assertNotNull(authenticationPolicies);
+        assertEquals(1, authenticationPolicies.size());
+    }
+
+    @Test
+    public void save() {
+
+        int beforeCount = authenticationPolicyDAO.findAll().size();
+        AuthenticationPolicy authenticationPolicy = entityFactory.newEntity(AuthenticationPolicy.class);
+        authenticationPolicy.setName("AuthenticationPolicyTest");
+        authenticationPolicy.setDescription("This is a sample authentication policy");
+        authenticationPolicyDAO.save(authenticationPolicy);
+
+        assertNotNull(authenticationPolicy);
+        assertNotNull(authenticationPolicy.getKey());
+
+        int afterCount = authenticationPolicyDAO.findAll().size();
+        assertEquals(afterCount, beforeCount + 1);
+    }
+
+    @Test
+    public void delete() {
+        AuthenticationPolicy authenticationPolicy = authenticationPolicyDAO.find("b912a0d4-a890-416f-9ab8-84ab077eb028");
+        assertNotNull(authenticationPolicy);
+        authenticationPolicyDAO.delete("b912a0d4-a890-416f-9ab8-84ab077eb028");
+        authenticationPolicy = authenticationPolicyDAO.find("b912a0d4-a890-416f-9ab8-84ab077eb028");
+        assertNull(authenticationPolicy);
+    }
+
+}
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationProcessorTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationProcessorTest.java
deleted file mode 100644
index fdc526c..0000000
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AuthenticationProcessorTest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.inner;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-import java.util.List;
-import org.apache.syncope.common.lib.types.AMImplementationType;
-import org.apache.syncope.common.lib.types.ImplementationEngine;
-import org.apache.syncope.core.persistence.api.dao.AuthenticationPolicyRule;
-import org.apache.syncope.core.persistence.api.dao.AuthenticationProcessorDAO;
-import org.apache.syncope.core.persistence.api.dao.ImplementationDAO;
-import org.apache.syncope.core.persistence.api.entity.Implementation;
-import org.apache.syncope.core.persistence.jpa.AbstractTest;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationPostProcessor;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationPreProcessor;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationProcessor;
-
-@Transactional("Master")
-public class AuthenticationProcessorTest extends AbstractTest {
-
-    @Autowired
-    private AuthenticationProcessorDAO authenticationProcessorDAO;
-
-    @Autowired
-    private ImplementationDAO implementationDAO;
-
-    @Test
-    public void findAll() {
-        List<AuthenticationProcessor> processors = authenticationProcessorDAO.findAll();
-        assertNotNull(processors);
-        assertFalse(processors.isEmpty());
-    }
-
-    @Test
-    public void findByKey() {
-        AuthenticationProcessor authPostProcessor =
-                authenticationProcessorDAO.find("2460e430-ce67-41a5-86ed-ea0a4e78c0a3");
-        assertNotNull(authPostProcessor);
-
-        AuthenticationProcessor authPreProcessor =
-                authenticationProcessorDAO.find("c413566e-8859-11e9-bc42-526af7764f64");
-        assertNotNull(authPreProcessor);
-    }
-
-    @Test
-    public void findByType() {
-        List<AuthenticationPostProcessor> processors = authenticationProcessorDAO.
-                find(AuthenticationPostProcessor.class);
-        assertNotNull(processors);
-        assertFalse(processors.isEmpty());
-    }
-
-    @Test
-    public void create() {
-
-        AuthenticationPostProcessor authenticationPostProcessor =
-                entityFactory.newEntity(AuthenticationPostProcessor.class);
-        authenticationPostProcessor.setDefaultFailureLoginURL("login/error");
-        authenticationPostProcessor.setDefaultSuccessLoginURL("login");
-
-        Implementation postProcessing = entityFactory.newEntity(Implementation.class);
-        postProcessing.setKey("PostProcessingTest");
-        postProcessing.setEngine(ImplementationEngine.JAVA);
-        postProcessing.setType(AMImplementationType.AUTH_POST_PROCESSING);
-        postProcessing.setBody(AuthenticationPolicyRule.class.getName());
-        postProcessing = implementationDAO.save(postProcessing);
-        authenticationPostProcessor.addAuthPostProcessing(postProcessing);
-
-        AuthenticationPreProcessor authenticationPreProcessor =
-                entityFactory.newEntity(AuthenticationPreProcessor.class);
-
-        Implementation preProcessing = entityFactory.newEntity(Implementation.class);
-        preProcessing.setKey("PreProcessingTest");
-        preProcessing.setEngine(ImplementationEngine.JAVA);
-        preProcessing.setType(AMImplementationType.AUTH_PRE_PROCESSING);
-        preProcessing.setBody(AuthenticationPolicyRule.class.getName());
-        preProcessing = implementationDAO.save(preProcessing);
-        authenticationPreProcessor.addAuthPreProcessing(preProcessing);
-    }
-
-    @Test
-    public void update() {
-        AuthenticationPostProcessor authPostProcessor =
-                authenticationProcessorDAO.find("2460e430-ce67-41a5-86ed-ea0a4e78c0a3");
-        assertNotNull(authPostProcessor);
-        assertEquals(1, authPostProcessor.getAuthenticationPostProcessing().size());
-        assertEquals("login", authPostProcessor.getDefaultSuccessLoginURL());
-
-        authPostProcessor.setDefaultSuccessLoginURL("login/home");
-        authPostProcessor = authenticationProcessorDAO.save(authPostProcessor);
-
-        assertNotNull(authPostProcessor);
-        assertEquals("login/home", authPostProcessor.getDefaultSuccessLoginURL());
-    }
-
-    @Test
-    public void delete() {
-        AuthenticationPostProcessor authPostProcessor =
-                authenticationProcessorDAO.find("2460e430-ce67-41a5-86ed-ea0a4e78c0a3");
-        assertNotNull(authPostProcessor);
-
-        authenticationProcessorDAO.delete(authPostProcessor);
-
-        authPostProcessor = authenticationProcessorDAO.find("2460e430-ce67-41a5-86ed-ea0a4e78c0a3");
-        assertNull(authPostProcessor);
-    }
-}
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ImplementationTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ImplementationTest.java
index 533eca0..9fc9df7 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ImplementationTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ImplementationTest.java
@@ -45,7 +45,7 @@ public class ImplementationTest extends AbstractTest {
         List<Implementation> implementations = implementationDAO.findAll();
         assertFalse(implementations.isEmpty());
 
-        assertEquals(23, implementations.size());
+        assertEquals(18, implementations.size());
 
         implementations = implementationDAO.findByType(IdMImplementationType.PULL_ACTIONS);
         assertEquals(1, implementations.size());
@@ -73,18 +73,6 @@ public class ImplementationTest extends AbstractTest {
 
         implementations = implementationDAO.findByType(IdMImplementationType.PUSH_CORRELATION_RULE);
         assertEquals(1, implementations.size());
-
-        implementations = implementationDAO.findByType(AMImplementationType.AUTH_MODULE_CONFIGURATIONS);
-        assertEquals(1, implementations.size());
-
-        implementations = implementationDAO.findByType(AMImplementationType.AUTH_POLICY_CONFIGURATIONS);
-        assertEquals(1, implementations.size());
-
-        implementations = implementationDAO.findByType(AMImplementationType.AUTH_POST_PROCESSING);
-        assertEquals(1, implementations.size());
-
-        implementations = implementationDAO.findByType(AMImplementationType.AUTH_PRE_PROCESSING);
-        assertEquals(1, implementations.size());
     }
 
     @Test
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PolicyTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PolicyTest.java
index 3b1db42..0dd95be 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PolicyTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PolicyTest.java
@@ -18,42 +18,35 @@
  */
 package org.apache.syncope.core.persistence.jpa.inner;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.util.List;
-import java.util.UUID;
 import org.apache.syncope.common.lib.policy.DefaultPasswordRuleConf;
 import org.apache.syncope.common.lib.policy.DefaultPullCorrelationRuleConf;
 import org.apache.syncope.common.lib.policy.DefaultPushCorrelationRuleConf;
-import org.apache.syncope.common.lib.types.AMImplementationType;
 import org.apache.syncope.common.lib.types.ConflictResolutionAction;
 import org.apache.syncope.common.lib.types.IdMImplementationType;
 import org.apache.syncope.common.lib.types.IdRepoImplementationType;
 import org.apache.syncope.common.lib.types.ImplementationEngine;
-import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
 import org.apache.syncope.core.persistence.api.dao.AnyTypeDAO;
-import org.apache.syncope.core.persistence.api.dao.AuthenticationPolicyRule;
 import org.apache.syncope.core.persistence.api.dao.ImplementationDAO;
 import org.apache.syncope.core.persistence.api.dao.PolicyDAO;
+import org.apache.syncope.core.persistence.api.dao.PullCorrelationRule;
 import org.apache.syncope.core.persistence.api.entity.Implementation;
+import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
 import org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy;
 import org.apache.syncope.core.persistence.api.entity.policy.Policy;
+import org.apache.syncope.core.persistence.api.entity.policy.PullCorrelationRuleEntity;
+import org.apache.syncope.core.persistence.api.entity.policy.PullPolicy;
+import org.apache.syncope.core.persistence.api.entity.policy.PushCorrelationRuleEntity;
+import org.apache.syncope.core.persistence.api.entity.policy.PushPolicy;
 import org.apache.syncope.core.persistence.jpa.AbstractTest;
+import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
-import org.apache.syncope.core.persistence.api.entity.policy.PullPolicy;
-import org.apache.syncope.core.persistence.api.dao.PullCorrelationRule;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationPostProcessor;
-import org.apache.syncope.core.persistence.api.entity.authentication.AuthenticationPreProcessor;
-import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
-import org.apache.syncope.core.persistence.api.entity.policy.PullCorrelationRuleEntity;
-import org.apache.syncope.core.persistence.api.entity.policy.PushCorrelationRuleEntity;
-import org.apache.syncope.core.persistence.api.entity.policy.PushPolicy;
+
+import java.util.List;
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.*;
 
 @Transactional("Master")
 public class PolicyTest extends AbstractTest {
@@ -82,7 +75,7 @@ public class PolicyTest extends AbstractTest {
         PullCorrelationRuleEntity pullCR = pullPolicy.getCorrelationRule(anyTypeDAO.findUser()).orElse(null);
         assertNotNull(pullCR);
         DefaultPullCorrelationRuleConf pullCRConf =
-                POJOHelper.deserialize(pullCR.getImplementation().getBody(), DefaultPullCorrelationRuleConf.class);
+            POJOHelper.deserialize(pullCR.getImplementation().getBody(), DefaultPullCorrelationRuleConf.class);
         assertNotNull(pullCRConf);
         assertEquals(2, pullCRConf.getSchemas().size());
         assertTrue(pullCRConf.getSchemas().contains("username"));
@@ -94,7 +87,7 @@ public class PolicyTest extends AbstractTest {
         PushCorrelationRuleEntity pushCR = pushPolicy.getCorrelationRule(anyTypeDAO.findUser()).orElse(null);
         assertNotNull(pushCR);
         DefaultPushCorrelationRuleConf pushCRConf =
-                POJOHelper.deserialize(pushCR.getImplementation().getBody(), DefaultPushCorrelationRuleConf.class);
+            POJOHelper.deserialize(pushCR.getImplementation().getBody(), DefaultPushCorrelationRuleConf.class);
         assertNotNull(pushCRConf);
         assertEquals(1, pushCRConf.getSchemas().size());
         assertTrue(pushCRConf.getSchemas().contains("surname"));
@@ -149,55 +142,13 @@ public class PolicyTest extends AbstractTest {
 
         assertNotNull(policy);
         assertEquals(pullURuleName,
-                policy.getCorrelationRule(anyTypeDAO.findUser()).get().getImplementation().getKey());
+            policy.getCorrelationRule(anyTypeDAO.findUser()).get().getImplementation().getKey());
         assertEquals(pullGRuleName,
-                policy.getCorrelationRule(anyTypeDAO.findGroup()).get().getImplementation().getKey());
+            policy.getCorrelationRule(anyTypeDAO.findGroup()).get().getImplementation().getKey());
 
         AuthenticationPolicy authenticationPolicy = entityFactory.newEntity(AuthenticationPolicy.class);
-        authenticationPolicy.setAuthenticationAttemptsInterval(1);
-        authenticationPolicy.setAuthenticationFailureLockoutDuration(10);
-
-        AuthenticationPostProcessor authenticationPostProcessor =
-                entityFactory.newEntity(AuthenticationPostProcessor.class);
-        authenticationPostProcessor.setDefaultFailureLoginURL("login/error");
-        authenticationPostProcessor.setDefaultSuccessLoginURL("login");
-        authenticationPostProcessor.setAuthenticationPolicy(authenticationPolicy);
-        Implementation postProcessing = entityFactory.newEntity(Implementation.class);
-        postProcessing.setKey("PostProcessingKey");
-        postProcessing.setEngine(ImplementationEngine.JAVA);
-        postProcessing.setType(AMImplementationType.AUTH_POST_PROCESSING);
-        postProcessing.setBody(AuthenticationPolicyRule.class.getName());
-        postProcessing = implementationDAO.save(postProcessing);
-        authenticationPostProcessor.addAuthPostProcessing(postProcessing);
-        authenticationPolicy.setAuthenticationPostProcessor(authenticationPostProcessor);
-
-        AuthenticationPreProcessor authenticationPreProcessor =
-                entityFactory.newEntity(AuthenticationPreProcessor.class);
-        authenticationPreProcessor.setAuthenticationPolicy(authenticationPolicy);
-        Implementation preProcessing = entityFactory.newEntity(Implementation.class);
-        preProcessing.setKey("PreProcessingKey");
-        preProcessing.setEngine(ImplementationEngine.JAVA);
-        preProcessing.setType(AMImplementationType.AUTH_PRE_PROCESSING);
-        preProcessing.setBody(AuthenticationPolicyRule.class.getName());
-        preProcessing = implementationDAO.save(preProcessing);
-        authenticationPreProcessor.addAuthPreProcessing(preProcessing);
-        authenticationPolicy.setAuthenticationPreProcessor(authenticationPreProcessor);
-
         authenticationPolicy.setDescription("Syncope Account Policy");
-        authenticationPolicy.setLockoutAttributeName("locked");
-        authenticationPolicy.setLockoutAttributeValue("true");
-        authenticationPolicy.setMaxAuthenticationAttempts(5);
-
-        Implementation type = entityFactory.newEntity(Implementation.class);
-        type.setKey("AuthPolicyConfKey");
-        type.setEngine(ImplementationEngine.JAVA);
-        type.setType(AMImplementationType.AUTH_POLICY_CONFIGURATIONS);
-        type.setBody(AuthenticationPolicyRule.class.getName());
-        type = implementationDAO.save(type);
-
-        authenticationPolicy.addConfiguration(type);
         authenticationPolicy = policyDAO.save(authenticationPolicy);
-
         assertNotNull(authenticationPolicy);
 
     }
@@ -242,15 +193,4 @@ public class PolicyTest extends AbstractTest {
         Policy actual = policyDAO.find("66691e96-285f-4464-bc19-e68384ea4c85");
         assertNull(actual);
     }
-
-    @Test
-    public void deleteAuthenticationPolicy() {
-        Policy policy = policyDAO.find("b912a0d4-a890-416f-9ab8-84ab077eb028");
-        assertNotNull(policy);
-
-        policyDAO.delete(policy);
-
-        Policy actual = policyDAO.find("b912a0d4-a890-416f-9ab8-84ab077eb028");
-        assertNull(actual);
-    }
 }
diff --git a/core/persistence-jpa/src/test/resources/domains/MasterContent.xml b/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
index b27fd47..39020ab 100644
--- a/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
+++ b/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
@@ -44,11 +44,6 @@ under the License.
                   body='{"@class":"org.apache.syncope.common.lib.policy.DefaultPasswordRuleConf","maxLength":0,"minLength":10,"nonAlphanumericRequired":true,"alphanumericRequired":false,"digitRequired":true,"lowercaseRequired":true,"uppercaseRequired":true,"mustStartWithDigit":true,"mustntStartWithDigit":false,"mustEndWithDigit":true,"mustntEndWithDigit":false,"mustStartWithNonAlpha":false,"mustStartWithAlpha":false,"mustntStartWithNonAlpha":false,"mustntStartWithAlpha":false,"mustEndWit [...]
   <PasswordPolicyRule policy_id="55e5de0b-c79c-4e66-adda-251b6fb8579a" implementation_id="DefaultPasswordRuleConf3"/>
 
-  <AuthenticationPolicy id="b912a0d4-a890-416f-9ab8-84ab077eb028" name="DefaultAuthenticationPolicy"/>
-  <Implementation id="DefaultAuthenticationPolicyConf" type="AUTH_POLICY_CONFIGURATIONS" engine="JAVA"
-                  body='{"@class":"org.apache.syncope.common.lib.authentication.DefaultAuthenticationPolicyConf","name":"DefaultAuthenticationPolicyConf"}'/>
-  <AuthenticationPolicyConf authentication_policy_id="b912a0d4-a890-416f-9ab8-84ab077eb028" implementation_id="DefaultAuthenticationPolicyConf"/>
-  
   <RelationshipType id="inclusion" description="Models the act that an object is included in another"/>
   <RelationshipType id="neighborhood" description="Models the act that an object is near another"/>
   
@@ -70,8 +65,7 @@ under the License.
       
   <AnyTypeClass id="csv"/>
 
-  <Realm id="e4c28e7a-9dbf-4ee7-9441-93812a0d4a28" name="/" passwordPolicy_id="986d1236-3ac5-4a19-810c-5ab21d79cba1"
-         authenticationPolicy_id="b912a0d4-a890-416f-9ab8-84ab077eb028"/>
+  <Realm id="e4c28e7a-9dbf-4ee7-9441-93812a0d4a28" name="/" passwordPolicy_id="986d1236-3ac5-4a19-810c-5ab21d79cba1" />
   <Realm id="722f3d84-9c2b-4525-8f6e-e4b82c55a36c" name="odd" 
          parent_id="e4c28e7a-9dbf-4ee7-9441-93812a0d4a28" accountPolicy_id="06e2ed52-6966-44aa-a177-a0ca7434201f"/>
   <Realm id="c5b75db1-fce7-470f-b780-3b9934d82a9d" name="even" 
@@ -2475,25 +2469,7 @@ $$ }&#10;
   <SyncopeLogger logType="AUDIT" logName="syncope.audit.[LOGIC]:[AnyObjectLogic]:[]:[unlink]:[SUCCESS]" logLevel="DEBUG"/>
   <SyncopeLogger logType="AUDIT" logName="syncope.audit.[LOGIC]:[AnyObjectLogic]:[]:[update]:[SUCCESS]" logLevel="DEBUG"/>
 
-  <AuthenticationModule id="be456831-593d-4003-b273-4c3fb61700df" name="TestAuthModule"/>
-  <Implementation id="DefaultAuthenticationModuleConf" type="AUTH_MODULE_CONFIGURATIONS" engine="JAVA"
-                  body='{"@class":"org.apache.syncope.common.lib.authentication.DefaultAuthenticationModuleConf","name":"DefaultAuthenticationModuleConf"}'/>
-  <AuthenticationModuleConf authentication_module_id="be456831-593d-4003-b273-4c3fb61700df" implementation_id="DefaultAuthenticationModuleConf"/>
-
-  <AuthenticationChain id="4735ce66-aa3f-416b-b810-9b2c1d25ada7" name="ChainAuthenticationPolicy"/>
-  <Implementation id="ChainAuthenticationPolicyConf" type="AUTH_CHAIN_CONFIGURATIONS" engine="JAVA"
-                  body='{"@class":"org.apache.syncope.common.lib.authentication.ChainAuthenticationPolicyConf","name":"ChainAuthenticationPolicyConf"}'/>
-  <AuthenticationChainConf authentication_chain_id="4735ce66-aa3f-416b-b810-9b2c1d25ada7" implementation_id="ChainAuthenticationPolicyConf"/>
-
-  <AuthenticationPostProcessor id="2460e430-ce67-41a5-86ed-ea0a4e78c0a3" name="TestPostProcessor" authenticationPolicy_id="b912a0d4-a890-416f-9ab8-84ab077eb028"
-                               defaultSuccessLoginURL="login"/>
-  <Implementation id="TestAuthPostProcessorAction" type="AUTH_POST_PROCESSING" engine="JAVA"
-                  body='{"@class":"org.apache.syncope.common.lib.authentication.TestAuthPostProcessor","name":"TestAuthPostProcessorAction"}'/>
-  <AuthenticationPostProcessorActions authentication_post_processor="2460e430-ce67-41a5-86ed-ea0a4e78c0a3"
-                                      implementation_id="TestAuthPostProcessorAction" />
-
-  <AuthenticationPreProcessor id="c413566e-8859-11e9-bc42-526af7764f64" name="TestPreProcessor" authenticationPolicy_id="b912a0d4-a890-416f-9ab8-84ab077eb028"/>
-  <Implementation id="TestAuthPreProcessorAction" type="AUTH_PRE_PROCESSING" engine="JAVA"
-                  body='{"@class":"org.apache.syncope.common.lib.authentication.TestAuthPreProcessorAction","name":"TestAuthPreProcessorAction"}'/>
-  <AuthenticationPreProcessorActions authentication_pre_processor="c413566e-8859-11e9-bc42-526af7764f64" implementation_id="TestAuthPreProcessorAction"/>
+  <AuthenticationPolicy id="b912a0d4-a890-416f-9ab8-84ab077eb028" name="DefaultAuthenticationPolicy" description="Default authentication policy"/>
+  <AuthenticationModule id="be456831-593d-4003-b273-4c3fb61700df" name="DefaultAuthenticationModule"/>
+
 </dataset>


[syncope] 06/12: resume on auth modules; clean up to base essentials

Posted by mm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mmoayyed pushed a commit to branch SYNCOPE-163-1
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 068d5a21f3765be7ee7587c10a6a41cb15bc7dfa
Author: Misagh Moayyed <mm...@gmail.com>
AuthorDate: Mon Feb 24 16:47:15 2020 +0330

    resume on auth modules; clean up to base essentials
---
 .../console/rest/ClientApplicationRestClient.java  |  53 +++++++++
 .../org/apache/syncope/common/lib/to/AnyTO.java    |   3 +
 .../syncope/common/lib/to/ClientApplicationTO.java | 106 +++++++++++++++++
 .../common/lib/to/OpenIdConnectRelyingPartyTO.java | 108 ++++++++++++++++++
 .../common/lib/to/SAML2ServiceProviderTO.java      |  94 ++++++++++++++++
 .../rest/api/service/ClientApplicationService.java | 125 +++++++++++++++++++++
 .../core/logic/AbstractClientApplicationLogic.java |  25 +++++
 .../AbstractClientApplicationServiceImpl.java      |  66 +++++++++++
 .../JPAOpenIdConnectRelyingParty.java              |  30 ++---
 9 files changed, 596 insertions(+), 14 deletions(-)

diff --git a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/ClientApplicationRestClient.java b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/ClientApplicationRestClient.java
new file mode 100644
index 0000000..0dfb663
--- /dev/null
+++ b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/ClientApplicationRestClient.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.rest;
+
+import org.apache.syncope.common.lib.to.ApplicationTO;
+import org.apache.syncope.common.rest.api.service.ClientApplicationService;
+
+import java.util.List;
+
+/**
+ * Console client for invoking Rest Client Application's services.
+ */
+public class ClientApplicationRestClient extends BaseRestClient {
+
+    private static final long serialVersionUID = -3161863874876938094L;
+
+    public static void delete(final String key) {
+        getService(ClientApplicationService.class).delete(key);
+    }
+
+    public static ApplicationTO read(final String key) {
+        return getService(ClientApplicationService.class).read(key);
+    }
+
+    public static void update(final ApplicationTO applicationTO) {
+        getService(ClientApplicationService.class).update(applicationTO);
+    }
+
+    public static void create(final ApplicationTO applicationTO) {
+        getService(ClientApplicationService.class).create(applicationTO);
+    }
+
+    public static List<ApplicationTO> list() {
+        return getService(ClientApplicationService.class).list();
+    }
+
+}
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/AnyTO.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/AnyTO.java
index 662c601..7d0c740 100644
--- a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/AnyTO.java
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/AnyTO.java
@@ -71,6 +71,9 @@ public abstract class AnyTO extends AbstractAnnotatedBean implements EntityTO, R
 
     private final Set<String> resources = new HashSet<>();
 
+    protected AnyTO() {
+    }
+
     @Schema(name = "@class", required = true)
     public abstract String getDiscriminator();
 
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/ClientApplicationTO.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/ClientApplicationTO.java
new file mode 100644
index 0000000..aa3421d
--- /dev/null
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/ClientApplicationTO.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.common.lib.to;
+
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import io.swagger.v3.oas.annotations.media.Schema;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.syncope.common.lib.BaseBean;
+
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType
+@XmlSeeAlso({OpenIdConnectRelyingPartyTO.class, SAML2ServiceProviderTO.class})
+@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "@class")
+@JsonPropertyOrder(value = {"@class", "key", "name", "description"})
+@Schema(subTypes = {OpenIdConnectRelyingPartyTO.class, SAML2ServiceProviderTO.class}, discriminatorProperty = "@class")
+public abstract class ClientApplicationTO extends BaseBean implements EntityTO {
+
+    private static final long serialVersionUID = 6577639976115661357L;
+
+    private String key;
+
+    private String name;
+
+    private String description;
+
+    @Override
+    public String getKey() {
+        return key;
+    }
+
+    @Override
+    public void setKey(final String key) {
+        this.key = key;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(final String description) {
+        this.description = description;
+    }
+
+    @Schema(name = "@class", required = true)
+    public abstract String getDiscriminator();
+
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (obj == this) {
+            return true;
+        }
+        if (obj.getClass() != getClass()) {
+            return false;
+        }
+        ClientApplicationTO rhs = (ClientApplicationTO) obj;
+        return new EqualsBuilder()
+            .appendSuper(super.equals(obj))
+            .append(this.key, rhs.key)
+            .append(this.name, rhs.name)
+            .append(this.description, rhs.description)
+            .isEquals();
+    }
+
+    @Override
+    public int hashCode() {
+        return new HashCodeBuilder()
+            .appendSuper(super.hashCode())
+            .append(key)
+            .append(name)
+            .append(description)
+            .toHashCode();
+    }
+}
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/OpenIdConnectRelyingPartyTO.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/OpenIdConnectRelyingPartyTO.java
new file mode 100644
index 0000000..a8c5ec1
--- /dev/null
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/OpenIdConnectRelyingPartyTO.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.common.lib.to;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@XmlRootElement(name = "openIdConnectRelyingParty")
+@XmlType
+@Schema(allOf = { ClientApplicationTO.class })
+public class OpenIdConnectRelyingPartyTO extends ClientApplicationTO {
+    private static final long serialVersionUID = -6370888503924521351L;
+
+    private String clientId;
+
+    private String clientSecret;
+
+    private List<String> redirectUris = new ArrayList<>();
+
+    @XmlTransient
+    @JsonProperty("@class")
+    @Schema(name = "@class", required = true, example = "org.apache.syncope.common.lib.to.OpenIdConnectRelyingPartyTO")
+    @Override
+    public String getDiscriminator() {
+        return getClass().getName();
+    }
+
+    public String getClientId() {
+        return clientId;
+    }
+
+    public void setClientId(final String clientId) {
+        this.clientId = clientId;
+    }
+
+    public String getClientSecret() {
+        return clientSecret;
+    }
+
+    public void setClientSecret(final String clientSecret) {
+        this.clientSecret = clientSecret;
+    }
+
+    public List<String> getRedirectUris() {
+        return redirectUris;
+    }
+
+    public void setRedirectUris(final List<String> redirectUris) {
+        this.redirectUris = redirectUris;
+    }
+
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (obj == this) {
+            return true;
+        }
+        if (obj.getClass() != getClass()) {
+            return false;
+        }
+        OpenIdConnectRelyingPartyTO rhs = (OpenIdConnectRelyingPartyTO) obj;
+        return new EqualsBuilder()
+            .appendSuper(super.equals(obj))
+            .append(this.clientId, rhs.clientId)
+            .append(this.clientSecret, rhs.clientSecret)
+            .append(this.redirectUris, rhs.redirectUris)
+            .isEquals();
+    }
+
+    @Override
+    public int hashCode() {
+        return new HashCodeBuilder()
+            .appendSuper(super.hashCode())
+            .append(clientId)
+            .append(clientSecret)
+            .append(redirectUris)
+            .toHashCode();
+    }
+}
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/SAML2ServiceProviderTO.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/SAML2ServiceProviderTO.java
new file mode 100644
index 0000000..82c886b
--- /dev/null
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/SAML2ServiceProviderTO.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.common.lib.to;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement(name = "saml2ServiceProvider")
+@XmlType
+@Schema(allOf = { ClientApplicationTO.class })
+public class SAML2ServiceProviderTO extends ClientApplicationTO {
+    private static final long serialVersionUID = -6370888503924521351L;
+
+    private String entityId;
+
+    private String metadataLocation;
+
+    @XmlTransient
+    @JsonProperty("@class")
+    @Schema(name = "@class", required = true, example = "org.apache.syncope.common.lib.to.SAML2ServiceProviderTO")
+    @Override
+    public String getDiscriminator() {
+        return getClass().getName();
+    }
+
+    public String getEntityId() {
+        return entityId;
+    }
+
+    public void setEntityId(final String entityId) {
+        this.entityId = entityId;
+    }
+
+    public String getMetadataLocation() {
+        return metadataLocation;
+    }
+
+    public void setMetadataLocation(final String metadataLocation) {
+        this.metadataLocation = metadataLocation;
+    }
+
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (obj == this) {
+            return true;
+        }
+        if (obj.getClass() != getClass()) {
+            return false;
+        }
+        SAML2ServiceProviderTO rhs = (SAML2ServiceProviderTO) obj;
+        return new EqualsBuilder()
+            .appendSuper(super.equals(obj))
+            .append(this.entityId, rhs.entityId)
+            .append(this.metadataLocation, rhs.metadataLocation)
+            .isEquals();
+    }
+
+    @Override
+    public int hashCode() {
+        return new HashCodeBuilder()
+            .appendSuper(super.hashCode())
+            .append(entityId)
+            .append(metadataLocation)
+            .toHashCode();
+    }
+}
+
diff --git a/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ClientApplicationService.java b/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ClientApplicationService.java
new file mode 100644
index 0000000..a90740d
--- /dev/null
+++ b/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ClientApplicationService.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.common.rest.api.service;
+
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.enums.ParameterIn;
+import io.swagger.v3.oas.annotations.headers.Header;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import io.swagger.v3.oas.annotations.security.SecurityRequirement;
+import io.swagger.v3.oas.annotations.security.SecurityRequirements;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.apache.syncope.common.lib.to.ClientApplicationTO;
+import org.apache.syncope.common.rest.api.RESTHeaders;
+
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import java.util.List;
+
+/**
+ * REST operations for applications.
+ */
+@Tag(name = "ClientApplications")
+@SecurityRequirements({
+    @SecurityRequirement(name = "BasicAuthentication"),
+    @SecurityRequirement(name = "Bearer")})
+@Path("clientApplications")
+public interface ClientApplicationService extends JAXRSService {
+
+    /**
+     * Returns a list of all applications.
+     *
+     * @return list of all applications.
+     */
+    @GET
+    @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
+    List<ClientApplicationTO> list();
+
+    /**
+     * Returns application with matching key.
+     *
+     * @param key application key to be read
+     * @return application with matching key
+     */
+    @GET
+    @Path("{key}")
+    @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
+    ClientApplicationTO read(@NotNull @PathParam("key") String key);
+
+    /**
+     * Creates a new application.
+     *
+     * @param applicationTO application to be created
+     * @return Response object featuring Location header of created application
+     */
+    @ApiResponses(
+        @ApiResponse(responseCode = "201",
+            description = "Application successfully created", headers = {
+            @Header(name = RESTHeaders.RESOURCE_KEY, schema =
+            @Schema(type = "string"),
+                description = "Key value for the entity created"),
+            @Header(name = HttpHeaders.LOCATION, schema =
+            @Schema(type = "string"),
+                description = "URL of the entity created") }))
+    @POST
+    @Consumes({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
+    @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
+    Response create(@NotNull ClientApplicationTO applicationTO);
+
+    /**
+     * Updates the application matching the provided key.
+     *
+     * @param applicationTO application to be stored
+     */
+    @Parameter(name = "key", description = "Application's key", in = ParameterIn.PATH, schema =
+    @Schema(type = "string"))
+    @ApiResponses(
+        @ApiResponse(responseCode = "204", description = "Operation was successful"))
+    @PUT
+    @Path("{key}")
+    @Consumes({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
+    @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
+    void update(@NotNull ClientApplicationTO applicationTO);
+
+    /**
+     * Deletes the application matching the provided key.
+     *
+     * @param key application key to be deleted
+     */
+    @ApiResponses(
+        @ApiResponse(responseCode = "204", description = "Operation was successful"))
+    @DELETE
+    @Path("{key}")
+    @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
+    void delete(@NotNull @PathParam("key") String key);
+}
diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java
new file mode 100644
index 0000000..79ccf62
--- /dev/null
+++ b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.core.logic;
+
+import org.apache.syncope.common.lib.to.DynRealmTO;
+
+public abstract class AbstractClientApplicationLogic extends AbstractTransactionalLogic<DynRealmTO> {
+}
diff --git a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractClientApplicationServiceImpl.java b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractClientApplicationServiceImpl.java
new file mode 100644
index 0000000..f7c4295
--- /dev/null
+++ b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractClientApplicationServiceImpl.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.rest.cxf.service;
+
+import org.apache.syncope.common.lib.to.ClientApplicationTO;
+import org.apache.syncope.common.rest.api.RESTHeaders;
+import org.apache.syncope.common.rest.api.service.ClientApplicationService;
+import org.apache.syncope.core.logic.AbstractClientApplicationLogic;
+
+import javax.ws.rs.core.Response;
+
+import java.net.URI;
+import java.util.List;
+
+public abstract class AbstractClientApplicationServiceImpl extends AbstractServiceImpl
+    implements ClientApplicationService {
+
+    protected abstract AbstractClientApplicationLogic getLogic();
+
+    @Override
+    public List<ClientApplicationTO> list() {
+        return getLogic().list();
+    }
+
+    @Override
+    public ClientApplicationTO read(final String key) {
+        return getLogic().read(key);
+    }
+
+
+    @Override
+    public Response create(final ClientApplicationTO applicationTO) {
+        ClientApplicationTO created = getLogic().create(applicationTO);
+        URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build();
+        return Response.created(location).
+            header(RESTHeaders.RESOURCE_KEY, created.getKey()).
+            build();
+    }
+
+    @Override
+    public void update(final ClientApplicationTO applicationTO) {
+        getLogic().update(applicationTO);
+    }
+
+    @Override
+    public void delete(final String key) {
+        getLogic().delete(key);
+    }
+
+}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAOpenIdConnectRelyingParty.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAOpenIdConnectRelyingParty.java
index 6acd0ea..f07984d 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAOpenIdConnectRelyingParty.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAOpenIdConnectRelyingParty.java
@@ -61,31 +61,39 @@ public class JPAOpenIdConnectRelyingParty extends AbstractGeneratedKeyEntity imp
     @Override
     public String getName() {
         return name;
-    }    @Override
-    public List<String> getRedirectUris() {
-        return redirectUris;
     }
 
     @Override
     public void setName(final String name) {
         this.name = name;
     }    @Override
-    public void setRedirectUris(final List<String> redirectUris) {
-        this.redirectUris = redirectUris;
+    public List<String> getRedirectUris() {
+        return redirectUris;
     }
 
     @Override
     public String getDescription() {
         return description;
-    }    @Override
-    public String getClientId() {
-        return clientId;
     }
 
     @Override
     public void setDescription(final String description) {
         this.description = description;
     }    @Override
+    public void setRedirectUris(final List<String> redirectUris) {
+        this.redirectUris = redirectUris;
+    }
+
+
+
+    @Override
+    public String getClientId() {
+        return clientId;
+    }
+
+
+
+    @Override
     public void setClientId(final String clientId) {
         this.clientId = clientId;
     }
@@ -101,11 +109,5 @@ public class JPAOpenIdConnectRelyingParty extends AbstractGeneratedKeyEntity imp
     }
 
 
-
-
-
-
-
-
 }
 


[syncope] 11/12: clean up service impls & data binders

Posted by mm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mmoayyed pushed a commit to branch SYNCOPE-163-1
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit ec7c18d67b49c0ad50450a60419a6c6a1728d3d6
Author: Misagh Moayyed <mm...@gmail.com>
AuthorDate: Wed Feb 26 13:29:19 2020 +0330

    clean up service impls & data binders
---
 .../common/lib/to/AuthenticationPolicyTO.java      | 27 ++++---
 .../syncope/common/lib/to/ClientApplicationTO.java | 35 +++++----
 .../rest/api/service/ClientApplicationService.java |  8 ---
 .../service/OpenIdConnectRelyingPartyService.java  | 19 ++---
 .../api/service/SAML2ServiceProviderService.java   | 19 ++---
 .../core/logic/AbstractClientApplicationLogic.java | 13 ++--
 .../core/logic/OpenIdConnectRelyingPartyLogic.java | 20 +++---
 .../core/logic/SAML2ServiceProviderLogic.java      | 19 ++---
 .../OpenIdConnectRelyingPartyServiceImpl.java      |  4 +-
 .../service/SAML2ServiceProviderServiceImpl.java   |  5 +-
 .../JPAOpenIdConnectRelyingParty.java              |  1 +
 .../authentication/JPASAML2ServiceProvider.java    | 21 +++---
 .../data/OpenIdConnectRelyingPartyDataBinder.java  |  8 +--
 .../api/data/SAML2ServiceProviderDataBinder.java   |  8 +--
 .../OpenIdConnectRelyingPartyDataBinderImpl.java   | 82 ++++++++++++++++++++++
 .../data/SAML2ServiceProviderDataBinderImpl.java   | 81 +++++++++++++++++++++
 16 files changed, 278 insertions(+), 92 deletions(-)

diff --git a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SAML2ServiceProviderServiceImpl.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/AuthenticationPolicyTO.java
similarity index 60%
copy from core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SAML2ServiceProviderServiceImpl.java
copy to common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/AuthenticationPolicyTO.java
index 960a442..feb7f32 100644
--- a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SAML2ServiceProviderServiceImpl.java
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/AuthenticationPolicyTO.java
@@ -17,20 +17,25 @@
  *
  */
 
-package org.apache.syncope.core.rest.cxf.service;
+package org.apache.syncope.common.lib.to;
 
-import org.apache.syncope.core.logic.AbstractClientApplicationLogic;
-import org.apache.syncope.core.logic.SAML2ServiceProviderLogic;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
 
-@Service
-public class SAML2ServiceProviderServiceImpl extends AbstractClientApplicationServiceImpl {
-    @Autowired
-    private SAML2ServiceProviderLogic logic;
+@XmlRootElement(name = "authenticationPolicy")
+@XmlType
+public class AuthenticationPolicyTO implements EntityTO {
+    private static final long serialVersionUID = -6711411162433533300L;
+
+    private String key;
+
+    @Override
+    public String getKey() {
+        return key;
+    }
 
     @Override
-    protected AbstractClientApplicationLogic getLogic() {
-        return this.logic;
+    public void setKey(final String key) {
+        this.key = key;
     }
 }
diff --git a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/ClientApplicationTO.java b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/ClientApplicationTO.java
index aa3421d..f705dae 100644
--- a/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/ClientApplicationTO.java
+++ b/common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/ClientApplicationTO.java
@@ -32,7 +32,7 @@ import javax.xml.bind.annotation.XmlType;
 @XmlType
 @XmlSeeAlso({OpenIdConnectRelyingPartyTO.class, SAML2ServiceProviderTO.class})
 @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "@class")
-@JsonPropertyOrder(value = {"@class", "key", "name", "description"})
+@JsonPropertyOrder(value = {"@class", "key", "name", "description", "authenticationPolicy"})
 @Schema(subTypes = {OpenIdConnectRelyingPartyTO.class, SAML2ServiceProviderTO.class}, discriminatorProperty = "@class")
 public abstract class ClientApplicationTO extends BaseBean implements EntityTO {
 
@@ -44,6 +44,16 @@ public abstract class ClientApplicationTO extends BaseBean implements EntityTO {
 
     private String description;
 
+    private AuthenticationPolicyTO authenticationPolicy;
+
+    public AuthenticationPolicyTO getAuthenticationPolicy() {
+        return authenticationPolicy;
+    }
+
+    public void setAuthenticationPolicy(final AuthenticationPolicyTO authenticationPolicy) {
+        this.authenticationPolicy = authenticationPolicy;
+    }
+
     @Override
     public String getKey() {
         return key;
@@ -73,9 +83,19 @@ public abstract class ClientApplicationTO extends BaseBean implements EntityTO {
     @Schema(name = "@class", required = true)
     public abstract String getDiscriminator();
 
+    @Override
+    public int hashCode() {
+        return new HashCodeBuilder()
+            .appendSuper(super.hashCode())
+            .append(key)
+            .append(name)
+            .append(description)
+            .append(authenticationPolicy)
+            .toHashCode();
+    }
 
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (obj == null) {
             return false;
         }
@@ -91,16 +111,7 @@ public abstract class ClientApplicationTO extends BaseBean implements EntityTO {
             .append(this.key, rhs.key)
             .append(this.name, rhs.name)
             .append(this.description, rhs.description)
+            .append(this.authenticationPolicy, rhs.authenticationPolicy)
             .isEquals();
     }
-
-    @Override
-    public int hashCode() {
-        return new HashCodeBuilder()
-            .appendSuper(super.hashCode())
-            .append(key)
-            .append(name)
-            .append(description)
-            .toHashCode();
-    }
 }
diff --git a/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ClientApplicationService.java b/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ClientApplicationService.java
index a90740d..56740ee 100644
--- a/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ClientApplicationService.java
+++ b/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ClientApplicationService.java
@@ -25,9 +25,6 @@ import io.swagger.v3.oas.annotations.headers.Header;
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.responses.ApiResponse;
 import io.swagger.v3.oas.annotations.responses.ApiResponses;
-import io.swagger.v3.oas.annotations.security.SecurityRequirement;
-import io.swagger.v3.oas.annotations.security.SecurityRequirements;
-import io.swagger.v3.oas.annotations.tags.Tag;
 import org.apache.syncope.common.lib.to.ClientApplicationTO;
 import org.apache.syncope.common.rest.api.RESTHeaders;
 
@@ -49,11 +46,6 @@ import java.util.List;
 /**
  * REST operations for applications.
  */
-@Tag(name = "ClientApplications")
-@SecurityRequirements({
-    @SecurityRequirement(name = "BasicAuthentication"),
-    @SecurityRequirement(name = "Bearer")})
-@Path("clientApplications")
 public interface ClientApplicationService extends JAXRSService {
 
     /**
diff --git a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/OpenIdConnectRelyingPartyDataBinder.java b/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/OpenIdConnectRelyingPartyService.java
similarity index 59%
copy from core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/OpenIdConnectRelyingPartyDataBinder.java
copy to common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/OpenIdConnectRelyingPartyService.java
index 87a1f57..ce2f57c 100644
--- a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/OpenIdConnectRelyingPartyDataBinder.java
+++ b/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/OpenIdConnectRelyingPartyService.java
@@ -17,15 +17,18 @@
  *
  */
 
-package org.apache.syncope.core.provisioning.api.data;
+package org.apache.syncope.common.rest.api.service;
 
-import org.apache.syncope.common.lib.to.ClientApplicationTO;
-import org.apache.syncope.core.persistence.api.entity.authentication.OpenIdConnectRelyingParty;
+import io.swagger.v3.oas.annotations.security.SecurityRequirement;
+import io.swagger.v3.oas.annotations.security.SecurityRequirements;
+import io.swagger.v3.oas.annotations.tags.Tag;
 
-public interface OpenIdConnectRelyingPartyDataBinder {
-    OpenIdConnectRelyingParty create(ClientApplicationTO applicationTO);
+import javax.ws.rs.Path;
 
-    OpenIdConnectRelyingParty update(OpenIdConnectRelyingParty application, ClientApplicationTO applicationTO);
-
-    ClientApplicationTO getClientApplicationTO(OpenIdConnectRelyingParty application);
+@Tag(name = "OpenIdConnectRelyingParties")
+@SecurityRequirements({
+    @SecurityRequirement(name = "BasicAuthentication"),
+    @SecurityRequirement(name = "Bearer")})
+@Path("openIdConnectRelyingParties")
+public interface OpenIdConnectRelyingPartyService extends ClientApplicationService {
 }
diff --git a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/OpenIdConnectRelyingPartyDataBinder.java b/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/SAML2ServiceProviderService.java
similarity index 60%
copy from core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/OpenIdConnectRelyingPartyDataBinder.java
copy to common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/SAML2ServiceProviderService.java
index 87a1f57..2373270 100644
--- a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/OpenIdConnectRelyingPartyDataBinder.java
+++ b/common/idrepo/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/SAML2ServiceProviderService.java
@@ -17,15 +17,18 @@
  *
  */
 
-package org.apache.syncope.core.provisioning.api.data;
+package org.apache.syncope.common.rest.api.service;
 
-import org.apache.syncope.common.lib.to.ClientApplicationTO;
-import org.apache.syncope.core.persistence.api.entity.authentication.OpenIdConnectRelyingParty;
+import io.swagger.v3.oas.annotations.security.SecurityRequirement;
+import io.swagger.v3.oas.annotations.security.SecurityRequirements;
+import io.swagger.v3.oas.annotations.tags.Tag;
 
-public interface OpenIdConnectRelyingPartyDataBinder {
-    OpenIdConnectRelyingParty create(ClientApplicationTO applicationTO);
+import javax.ws.rs.Path;
 
-    OpenIdConnectRelyingParty update(OpenIdConnectRelyingParty application, ClientApplicationTO applicationTO);
-
-    ClientApplicationTO getClientApplicationTO(OpenIdConnectRelyingParty application);
+@Tag(name = "SAML2ServiceProviders")
+@SecurityRequirements({
+    @SecurityRequirement(name = "BasicAuthentication"),
+    @SecurityRequirement(name = "Bearer")})
+@Path("saml2ServiceProviders")
+public interface SAML2ServiceProviderService extends ClientApplicationService {
 }
diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java
index 24cd2f1..7256a6e 100644
--- a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java
+++ b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/AbstractClientApplicationLogic.java
@@ -24,7 +24,8 @@ import org.apache.syncope.common.lib.to.ClientApplicationTO;
 import java.lang.reflect.Method;
 import java.util.List;
 
-public abstract class AbstractClientApplicationLogic extends AbstractTransactionalLogic<ClientApplicationTO> {
+public abstract class AbstractClientApplicationLogic<T extends ClientApplicationTO>
+    extends AbstractTransactionalLogic<ClientApplicationTO> {
 
     @Override
     protected ClientApplicationTO resolveReference(final Method method, final Object... args)
@@ -32,14 +33,14 @@ public abstract class AbstractClientApplicationLogic extends AbstractTransaction
         throw new UnresolvedReferenceException();
     }
 
-    public abstract ClientApplicationTO delete(String key);
+    public abstract T delete(String key);
 
-    public abstract List<ClientApplicationTO> list();
+    public abstract List<T> list();
 
-    public abstract ClientApplicationTO read(String key);
+    public abstract T read(String key);
 
-    public abstract ClientApplicationTO create(ClientApplicationTO applicationTO);
+    public abstract T create(T applicationTO);
 
-    public abstract ClientApplicationTO update(ClientApplicationTO applicationTO);
+    public abstract T update(T applicationTO);
 
 }
diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/OpenIdConnectRelyingPartyLogic.java b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/OpenIdConnectRelyingPartyLogic.java
index f08bfdf..bd1668d 100644
--- a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/OpenIdConnectRelyingPartyLogic.java
+++ b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/OpenIdConnectRelyingPartyLogic.java
@@ -19,7 +19,7 @@
 
 package org.apache.syncope.core.logic;
 
-import org.apache.syncope.common.lib.to.ClientApplicationTO;
+import org.apache.syncope.common.lib.to.OpenIdConnectRelyingPartyTO;
 import org.apache.syncope.common.lib.types.IdRepoEntitlement;
 import org.apache.syncope.core.persistence.api.dao.NotFoundException;
 import org.apache.syncope.core.persistence.api.dao.authentication.OpenIdConnectRelyingPartyDAO;
@@ -34,7 +34,7 @@ import java.util.List;
 import java.util.stream.Collectors;
 
 @Component
-public class OpenIdConnectRelyingPartyLogic extends AbstractClientApplicationLogic {
+public class OpenIdConnectRelyingPartyLogic extends AbstractClientApplicationLogic<OpenIdConnectRelyingPartyTO> {
     @Autowired
     private OpenIdConnectRelyingPartyDAO openIdConnectRelyingPartyDAO;
 
@@ -44,7 +44,7 @@ public class OpenIdConnectRelyingPartyLogic extends AbstractClientApplicationLog
     @PreAuthorize("hasRole('" + IdRepoEntitlement.OIDC_RELYING_PARTY_READ + "')")
     @Transactional(readOnly = true)
     @Override
-    public ClientApplicationTO read(final String key) {
+    public OpenIdConnectRelyingPartyTO read(final String key) {
         OpenIdConnectRelyingParty application = openIdConnectRelyingPartyDAO.find(key);
         if (application == null) {
             LOG.error("Could not find application '" + key + '\'');
@@ -58,32 +58,32 @@ public class OpenIdConnectRelyingPartyLogic extends AbstractClientApplicationLog
     @PreAuthorize("hasRole('" + IdRepoEntitlement.OIDC_RELYING_PARTY_LIST + "')")
     @Transactional(readOnly = true)
     @Override
-    public List<ClientApplicationTO> list() {
+    public List<OpenIdConnectRelyingPartyTO> list() {
         return openIdConnectRelyingPartyDAO.findAll()
             .stream().map(binder::getClientApplicationTO).collect(Collectors.toList());
     }
 
     @PreAuthorize("hasRole('" + IdRepoEntitlement.OIDC_RELYING_PARTY_CREATE + "')")
     @Override
-    public ClientApplicationTO create(final ClientApplicationTO applicationTO) {
+    public OpenIdConnectRelyingPartyTO create(final OpenIdConnectRelyingPartyTO applicationTO) {
         return binder.getClientApplicationTO(openIdConnectRelyingPartyDAO.save(binder.create(applicationTO)));
     }
 
     @Override
     @PreAuthorize("hasRole('" + IdRepoEntitlement.APPLICATION_UPDATE + "')")
-    public ClientApplicationTO update(final ClientApplicationTO applicationTO) {
+    public OpenIdConnectRelyingPartyTO update(final OpenIdConnectRelyingPartyTO applicationTO) {
         OpenIdConnectRelyingParty application = openIdConnectRelyingPartyDAO.find(applicationTO.getKey());
         if (application == null) {
             LOG.error("Could not find application '" + applicationTO.getKey() + '\'');
             throw new NotFoundException(applicationTO.getKey());
         }
-
-        return binder.getClientApplicationTO(openIdConnectRelyingPartyDAO.save(binder.update(application, applicationTO)));
+        return binder.getClientApplicationTO(
+            openIdConnectRelyingPartyDAO.save(binder.update(application, applicationTO)));
     }
 
     @Override
     @PreAuthorize("hasRole('" + IdRepoEntitlement.OIDC_RELYING_PARTY_DELETE + "')")
-    public ClientApplicationTO delete(final String key) {
+    public OpenIdConnectRelyingPartyTO delete(final String key) {
         OpenIdConnectRelyingParty application = openIdConnectRelyingPartyDAO.find(key);
         if (application == null) {
             LOG.error("Could not find application '" + key + '\'');
@@ -91,7 +91,7 @@ public class OpenIdConnectRelyingPartyLogic extends AbstractClientApplicationLog
             throw new NotFoundException(key);
         }
 
-        ClientApplicationTO deleted = binder.getClientApplicationTO(application);
+        OpenIdConnectRelyingPartyTO deleted = binder.getClientApplicationTO(application);
         openIdConnectRelyingPartyDAO.delete(key);
         return deleted;
     }
diff --git a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/SAML2ServiceProviderLogic.java b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/SAML2ServiceProviderLogic.java
index a2d5092..8965481 100644
--- a/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/SAML2ServiceProviderLogic.java
+++ b/core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/SAML2ServiceProviderLogic.java
@@ -19,7 +19,7 @@
 
 package org.apache.syncope.core.logic;
 
-import org.apache.syncope.common.lib.to.ClientApplicationTO;
+import org.apache.syncope.common.lib.to.SAML2ServiceProviderTO;
 import org.apache.syncope.common.lib.types.IdRepoEntitlement;
 import org.apache.syncope.core.persistence.api.dao.NotFoundException;
 import org.apache.syncope.core.persistence.api.dao.authentication.SAML2ServiceProviderDAO;
@@ -34,7 +34,7 @@ import java.util.List;
 import java.util.stream.Collectors;
 
 @Component
-public class SAML2ServiceProviderLogic extends AbstractClientApplicationLogic {
+public class SAML2ServiceProviderLogic extends AbstractClientApplicationLogic<SAML2ServiceProviderTO> {
 
     @Autowired
     private SAML2ServiceProviderDAO saml2ServiceProviderDAO;
@@ -44,7 +44,7 @@ public class SAML2ServiceProviderLogic extends AbstractClientApplicationLogic {
 
     @Override
     @PreAuthorize("hasRole('" + IdRepoEntitlement.SAML2_SERVICE_PROVIDER_DELETE + "')")
-    public ClientApplicationTO delete(final String key) {
+    public SAML2ServiceProviderTO delete(final String key) {
         SAML2ServiceProvider application = saml2ServiceProviderDAO.find(key);
         if (application == null) {
             LOG.error("Could not find application '" + key + '\'');
@@ -52,7 +52,7 @@ public class SAML2ServiceProviderLogic extends AbstractClientApplicationLogic {
             throw new NotFoundException(key);
         }
 
-        ClientApplicationTO deleted = binder.getClientApplicationTO(application);
+        SAML2ServiceProviderTO deleted = binder.getClientApplicationTO(application);
         saml2ServiceProviderDAO.delete(key);
         return deleted;
     }
@@ -60,14 +60,15 @@ public class SAML2ServiceProviderLogic extends AbstractClientApplicationLogic {
     @Override
     @PreAuthorize("hasRole('" + IdRepoEntitlement.SAML2_SERVICE_PROVIDER_LIST + "')")
     @Transactional(readOnly = true)
-    public List<ClientApplicationTO> list() {
-        return saml2ServiceProviderDAO.findAll().stream().map(binder::getClientApplicationTO).collect(Collectors.toList());
+    public List<SAML2ServiceProviderTO> list() {
+        return saml2ServiceProviderDAO.findAll().stream()
+            .map(binder::getClientApplicationTO).collect(Collectors.toList());
     }
 
     @PreAuthorize("hasRole('" + IdRepoEntitlement.SAML2_SERVICE_PROVIDER_READ + "')")
     @Transactional(readOnly = true)
     @Override
-    public ClientApplicationTO read(final String key) {
+    public SAML2ServiceProviderTO read(final String key) {
         SAML2ServiceProvider application = saml2ServiceProviderDAO.find(key);
         if (application == null) {
             LOG.error("Could not find application '" + key + '\'');
@@ -80,13 +81,13 @@ public class SAML2ServiceProviderLogic extends AbstractClientApplicationLogic {
 
     @Override
     @PreAuthorize("hasRole('" + IdRepoEntitlement.SAML2_SERVICE_PROVIDER_CREATE + "')")
-    public ClientApplicationTO create(final ClientApplicationTO applicationTO) {
+    public SAML2ServiceProviderTO create(final SAML2ServiceProviderTO applicationTO) {
         return binder.getClientApplicationTO(saml2ServiceProviderDAO.save(binder.create(applicationTO)));
     }
 
     @Override
     @PreAuthorize("hasRole('" + IdRepoEntitlement.APPLICATION_UPDATE + "')")
-    public ClientApplicationTO update(final ClientApplicationTO applicationTO) {
+    public SAML2ServiceProviderTO update(final SAML2ServiceProviderTO applicationTO) {
         SAML2ServiceProvider application = saml2ServiceProviderDAO.find(applicationTO.getKey());
         if (application == null) {
             LOG.error("Could not find application '" + applicationTO.getKey() + '\'');
diff --git a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/OpenIdConnectRelyingPartyServiceImpl.java b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/OpenIdConnectRelyingPartyServiceImpl.java
index 84f01de..03ece06 100644
--- a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/OpenIdConnectRelyingPartyServiceImpl.java
+++ b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/OpenIdConnectRelyingPartyServiceImpl.java
@@ -19,13 +19,15 @@
 
 package org.apache.syncope.core.rest.cxf.service;
 
+import org.apache.syncope.common.rest.api.service.OpenIdConnectRelyingPartyService;
 import org.apache.syncope.core.logic.AbstractClientApplicationLogic;
 import org.apache.syncope.core.logic.OpenIdConnectRelyingPartyLogic;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 @Service
-public class OpenIdConnectRelyingPartyServiceImpl extends AbstractClientApplicationServiceImpl {
+public class OpenIdConnectRelyingPartyServiceImpl extends AbstractClientApplicationServiceImpl
+    implements OpenIdConnectRelyingPartyService {
     @Autowired
     private OpenIdConnectRelyingPartyLogic logic;
 
diff --git a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SAML2ServiceProviderServiceImpl.java b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SAML2ServiceProviderServiceImpl.java
index 960a442..69b41f1 100644
--- a/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SAML2ServiceProviderServiceImpl.java
+++ b/core/idrepo/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SAML2ServiceProviderServiceImpl.java
@@ -19,13 +19,16 @@
 
 package org.apache.syncope.core.rest.cxf.service;
 
+import org.apache.syncope.common.rest.api.service.SAML2ServiceProviderService;
 import org.apache.syncope.core.logic.AbstractClientApplicationLogic;
 import org.apache.syncope.core.logic.SAML2ServiceProviderLogic;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 @Service
-public class SAML2ServiceProviderServiceImpl extends AbstractClientApplicationServiceImpl {
+public class SAML2ServiceProviderServiceImpl extends AbstractClientApplicationServiceImpl
+    implements SAML2ServiceProviderService {
+    
     @Autowired
     private SAML2ServiceProviderLogic logic;
 
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAOpenIdConnectRelyingParty.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAOpenIdConnectRelyingParty.java
index 39094ae..df63b9d 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAOpenIdConnectRelyingParty.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPAOpenIdConnectRelyingParty.java
@@ -92,6 +92,7 @@ public class JPAOpenIdConnectRelyingParty extends AbstractGeneratedKeyEntity imp
 
     @Override
     public void setAuthenticationPolicy(final AuthenticationPolicy authenticationPolicy) {
+        checkType(authenticationPolicy, JPAAuthenticationPolicy.class);
         this.authenticationPolicy = (JPAAuthenticationPolicy) authenticationPolicy;
     }
 
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPASAML2ServiceProvider.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPASAML2ServiceProvider.java
index fd167d4..8ae5469 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPASAML2ServiceProvider.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/authentication/JPASAML2ServiceProvider.java
@@ -54,16 +54,6 @@ public class JPASAML2ServiceProvider extends AbstractGeneratedKeyEntity implemen
     private JPAAuthenticationPolicy authenticationPolicy;
 
     @Override
-    public JPAAuthenticationPolicy getAuthenticationPolicy() {
-        return authenticationPolicy;
-    }
-
-    @Override
-    public void setAuthenticationPolicy(final AuthenticationPolicy authenticationPolicy) {
-        this.authenticationPolicy = (JPAAuthenticationPolicy) authenticationPolicy;
-    }
-
-    @Override
     public String getEntityId() {
         return entityId;
     }
@@ -102,4 +92,15 @@ public class JPASAML2ServiceProvider extends AbstractGeneratedKeyEntity implemen
     public void setDescription(final String description) {
         this.description = description;
     }
+
+    @Override
+    public JPAAuthenticationPolicy getAuthenticationPolicy() {
+        return authenticationPolicy;
+    }
+
+    @Override
+    public void setAuthenticationPolicy(final AuthenticationPolicy authenticationPolicy) {
+        checkType(authenticationPolicy, JPAAuthenticationPolicy.class);
+        this.authenticationPolicy = (JPAAuthenticationPolicy) authenticationPolicy;
+    }
 }
diff --git a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/OpenIdConnectRelyingPartyDataBinder.java b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/OpenIdConnectRelyingPartyDataBinder.java
index 87a1f57..876276c 100644
--- a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/OpenIdConnectRelyingPartyDataBinder.java
+++ b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/OpenIdConnectRelyingPartyDataBinder.java
@@ -19,13 +19,13 @@
 
 package org.apache.syncope.core.provisioning.api.data;
 
-import org.apache.syncope.common.lib.to.ClientApplicationTO;
+import org.apache.syncope.common.lib.to.OpenIdConnectRelyingPartyTO;
 import org.apache.syncope.core.persistence.api.entity.authentication.OpenIdConnectRelyingParty;
 
 public interface OpenIdConnectRelyingPartyDataBinder {
-    OpenIdConnectRelyingParty create(ClientApplicationTO applicationTO);
+    OpenIdConnectRelyingParty create(OpenIdConnectRelyingPartyTO applicationTO);
 
-    OpenIdConnectRelyingParty update(OpenIdConnectRelyingParty application, ClientApplicationTO applicationTO);
+    OpenIdConnectRelyingParty update(OpenIdConnectRelyingParty application, OpenIdConnectRelyingPartyTO applicationTO);
 
-    ClientApplicationTO getClientApplicationTO(OpenIdConnectRelyingParty application);
+    OpenIdConnectRelyingPartyTO getClientApplicationTO(OpenIdConnectRelyingParty application);
 }
diff --git a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/SAML2ServiceProviderDataBinder.java b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/SAML2ServiceProviderDataBinder.java
index 9b3b2be..f0129cf 100644
--- a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/SAML2ServiceProviderDataBinder.java
+++ b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/SAML2ServiceProviderDataBinder.java
@@ -18,14 +18,14 @@
  */
 package org.apache.syncope.core.provisioning.api.data;
 
-import org.apache.syncope.common.lib.to.ClientApplicationTO;
+import org.apache.syncope.common.lib.to.SAML2ServiceProviderTO;
 import org.apache.syncope.core.persistence.api.entity.authentication.SAML2ServiceProvider;
 
 public interface SAML2ServiceProviderDataBinder {
 
-    SAML2ServiceProvider create(ClientApplicationTO applicationTO);
+    SAML2ServiceProvider create(SAML2ServiceProviderTO applicationTO);
 
-    SAML2ServiceProvider update(SAML2ServiceProvider application, ClientApplicationTO applicationTO);
+    SAML2ServiceProvider update(SAML2ServiceProvider application, SAML2ServiceProviderTO applicationTO);
 
-    ClientApplicationTO getClientApplicationTO(SAML2ServiceProvider application);
+    SAML2ServiceProviderTO getClientApplicationTO(SAML2ServiceProvider application);
 }
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/OpenIdConnectRelyingPartyDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/OpenIdConnectRelyingPartyDataBinderImpl.java
new file mode 100644
index 0000000..02ebc9e
--- /dev/null
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/OpenIdConnectRelyingPartyDataBinderImpl.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.core.provisioning.java.data;
+
+import org.apache.syncope.common.lib.to.OpenIdConnectRelyingPartyTO;
+import org.apache.syncope.core.persistence.api.dao.authentication.AuthenticationPolicyDAO;
+import org.apache.syncope.core.persistence.api.dao.authentication.OpenIdConnectRelyingPartyDAO;
+import org.apache.syncope.core.persistence.api.entity.EntityFactory;
+import org.apache.syncope.core.persistence.api.entity.authentication.OpenIdConnectRelyingParty;
+import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
+import org.apache.syncope.core.provisioning.api.data.OpenIdConnectRelyingPartyDataBinder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class OpenIdConnectRelyingPartyDataBinderImpl implements OpenIdConnectRelyingPartyDataBinder {
+    private static final Logger LOG = LoggerFactory.getLogger(OpenIdConnectRelyingPartyDataBinderImpl.class);
+
+    @Autowired
+    private OpenIdConnectRelyingPartyDAO openIdConnectRelyingPartyDAO;
+
+    @Autowired
+    private EntityFactory entityFactory;
+
+    @Autowired
+    private AuthenticationPolicyDAO authenticationPolicyDAO;
+    
+    @Override
+    public OpenIdConnectRelyingParty create(final OpenIdConnectRelyingPartyTO applicationTO) {
+        return update(entityFactory.newEntity(OpenIdConnectRelyingParty.class), applicationTO);
+    }
+
+    @Override
+    public OpenIdConnectRelyingParty update(final OpenIdConnectRelyingParty toBeUpdated, final OpenIdConnectRelyingPartyTO applicationTO) {
+        OpenIdConnectRelyingParty application = openIdConnectRelyingPartyDAO.save(toBeUpdated);
+
+        application.setDescription(applicationTO.getDescription());
+        application.setName(applicationTO.getName());
+        application.setClientSecret(applicationTO.getClientSecret());
+        application.setClientId(applicationTO.getClientId());
+        application.setRedirectUris(applicationTO.getRedirectUris());
+
+        AuthenticationPolicy authenticationPolicy = authenticationPolicyDAO.
+            find(applicationTO.getAuthenticationPolicy().getKey());
+        application.setAuthenticationPolicy(authenticationPolicy);
+
+        return application;
+    }
+
+    @Override
+    public OpenIdConnectRelyingPartyTO getClientApplicationTO(final OpenIdConnectRelyingParty serviceProvider) {
+        OpenIdConnectRelyingPartyTO applicationTO = new OpenIdConnectRelyingPartyTO();
+
+        applicationTO.setKey(serviceProvider.getKey());
+        applicationTO.setDescription(serviceProvider.getDescription());
+        applicationTO.setClientId(serviceProvider.getClientId());
+        applicationTO.setClientSecret(serviceProvider.getClientSecret());
+        applicationTO.setRedirectUris(serviceProvider.getRedirectUris());
+        applicationTO.setName(serviceProvider.getName());
+
+        return applicationTO;
+    }
+}
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/SAML2ServiceProviderDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/SAML2ServiceProviderDataBinderImpl.java
new file mode 100644
index 0000000..e7a7d6a
--- /dev/null
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/SAML2ServiceProviderDataBinderImpl.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.core.provisioning.java.data;
+
+import org.apache.syncope.common.lib.to.SAML2ServiceProviderTO;
+import org.apache.syncope.core.persistence.api.dao.authentication.AuthenticationPolicyDAO;
+import org.apache.syncope.core.persistence.api.dao.authentication.SAML2ServiceProviderDAO;
+import org.apache.syncope.core.persistence.api.entity.EntityFactory;
+import org.apache.syncope.core.persistence.api.entity.authentication.SAML2ServiceProvider;
+import org.apache.syncope.core.persistence.api.entity.policy.AuthenticationPolicy;
+import org.apache.syncope.core.provisioning.api.data.SAML2ServiceProviderDataBinder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SAML2ServiceProviderDataBinderImpl implements SAML2ServiceProviderDataBinder {
+    private static final Logger LOG = LoggerFactory.getLogger(SAML2ServiceProviderDataBinderImpl.class);
+
+    @Autowired
+    private SAML2ServiceProviderDAO saml2ServiceProviderDAO;
+
+    @Autowired
+    private EntityFactory entityFactory;
+
+    @Autowired
+    private AuthenticationPolicyDAO authenticationPolicyDAO;
+
+    @Override
+    public SAML2ServiceProvider create(final SAML2ServiceProviderTO applicationTO) {
+        return update(entityFactory.newEntity(SAML2ServiceProvider.class), applicationTO);
+    }
+
+    @Override
+    public SAML2ServiceProvider update(final SAML2ServiceProvider toBeUpdated,
+                                       final SAML2ServiceProviderTO applicationTO) {
+        SAML2ServiceProvider application = saml2ServiceProviderDAO.save(toBeUpdated);
+
+        application.setDescription(applicationTO.getDescription());
+        application.setName(applicationTO.getName());
+        application.setEntityId(applicationTO.getEntityId());
+        application.setMetadataLocation(applicationTO.getMetadataLocation());
+
+        AuthenticationPolicy authenticationPolicy = authenticationPolicyDAO.
+            find(applicationTO.getAuthenticationPolicy().getKey());
+        application.setAuthenticationPolicy(authenticationPolicy);
+
+        return application;
+    }
+
+    @Override
+    public SAML2ServiceProviderTO getClientApplicationTO(final SAML2ServiceProvider serviceProvider) {
+        SAML2ServiceProviderTO applicationTO = new SAML2ServiceProviderTO();
+
+        applicationTO.setKey(serviceProvider.getKey());
+        applicationTO.setDescription(serviceProvider.getDescription());
+        applicationTO.setEntityId(serviceProvider.getEntityId());
+        applicationTO.setMetadataLocation(serviceProvider.getMetadataLocation());
+        applicationTO.setName(serviceProvider.getName());
+
+        return applicationTO;
+    }
+}