UserService (interface)

Allows the domain object to obtain the identity of the user interacting with said object.

If SudoService has been used to temporarily override the user and/or roles, then this service will report the overridden values instead.

API

UserService.java
interface UserService {
  Optional<UserMemento> currentUser()     (1)
  UserMemento getUser()     (2)
  UserMemento currentUserElseFail()     (3)
  Optional<String> currentUserName()     (4)
  String currentUserNameElseNobody()     (5)
}
1 currentUser()

Optionally gets the details about the current user, based on whether an ExecutionContext can be found with the current thread’s context.

2 getUser()

Gets the details about the current user.

3 currentUserElseFail()

Gets the details about the current user.

4 currentUserName()

Optionally gets the the current user’s name, based on whether an ExecutionContext can be found with the current thread’s context.

5 currentUserNameElseNobody()

Returns either the current user’s name or else Nobody .

Members

currentUser()

Optionally gets the details about the current user, based on whether an ExecutionContext can be found with the current thread’s context.

getUser()

Gets the details about the current user.

currentUserElseFail()

Gets the details about the current user.

currentUserName()

Optionally gets the the current user’s name, based on whether an ExecutionContext can be found with the current thread’s context.

currentUserNameElseNobody()

Returns either the current user’s name or else Nobody .

Implementation

The core framework provides a default implementation of this service (o.a.i.core.runtime.services.user.UserServiceDefault).

Usage by Framework

The roles associated with the UserMemento will be based on the configured security (typically Shiro).

In addition, when using the Web UI (Wicket viewer) there will be an additional "org.apache.isis.viewer.wicket.roles.USER" role; this is used internally to restrict access to web pages without authenticating.