All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.wavemaker.runtime.security.WMAuthenticationEntryPoint Maven / Gradle / Ivy

There is a newer version: 11.9.2.ee
Show newest version
/**
 * Copyright (C) 2020 WaveMaker, Inc.
 * 

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *

* http://www.apache.org/licenses/LICENSE-2.0 *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.wavemaker.runtime.security; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint; import com.wavemaker.runtime.security.entrypoint.FormLoginEntryPoint; import com.wavemaker.runtime.util.HttpRequestUtils; import static com.wavemaker.runtime.security.SecurityConstants.SESSION_NOT_FOUND; import static com.wavemaker.runtime.security.SecurityConstants.X_WM_LOGIN_ERROR_MESSAGE; public class WMAuthenticationEntryPoint extends LoginUrlAuthenticationEntryPoint implements FormLoginEntryPoint { /** * @param loginFormUrl URL where the login page can be found. Should either be * relative to the web-app context path (include a leading {@code /}) or an absolute * URL. */ public WMAuthenticationEntryPoint(final String loginFormUrl) { super(loginFormUrl); } @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { if (HttpRequestUtils.isAjaxRequest(request)) { response.setHeader(X_WM_LOGIN_ERROR_MESSAGE, SESSION_NOT_FOUND); response.sendError(HttpServletResponse.SC_UNAUTHORIZED); } else { super.commence(request, response, authException); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy