4c3671c0f7a9b9a51c0acc996b044cf9c0ebc6b1
[examples/facebook-app] / src / main / java / de / juplo / yourshouter / SocialAuthenticationEntryPoint.java
1 package de.juplo.yourshouter;
2
3 import java.io.IOException;
4 import javax.servlet.ServletException;
5 import javax.servlet.http.HttpServletRequest;
6 import javax.servlet.http.HttpServletResponse;
7 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory;
9 import org.springframework.security.core.AuthenticationException;
10 import org.springframework.security.web.AuthenticationEntryPoint;
11 import org.springframework.stereotype.Service;
12
13
14 /**
15  * Specialized implementation of {@link AuthenticationEntryPoint}, that
16  * redirects to the social sign-in-page, to let the user decide to sign in or
17  * not.
18  *
19  * @author Kai Moritz
20  */
21 @Service
22 public class SocialAuthenticationEntryPoint implements AuthenticationEntryPoint
23 {
24   private static final Logger LOG =
25       LoggerFactory.getLogger(SocialAuthenticationEntryPoint.class);
26
27
28   /**
29    * {@inheritDoc}
30    *
31    * To commence the sign-in through the Graph-API, we only have to redirect
32    * to our already implemented sign-in-page.
33    */
34   @Override
35   public void commence(
36       HttpServletRequest request,
37       HttpServletResponse response,
38       AuthenticationException exception
39       )
40       throws
41         IOException,
42         ServletException
43   {
44     LOG.info(
45         "redirecting unauthenticated request {} to /signin.html",
46         request.getRequestURI()
47         );
48     response.sendRedirect("/signin.html");
49   }
50 }