Commit 80eba845f788a74da1dc09141f1a0bfafa6d7fc8
1 parent
62ee06d9
Exists in
master
FWK-222: Exibindo a mensagem correta no response payload com HTTP 401 e
403 Task-Url: https://demoiselle.atlassian.net/browse/FWK-222
Showing
2 changed files
with
8 additions
and
2 deletions
Show diff stats
impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/AuthenticationExceptionMapper.java
| ... | ... | @@ -41,6 +41,7 @@ import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED; |
| 41 | 41 | |
| 42 | 42 | import java.util.logging.Logger; |
| 43 | 43 | |
| 44 | +import javax.ws.rs.Produces; | |
| 44 | 45 | import javax.ws.rs.core.Response; |
| 45 | 46 | import javax.ws.rs.ext.ExceptionMapper; |
| 46 | 47 | import javax.ws.rs.ext.Provider; |
| ... | ... | @@ -58,12 +59,14 @@ public class AuthenticationExceptionMapper implements ExceptionMapper<Authentica |
| 58 | 59 | private transient Logger logger; |
| 59 | 60 | |
| 60 | 61 | @Override |
| 62 | + @Produces("text/plain") | |
| 61 | 63 | public Response toResponse(AuthenticationException exception) { |
| 62 | 64 | int status = SC_UNAUTHORIZED; |
| 65 | + | |
| 63 | 66 | String message = getBundle().getString("mapping-violations", status); |
| 64 | 67 | getLogger().log(FINE, message, exception); |
| 65 | 68 | |
| 66 | - return Response.status(status).build(); | |
| 69 | + return Response.status(status).entity(exception.getMessage()).build(); | |
| 67 | 70 | } |
| 68 | 71 | |
| 69 | 72 | private ResourceBundle getBundle() { | ... | ... |
impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/AuthorizationExceptionMapper.java
| ... | ... | @@ -41,6 +41,7 @@ import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN; |
| 41 | 41 | |
| 42 | 42 | import java.util.logging.Logger; |
| 43 | 43 | |
| 44 | +import javax.ws.rs.Produces; | |
| 44 | 45 | import javax.ws.rs.core.Response; |
| 45 | 46 | import javax.ws.rs.ext.ExceptionMapper; |
| 46 | 47 | import javax.ws.rs.ext.Provider; |
| ... | ... | @@ -58,12 +59,14 @@ public class AuthorizationExceptionMapper implements ExceptionMapper<Authorizati |
| 58 | 59 | private transient Logger logger; |
| 59 | 60 | |
| 60 | 61 | @Override |
| 62 | + @Produces("text/plain") | |
| 61 | 63 | public Response toResponse(AuthorizationException exception) { |
| 62 | 64 | int status = SC_FORBIDDEN; |
| 65 | + | |
| 63 | 66 | String message = getBundle().getString("mapping-violations", status); |
| 64 | 67 | getLogger().log(FINE, message, exception); |
| 65 | 68 | |
| 66 | - return Response.status(status).build(); | |
| 69 | + return Response.status(status).entity(exception.getMessage()).build(); | |
| 67 | 70 | } |
| 68 | 71 | |
| 69 | 72 | private ResourceBundle getBundle() { | ... | ... |