kapua icon indicating copy to clipboard operation
kapua copied to clipboard

:recycle: [Service Configuration] Service Configurations refactoring

Open dseurotech opened this issue 1 year ago • 1 comments

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.

dseurotech avatar Jul 09 '24 13:07 dseurotech

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

@@            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 Coverage Δ
...ons/configuration/ServiceConfigurationManager.java 0.00% <ø> (ø)
...se/kapua/commons/configuration/ValueTokenizer.java 89.60% <100.00%> (ø)
...onfiguration/metatype/PasswordPropertyAdapter.java 13.63% <ø> (ø)
.../kapua/app/api/web/RestApiJAXBContextProvider.java 0.00% <ø> (ø)
.../kapua/service/account/internal/AccountModule.java 93.75% <100.00%> (-0.70%) :arrow_down:
...rnal/AccountServiceConfigurationManagerModule.java 100.00% <100.00%> (ø)
...eclipse/kapua/model/config/metatype/EmptyTocd.java 100.00% <ø> (ø)
.../eclipse/kapua/model/config/metatype/KapuaTad.java 100.00% <100.00%> (ø)
...e/kapua/model/config/metatype/KapuaTdesignate.java 100.00% <100.00%> (ø)
...se/kapua/model/config/metatype/KapuaTmetadata.java 100.00% <100.00%> (ø)
... and 52 more

... and 1 file with indirect coverage changes

codecov[bot] avatar Jul 09 '24 13:07 codecov[bot]