55
66package pl .edu .icm .unity .webui .console .services .authnlayout ;
77
8+ import static pl .edu .icm .unity .webui .VaadinEndpointProperties .PREFIX ;
9+
810import java .io .IOException ;
911import java .io .StringReader ;
1012import java .util .ArrayList ;
@@ -85,78 +87,61 @@ public Properties toProperties(UnityMessageSource msg, FileStorageService fileSt
8587 {
8688 Properties raw = new Properties ();
8789
88- raw .put (VaadinEndpointProperties .PREFIX + VaadinEndpointProperties .AUTHN_SHOW_SEARCH ,
89- String .valueOf (showSearch ));
90- raw .put (VaadinEndpointProperties .PREFIX + VaadinEndpointProperties .AUTHN_ADD_ALL ,
91- String .valueOf (addAllAuthnOptions ));
92- raw .put (VaadinEndpointProperties .PREFIX + VaadinEndpointProperties .AUTHN_SHOW_CANCEL ,
93- String .valueOf (showCancel ));
94- raw .put (VaadinEndpointProperties .PREFIX + VaadinEndpointProperties .AUTHN_SHOW_LAST_OPTION_ONLY ,
95- String .valueOf (showLastUsedAuthnOption ));
96- raw .put (VaadinEndpointProperties .PREFIX + VaadinEndpointProperties .AUTO_LOGIN ,
97- String .valueOf (autoLogin ));
98-
99- raw .put (VaadinEndpointProperties .PREFIX + VaadinEndpointProperties .ENABLE_REGISTRATION ,
100- String .valueOf (enableRegistration ));
101-
102- raw .put (VaadinEndpointProperties .PREFIX + VaadinEndpointProperties .SHOW_REGISTRATION_FORMS_IN_HEADER ,
90+ raw .put (PREFIX + VaadinEndpointProperties .AUTHN_SHOW_SEARCH , String .valueOf (showSearch ));
91+ raw .put (PREFIX + VaadinEndpointProperties .AUTHN_ADD_ALL , String .valueOf (addAllAuthnOptions ));
92+ raw .put (PREFIX + VaadinEndpointProperties .AUTHN_SHOW_CANCEL , String .valueOf (showCancel ));
93+ raw .put (PREFIX + VaadinEndpointProperties .AUTHN_SHOW_LAST_OPTION_ONLY , String .valueOf (showLastUsedAuthnOption ));
94+ raw .put (PREFIX + VaadinEndpointProperties .AUTO_LOGIN , String .valueOf (autoLogin ));
95+
96+ raw .put (PREFIX + VaadinEndpointProperties .ENABLE_REGISTRATION , String .valueOf (enableRegistration ));
97+
98+ raw .put (PREFIX + VaadinEndpointProperties .SHOW_REGISTRATION_FORMS_IN_HEADER ,
10399 String .valueOf (showRegistrationFormsInHeader ));
104100
105- raw .put (VaadinEndpointProperties .PREFIX + VaadinEndpointProperties .PRODUCTION_MODE ,
106- String .valueOf (productionMode ));
101+ raw .put (PREFIX + VaadinEndpointProperties .PRODUCTION_MODE , String .valueOf (productionMode ));
107102 if (webContentDir != null )
108- {
109- raw .put (VaadinEndpointProperties .PREFIX + VaadinEndpointProperties .WEB_CONTENT_PATH ,
110- webContentDir );
111- }
103+ raw .put (PREFIX + VaadinEndpointProperties .WEB_CONTENT_PATH , webContentDir );
112104
113- raw .put (VaadinEndpointProperties . PREFIX + VaadinEndpointProperties .TEMPLATE , template );
105+ raw .put (PREFIX + VaadinEndpointProperties .TEMPLATE , template );
114106
115- raw .put (VaadinEndpointProperties .PREFIX + VaadinEndpointProperties .CRED_RESET_COMPACT ,
116- String .valueOf (compactCredentialReset ));
107+ raw .put (PREFIX + VaadinEndpointProperties .CRED_RESET_COMPACT , String .valueOf (compactCredentialReset ));
117108
118109 if (externalRegistrationURL != null )
119- {
120- raw .put (VaadinEndpointProperties .PREFIX + VaadinEndpointProperties .EXTERNAL_REGISTRATION_URL ,
121- externalRegistrationURL );
122- }
110+ raw .put (PREFIX + VaadinEndpointProperties .EXTERNAL_REGISTRATION_URL , externalRegistrationURL );
111+
123112 if (registrationForms != null && !registrationForms .isEmpty ())
124113 {
125- registrationForms .forEach (c -> raw .put (VaadinEndpointProperties . PREFIX
114+ registrationForms .forEach (c -> raw .put (PREFIX
126115 + VaadinEndpointProperties .ENABLED_REGISTRATION_FORMS
127116 + (registrationForms .indexOf (c ) + 1 ), c ));
128117 }
129118
130119 if (title != null )
131- {
132- title .toProperties (raw , VaadinEndpointProperties .PREFIX + VaadinEndpointProperties .AUTHN_TITLE ,
133- msg );
134- }
120+ title .toProperties (raw , PREFIX + VaadinEndpointProperties .AUTHN_TITLE , msg );
135121
136122 if (logo != null )
137123 {
138124 FileFieldUtils .saveInProperties (getLogo (),
139- VaadinEndpointProperties . PREFIX + VaadinEndpointProperties .AUTHN_LOGO , raw ,
125+ PREFIX + VaadinEndpointProperties .AUTHN_LOGO , raw ,
140126 fileStorageService , StandardOwner .SERVICE .toString (), serviceName );
141127 } else
142128 {
143- raw .put (VaadinEndpointProperties . PREFIX + VaadinEndpointProperties .AUTHN_LOGO , "" );
129+ raw .put (PREFIX + VaadinEndpointProperties .AUTHN_LOGO , "" );
144130 }
145131
146132 if (defaultMainTheme != null )
147- raw .put (VaadinEndpointProperties . PREFIX + VaadinEndpointProperties .THEME , defaultMainTheme );
133+ raw .put (PREFIX + VaadinEndpointProperties .THEME , defaultMainTheme );
148134 if (defaultAuthnTheme != null )
149- raw .put (VaadinEndpointProperties .PREFIX + VaadinEndpointProperties .AUTHN_THEME , defaultAuthnTheme );
150-
135+ raw .put (PREFIX + VaadinEndpointProperties .AUTHN_THEME , defaultAuthnTheme );
151136 AuthnLayoutPropertiesParser parser = new AuthnLayoutPropertiesParser (msg );
152137 raw .putAll (parser .toProperties (authenticationLayoutConfiguration ));
153- raw .putAll (parser .returningUserColumnElementToProperties (
154- retUserLayoutConfiguration ));
138+ raw .putAll (parser .returningUserColumnElementToProperties (retUserLayoutConfiguration ));
155139
156140 return raw ;
157141 }
158142
159- public void fromProperties (String vaadinProperties , UnityMessageSource msg , ImageAccessService imageAccessService )
143+ public void fromProperties (String vaadinProperties , UnityMessageSource msg , ImageAccessService imageAccessService ,
144+ String systemDefaultTheme )
160145 {
161146 Properties raw = new Properties ();
162147 try
@@ -168,19 +153,20 @@ public void fromProperties(String vaadinProperties, UnityMessageSource msg, Imag
168153 }
169154
170155 VaadinEndpointProperties vProperties = new VaadinEndpointProperties (raw );
171- fromProperties (vProperties , msg , imageAccessService );
156+ fromProperties (vProperties , msg , imageAccessService , systemDefaultTheme );
172157 }
173158
174- public void fromProperties (VaadinEndpointProperties vaadinProperties , UnityMessageSource msg ,
175- ImageAccessService imageAccessService )
159+ private void fromProperties (VaadinEndpointProperties vaadinProperties , UnityMessageSource msg ,
160+ ImageAccessService imageAccessService , String systemDefaultTheme )
176161 {
177-
178-
162+ //this is set for effective endpoint configuration at endpoint loading - we copy this here
163+ //to have consistent setup. However this property is not persisted.
164+ if (systemDefaultTheme != null )
165+ vaadinProperties .setProperty (VaadinEndpointProperties .DEF_THEME , systemDefaultTheme );
179166
180167 if (vaadinProperties .isSet (VaadinEndpointProperties .WEB_CONTENT_PATH ))
181- {
182168 webContentDir = vaadinProperties .getValue (VaadinEndpointProperties .WEB_CONTENT_PATH );
183- }
169+
184170 productionMode = vaadinProperties .getBooleanValue (VaadinEndpointProperties .PRODUCTION_MODE );
185171 template = vaadinProperties .getValue (VaadinEndpointProperties .TEMPLATE );
186172 compactCredentialReset = vaadinProperties .getBooleanValue (VaadinEndpointProperties .CRED_RESET_COMPACT );
@@ -201,6 +187,7 @@ public void fromProperties(VaadinEndpointProperties vaadinProperties, UnityMessa
201187 .getListOfValues (VaadinEndpointProperties .ENABLED_REGISTRATION_FORMS );
202188
203189 String logoUri = vaadinProperties .getValue (VaadinEndpointProperties .AUTHN_LOGO );
190+
204191 logo = imageAccessService .getEditableImageResourceFromUriOrNull (logoUri , Optional
205192 .of (vaadinProperties .getEffectiveAuthenticationTheme ())).orElse (null );
206193
@@ -214,13 +201,9 @@ public void fromProperties(VaadinEndpointProperties vaadinProperties, UnityMessa
214201 retUserLayoutConfiguration = parser .getReturingUserColumnElementsFromProperties (vaadinProperties );
215202
216203 if (vaadinProperties .isSet (VaadinEndpointProperties .THEME ))
217- {
218204 defaultMainTheme = vaadinProperties .getValue (VaadinEndpointProperties .THEME );
219- }
220205 if (vaadinProperties .isSet (VaadinEndpointProperties .AUTHN_THEME ))
221- {
222206 defaultAuthnTheme = vaadinProperties .getValue (VaadinEndpointProperties .AUTHN_THEME );
223- }
224207 }
225208
226209 public boolean isShowSearch ()
0 commit comments