Package io.jmix.core.security.impl
Class SystemAuthenticatorImpl
java.lang.Object
io.jmix.core.security.impl.SystemAuthenticatorSupport
io.jmix.core.security.impl.SystemAuthenticatorImpl
- All Implemented Interfaces:
SystemAuthenticator
@Component("core_SystemAuthenticator")
public class SystemAuthenticatorImpl
extends SystemAuthenticatorSupport
implements SystemAuthenticator
-
Nested Class Summary
Nested classes/interfaces inherited from class io.jmix.core.security.impl.SystemAuthenticatorSupport
SystemAuthenticatorSupport.NullAuthentication
Nested classes/interfaces inherited from interface io.jmix.core.security.SystemAuthenticator
SystemAuthenticator.AuthenticatedOperation<T>
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.springframework.security.authentication.AuthenticationManager
Fields inherited from class io.jmix.core.security.impl.SystemAuthenticatorSupport
NULL_AUTHENTICATION, threadLocalStack
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.core.Authentication
begin()
Authenticate as the 'system' user.org.springframework.security.core.Authentication
Begins an authenticated code block.protected void
beginServerSessionOnStartup
(org.springframework.context.event.ContextRefreshedEvent event) void
end()
End of an authenticated code block.protected void
endServerSessionOnStartup
(org.springframework.context.event.ContextRefreshedEvent event) void
runWithSystem
(Runnable operation) Execute code as the 'system' user.void
runWithUser
(String login, Runnable operation) Execute code on behalf of the specified user.<T> T
withSystem
(SystemAuthenticator.AuthenticatedOperation<T> operation) Execute code as the 'system' user and return a result.<T> T
withUser
(String login, SystemAuthenticator.AuthenticatedOperation<T> operation) Execute code on behalf of the specified user and return a result.Methods inherited from class io.jmix.core.security.impl.SystemAuthenticatorSupport
pollAuthentication, pushAuthentication
-
Field Details
-
authenticationManager
@Autowired(required=false) protected org.springframework.security.authentication.AuthenticationManager authenticationManager
-
-
Constructor Details
-
SystemAuthenticatorImpl
public SystemAuthenticatorImpl()
-
-
Method Details
-
beginServerSessionOnStartup
@EventListener @Order(105) protected void beginServerSessionOnStartup(org.springframework.context.event.ContextRefreshedEvent event) -
endServerSessionOnStartup
@EventListener @Order(995) protected void endServerSessionOnStartup(org.springframework.context.event.ContextRefreshedEvent event) -
begin
Description copied from interface:SystemAuthenticator
Begins an authenticated code block.
Saves the current thread session on a stack to get it back onSystemAuthenticator.end()
. SubsequentSystemAuthenticator.end()
method must be called in "finally" section.- Specified by:
begin
in interfaceSystemAuthenticator
- Parameters:
login
- user login. If null, authenticates as the 'system' user.- Returns:
- populated
Authentication
object
-
begin
public org.springframework.security.core.Authentication begin()Description copied from interface:SystemAuthenticator
Authenticate as the 'system' user.
Same asSystemAuthenticator.begin(String)
with null parameter.- Specified by:
begin
in interfaceSystemAuthenticator
-
end
public void end()Description copied from interface:SystemAuthenticator
End of an authenticated code block.
The previous session (or null) is set to security context. Must be called in "finally" section of a try/finally block.- Specified by:
end
in interfaceSystemAuthenticator
-
withUser
public <T> T withUser(@Nullable String login, SystemAuthenticator.AuthenticatedOperation<T> operation) Description copied from interface:SystemAuthenticator
Execute code on behalf of the specified user and return a result.- Specified by:
withUser
in interfaceSystemAuthenticator
- Parameters:
login
- user login. If null, the system session is used.operation
- code to execute- Returns:
- result of the execution
-
runWithUser
Description copied from interface:SystemAuthenticator
Execute code on behalf of the specified user.- Specified by:
runWithUser
in interfaceSystemAuthenticator
- Parameters:
login
- user login. If null, the system session is used.operation
- code to execute
-
withSystem
Description copied from interface:SystemAuthenticator
Execute code as the 'system' user and return a result.- Specified by:
withSystem
in interfaceSystemAuthenticator
- Parameters:
operation
- code to execute- Returns:
- result of the execution
-
runWithSystem
Description copied from interface:SystemAuthenticator
Execute code as the 'system' user.- Specified by:
runWithSystem
in interfaceSystemAuthenticator
- Parameters:
operation
- code to execute
-