@Component(value="ui_LoginScreenSupport")
public class LoginScreenSupport
extends java.lang.Object
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); }
AuthDetails
Modifier and Type | Field and Description |
---|---|
protected io.jmix.core.AccessManager |
accessManager |
protected org.springframework.context.ApplicationEventPublisher |
applicationEventPublisher |
protected org.springframework.security.authentication.AuthenticationManager |
authenticationManager |
protected io.jmix.ui.sys.AppCookies |
cookies |
protected io.jmix.core.CoreProperties |
coreProperties |
protected io.jmix.ui.deviceinfo.DeviceInfoProvider |
deviceInfoProvider |
protected io.jmix.core.Messages |
messages |
protected org.springframework.security.web.authentication.RememberMeServices |
rememberMeServices |
protected io.jmix.ui.ScreenBuilders |
screenBuilders |
protected io.jmix.ui.UiProperties |
uiProperties |
Constructor and Description |
---|
LoginScreenSupport() |
Modifier and Type | Method and Description |
---|---|
org.springframework.security.core.Authentication |
authenticate(AuthDetails authDetails,
io.jmix.ui.screen.FrameOwner frameOwner)
Performs authentication via
AuthenticationManager and uses
UsernamePasswordAuthenticationToken with credentials from AuthDetails . |
protected void |
checkLoginToUi(AuthDetails authDetails,
org.springframework.security.core.Authentication authentication) |
protected org.springframework.security.core.Authentication |
createAuthenticationToken(java.lang.String username,
java.lang.String password,
java.util.Locale locale,
java.util.TimeZone timeZone) |
protected io.jmix.ui.sys.AppCookies |
getCookies() |
protected java.util.Locale |
getDefaultLocale() |
protected java.util.TimeZone |
getDeviceTimeZone() |
protected void |
onSuccessfulAuthentication(org.springframework.security.core.Authentication authentication,
AuthDetails authDetails,
io.jmix.ui.screen.FrameOwner frameOwner) |
protected void |
saveCookies(AuthDetails authDetails) |
void |
setAccessManager(io.jmix.core.AccessManager accessManager) |
void |
setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) |
void |
setAuthenticationManager(org.springframework.security.authentication.AuthenticationManager authenticationManager) |
void |
setAuthenticationStrategy(org.springframework.security.web.authentication.session.SessionAuthenticationStrategy authenticationStrategy) |
void |
setCoreProperties(io.jmix.core.CoreProperties coreProperties) |
void |
setDeviceInfoProvider(io.jmix.ui.deviceinfo.DeviceInfoProvider deviceInfoProvider) |
void |
setMessages(io.jmix.core.Messages messages) |
void |
setRememberMeServices(org.springframework.security.web.authentication.RememberMeServices rememberMeServices) |
void |
setScreenBuilders(io.jmix.ui.ScreenBuilders screenBuilders) |
void |
setUiProperties(io.jmix.ui.UiProperties uiProperties) |
protected void |
showMainScreen(io.jmix.ui.screen.FrameOwner frameOwner) |
protected org.springframework.security.authentication.AuthenticationManager authenticationManager
protected io.jmix.ui.UiProperties uiProperties
protected io.jmix.core.CoreProperties coreProperties
protected io.jmix.ui.ScreenBuilders screenBuilders
protected io.jmix.core.AccessManager accessManager
protected io.jmix.core.Messages messages
protected io.jmix.ui.deviceinfo.DeviceInfoProvider deviceInfoProvider
protected org.springframework.security.web.authentication.RememberMeServices rememberMeServices
protected org.springframework.context.ApplicationEventPublisher applicationEventPublisher
protected io.jmix.ui.sys.AppCookies cookies
@Autowired public void setAuthenticationManager(org.springframework.security.authentication.AuthenticationManager authenticationManager)
@Autowired public void setUiProperties(io.jmix.ui.UiProperties uiProperties)
@Autowired public void setCoreProperties(io.jmix.core.CoreProperties coreProperties)
@Autowired public void setScreenBuilders(io.jmix.ui.ScreenBuilders screenBuilders)
@Autowired public void setAccessManager(io.jmix.core.AccessManager accessManager)
@Autowired public void setMessages(io.jmix.core.Messages messages)
@Autowired public void setDeviceInfoProvider(io.jmix.ui.deviceinfo.DeviceInfoProvider deviceInfoProvider)
@Autowired public void setRememberMeServices(org.springframework.security.web.authentication.RememberMeServices rememberMeServices)
@Autowired(required=false) public void setAuthenticationStrategy(org.springframework.security.web.authentication.session.SessionAuthenticationStrategy authenticationStrategy)
@Autowired public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
public org.springframework.security.core.Authentication authenticate(AuthDetails authDetails, @Nullable io.jmix.ui.screen.FrameOwner frameOwner) throws org.springframework.security.core.AuthenticationException
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
.
authDetails
- authentication detailsframeOwner
- invoking screen to open main screenorg.springframework.security.core.AuthenticationException
- if exception occurs while authentication processprotected void onSuccessfulAuthentication(org.springframework.security.core.Authentication authentication, AuthDetails authDetails, @Nullable io.jmix.ui.screen.FrameOwner frameOwner)
protected void saveCookies(AuthDetails authDetails)
protected void checkLoginToUi(AuthDetails authDetails, org.springframework.security.core.Authentication authentication)
protected void showMainScreen(@Nullable io.jmix.ui.screen.FrameOwner frameOwner)
protected org.springframework.security.core.Authentication createAuthenticationToken(java.lang.String username, java.lang.String password, @Nullable java.util.Locale locale, @Nullable java.util.TimeZone timeZone)
protected java.util.Locale getDefaultLocale()
@Nullable protected java.util.TimeZone getDeviceTimeZone()
protected io.jmix.ui.sys.AppCookies getCookies()