use of org.craftercms.studio.api.v1.ebus.RepositoryEventContext in project studio by craftercms.
the class SecurityServiceImpl method getCurrentUser.
@Override
public String getCurrentUser() {
String username = null;
RequestContext context = RequestContext.getCurrent();
if (context != null) {
HttpSession httpSession = context.getRequest().getSession();
Authentication auth = (Authentication) httpSession.getAttribute(HTTP_SESSION_ATTRIBUTE_AUTHENTICATION);
if (auth != null) {
username = auth.getUsername();
}
} else {
CronJobContext cronJobContext = CronJobContext.getCurrent();
if (cronJobContext != null) {
username = cronJobContext.getCurrentUser();
} else {
RepositoryEventContext repositoryEventContext = RepositoryEventContext.getCurrent();
if (repositoryEventContext != null) {
username = repositoryEventContext.getCurrentUser();
}
}
}
return username;
}
use of org.craftercms.studio.api.v1.ebus.RepositoryEventContext in project studio by craftercms.
the class SecurityServiceImpl method getJobOrEventTicket.
protected String getJobOrEventTicket() {
String ticket = null;
CronJobContext cronJobContext = CronJobContext.getCurrent();
if (cronJobContext != null) {
ticket = cronJobContext.getAuthenticationToken();
} else {
RepositoryEventContext repositoryEventContext = RepositoryEventContext.getCurrent();
if (repositoryEventContext != null) {
ticket = repositoryEventContext.getAuthenticationToken();
}
}
return ticket;
}
Aggregations