use of io.jmix.core.security.ClientDetails in project jmix by jmix-framework.
the class LastSecurityFilter method parseRequestLocale.
/**
* Method parses the request locale and sets it to the authentication
*/
protected void parseRequestLocale(ServletRequest request) {
Locale locale = localeProvider.getLocale((HttpServletRequest) request);
if (locale != null) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication instanceof OAuth2Authentication) {
Authentication userAuthentication = ((OAuth2Authentication) authentication).getUserAuthentication();
if (userAuthentication.getDetails() instanceof ClientDetails && userAuthentication instanceof AbstractAuthenticationToken) {
ClientDetails clientDetails = (ClientDetails) userAuthentication.getDetails();
((AbstractAuthenticationToken) userAuthentication).setDetails(ClientDetails.builder().of(clientDetails).locale(locale).build());
}
}
}
}
Aggregations