Commit b7d8fb0931469d225eb287c2ff78a69c9962598e
1 parent
4955b827
Exists in
master
Ajuste na serialização do SecurityObserver
Showing
1 changed file
with
16 additions
and
8 deletions
Show diff stats
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityObserver.java
@@ -61,8 +61,7 @@ public class SecurityObserver implements Serializable { | @@ -61,8 +61,7 @@ public class SecurityObserver implements Serializable { | ||
61 | 61 | ||
62 | private static final long serialVersionUID = 1L; | 62 | private static final long serialVersionUID = 1L; |
63 | 63 | ||
64 | - @Inject | ||
65 | - private JsfSecurityConfig config; | 64 | + private transient JsfSecurityConfig config; |
66 | 65 | ||
67 | private transient Map<String, Object> savedParams; | 66 | private transient Map<String, Object> savedParams; |
68 | 67 | ||
@@ -83,11 +82,19 @@ public class SecurityObserver implements Serializable { | @@ -83,11 +82,19 @@ public class SecurityObserver implements Serializable { | ||
83 | return this.savedParams; | 82 | return this.savedParams; |
84 | } | 83 | } |
85 | 84 | ||
85 | + public JsfSecurityConfig getConfig() { | ||
86 | + if (this.config == null) { | ||
87 | + this.config = Beans.getReference(JsfSecurityConfig.class); | ||
88 | + } | ||
89 | + | ||
90 | + return this.config; | ||
91 | + } | ||
92 | + | ||
86 | private void saveCurrentState() { | 93 | private void saveCurrentState() { |
87 | clear(); | 94 | clear(); |
88 | FacesContext facesContext = Beans.getReference(FacesContext.class); | 95 | FacesContext facesContext = Beans.getReference(FacesContext.class); |
89 | 96 | ||
90 | - if (!config.getLoginPage().equals(facesContext.getViewRoot().getViewId())) { | 97 | + if (!getConfig().getLoginPage().equals(facesContext.getViewRoot().getViewId())) { |
91 | getSavedParams().putAll(facesContext.getExternalContext().getRequestParameterMap()); | 98 | getSavedParams().putAll(facesContext.getExternalContext().getRequestParameterMap()); |
92 | savedViewId = facesContext.getViewRoot().getViewId(); | 99 | savedViewId = facesContext.getViewRoot().getViewId(); |
93 | } | 100 | } |
@@ -97,7 +104,7 @@ public class SecurityObserver implements Serializable { | @@ -97,7 +104,7 @@ public class SecurityObserver implements Serializable { | ||
97 | saveCurrentState(); | 104 | saveCurrentState(); |
98 | 105 | ||
99 | try { | 106 | try { |
100 | - Redirector.redirect(config.getLoginPage()); | 107 | + Redirector.redirect(getConfig().getLoginPage()); |
101 | 108 | ||
102 | } catch (PageNotFoundException cause) { | 109 | } catch (PageNotFoundException cause) { |
103 | // TODO Colocar a mensagem no bundle | 110 | // TODO Colocar a mensagem no bundle |
@@ -116,9 +123,9 @@ public class SecurityObserver implements Serializable { | @@ -116,9 +123,9 @@ public class SecurityObserver implements Serializable { | ||
116 | if (savedViewId != null) { | 123 | if (savedViewId != null) { |
117 | Redirector.redirect(savedViewId, getSavedParams()); | 124 | Redirector.redirect(savedViewId, getSavedParams()); |
118 | 125 | ||
119 | - } else if (config.isRedirectEnabled()) { | 126 | + } else if (getConfig().isRedirectEnabled()) { |
120 | redirectedFromConfig = true; | 127 | redirectedFromConfig = true; |
121 | - Redirector.redirect(config.getRedirectAfterLogin(), getSavedParams()); | 128 | + Redirector.redirect(getConfig().getRedirectAfterLogin(), getSavedParams()); |
122 | } | 129 | } |
123 | 130 | ||
124 | } catch (PageNotFoundException cause) { | 131 | } catch (PageNotFoundException cause) { |
@@ -140,8 +147,8 @@ public class SecurityObserver implements Serializable { | @@ -140,8 +147,8 @@ public class SecurityObserver implements Serializable { | ||
140 | 147 | ||
141 | public void onLogoutSuccessful(@Observes final AfterLogoutSuccessful event) { | 148 | public void onLogoutSuccessful(@Observes final AfterLogoutSuccessful event) { |
142 | try { | 149 | try { |
143 | - if (config.isRedirectEnabled()) { | ||
144 | - Redirector.redirect(config.getRedirectAfterLogout()); | 150 | + if (getConfig().isRedirectEnabled()) { |
151 | + Redirector.redirect(getConfig().getRedirectAfterLogout()); | ||
145 | } | 152 | } |
146 | 153 | ||
147 | } catch (PageNotFoundException cause) { | 154 | } catch (PageNotFoundException cause) { |
@@ -165,4 +172,5 @@ public class SecurityObserver implements Serializable { | @@ -165,4 +172,5 @@ public class SecurityObserver implements Serializable { | ||
165 | savedViewId = null; | 172 | savedViewId = null; |
166 | getSavedParams().clear(); | 173 | getSavedParams().clear(); |
167 | } | 174 | } |
175 | + | ||
168 | } | 176 | } |