+package de.juplo.yourshouter;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.web.AuthenticationEntryPoint;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * Specialized implementation of {@link AuthenticationEntryPoint}, that
+ * redirects to the social sign-in-page, to let the user decide to sign in or
+ * not.
+ *
+ * @author Kai Moritz
+ */
+@Service
+public class SocialAuthenticationEntryPoint implements AuthenticationEntryPoint
+{
+ private static final Logger LOG =
+ LoggerFactory.getLogger(SocialAuthenticationEntryPoint.class);
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * To commence the sign-in through the Graph-API, we only have to redirect
+ * to our already implemented sign-in-page.
+ */
+ @Override
+ public void commence(
+ HttpServletRequest request,
+ HttpServletResponse response,
+ AuthenticationException exception
+ )
+ throws
+ IOException,
+ ServletException
+ {
+ LOG.info(
+ "redirecting unauthenticated request {} to /signin.html",
+ request.getRequestURI()
+ );
+ response.sendRedirect("/signin.html");
+ }
+}