package es.esky.rol.security;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

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

public class TokenAuthenticationEntryPoint implements AuthenticationEntryPoint {

    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException {
        response.addHeader("WWW-Authenticate", "Basic realm=\"TOKEN_API\"");
        response.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage());
    }
}

@@ -1,8 +1,630 @@
+/*%0A * Copyright 2016-2017 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0A
 package 
@@ -901,16 +901,192 @@
 ption;%0A%0A
+/**%0A * Http basic authentication token based entry point.%0A * %3Cp%3E%0A * Configure entry point to respond with an 401 http error and set Token realm in www-authenticate header.%0A */%0A
 public c
@@ -1159,16 +1159,53 @@
 oint %7B%0A%0A
+    /**%0A     * %7B@inheritDoc%7D%0A     */%0A
     @Ove

Add documentation