5 changed files with 309 additions and 864 deletions
@ -0,0 +1,54 @@ |
|||||||
|
package de.superx.saiku; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
|
||||||
|
import jakarta.servlet.FilterChain; |
||||||
|
import jakarta.servlet.ServletException; |
||||||
|
import jakarta.servlet.ServletRequest; |
||||||
|
import jakarta.servlet.ServletResponse; |
||||||
|
import jakarta.servlet.http.HttpServletRequest; |
||||||
|
|
||||||
|
import org.apache.log4j.Logger; |
||||||
|
import org.springframework.context.ApplicationContext; |
||||||
|
import org.springframework.security.web.authentication.AnonymousAuthenticationFilter; |
||||||
|
import org.springframework.security.core.context.SecurityContextHolder; |
||||||
|
import org.springframework.web.context.WebApplicationContext; |
||||||
|
|
||||||
|
import de.superx.servlet.RequestParameter; |
||||||
|
import de.superx.servlet.ServletBasics; |
||||||
|
import de.superx.servlet.UserInitializer; |
||||||
|
|
||||||
|
public class SuperXLDAPAnmeldungFilter extends AnonymousAuthenticationFilter { |
||||||
|
public static Logger logger = Logger.getLogger(SuperXLDAPAnmeldungFilter.class); |
||||||
|
|
||||||
|
public SuperXLDAPAnmeldungFilter(String key) { |
||||||
|
super(key); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) |
||||||
|
throws IOException, ServletException { |
||||||
|
HttpServletRequest req=(HttpServletRequest) request; |
||||||
|
if(SecurityContextHolder.getContext().getAuthentication()!=null |
||||||
|
&& req.getSession().getAttribute("user")==null) |
||||||
|
{ |
||||||
|
String kennungImRequest = SecurityContextHolder.getContext().getAuthentication().getName(); |
||||||
|
if (kennungImRequest != null ) { |
||||||
|
logger.debug("Gastanmeldung kennung=gast* im Request gefunden"); |
||||||
|
UserInitializer ui; |
||||||
|
try { |
||||||
|
/*ui = new UserInitializer((HttpServletRequest) request); |
||||||
|
ui.perform(null, (ApplicationContext) request.getServletContext() |
||||||
|
.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE)); |
||||||
|
logger.info("Gastanmeldung als " + ui.getUser().getName()+" erfolgreich");*/ |
||||||
|
} catch (Exception e) { |
||||||
|
e.printStackTrace(); |
||||||
|
logger.error("Gastanmeldung fehlgeschlagen " + e); |
||||||
|
throw new ServletException("Gastanmeldung fehlgeschlagen " + e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
chain.doFilter(request, response); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
Binary file not shown.
Loading…
Reference in new issue