@Component(value="cuba_Authentication")
public class Authentication
extends java.lang.Object
authentication.begin(); try { // valid current thread's user session presents here } finally { authentication.end(); }
Modifier and Type | Class and Description |
---|---|
static interface |
Authentication.AuthenticatedOperation<T> |
Modifier and Type | Field and Description |
---|---|
protected AuthenticationManager |
authenticationManager |
protected java.lang.ThreadLocal<java.lang.Integer> |
cleanupCounter |
static java.lang.String |
NAME |
protected ServerConfig |
serverConfig |
protected java.util.Map<java.lang.String,java.util.UUID> |
sessions |
protected UserSessionsAPI |
userSessions |
Constructor and Description |
---|
Authentication() |
Modifier and Type | Method and Description |
---|---|
UserSession |
begin()
Authenticate with login set in
cuba.jmxUserLogin app property. |
UserSession |
begin(java.lang.String login)
Begin an authenticated code block.
|
void |
end()
End of an authenticated code block.
|
protected java.lang.String |
getSystemLogin() |
<T> T |
withSystemUser(Authentication.AuthenticatedOperation<T> operation)
Execute code on behalf of the user with login set in
cuba.jmxUserLogin app property. |
<T> T |
withUser(java.lang.String login,
Authentication.AuthenticatedOperation<T> operation)
Execute code on behalf of the specified user.
|
public static final java.lang.String NAME
@Inject protected AuthenticationManager authenticationManager
@Inject protected UserSessionsAPI userSessions
@Inject protected ServerConfig serverConfig
protected java.lang.ThreadLocal<java.lang.Integer> cleanupCounter
protected java.util.Map<java.lang.String,java.util.UUID> sessions
public UserSession begin(@Nullable java.lang.String login)
end()
method must be called in "finally" section.login
- user login. If null, a value of cuba.jmxUserLogin
app property is used.public UserSession begin()
cuba.jmxUserLogin
app property.
begin(String)
with null parameterpublic void end()
public <T> T withUser(@Nullable java.lang.String login, Authentication.AuthenticatedOperation<T> operation)
login
- user login. If null, a value of cuba.jmxUserLogin
app property is used.operation
- code to executepublic <T> T withSystemUser(Authentication.AuthenticatedOperation<T> operation)
cuba.jmxUserLogin
app property.operation
- code to executeprotected java.lang.String getSystemLogin()