public RunAsLifecycleInterceptor(final Map<String, RunAsIdentityMetaData> runAsIdentityMetaDataMap) {
this.runAsIdentityMetaDataMap = runAsIdentityMetaDataMap;
}
private void handle(ServletInfo servletInfo, LifecycleContext context) throws ServletException {
RunAsIdentityMetaData identity = null;
RunAs old = null;
SecurityContext sc = SecurityActions.getSecurityContext();
if (sc == null) {
context.proceed();
return;
}
try {
identity = runAsIdentityMetaDataMap.get(servletInfo.getName());
RunAsIdentity runAsIdentity = null;
if (identity != null) {
UndertowLogger.ROOT_LOGGER.tracef("%s, runAs: %s", servletInfo.getName(), identity);
runAsIdentity = new RunAsIdentity(identity.getRoleName(), identity.getPrincipalName(), identity.getRunAsRoles());
}
old = SecurityActions.setRunAsIdentity(runAsIdentity, sc);
// Perform the request
context.proceed();