Commit 7409afbb43fb768332a270c73186365b70830c25
1 parent
757f5ef5
Exists in
master
O autenticador do arquétipo html-rest aceita qualquer username desde que
a senha seja "secret"
Showing
3 changed files
with
18 additions
and
4 deletions
Show diff stats
archetype/html-rest/src/main/resources/archetype-resources/src/main/java/security/AppAuthenticator.java
| ... | ... | @@ -19,7 +19,7 @@ public class AppAuthenticator implements Authenticator { |
| 19 | 19 | public void authenticate() throws Exception { |
| 20 | 20 | Credentials credentials = Beans.getReference(Credentials.class); |
| 21 | 21 | |
| 22 | - if (credentials.getUsername().equals("admin") && credentials.getPassword().equals("admin")) { | |
| 22 | + if (credentials.getPassword().equals("secret")) { | |
| 23 | 23 | this.user = new AppUser(credentials.getUsername()); |
| 24 | 24 | } else { |
| 25 | 25 | throw new InvalidCredentialsException(); | ... | ... |
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
| ... | ... | @@ -30,7 +30,7 @@ |
| 30 | 30 | <filter-class>br.gov.frameworkdemoiselle.util.CacheFilter</filter-class> |
| 31 | 31 | <init-param> |
| 32 | 32 | <param-name>value</param-name> |
| 33 | - <param-value>max-age=9223372036854775807,public</param-value> | |
| 33 | + <param-value>max-age=9223372036854775807</param-value> | |
| 34 | 34 | </init-param> |
| 35 | 35 | </filter> |
| 36 | 36 | <filter-mapping> | ... | ... |
impl/extension/rest/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/MetadataREST.java
| ... | ... | @@ -10,13 +10,19 @@ import javax.ws.rs.Path; |
| 10 | 10 | import javax.ws.rs.PathParam; |
| 11 | 11 | import javax.ws.rs.Produces; |
| 12 | 12 | |
| 13 | +import org.slf4j.Logger; | |
| 14 | + | |
| 13 | 15 | import br.gov.frameworkdemoiselle.NotFoundException; |
| 16 | +import br.gov.frameworkdemoiselle.ServiceUnavailableException; | |
| 14 | 17 | import br.gov.frameworkdemoiselle.util.Metadata; |
| 15 | 18 | |
| 16 | 19 | @Path("metadata") |
| 17 | 20 | public class MetadataREST { |
| 18 | 21 | |
| 19 | 22 | @Inject |
| 23 | + private Logger logger; | |
| 24 | + | |
| 25 | + @Inject | |
| 20 | 26 | private ResourceBundle bundle; |
| 21 | 27 | |
| 22 | 28 | @GET |
| ... | ... | @@ -29,8 +35,16 @@ public class MetadataREST { |
| 29 | 35 | @GET |
| 30 | 36 | @Path("version") |
| 31 | 37 | @Produces("text/plain") |
| 32 | - public String getAppVersion() { | |
| 33 | - return bundle.getString("application.version"); | |
| 38 | + public String getAppVersion() throws Exception { | |
| 39 | + String key = "application.version"; | |
| 40 | + | |
| 41 | + if (!bundle.containsKey(key)) { | |
| 42 | + // logger.debug(); | |
| 43 | + | |
| 44 | + throw new ServiceUnavailableException(); | |
| 45 | + } | |
| 46 | + | |
| 47 | + return bundle.getString(key); | |
| 34 | 48 | } |
| 35 | 49 | |
| 36 | 50 | @GET | ... | ... |