Commit 53d345a81b747b3029b7d29b872d4c8b4450ac72

Authored by Cleverson Sacramento
1 parent 197d7321
Exists in master

Remocação da classe SecurityConfigImpl e movendo o código para

SecurityConfig.
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/SecurityConfig.java
  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 + */
1 37 package br.gov.frameworkdemoiselle.internal.configuration;
2 38  
  39 +import java.io.Serializable;
  40 +
  41 +import br.gov.frameworkdemoiselle.annotation.Name;
  42 +import br.gov.frameworkdemoiselle.configuration.Configuration;
3 43 import br.gov.frameworkdemoiselle.security.Authenticator;
4 44 import br.gov.frameworkdemoiselle.security.Authorizer;
5 45  
... ... @@ -9,7 +49,19 @@ import br.gov.frameworkdemoiselle.security.Authorizer;
9 49 *
10 50 * @author SERPRO
11 51 */
12   -public interface SecurityConfig {
  52 +@Configuration(prefix = "frameworkdemoiselle.security.")
  53 +public class SecurityConfig implements Serializable {
  54 +
  55 + private static final long serialVersionUID = 1L;
  56 +
  57 + @Name("enabled")
  58 + private boolean enabled = true;
  59 +
  60 + @Name("authenticator.class")
  61 + private Class<? extends Authenticator> authenticatorClass;
  62 +
  63 + @Name("authorizer.class")
  64 + private Class<? extends Authorizer> authorizerClass;
13 65  
14 66 /**
15 67 * Tells whether or not the security is enabled for the current application. This value could be defined in the
... ... @@ -18,15 +70,27 @@ public interface SecurityConfig {
18 70 * @return the value defined for the key <i>frameworkdemoiselle.security.enabled</i> in the
19 71 * <b>demoiselle.properties</b> file. If there is no value defined, returns the default value <tt>true</tt>
20 72 */
21   - boolean isEnabled();
  73 + public boolean isEnabled() {
  74 + return this.enabled;
  75 + }
22 76  
23   - void setEnabled(boolean enabled);
  77 + public void setEnabled(boolean enabled) {
  78 + this.enabled = enabled;
  79 + }
24 80  
25   - Class<? extends Authenticator> getAuthenticatorClass();
  81 + public Class<? extends Authenticator> getAuthenticatorClass() {
  82 + return this.authenticatorClass;
  83 + }
26 84  
27   - void setAuthenticatorClass(Class<? extends Authenticator> authenticatorClass);
  85 + public void setAuthenticatorClass(Class<? extends Authenticator> authenticatorClass) {
  86 + this.authenticatorClass = authenticatorClass;
  87 + }
28 88  
29   - Class<? extends Authorizer> getAuthorizerClass();
  89 + public Class<? extends Authorizer> getAuthorizerClass() {
  90 + return this.authorizerClass;
  91 + }
30 92  
31   - void setAuthorizerClass(Class<? extends Authorizer> authorizerClass);
  93 + public void setAuthorizerClass(Class<? extends Authorizer> authorizerClass) {
  94 + this.authorizerClass = authorizerClass;
  95 + }
32 96 }
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/SecurityConfigImpl.java
... ... @@ -1,113 +0,0 @@
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 br.gov.frameworkdemoiselle.internal.configuration;
38   -
39   -import java.io.Serializable;
40   -
41   -import br.gov.frameworkdemoiselle.annotation.Name;
42   -import br.gov.frameworkdemoiselle.configuration.Configuration;
43   -import br.gov.frameworkdemoiselle.security.Authenticator;
44   -import br.gov.frameworkdemoiselle.security.Authorizer;
45   -
46   -@Configuration(prefix = "frameworkdemoiselle.security.")
47   -public class SecurityConfigImpl implements Serializable, SecurityConfig {
48   -
49   - private static final long serialVersionUID = 1L;
50   -
51   - @Name("enabled")
52   - private boolean enabled = true;
53   -
54   - @Name("authenticator.class")
55   - private Class<? extends Authenticator> authenticatorClass;
56   -
57   - @Name("authorizer.class")
58   - private Class<? extends Authorizer> authorizerClass;
59   -
60   - /*
61   - * (non-Javadoc)
62   - * @see br.gov.frameworkdemoiselle.security.SecurityConfig#isEnabled()
63   - */
64   - @Override
65   - public boolean isEnabled() {
66   - return this.enabled;
67   - }
68   -
69   - /*
70   - * (non-Javadoc)
71   - * @see br.gov.frameworkdemoiselle.security.SecurityConfig#setEnabled(boolean)
72   - */
73   - @Override
74   - public void setEnabled(boolean enabled) {
75   - this.enabled = enabled;
76   - }
77   -
78   - /*
79   - * (non-Javadoc)
80   - * @see br.gov.frameworkdemoiselle.security.SecurityConfig#getAuthenticatorClass()
81   - */
82   - @Override
83   - public Class<? extends Authenticator> getAuthenticatorClass() {
84   - return this.authenticatorClass;
85   - }
86   -
87   - /*
88   - * (non-Javadoc)
89   - * @see br.gov.frameworkdemoiselle.security.SecurityConfig#setAuthenticatorClass(java.lang.Class)
90   - */
91   - @Override
92   - public void setAuthenticatorClass(Class<? extends Authenticator> authenticatorClass) {
93   - this.authenticatorClass = authenticatorClass;
94   - }
95   -
96   - /*
97   - * (non-Javadoc)
98   - * @see br.gov.frameworkdemoiselle.security.SecurityConfig#getAuthorizerClass()
99   - */
100   - @Override
101   - public Class<? extends Authorizer> getAuthorizerClass() {
102   - return this.authorizerClass;
103   - }
104   -
105   - /*
106   - * (non-Javadoc)
107   - * @see br.gov.frameworkdemoiselle.security.SecurityConfig#setAuthorizerClass(java.lang.Class)
108   - */
109   - @Override
110   - public void setAuthorizerClass(Class<? extends Authorizer> authorizerClass) {
111   - this.authorizerClass = authorizerClass;
112   - }
113   -}
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImpl.java
... ... @@ -45,7 +45,6 @@ import br.gov.frameworkdemoiselle.DemoiselleException;
45 45 import br.gov.frameworkdemoiselle.internal.bootstrap.AuthenticatorBootstrap;
46 46 import br.gov.frameworkdemoiselle.internal.bootstrap.AuthorizerBootstrap;
47 47 import br.gov.frameworkdemoiselle.internal.configuration.SecurityConfig;
48   -import br.gov.frameworkdemoiselle.internal.configuration.SecurityConfigImpl;
49 48 import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;
50 49 import br.gov.frameworkdemoiselle.security.AfterLoginSuccessful;
51 50 import br.gov.frameworkdemoiselle.security.AfterLogoutSuccessful;
... ... @@ -205,7 +204,7 @@ public class SecurityContextImpl implements SecurityContext {
205 204 }
206 205  
207 206 private SecurityConfig getConfig() {
208   - return Beans.getReference(SecurityConfigImpl.class);
  207 + return Beans.getReference(SecurityConfig.class);
209 208 }
210 209  
211 210 public void checkLoggedIn() throws NotLoggedInException {
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/SecurityConfigTest.java
... ... @@ -16,7 +16,7 @@ public class SecurityConfigTest {
16 16  
17 17 @Before
18 18 public void setUp() throws Exception {
19   - this.config = new SecurityConfigImpl();
  19 + this.config = new SecurityConfig();
20 20 }
21 21  
22 22 @Test
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImplTest.java
... ... @@ -64,7 +64,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
64 64 import org.powermock.modules.junit4.PowerMockRunner;
65 65  
66 66 import br.gov.frameworkdemoiselle.internal.bootstrap.AuthenticatorBootstrap;
67   -import br.gov.frameworkdemoiselle.internal.configuration.SecurityConfigImpl;
  67 +import br.gov.frameworkdemoiselle.internal.configuration.SecurityConfig;
68 68 import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;
69 69 import br.gov.frameworkdemoiselle.security.Authenticator;
70 70 import br.gov.frameworkdemoiselle.security.Authorizer;
... ... @@ -79,17 +79,17 @@ public class SecurityContextImplTest {
79 79  
80 80 private SecurityContextImpl context;
81 81  
82   - private SecurityConfigImpl config;
  82 + private SecurityConfig config;
83 83  
84 84 private ResourceBundle bundle;
85 85  
86 86 @Before
87 87 public void setUpConfig() {
88 88 context = new SecurityContextImpl();
89   - config = createMock(SecurityConfigImpl.class);
  89 + config = createMock(SecurityConfig.class);
90 90  
91 91 mockStatic(Beans.class);
92   - expect(Beans.getReference(SecurityConfigImpl.class)).andReturn(config).anyTimes();
  92 + expect(Beans.getReference(SecurityConfig.class)).andReturn(config).anyTimes();
93 93 }
94 94  
95 95 @Test
... ...