Class LoginScreenSupport

java.lang.Object
io.jmix.securityui.authentication.LoginScreenSupport

@Component("ui_LoginScreenSupport") public class LoginScreenSupport extends Object
Class that provides authentication via AuthenticationManager. It is intended to use from login screen.

Example usage:

 @Autowired
 private LoginScreenAuthenticator authenticator;

 private void doLogin(String username, String password) {
     Authentication authentication = authenticationSupport.authenticate(
             AuthDetails.of(username, password)
                     .withLocale(localesField.getValue())
                     .withRememberMe(rememberMeCheckBox.isChecked()), this);
 }

 
See Also:
  • Field Details

    • authenticationManager

      protected org.springframework.security.authentication.AuthenticationManager authenticationManager
    • uiProperties

      protected UiProperties uiProperties
    • coreProperties

      protected CoreProperties coreProperties
    • screenBuilders

      protected ScreenBuilders screenBuilders
    • accessManager

      protected AccessManager accessManager
    • messages

      protected Messages messages
    • deviceInfoProvider

      protected DeviceInfoProvider deviceInfoProvider
    • rememberMeServices

      protected org.springframework.security.web.authentication.RememberMeServices rememberMeServices
    • applicationEventPublisher

      protected org.springframework.context.ApplicationEventPublisher applicationEventPublisher
    • cookies

      protected AppCookies cookies
  • Constructor Details

    • LoginScreenSupport

      public LoginScreenSupport()
  • Method Details

    • setAuthenticationManager

      @Autowired public void setAuthenticationManager(org.springframework.security.authentication.AuthenticationManager authenticationManager)
    • setUiProperties

      @Autowired public void setUiProperties(UiProperties uiProperties)
    • setCoreProperties

      @Autowired public void setCoreProperties(CoreProperties coreProperties)
    • setScreenBuilders

      @Autowired public void setScreenBuilders(ScreenBuilders screenBuilders)
    • setAccessManager

      @Autowired public void setAccessManager(AccessManager accessManager)
    • setMessages

      @Autowired public void setMessages(Messages messages)
    • setDeviceInfoProvider

      @Autowired public void setDeviceInfoProvider(DeviceInfoProvider deviceInfoProvider)
    • setRememberMeServices

      @Autowired public void setRememberMeServices(org.springframework.security.web.authentication.RememberMeServices rememberMeServices)
    • setAuthenticationStrategy

      @Autowired(required=false) public void setAuthenticationStrategy(org.springframework.security.web.authentication.session.SessionAuthenticationStrategy authenticationStrategy)
    • setApplicationEventPublisher

      @Autowired public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
    • authenticate

      public org.springframework.security.core.Authentication authenticate(AuthDetails authDetails, @Nullable FrameOwner frameOwner) throws org.springframework.security.core.AuthenticationException
      Performs authentication via AuthenticationManager and uses UsernamePasswordAuthenticationToken with credentials from AuthDetails.

      If locale is not provided it will use the first locale from CoreProperties.getAvailableLocales() list.

      After successful authentication, there will be an attempt to open the main screen using UiProperties.getMainScreenId() from FrameOwner if it is not null.

      Parameters:
      authDetails - authentication details
      frameOwner - invoking screen to open main screen
      Returns:
      a fully authenticated object including credentials
      Throws:
      org.springframework.security.core.AuthenticationException - if exception occurs while authentication process
    • onSuccessfulAuthentication

      protected void onSuccessfulAuthentication(org.springframework.security.core.Authentication authentication, AuthDetails authDetails, @Nullable FrameOwner frameOwner)
    • saveCookies

      protected void saveCookies(AuthDetails authDetails)
    • checkLoginToUi

      protected void checkLoginToUi(AuthDetails authDetails, org.springframework.security.core.Authentication authentication)
    • showMainScreen

      protected void showMainScreen(@Nullable FrameOwner frameOwner)
    • createAuthenticationToken

      protected org.springframework.security.core.Authentication createAuthenticationToken(String username, String password, @Nullable Locale locale, @Nullable TimeZone timeZone)
    • getDefaultLocale

      protected Locale getDefaultLocale()
    • getDeviceTimeZone

      @Nullable protected TimeZone getDeviceTimeZone()
    • getCookies

      protected AppCookies getCookies()