public final class AtlassianHostUser extends Object
This class is the Atlassian Connect equivalent of Spring Security's User and can be resolved as a Spring
MVC controller argument by using the AuthenticationPrincipal annotation:
@Controller public class HelloWorldController { @RequestMapping(value = "/helloWorld", method = GET) public String (@AuthenticationPrincipal AtlassianHostUser hostUser) { ... } }
Outside of the context of a controller, the current authentication principal can be obtained programmatically via
SecurityContextHolder:
Optional<AtlassianHostUser> optionalHostUser = Optional.ofNullable(SecurityContextHolder.getContext().getAuthentication()) .map(Authentication::getPrincipal) .filter(AtlassianHostUser.class::isInstance) .map(AtlassianHostUser.class::cast);
| Modifier and Type | Class and Description |
|---|---|
static class |
AtlassianHostUser.AtlassianHostUserBuilder
Builder used to create an
AtlassianHostUser. |
| Modifier | Constructor and Description |
|---|---|
protected |
AtlassianHostUser()
Creates a new empty Atlassian host principal (used for deserialization).
|
|
AtlassianHostUser(AtlassianHost host,
Optional<String> optionalUserKey)
Deprecated.
as of 1.5.0 with migration to Atlassian Account ID, replaced by
AtlassianHostUser.AtlassianHostUserBuilder |
| Modifier and Type | Method and Description |
|---|---|
static AtlassianHostUser.AtlassianHostUserBuilder |
builder(AtlassianHost host)
Creates an
AtlassianHostUser.AtlassianHostUserBuilder using the provided host. |
boolean |
equals(Object o) |
AtlassianHost |
getHost()
Returns the host from which the request originated.
|
Optional<String> |
getUserAccountId()
The Atlassian Account ID of the user on whose behalf a request was made.
|
Optional<String> |
getUserKey()
Deprecated.
as of 1.5.0 with migration to Atlassian Account ID
|
int |
hashCode() |
String |
toString() |
protected AtlassianHostUser()
@Deprecated public AtlassianHostUser(AtlassianHost host, Optional<String> optionalUserKey)
AtlassianHostUser.AtlassianHostUserBuilderhost - the host from which the request originatedoptionalUserKey - the key of the user on whose behalf a request was made (optional)public AtlassianHost getHost()
@Deprecated public Optional<String> getUserKey()
public Optional<String> getUserAccountId()
public static AtlassianHostUser.AtlassianHostUserBuilder builder(AtlassianHost host)
AtlassianHostUser.AtlassianHostUserBuilder using the provided host.host - the host to create the AtlassianHostUser forCopyright © 2019 Atlassian. All rights reserved.