>>>>> Steinar Bang <s...@dod.no>:

>>> Is there a code example somewhere of an SCR component that saves a
>>> value to a cfg file in karaf?

> Looks like injecting a ConfigRepository service may be the way to go...?
>  
> https://github.com/apache/karaf/blob/main/config/core/src/main/java/org/apache/karaf/config/core/ConfigRepository.java#L26

> I will try!

Using ConfigReposity worked.

This code gets config matching a pid which is the fully qualified
classname and looks for the value "cipherkey". If no value can be found
a new value is created and saved using ConfigRepository:
 
https://github.com/steinarb/authservice/blob/fc6c29fb5cede9d9f3e8d4212124adc815ac6cf6/authservice/authservice.web.security.cipherkey/src/main/java/no/priv/bang/authservice/web/security/cipherkey/ChipherKeyServiceProvider.java#L32

Reply via email to