package com.ndpmedia.rocketmq.authentication;

import com.ndpmedia.rocketmq.cockpit.util.LoginConstant;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * the spring security configuration.
 * when the access is denied.
 */
public class RocketMQUserAccessDeniedHandler implements AccessDeniedHandler, LoginConstant {
    private String accessDeniedURL;

    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response,
                       AccessDeniedException accessDeniedException) throws IOException, ServletException {
        response.sendRedirect(accessDeniedURL);
        String deniedMessage = accessDeniedException.getMessage();

        request.getSession().setAttribute(ACCESS_DENIED_MSG, deniedMessage);
    }

    public String getAccessDeniedURL() {
        return accessDeniedURL;
    }

    public void setAccessDeniedURL(String accessDeniedURL) {
        this.accessDeniedURL = accessDeniedURL;
    }
}

@@ -805,55 +805,235 @@
 n %7B%0A
-        response.sendRedirect(accessDeniedURL);
+%0A        if (accessDeniedURL.startsWith(%22/%22)) %7B%0A            response.sendRedirect(accessDeniedURL);%0A        %7D else %7B%0A            accessDeniedURL = request.getServletContext().getContextPath() + %22/%22 + accessDeniedURL;%0A        %7D%0A
 %0A   

Fix redirect path