use of org.craftercms.studio.impl.v2.service.security.Authentication in project studio by craftercms.
the class StudioAuthenticationTokenProcessingFilter method storeToken.
private void storeToken(String token) {
RequestContext context = RequestContext.getCurrent();
if (context != null) {
HttpSession httpSession = context.getRequest().getSession();
Authentication oldAuthentication = (Authentication) httpSession.getAttribute(HTTP_SESSION_ATTRIBUTE_AUTHENTICATION);
Authentication newAuthentication = new Authentication(oldAuthentication.getUsername(), token, oldAuthentication.getAuthenticationType(), oldAuthentication.getSsoLogoutUrl());
httpSession.setAttribute(HTTP_SESSION_ATTRIBUTE_AUTHENTICATION, newAuthentication);
}
}
use of org.craftercms.studio.impl.v2.service.security.Authentication in project studio by craftercms.
the class SecurityServiceImpl method getAuthentication.
@Override
public Authentication getAuthentication() {
Authentication auth = null;
RequestContext context = RequestContext.getCurrent();
if (context != null) {
HttpSession httpSession = context.getRequest().getSession();
auth = (Authentication) httpSession.getAttribute(HTTP_SESSION_ATTRIBUTE_AUTHENTICATION);
}
return auth;
}
use of org.craftercms.studio.impl.v2.service.security.Authentication 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.impl.v2.service.security.Authentication in project studio by craftercms.
the class SecurityServiceImpl method getCurrentToken.
@Override
public String getCurrentToken() {
String ticket = 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) {
ticket = auth.getToken();
}
} else {
ticket = getJobOrEventTicket();
}
if (ticket == null) {
ticket = "NOTICKET";
}
return ticket;
}
Aggregations