Commit e2d97c2573a1847b62abaca71940a1fcdb13bef1
Exists in
master
Merge branch '2.4.0' of https://github.com/demoiselle/framework.git into 2.4.0
Showing
6 changed files
with
219 additions
and
1 deletions
Show diff stats
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/JsfSecurityConfig.java
| @@ -41,7 +41,7 @@ import java.io.Serializable; | @@ -41,7 +41,7 @@ import java.io.Serializable; | ||
| 41 | import br.gov.frameworkdemoiselle.annotation.Name; | 41 | import br.gov.frameworkdemoiselle.annotation.Name; |
| 42 | import br.gov.frameworkdemoiselle.configuration.Configuration; | 42 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
| 43 | 43 | ||
| 44 | -@Configuration(prefix = "frameworkdemoiselle.security.") | 44 | +@Configuration(prefix = "frameworkdemoiselle.security") |
| 45 | public class JsfSecurityConfig implements Serializable { | 45 | public class JsfSecurityConfig implements Serializable { |
| 46 | 46 | ||
| 47 | private static final long serialVersionUID = 1L; | 47 | private static final long serialVersionUID = 1L; |
impl/extension/jsf/src/test/java/exception/handler/authentication/AuthenticationBean.java
0 → 100644
| @@ -0,0 +1,50 @@ | @@ -0,0 +1,50 @@ | ||
| 1 | +/* | ||
| 2 | + * Demoiselle Framework | ||
| 3 | + * Copyright (C) 2010 SERPRO | ||
| 4 | + * ---------------------------------------------------------------------------- | ||
| 5 | + * This file is part of Demoiselle Framework. | ||
| 6 | + * | ||
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | ||
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | ||
| 9 | + * as published by the Free Software Foundation. | ||
| 10 | + * | ||
| 11 | + * This program is distributed in the hope that it will be useful, | ||
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | + * GNU General Public License for more details. | ||
| 15 | + * | ||
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | ||
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | ||
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 20 | + * ---------------------------------------------------------------------------- | ||
| 21 | + * Este arquivo é parte do Framework Demoiselle. | ||
| 22 | + * | ||
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
| 25 | + * do Software Livre (FSF). | ||
| 26 | + * | ||
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
| 30 | + * para maiores detalhes. | ||
| 31 | + * | ||
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | ||
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
| 36 | + */ | ||
| 37 | +package exception.handler.authentication; | ||
| 38 | + | ||
| 39 | +import br.gov.frameworkdemoiselle.security.NotLoggedInException; | ||
| 40 | +import br.gov.frameworkdemoiselle.stereotype.ViewController; | ||
| 41 | + | ||
| 42 | +@ViewController | ||
| 43 | +public class AuthenticationBean { | ||
| 44 | + | ||
| 45 | + private String msg = "Authentication Exception"; | ||
| 46 | + | ||
| 47 | + public String getMsg() { | ||
| 48 | + throw new NotLoggedInException(msg); | ||
| 49 | + } | ||
| 50 | +} |
impl/extension/jsf/src/test/java/exception/handler/authentication/AuthenticationExceptionTest.java
0 → 100644
| @@ -0,0 +1,90 @@ | @@ -0,0 +1,90 @@ | ||
| 1 | +/* | ||
| 2 | + * Demoiselle Framework | ||
| 3 | + * Copyright (C) 2010 SERPRO | ||
| 4 | + * ---------------------------------------------------------------------------- | ||
| 5 | + * This file is part of Demoiselle Framework. | ||
| 6 | + * | ||
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | ||
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | ||
| 9 | + * as published by the Free Software Foundation. | ||
| 10 | + * | ||
| 11 | + * This program is distributed in the hope that it will be useful, | ||
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | + * GNU General Public License for more details. | ||
| 15 | + * | ||
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | ||
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | ||
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 20 | + * ---------------------------------------------------------------------------- | ||
| 21 | + * Este arquivo é parte do Framework Demoiselle. | ||
| 22 | + * | ||
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
| 25 | + * do Software Livre (FSF). | ||
| 26 | + * | ||
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
| 30 | + * para maiores detalhes. | ||
| 31 | + * | ||
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | ||
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
| 36 | + */ | ||
| 37 | +package exception.handler.authentication; | ||
| 38 | + | ||
| 39 | +import static org.junit.Assert.assertTrue; | ||
| 40 | + | ||
| 41 | +import java.io.IOException; | ||
| 42 | +import java.net.URL; | ||
| 43 | + | ||
| 44 | +import org.apache.commons.httpclient.HttpClient; | ||
| 45 | +import org.apache.commons.httpclient.HttpException; | ||
| 46 | +import org.apache.commons.httpclient.methods.GetMethod; | ||
| 47 | +import org.jboss.arquillian.container.test.api.Deployment; | ||
| 48 | +import org.jboss.arquillian.junit.Arquillian; | ||
| 49 | +import org.jboss.arquillian.test.api.ArquillianResource; | ||
| 50 | +import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
| 51 | +import org.junit.Test; | ||
| 52 | +import org.junit.runner.RunWith; | ||
| 53 | + | ||
| 54 | +import test.Tests; | ||
| 55 | + | ||
| 56 | +@RunWith(Arquillian.class) | ||
| 57 | +public class AuthenticationExceptionTest { | ||
| 58 | + | ||
| 59 | + @ArquillianResource | ||
| 60 | + private URL deploymentUrl; | ||
| 61 | + | ||
| 62 | + private static final String PATH = "src/test/resources/security-authentication"; | ||
| 63 | + | ||
| 64 | + @Deployment(testable = false) | ||
| 65 | + public static WebArchive createDeployment() { | ||
| 66 | + return Tests.createDeployment().addClass(AuthenticationExceptionTest.class) | ||
| 67 | + .addClass(AuthenticationBean.class) | ||
| 68 | + .addAsWebResource(Tests.createFileAsset(PATH + "/index.xhtml"), "index.xhtml") | ||
| 69 | + .addAsWebResource(Tests.createFileAsset(PATH + "/login.xhtml"), "login.xhtml") | ||
| 70 | + .addAsWebInfResource(Tests.createFileAsset(PATH + "/web.xml"), "web.xml"); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + @Test | ||
| 74 | + public void authenticationException() { | ||
| 75 | + HttpClient client = new HttpClient(); | ||
| 76 | + GetMethod method = new GetMethod(deploymentUrl + "/index.jsf"); | ||
| 77 | + | ||
| 78 | + try { | ||
| 79 | + client.executeMethod(method); | ||
| 80 | + String message = method.getResponseBodyAsString(); | ||
| 81 | + System.out.println("MESAGE: " + message); | ||
| 82 | + assertTrue(message.contains("Called the page /login")); | ||
| 83 | + | ||
| 84 | + } catch (HttpException e) { | ||
| 85 | + e.printStackTrace(); | ||
| 86 | + } catch (IOException e) { | ||
| 87 | + e.printStackTrace(); | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | +} |
impl/extension/jsf/src/test/resources/security-authentication/index.xhtml
0 → 100644
impl/extension/jsf/src/test/resources/security-authentication/login.xhtml
0 → 100644
impl/extension/jsf/src/test/resources/security-authentication/web.xml
0 → 100644
| @@ -0,0 +1,61 @@ | @@ -0,0 +1,61 @@ | ||
| 1 | +<!-- | ||
| 2 | + Demoiselle Framework | ||
| 3 | + Copyright (C) 2010 SERPRO | ||
| 4 | + ============================================================================ | ||
| 5 | + This file is part of Demoiselle Framework. | ||
| 6 | + | ||
| 7 | + Demoiselle Framework is free software; you can redistribute it and/or | ||
| 8 | + modify it under the terms of the GNU Lesser General Public License version 3 | ||
| 9 | + as published by the Free Software Foundation. | ||
| 10 | + | ||
| 11 | + This program is distributed in the hope that it will be useful, | ||
| 12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | + GNU General Public License for more details. | ||
| 15 | + | ||
| 16 | + You should have received a copy of the GNU Lesser General Public License version 3 | ||
| 17 | + along with this program; if not, see <http://www.gnu.org/licenses /> | ||
| 18 | + or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
| 19 | + Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 20 | + ============================================================================ | ||
| 21 | + Este arquivo é parte do Framework Demoiselle. | ||
| 22 | + | ||
| 23 | + O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
| 24 | + modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
| 25 | + do Software Livre (FSF). | ||
| 26 | + | ||
| 27 | + Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
| 28 | + GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
| 29 | + APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
| 30 | + para maiores detalhes. | ||
| 31 | + | ||
| 32 | + Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
| 33 | + "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses /> | ||
| 34 | + ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
| 35 | + 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
| 36 | +--> | ||
| 37 | +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | ||
| 38 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> | ||
| 39 | + | ||
| 40 | + <listener> | ||
| 41 | + <listener-class>br.gov.frameworkdemoiselle.util.ServletListener</listener-class> | ||
| 42 | + </listener> | ||
| 43 | + <filter> | ||
| 44 | + <filter-name>Demoiselle Servlet Filter</filter-name> | ||
| 45 | + <filter-class>br.gov.frameworkdemoiselle.util.ServletFilter</filter-class> | ||
| 46 | + </filter> | ||
| 47 | + <filter-mapping> | ||
| 48 | + <filter-name>Demoiselle Servlet Filter</filter-name> | ||
| 49 | + <url-pattern>/*</url-pattern> | ||
| 50 | + </filter-mapping> | ||
| 51 | + | ||
| 52 | + <servlet> | ||
| 53 | + <servlet-name>Faces Servlet</servlet-name> | ||
| 54 | + <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> | ||
| 55 | + <load-on-startup>1</load-on-startup> | ||
| 56 | + </servlet> | ||
| 57 | + <servlet-mapping> | ||
| 58 | + <servlet-name>Faces Servlet</servlet-name> | ||
| 59 | + <url-pattern>*.jsf</url-pattern> | ||
| 60 | + </servlet-mapping> | ||
| 61 | +</web-app> | ||
| 0 | \ No newline at end of file | 62 | \ No newline at end of file |