Commit 267885c5a7bb794c86dea042d003106d9c1b3879
1 parent
da970e93
Exists in
master
Ajuste na Serialização do SecurityObserver
Showing
1 changed file
with
13 additions
and
5 deletions
Show diff stats
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityObserver.java
@@ -64,7 +64,7 @@ public class SecurityObserver implements Serializable { | @@ -64,7 +64,7 @@ public class SecurityObserver implements Serializable { | ||
64 | @Inject | 64 | @Inject |
65 | private JsfSecurityConfig config; | 65 | private JsfSecurityConfig config; |
66 | 66 | ||
67 | - private Map<String, Object> savedParams = new HashMap<String, Object>(); | 67 | + private Map<String, Object> savedParams; |
68 | 68 | ||
69 | private String savedViewId; | 69 | private String savedViewId; |
70 | 70 | ||
@@ -74,13 +74,21 @@ public class SecurityObserver implements Serializable { | @@ -74,13 +74,21 @@ public class SecurityObserver implements Serializable { | ||
74 | public SecurityObserver() { | 74 | public SecurityObserver() { |
75 | clear(); | 75 | clear(); |
76 | } | 76 | } |
77 | + | ||
78 | + private Map<String, Object> getSavedParams(){ | ||
79 | + if(this.savedParams == null) { | ||
80 | + this.savedParams = new HashMap<String, Object>(); | ||
81 | + } | ||
82 | + | ||
83 | + return this.savedParams; | ||
84 | + } | ||
77 | 85 | ||
78 | private void saveCurrentState() { | 86 | private void saveCurrentState() { |
79 | clear(); | 87 | clear(); |
80 | FacesContext facesContext = Beans.getReference(FacesContext.class); | 88 | FacesContext facesContext = Beans.getReference(FacesContext.class); |
81 | 89 | ||
82 | if (!config.getLoginPage().equals(facesContext.getViewRoot().getViewId())) { | 90 | if (!config.getLoginPage().equals(facesContext.getViewRoot().getViewId())) { |
83 | - savedParams.putAll(facesContext.getExternalContext().getRequestParameterMap()); | 91 | + getSavedParams().putAll(facesContext.getExternalContext().getRequestParameterMap()); |
84 | savedViewId = facesContext.getViewRoot().getViewId(); | 92 | savedViewId = facesContext.getViewRoot().getViewId(); |
85 | } | 93 | } |
86 | } | 94 | } |
@@ -106,11 +114,11 @@ public class SecurityObserver implements Serializable { | @@ -106,11 +114,11 @@ public class SecurityObserver implements Serializable { | ||
106 | 114 | ||
107 | try { | 115 | try { |
108 | if (savedViewId != null) { | 116 | if (savedViewId != null) { |
109 | - Redirector.redirect(savedViewId, savedParams); | 117 | + Redirector.redirect(savedViewId, getSavedParams()); |
110 | 118 | ||
111 | } else if (config.isRedirectEnabled()) { | 119 | } else if (config.isRedirectEnabled()) { |
112 | redirectedFromConfig = true; | 120 | redirectedFromConfig = true; |
113 | - Redirector.redirect(config.getRedirectAfterLogin(), savedParams); | 121 | + Redirector.redirect(config.getRedirectAfterLogin(), getSavedParams()); |
114 | } | 122 | } |
115 | 123 | ||
116 | } catch (PageNotFoundException cause) { | 124 | } catch (PageNotFoundException cause) { |
@@ -155,6 +163,6 @@ public class SecurityObserver implements Serializable { | @@ -155,6 +163,6 @@ public class SecurityObserver implements Serializable { | ||
155 | 163 | ||
156 | private void clear() { | 164 | private void clear() { |
157 | savedViewId = null; | 165 | savedViewId = null; |
158 | - savedParams.clear(); | 166 | + getSavedParams().clear(); |
159 | } | 167 | } |
160 | } | 168 | } |