eclipse / kapua

Eclipse Public License 2.0
222 stars 160 forks source link

:recycle: [Service Configuration] Service Configurations refactoring #4079

Open dseurotech opened 1 month ago

dseurotech commented 1 month ago

This PR continues the work initiated during the DI introduction, separating the logic of service configuration management into the ServiceConfigurationManager implementations. This also changes how ServiceConfigurationManagers are wired - managers are no longer annotated with @Named but are wired as contributors to a Map, e.g.:

    @ProvidesIntoMap
    @ClassMapKey(UserService.class)
    @Singleton
    ServiceConfigurationManager userServiceConfigurationManager(

Unfortunately Guice does not support overriding for Map binder entries, therefore each service configuration manager has been isolated in a separate Module wiring file. If you need to change the behaviour of any ServiceConfigurationManager, configure the locator.xml to ignore that full class name (including the package name) and provide a new implementation.

Having all service configuration managers in a map was functional to solve a vulnerability issue present in the Rest Apis, which were instantiating classes based on the name provided by the user. Now the value provided by the user is matched (at the string level) with the list of available keys.

Furthermore, within this PR the logic to retrieve the TMetadata for services has been isolated in its own provider, allowing for alternative implementations.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 62.19081% with 214 lines in your changes missing coverage. Please review.

Project coverage is 16.75%. Comparing base (ca5615b) to head (ccdca43). Report is 4 commits behind head on develop.

Files Patch % Lines
...configuration/ServiceConfigurationManagerImpl.java 5.63% 67 Missing :warning:
...configuration/ServiceConfigurationsFacadeImpl.java 0.00% 35 Missing :warning:
...cation/credential/shiro/CredentialServiceImpl.java 4.76% 20 Missing :warning:
...ion/ServiceConfigurationManagerCachingWrapper.java 0.00% 11 Missing :warning:
...cation/shiro/SystemPasswordLengthProviderImpl.java 28.57% 10 Missing :warning:
...ntial/shiro/AccountPasswordLengthProviderImpl.java 30.76% 9 Missing :warning:
...ns/configuration/KapuaConfigurableServiceBase.java 0.00% 7 Missing :warning:
...urceBasedServiceConfigurationMetadataProvider.java 30.00% 7 Missing :warning:
.../resources/v1/resources/ServiceConfigurations.java 0.00% 6 Missing :warning:
...pse/kapua/service/config/ServiceConfiguration.java 0.00% 4 Missing :warning:
... and 18 more
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/eclipse/kapua/pull/4079/graphs/tree.svg?width=650&height=150&src=pr&token=1P4N4CApH8&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse)](https://app.codecov.io/gh/eclipse/kapua/pull/4079?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse) ```diff @@ Coverage Diff @@ ## develop #4079 +/- ## ========================================== Coverage 16.75% 16.75% Complexity 22 22 ========================================== Files 2016 2023 +7 Lines 52357 52373 +16 Branches 4417 4417 ========================================== + Hits 8773 8776 +3 - Misses 43184 43198 +14 + Partials 400 399 -1 ``` | [Files](https://app.codecov.io/gh/eclipse/kapua/pull/4079?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse) | Coverage Δ | | |---|---|---| | [...ons/configuration/ServiceConfigurationManager.java](https://app.codecov.io/gh/eclipse/kapua/pull/4079?src=pr&el=tree&filepath=commons%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fcommons%2Fconfiguration%2FServiceConfigurationManager.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y29tbW9ucy9zcmMvbWFpbi9qYXZhL29yZy9lY2xpcHNlL2thcHVhL2NvbW1vbnMvY29uZmlndXJhdGlvbi9TZXJ2aWNlQ29uZmlndXJhdGlvbk1hbmFnZXIuamF2YQ==) | `0.00% <ø> (ø)` | | | [...se/kapua/commons/configuration/ValueTokenizer.java](https://app.codecov.io/gh/eclipse/kapua/pull/4079?src=pr&el=tree&filepath=commons%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fcommons%2Fconfiguration%2FValueTokenizer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y29tbW9ucy9zcmMvbWFpbi9qYXZhL29yZy9lY2xpcHNlL2thcHVhL2NvbW1vbnMvY29uZmlndXJhdGlvbi9WYWx1ZVRva2VuaXplci5qYXZh) | `89.60% <100.00%> (ø)` | | | [...onfiguration/metatype/PasswordPropertyAdapter.java](https://app.codecov.io/gh/eclipse/kapua/pull/4079?src=pr&el=tree&filepath=commons%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fcommons%2Fconfiguration%2Fmetatype%2FPasswordPropertyAdapter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y29tbW9ucy9zcmMvbWFpbi9qYXZhL29yZy9lY2xpcHNlL2thcHVhL2NvbW1vbnMvY29uZmlndXJhdGlvbi9tZXRhdHlwZS9QYXNzd29yZFByb3BlcnR5QWRhcHRlci5qYXZh) | `13.63% <ø> (ø)` | | | [.../kapua/app/api/web/RestApiJAXBContextProvider.java](https://app.codecov.io/gh/eclipse/kapua/pull/4079?src=pr&el=tree&filepath=rest-api%2Fweb%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fapp%2Fapi%2Fweb%2FRestApiJAXBContextProvider.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-cmVzdC1hcGkvd2ViL3NyYy9tYWluL2phdmEvb3JnL2VjbGlwc2Uva2FwdWEvYXBwL2FwaS93ZWIvUmVzdEFwaUpBWEJDb250ZXh0UHJvdmlkZXIuamF2YQ==) | `0.00% <ø> (ø)` | | | [.../kapua/service/account/internal/AccountModule.java](https://app.codecov.io/gh/eclipse/kapua/pull/4079?src=pr&el=tree&filepath=service%2Faccount%2Finternal%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fservice%2Faccount%2Finternal%2FAccountModule.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-c2VydmljZS9hY2NvdW50L2ludGVybmFsL3NyYy9tYWluL2phdmEvb3JnL2VjbGlwc2Uva2FwdWEvc2VydmljZS9hY2NvdW50L2ludGVybmFsL0FjY291bnRNb2R1bGUuamF2YQ==) | `93.75% <100.00%> (-0.70%)` | :arrow_down: | | [...rnal/AccountServiceConfigurationManagerModule.java](https://app.codecov.io/gh/eclipse/kapua/pull/4079?src=pr&el=tree&filepath=service%2Faccount%2Finternal%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fservice%2Faccount%2Finternal%2FAccountServiceConfigurationManagerModule.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-c2VydmljZS9hY2NvdW50L2ludGVybmFsL3NyYy9tYWluL2phdmEvb3JnL2VjbGlwc2Uva2FwdWEvc2VydmljZS9hY2NvdW50L2ludGVybmFsL0FjY291bnRTZXJ2aWNlQ29uZmlndXJhdGlvbk1hbmFnZXJNb2R1bGUuamF2YQ==) | `100.00% <100.00%> (ø)` | | | [...eclipse/kapua/model/config/metatype/EmptyTocd.java](https://app.codecov.io/gh/eclipse/kapua/pull/4079?src=pr&el=tree&filepath=service%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fmodel%2Fconfig%2Fmetatype%2FEmptyTocd.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-c2VydmljZS9hcGkvc3JjL21haW4vamF2YS9vcmcvZWNsaXBzZS9rYXB1YS9tb2RlbC9jb25maWcvbWV0YXR5cGUvRW1wdHlUb2NkLmphdmE=) | `100.00% <ø> (ø)` | | | [.../eclipse/kapua/model/config/metatype/KapuaTad.java](https://app.codecov.io/gh/eclipse/kapua/pull/4079?src=pr&el=tree&filepath=service%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fmodel%2Fconfig%2Fmetatype%2FKapuaTad.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-c2VydmljZS9hcGkvc3JjL21haW4vamF2YS9vcmcvZWNsaXBzZS9rYXB1YS9tb2RlbC9jb25maWcvbWV0YXR5cGUvS2FwdWFUYWQuamF2YQ==) | `100.00% <100.00%> (ø)` | | | [...e/kapua/model/config/metatype/KapuaTdesignate.java](https://app.codecov.io/gh/eclipse/kapua/pull/4079?src=pr&el=tree&filepath=service%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fmodel%2Fconfig%2Fmetatype%2FKapuaTdesignate.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-c2VydmljZS9hcGkvc3JjL21haW4vamF2YS9vcmcvZWNsaXBzZS9rYXB1YS9tb2RlbC9jb25maWcvbWV0YXR5cGUvS2FwdWFUZGVzaWduYXRlLmphdmE=) | `100.00% <100.00%> (ø)` | | | [...se/kapua/model/config/metatype/KapuaTmetadata.java](https://app.codecov.io/gh/eclipse/kapua/pull/4079?src=pr&el=tree&filepath=service%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fmodel%2Fconfig%2Fmetatype%2FKapuaTmetadata.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-c2VydmljZS9hcGkvc3JjL21haW4vamF2YS9vcmcvZWNsaXBzZS9rYXB1YS9tb2RlbC9jb25maWcvbWV0YXR5cGUvS2FwdWFUbWV0YWRhdGEuamF2YQ==) | `100.00% <100.00%> (ø)` | | | ... and [52 more](https://app.codecov.io/gh/eclipse/kapua/pull/4079?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse) | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/eclipse/kapua/pull/4079/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse)