Skip to content

Commit

Permalink
Fix #1685: Backport Fix #1683: Provide default lang.json for external…
Browse files Browse the repository at this point in the history
… resources
  • Loading branch information
romanstrobl committed Aug 6, 2024
1 parent 5004255 commit 35731da
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
import io.getlime.security.powerauth.rest.api.spring.annotation.support.PowerAuthEncryptionArgumentResolver;
import io.getlime.security.powerauth.rest.api.spring.annotation.support.PowerAuthWebArgumentResolver;
import io.getlime.security.powerauth.rest.api.spring.filter.PowerAuthRequestFilter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.UrlResource;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean;
Expand All @@ -52,11 +54,15 @@
* @author Petr Dvorak, petr@wultra.com
*/
@Configuration
@Slf4j
public class WebMvcConfiguration implements WebMvcConfigurer {

@Autowired
private WebFlowServerConfiguration configuration;

@Autowired
private ResourceLoader resourceLoader;

/* Register PowerAuth 2.0 Server Beans */

/**
Expand Down Expand Up @@ -139,7 +145,12 @@ public ReloadableResourceBundleMessageSourceWithListing messageSource() {

@Bean
public Resource languageSettingSource() throws MalformedURLException {
return new UrlResource(configuration.getResourcesLocation() + "lang.json");
Resource resource = resourceLoader.getResource(configuration.getResourcesLocation() + "lang.json");
if (!resource.exists()) {
logger.info("The lang.json file was not found in {}, using default location", configuration.getResourcesLocation());
resource = new UrlResource("classpath:/static/resources/lang.json");
}
return resource;
}

@Override
Expand Down

0 comments on commit 35731da

Please sign in to comment.