@@ -302,18 +302,17 @@ public Uid create(
302302 if (ObjectClass .ACCOUNT .equals (objectClass )) {
303303 UT user = buildNewUserEntity (
304304 SCIMUtils .extractSCIMSchemas (configuration .getCustomAttributesJSON (), SCIMv2Attribute .class ));
305+
305306 String username = accessor .findString (SCIMAttributeUtils .USER_ATTRIBUTE_USERNAME );
306307 if (username == null ) {
307308 username = accessor .findString (Name .NAME );
308309 }
309-
310- GuardedString password = accessor .findGuardedString (OperationalAttributes .PASSWORD_NAME );
311- Attribute status = accessor .find (OperationalAttributes .ENABLE_NAME );
310+ user .setUserName (username );
312311
313312 try {
314- user .setUserName (username );
315313 Optional .ofNullable (accessor .findString (SCIMAttributeUtils .USER_ATTRIBUTE_EXTERNAL_ID ))
316314 .ifPresent (user ::setExternalId );
315+
317316 // manage groups
318317 List <String > groups = accessor .findStringList (SCIMAttributeUtils .SCIM_USER_GROUPS );
319318 LOG .info ("Adding groups {0} to user {1}" , groups , username );
@@ -330,15 +329,16 @@ public Uid create(
330329 manageEntitlements (user , entitlements );
331330 }
332331
332+ GuardedString password = accessor .findGuardedString (OperationalAttributes .PASSWORD_NAME );
333333 if (password == null ) {
334334 LOG .warn ("Missing password attribute" );
335335 } else {
336336 user .setPassword (SecurityUtil .decrypt (password ));
337337 }
338338
339- if ( status == null || status . getValue () == null || status . getValue (). isEmpty ()) {
340- LOG . warn ( "{0} attribute value not correct or not found, won't handle User status" ,
341- OperationalAttributes .ENABLE_NAME );
339+ Attribute status = accessor . find ( OperationalAttributes . ENABLE_NAME );
340+ if ( status == null || CollectionUtil . isEmpty ( status . getValue ())) {
341+ LOG . warn ( "No {0} attribute provided, won't handle User status" , OperationalAttributes .ENABLE_NAME );
342342 } else {
343343 user .setActive (Boolean .valueOf (status .getValue ().get (0 ).toString ()));
344344 }
@@ -352,6 +352,7 @@ public Uid create(
352352 configuration .getCustomAttributesJSON (),
353353 configuration .getUseColonOnExtensionAttributes ());
354354 }
355+
355356 // enterprise user
356357 createAttributes .stream ().
357358 filter (ca -> ca .getName ().contains (SCIMv2EnterpriseUser .SCHEMA_URI )).
@@ -361,7 +362,8 @@ public Uid create(
361362 });
362363
363364 client .createUser (user );
364- // update also groups, if needed
365+
366+ // update also groups, if needed
365367 if (!scimGroups .isEmpty () && configuration .getExplicitGroupAddOnCreate ()) {
366368 LOG .info ("Updating groups {0} explicitly adding user {1}" , groups , user .getId ());
367369
@@ -420,19 +422,20 @@ public Uid update(
420422
421423 Uid returnUid = uid ;
422424 if (ObjectClass .ACCOUNT .equals (objectClass )) {
423- Attribute status = accessor .find (OperationalAttributes .ENABLE_NAME );
424- String username = accessor .findString (SCIMAttributeUtils .USER_ATTRIBUTE_USERNAME );
425- if (username == null ) {
426- username = accessor .findString (Name .NAME );
427- }
428425
429426 UT user = buildNewUserEntity (
430427 SCIMUtils .extractSCIMSchemas (configuration .getCustomAttributesJSON (), SCIMv2Attribute .class ));
431428 user .setId (uid .getUidValue ());
429+
430+ String username = accessor .findString (SCIMAttributeUtils .USER_ATTRIBUTE_USERNAME );
431+ if (username == null ) {
432+ username = accessor .findString (Name .NAME );
433+ }
432434 user .setUserName (username );
433- if (status == null || status .getValue () == null || status .getValue ().isEmpty ()) {
434- LOG .warn ("{0} attribute value not correct, can't handle User status update" ,
435- OperationalAttributes .ENABLE_NAME );
435+
436+ Attribute status = accessor .find (OperationalAttributes .ENABLE_NAME );
437+ if (status == null || CollectionUtil .isEmpty (status .getValue ())) {
438+ LOG .warn ("No {0} attribute provided, won't handle User status" , OperationalAttributes .ENABLE_NAME );
436439 } else {
437440 user .setActive (Boolean .valueOf (status .getValue ().get (0 ).toString ()));
438441 }
0 commit comments