@@ -239,23 +239,36 @@ public Saml2Settings build(Saml2Settings saml2Setting) {
239239 this .saml2Setting = saml2Setting ;
240240
241241 Boolean strict = loadBooleanProperty (STRICT_PROPERTY_KEY );
242- if (strict != null )
242+ if (strict != null ) {
243243 saml2Setting .setStrict (strict );
244+ }
244245
245246 Boolean debug = loadBooleanProperty (DEBUG_PROPERTY_KEY );
246- if (debug != null )
247+ if (debug != null ) {
247248 saml2Setting .setDebug (debug );
249+ }
248250
249251 this .loadSpSetting ();
250252 this .loadIdpSetting ();
251253 this .loadSecuritySetting ();
252254 this .loadCompressSetting ();
253255
254- saml2Setting .setContacts (loadContacts ());
256+ List <Contact > contacts = this .loadContacts ();
257+ if (!contacts .isEmpty ()) {
258+ saml2Setting .setContacts (loadContacts ());
259+ }
255260
256- saml2Setting .setOrganization (loadOrganization ());
261+ Organization org = this .loadOrganization ();
262+ if (org != null ) {
263+ saml2Setting .setOrganization (org );
264+ }
257265
258- saml2Setting .setUniqueIDPrefix (loadUniqueIDPrefix ());
266+ String uniqueIdPrefix = loadUniqueIDPrefix ();
267+ if (StringUtils .isNotEmpty (uniqueIdPrefix )) {
268+ saml2Setting .setUniqueIDPrefix (uniqueIdPrefix );
269+ } else if (saml2Setting .getUniqueIDPrefix () == null ){
270+ saml2Setting .setUniqueIDPrefix (Util .UNIQUE_ID_PREFIX );
271+ }
259272
260273 return saml2Setting ;
261274 }
@@ -265,45 +278,54 @@ public Saml2Settings build(Saml2Settings saml2Setting) {
265278 */
266279 private void loadIdpSetting () {
267280 String idpEntityID = loadStringProperty (IDP_ENTITYID_PROPERTY_KEY );
268- if (idpEntityID != null )
281+ if (idpEntityID != null ) {
269282 saml2Setting .setIdpEntityId (idpEntityID );
283+ }
270284
271285 URL idpSingleSignOnServiceUrl = loadURLProperty (IDP_SINGLE_SIGN_ON_SERVICE_URL_PROPERTY_KEY );
272- if (idpSingleSignOnServiceUrl != null )
286+ if (idpSingleSignOnServiceUrl != null ) {
273287 saml2Setting .setIdpSingleSignOnServiceUrl (idpSingleSignOnServiceUrl );
288+ }
274289
275290 String idpSingleSignOnServiceBinding = loadStringProperty (IDP_SINGLE_SIGN_ON_SERVICE_BINDING_PROPERTY_KEY );
276- if (idpSingleSignOnServiceBinding != null )
291+ if (idpSingleSignOnServiceBinding != null ) {
277292 saml2Setting .setIdpSingleSignOnServiceBinding (idpSingleSignOnServiceBinding );
293+ }
278294
279295 URL idpSingleLogoutServiceUrl = loadURLProperty (IDP_SINGLE_LOGOUT_SERVICE_URL_PROPERTY_KEY );
280- if (idpSingleLogoutServiceUrl != null )
296+ if (idpSingleLogoutServiceUrl != null ) {
281297 saml2Setting .setIdpSingleLogoutServiceUrl (idpSingleLogoutServiceUrl );
298+ }
282299
283300 URL idpSingleLogoutServiceResponseUrl = loadURLProperty (IDP_SINGLE_LOGOUT_SERVICE_RESPONSE_URL_PROPERTY_KEY );
284- if (idpSingleLogoutServiceResponseUrl != null )
301+ if (idpSingleLogoutServiceResponseUrl != null ) {
285302 saml2Setting .setIdpSingleLogoutServiceResponseUrl (idpSingleLogoutServiceResponseUrl );
303+ }
286304
287305 String idpSingleLogoutServiceBinding = loadStringProperty (IDP_SINGLE_LOGOUT_SERVICE_BINDING_PROPERTY_KEY );
288- if (idpSingleLogoutServiceBinding != null )
306+ if (idpSingleLogoutServiceBinding != null ) {
289307 saml2Setting .setIdpSingleLogoutServiceBinding (idpSingleLogoutServiceBinding );
308+ }
290309
291310 List <X509Certificate > idpX509certMulti = loadCertificateListFromProp (IDP_X509CERTMULTI_PROPERTY_KEY );
292- if (idpX509certMulti != null )
311+ if (idpX509certMulti != null ) {
293312 saml2Setting .setIdpx509certMulti (idpX509certMulti );
313+ }
294314
295315 X509Certificate idpX509cert = loadCertificateFromProp (IDP_X509CERT_PROPERTY_KEY );
296316 if (idpX509cert != null ) {
297317 saml2Setting .setIdpx509cert (idpX509cert );
298318 }
299319
300320 String idpCertFingerprint = loadStringProperty (CERTFINGERPRINT_PROPERTY_KEY );
301- if (idpCertFingerprint != null )
321+ if (idpCertFingerprint != null ) {
302322 saml2Setting .setIdpCertFingerprint (idpCertFingerprint );
323+ }
303324
304325 String idpCertFingerprintAlgorithm = loadStringProperty (CERTFINGERPRINT_ALGORITHM_PROPERTY_KEY );
305- if (idpCertFingerprintAlgorithm != null && !idpCertFingerprintAlgorithm .isEmpty ())
326+ if (idpCertFingerprintAlgorithm != null && !idpCertFingerprintAlgorithm .isEmpty ()) {
306327 saml2Setting .setIdpCertFingerprintAlgorithm (idpCertFingerprintAlgorithm );
328+ }
307329 }
308330
309331 /**
@@ -376,8 +398,9 @@ private void loadSecuritySetting() {
376398 }
377399
378400 Boolean allowRepeatAttributeName = loadBooleanProperty (SECURITY_ALLOW_REPEAT_ATTRIBUTE_NAME_PROPERTY_KEY );
379- if (allowRepeatAttributeName != null )
401+ if (allowRepeatAttributeName != null ) {
380402 saml2Setting .setAllowRepeatAttributeName (allowRepeatAttributeName );
403+ }
381404 }
382405
383406 /**
@@ -443,40 +466,42 @@ private List<Contact> loadContacts() {
443466 */
444467 private String loadUniqueIDPrefix () {
445468 String uniqueIDPrefix = loadStringProperty (UNIQUE_ID_PREFIX_PROPERTY_KEY );
446- if (StringUtils .isNotEmpty (uniqueIDPrefix )) {
447- return uniqueIDPrefix ;
448- } else {
449- return Util .UNIQUE_ID_PREFIX ;
450- }
469+ return uniqueIDPrefix ;
451470 }
452471
453472 /**
454473 * Loads the SP settings from the properties file
455474 */
456475 private void loadSpSetting () {
457476 String spEntityID = loadStringProperty (SP_ENTITYID_PROPERTY_KEY );
458- if (spEntityID != null )
477+ if (spEntityID != null ) {
459478 saml2Setting .setSpEntityId (spEntityID );
479+ }
460480
461481 URL assertionConsumerServiceUrl = loadURLProperty (SP_ASSERTION_CONSUMER_SERVICE_URL_PROPERTY_KEY );
462- if (assertionConsumerServiceUrl != null )
482+ if (assertionConsumerServiceUrl != null ) {
463483 saml2Setting .setSpAssertionConsumerServiceUrl (assertionConsumerServiceUrl );
484+ }
464485
465486 String spAssertionConsumerServiceBinding = loadStringProperty (SP_ASSERTION_CONSUMER_SERVICE_BINDING_PROPERTY_KEY );
466- if (spAssertionConsumerServiceBinding != null )
487+ if (spAssertionConsumerServiceBinding != null ) {
467488 saml2Setting .setSpAssertionConsumerServiceBinding (spAssertionConsumerServiceBinding );
489+ }
468490
469491 URL spSingleLogoutServiceUrl = loadURLProperty (SP_SINGLE_LOGOUT_SERVICE_URL_PROPERTY_KEY );
470- if (spSingleLogoutServiceUrl != null )
492+ if (spSingleLogoutServiceUrl != null ) {
471493 saml2Setting .setSpSingleLogoutServiceUrl (spSingleLogoutServiceUrl );
494+ }
472495
473496 String spSingleLogoutServiceBinding = loadStringProperty (SP_SINGLE_LOGOUT_SERVICE_BINDING_PROPERTY_KEY );
474- if (spSingleLogoutServiceBinding != null )
497+ if (spSingleLogoutServiceBinding != null ) {
475498 saml2Setting .setSpSingleLogoutServiceBinding (spSingleLogoutServiceBinding );
499+ }
476500
477501 String spNameIDFormat = loadStringProperty (SP_NAMEIDFORMAT_PROPERTY_KEY );
478- if (spNameIDFormat != null && !spNameIDFormat .isEmpty ())
502+ if (spNameIDFormat != null && !spNameIDFormat .isEmpty ()) {
479503 saml2Setting .setSpNameIDFormat (spNameIDFormat );
504+ }
480505
481506 boolean keyStoreEnabled = this .samlData .get (KEYSTORE_KEY ) != null && this .samlData .get (KEYSTORE_ALIAS ) != null
482507 && this .samlData .get (KEYSTORE_KEY_PASSWORD ) != null ;
@@ -496,14 +521,17 @@ private void loadSpSetting() {
496521 spPrivateKey = loadPrivateKeyFromProp (SP_PRIVATEKEY_PROPERTY_KEY );
497522 }
498523
499- if (spX509cert != null )
524+ if (spX509cert != null ) {
500525 saml2Setting .setSpX509cert (spX509cert );
501- if (spPrivateKey != null )
526+ }
527+ if (spPrivateKey != null ) {
502528 saml2Setting .setSpPrivateKey (spPrivateKey );
529+ }
503530
504531 X509Certificate spX509certNew = loadCertificateFromProp (SP_X509CERTNEW_PROPERTY_KEY );
505- if (spX509certNew != null )
532+ if (spX509certNew != null ) {
506533 saml2Setting .setSpX509certNew (spX509certNew );
534+ }
507535 }
508536
509537 /**
0 commit comments