A self hosted chat application with end-to-end encrypted messaging.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
997 B

5 years ago
5 years ago
5 years ago
  1. package org.ros.chatto;
  2. import java.io.IOException;
  3. import java.io.PrintWriter;
  4. import javax.servlet.ServletException;
  5. import javax.servlet.http.HttpServletRequest;
  6. import javax.servlet.http.HttpServletResponse;
  7. import org.springframework.security.core.AuthenticationException;
  8. import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint;
  9. import org.springframework.stereotype.Component;
  10. @Component
  11. public final class RESTAuthenticationEntryPoint
  12. extends BasicAuthenticationEntryPoint {
  13. @Override
  14. public void commence(HttpServletRequest request,
  15. HttpServletResponse response, AuthenticationException authEx)
  16. throws IOException, ServletException {
  17. response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
  18. PrintWriter writer = response.getWriter();
  19. writer.println("HTTP ApplicationStatus 401 - " + authEx.getMessage());
  20. }
  21. @Override
  22. public void afterPropertiesSet() throws Exception {
  23. setRealmName("Chatto");
  24. super.afterPropertiesSet();
  25. }
  26. }