Commit 38aba6bffe1a1465c3e4c9bad2030c5828c1ba31
1 parent
6d43430f
Exists in
master
Ajuste no tratamento de Invalid Credencials
Showing
2 changed files
with
17 additions
and
13 deletions
Show diff stats
impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/security/AbstractHTTPAuthorizationFilter.java
@@ -57,12 +57,11 @@ import javax.servlet.http.HttpServletResponse; | @@ -57,12 +57,11 @@ import javax.servlet.http.HttpServletResponse; | ||
57 | 57 | ||
58 | import br.gov.frameworkdemoiselle.util.Beans; | 58 | import br.gov.frameworkdemoiselle.util.Beans; |
59 | import br.gov.frameworkdemoiselle.util.NameQualifier; | 59 | import br.gov.frameworkdemoiselle.util.NameQualifier; |
60 | -import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
61 | import br.gov.frameworkdemoiselle.util.Strings; | 60 | import br.gov.frameworkdemoiselle.util.Strings; |
62 | 61 | ||
63 | public abstract class AbstractHTTPAuthorizationFilter implements Filter { | 62 | public abstract class AbstractHTTPAuthorizationFilter implements Filter { |
64 | 63 | ||
65 | - private transient ResourceBundle bundle; | 64 | + // private transient ResourceBundle bundle; |
66 | 65 | ||
67 | private transient Logger logger; | 66 | private transient Logger logger; |
68 | 67 | ||
@@ -94,9 +93,8 @@ public abstract class AbstractHTTPAuthorizationFilter implements Filter { | @@ -94,9 +93,8 @@ public abstract class AbstractHTTPAuthorizationFilter implements Filter { | ||
94 | performLogout(request, response); | 93 | performLogout(request, response); |
95 | 94 | ||
96 | } catch (InvalidCredentialsException cause) { | 95 | } catch (InvalidCredentialsException cause) { |
97 | - String message = getBundle().getString("authentication-failed"); | ||
98 | - getLogger().log(FINE, message, cause); | ||
99 | - | 96 | + // String message = getBundle().getString(cause.getMessage()); |
97 | + getLogger().log(FINE, cause.getMessage(), cause); | ||
100 | setUnauthorizedStatus(response, cause); | 98 | setUnauthorizedStatus(response, cause); |
101 | } | 99 | } |
102 | 100 | ||
@@ -163,13 +161,13 @@ public abstract class AbstractHTTPAuthorizationFilter implements Filter { | @@ -163,13 +161,13 @@ public abstract class AbstractHTTPAuthorizationFilter implements Filter { | ||
163 | response.getWriter().write(cause.getMessage()); | 161 | response.getWriter().write(cause.getMessage()); |
164 | } | 162 | } |
165 | 163 | ||
166 | - private ResourceBundle getBundle() { | ||
167 | - if (bundle == null) { | ||
168 | - bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-rest-bundle")); | ||
169 | - } | ||
170 | - | ||
171 | - return bundle; | ||
172 | - } | 164 | + // private ResourceBundle getBundle() { |
165 | + // if (bundle == null) { | ||
166 | + // bundle = Beans.getReference(ResourceBundle.class, new NameQualifier("demoiselle-rest-bundle")); | ||
167 | + // } | ||
168 | + // | ||
169 | + // return bundle; | ||
170 | + // } | ||
173 | 171 | ||
174 | private Logger getLogger() { | 172 | private Logger getLogger() { |
175 | if (logger == null) { | 173 | if (logger == null) { |
impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/util/ValidatePayloadInterceptor.java
@@ -45,6 +45,7 @@ import javax.interceptor.Interceptor; | @@ -45,6 +45,7 @@ import javax.interceptor.Interceptor; | ||
45 | import javax.interceptor.InvocationContext; | 45 | import javax.interceptor.InvocationContext; |
46 | import javax.validation.ConstraintViolation; | 46 | import javax.validation.ConstraintViolation; |
47 | import javax.validation.ConstraintViolationException; | 47 | import javax.validation.ConstraintViolationException; |
48 | +import javax.validation.UnexpectedTypeException; | ||
48 | import javax.validation.Validation; | 49 | import javax.validation.Validation; |
49 | import javax.validation.Validator; | 50 | import javax.validation.Validator; |
50 | import javax.validation.ValidatorFactory; | 51 | import javax.validation.ValidatorFactory; |
@@ -68,7 +69,12 @@ public class ValidatePayloadInterceptor implements Serializable { | @@ -68,7 +69,12 @@ public class ValidatePayloadInterceptor implements Serializable { | ||
68 | if (params != null) { | 69 | if (params != null) { |
69 | ValidatorFactory dfv = Validation.buildDefaultValidatorFactory(); | 70 | ValidatorFactory dfv = Validation.buildDefaultValidatorFactory(); |
70 | Validator validator = dfv.getValidator(); | 71 | Validator validator = dfv.getValidator(); |
71 | - violations.addAll(validator.validate(params)); | 72 | + |
73 | + try { | ||
74 | + violations.addAll(validator.validate(params)); | ||
75 | + } catch (UnexpectedTypeException cause) { | ||
76 | + // TODO Colocar a mensagem no log | ||
77 | + } | ||
72 | } | 78 | } |
73 | } | 79 | } |
74 | 80 |