public interface SystemAuthenticator
Example usage:
authenticator.withSystem(() -> { // valid current thread's authentication presents here return null; });;or
authenticator.begin(); try { // valid current thread's authentication presents here } finally { authenticator.end(); }
Modifier and Type | Interface and Description |
---|---|
static interface |
SystemAuthenticator.AuthenticatedOperation<T> |
Modifier and Type | Method and Description |
---|---|
org.springframework.security.core.Authentication |
begin()
Authenticate as the 'system' user.
|
org.springframework.security.core.Authentication |
begin(java.lang.String login)
Begins an authenticated code block.
|
void |
end()
End of an authenticated code block.
|
<T> T |
withSystem(SystemAuthenticator.AuthenticatedOperation<T> operation)
Execute code as the 'system' user.
|
<T> T |
withUser(java.lang.String login,
SystemAuthenticator.AuthenticatedOperation<T> operation)
Execute code on behalf of the specified user.
|
org.springframework.security.core.Authentication begin(@Nullable java.lang.String login)
end()
.
Subsequent end()
method must be called in "finally" section.login
- user login. If null, authenticates as the 'system' user.Authentication
objectorg.springframework.security.core.Authentication begin()
begin(String)
with null parameter.void end()
<T> T withUser(@Nullable java.lang.String login, SystemAuthenticator.AuthenticatedOperation<T> operation)
login
- user login. If null, the system session is used.operation
- code to execute<T> T withSystem(SystemAuthenticator.AuthenticatedOperation<T> operation)
operation
- code to execute