class OAuthConfigurationService {

  public void updateOAuthConfiguration(AuthenticationProperties authenticationProperties) {
    Collection<OAuthConfiguration> oAuthConfigurations = getOAuthConfigurations();

    OAuthConfiguration clientId =
        getConfigurationByName(oAuthConfigurations, OAuthConfigurationName.CLIENT_ID);
    OAuthConfiguration clientSecret =
        getConfigurationByName(oAuthConfigurations, OAuthConfigurationName.CLIENT_SECRET);
    OAuthConfiguration scope =
        getConfigurationByName(oAuthConfigurations, OAuthConfigurationName.SCOPE);

    clientId.setValue(authenticationProperties.getClientId());
    clientSecret.setValue(authenticationProperties.getClientSecret());
    scope.setValue(authenticationProperties.getScope());

    oAuthConfigurationRepository.save(clientId);
    oAuthConfigurationRepository.save(clientSecret);
    oAuthConfigurationRepository.save(scope);

    logger.info("Updated OAuth Configuration");
  }

}