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 | Constructor and Description |
|---|---|
protected |
AtlassianHostUser()
Creates a new empty Atlassian host principal (used for deserialization).
|
|
AtlassianHostUser(AtlassianHost host,
Optional<String> optionalUserKey)
Creates a new Atlassian host principal.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
AtlassianHost |
getHost()
Returns the host from which the request originated.
|
Optional<String> |
getUserKey()
The the key of the user on whose behalf a request was made.
|
int |
hashCode() |
String |
toString() |
protected AtlassianHostUser()
public AtlassianHostUser(AtlassianHost host, Optional<String> optionalUserKey)
host - the host from which the request originatedoptionalUserKey - the key of the user on whose behalf a request was made (optional)public AtlassianHost getHost()
public Optional<String> getUserKey()
Copyright © 2017 Atlassian. All rights reserved.