package de.gessnerfl.rabbitmq.queue.management.service.security;

import de.gessnerfl.rabbitmq.queue.management.javaconfig.LdapAuthWebSecurityConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import org.springframework.security.web.util.UrlUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class RedirectToOriginalUrlAuthenticationSuccessHandler  extends SimpleUrlAuthenticationSuccessHandler {
    private static final Logger LOGGER = LoggerFactory.getLogger(RedirectToOriginalUrlAuthenticationSuccessHandler.class);
    private static final String DEFAULT_TARGET_URL = "/";

    public RedirectToOriginalUrlAuthenticationSuccessHandler() {
        super(DEFAULT_TARGET_URL);
        this.setTargetUrlParameter(LdapAuthWebSecurityConfig.TARGET_AFTER_SUCCESSFUL_LOGIN_PARAM);
    }

    @Override
    protected String determineTargetUrl(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
        var targetUrl = super.determineTargetUrl(request, response, authentication);
        if (UrlUtils.isAbsoluteUrl(targetUrl)) {
            LOGGER.warn("Absolute target URL {} identified and suppressed", targetUrl.replaceAll("[\n\r\t]", "_"));
            return DEFAULT_TARGET_URL;
        }
        return targetUrl;
    }
}

@@ -147,65 +147,8 @@
 ig;%0A
-import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A
 impo
@@ -200,16 +200,16 @@
 cation;%0A
+
 import o
@@ -560,131 +560,8 @@
 r %7B%0A
-    private static final Logger LOGGER = LoggerFactory.getLogger(RedirectToOriginalUrlAuthenticationSuccessHandler.class);%0A
     
@@ -1051,16 +1051,16 @@
 ation);%0A
+
         
@@ -1104,124 +1104,8 @@
 ) %7B%0A
-            LOGGER.warn(%22Absolute target URL %7B%7D identified and suppressed%22, targetUrl.replaceAll(%22%5B%5Cn%5Cr%5Ct%5D%22, %22_%22));%0A
     

remove unneeded logging logging