Commit 7409afbb43fb768332a270c73186365b70830c25

Authored by Cleverson Sacramento
1 parent 757f5ef5
Exists in master

O autenticador do arquétipo html-rest aceita qualquer username desde que

a senha seja "secret"
archetype/html-rest/src/main/resources/archetype-resources/src/main/java/security/AppAuthenticator.java
@@ -19,7 +19,7 @@ public class AppAuthenticator implements Authenticator { @@ -19,7 +19,7 @@ public class AppAuthenticator implements Authenticator {
19 public void authenticate() throws Exception { 19 public void authenticate() throws Exception {
20 Credentials credentials = Beans.getReference(Credentials.class); 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 this.user = new AppUser(credentials.getUsername()); 23 this.user = new AppUser(credentials.getUsername());
24 } else { 24 } else {
25 throw new InvalidCredentialsException(); 25 throw new InvalidCredentialsException();
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
30 <filter-class>br.gov.frameworkdemoiselle.util.CacheFilter</filter-class> 30 <filter-class>br.gov.frameworkdemoiselle.util.CacheFilter</filter-class>
31 <init-param> 31 <init-param>
32 <param-name>value</param-name> 32 <param-name>value</param-name>
33 - <param-value>max-age=9223372036854775807,public</param-value> 33 + <param-value>max-age=9223372036854775807</param-value>
34 </init-param> 34 </init-param>
35 </filter> 35 </filter>
36 <filter-mapping> 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,13 +10,19 @@ import javax.ws.rs.Path;
10 import javax.ws.rs.PathParam; 10 import javax.ws.rs.PathParam;
11 import javax.ws.rs.Produces; 11 import javax.ws.rs.Produces;
12 12
  13 +import org.slf4j.Logger;
  14 +
13 import br.gov.frameworkdemoiselle.NotFoundException; 15 import br.gov.frameworkdemoiselle.NotFoundException;
  16 +import br.gov.frameworkdemoiselle.ServiceUnavailableException;
14 import br.gov.frameworkdemoiselle.util.Metadata; 17 import br.gov.frameworkdemoiselle.util.Metadata;
15 18
16 @Path("metadata") 19 @Path("metadata")
17 public class MetadataREST { 20 public class MetadataREST {
18 21
19 @Inject 22 @Inject
  23 + private Logger logger;
  24 +
  25 + @Inject
20 private ResourceBundle bundle; 26 private ResourceBundle bundle;
21 27
22 @GET 28 @GET
@@ -29,8 +35,16 @@ public class MetadataREST { @@ -29,8 +35,16 @@ public class MetadataREST {
29 @GET 35 @GET
30 @Path("version") 36 @Path("version")
31 @Produces("text/plain") 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 @GET 50 @GET