@@ -356,19 +356,19 @@ public String create(final UserOrgEditionVo user) {
356356 /**
357357 * Validate the user changes regarding the current user's right, replace group names with the exact CN, and replace
358358 * the company with a normalized one.<br>
359- * Rules, order is important :
359+ * Rules where order is important:
360360 * <ul>
361361 * <li>At least one valid delegate must exist (valid or not against the involved user). If not, act as if the
362362 * company does not exist.</li>
363363 * <li>Involved company must exist</li>
364- * <li>Involved company must be visible by the principal user. If not at if it does not exist, one</li>
365- * <li>Involved company must be writable by the principal user when there is one updated attribute. Otherwise
364+ * <li>Involved company must be visible by the principal user. If not, act if it does not exist, one</li>
365+ * <li>Involved company must be writable by the principal user when there is one updated attribute. Otherwise,
366366 * indicate the read-only state.</li>
367367 * <li>Involved groups must exist</li>
368368 * <li>Involved groups must be visible by the current user, if not, act as if it does not exist. So the user can
369369 * only involve visible groups he/she. These groups are completed with the other invisible groups the user may
370370 * already have.</li>
371- * <li>Involved changed groups must writable by the principal user. Otherwise indicate the read-only state.</li>
371+ * <li>Involved changed groups must writable by the principal user. Otherwise, indicate the read-only state.</li>
372372 * </ul>
373373 */
374374 private boolean validateChanges (final String principal , final UserOrgEditionVo importEntry ) {
@@ -552,7 +552,11 @@ private boolean hasAttributeChange(final SimpleUser importEntry, boolean hasChan
552552 @ SafeVarargs
553553 private boolean hasAttributeChange (final SimpleUser user1 , final SimpleUser user2 , final Function <SimpleUser , String >... equals ) {
554554 final var predicateFalse = Arrays .stream (equals ).filter (f -> !Strings .CI .equals (StringUtils .trimToNull (f .apply (user2 )), StringUtils .trimToNull (f .apply (user1 )))).findFirst ().orElse (null );
555- return predicateFalse != null && hasAttributeChange (user1 , true , String .format ("'%s' != '%s'" , predicateFalse .apply (user1 ), predicateFalse .apply (user2 )));
555+ if (predicateFalse == null ) {
556+ return false ;
557+ }
558+ hasAttributeChange (user1 , true , String .format ("'%s' != '%s'" , predicateFalse .apply (user1 ), predicateFalse .apply (user2 )));
559+ return true ;
556560 }
557561
558562 /**
@@ -714,7 +718,7 @@ public void lock(@PathParam("user") final String user) {
714718 * tools are watching.<br>
715719 * All memberships are updated, the user's DN is changed, all groups must be updated. Rules, order is important :
716720 * <ul>
717- * <li>Only users managing the company of this user can perform the disable , if not, act as if the user did not
721+ * <li>Only users managing the company of this user can perform the disablement , if not, act as if the user did not
718722 * exist</li>
719723 * <li>User must exist</li>
720724 * </ul>
@@ -734,7 +738,7 @@ public void isolate(@PathParam("user") final String user) {
734738 * Unlock a user.<br>
735739 * Rules, order is important :
736740 * <ul>
737- * <li>Only users managing the company of this user can perform the enable , if not, act as if the user did not
741+ * <li>Only users managing the company of this user can perform the enablement , if not, act as if the user did not
738742 * exist</li>
739743 * <li>User must exist</li>
740744 * </ul>
@@ -753,7 +757,7 @@ public void unlock(@PathParam("user") final String user) {
753757 * Restore a user from the isolate zone to the old company.<br>
754758 * Rules, order is important :
755759 * <ul>
756- * <li>Only users managing the company of this user can perform the enable , if not, act as if the user did not
760+ * <li>Only users managing the company of this user can perform the enablement , if not, act as if the user did not
757761 * exist</li>
758762 * <li>User must exist</li>
759763 * </ul>
@@ -988,20 +992,14 @@ public void decorate(final SessionSettings settings) {
988992
989993 @ Override
990994 public Collection <GrantedAuthority > getGrantedAuthorities (final String username ) {
991- try {
992- // Check if the user lock status without using cache
993- final var rawUserOrg = getUserRepository ().toUser (Normalizer .normalize (username ));
994- final var roles = new ArrayList <GrantedAuthority >();
995- for (String group : CollectionUtils .emptyIfNull (rawUserOrg .getGroups ())) {
996- roles .add (new SimpleGrantedAuthority (group .toUpperCase ()));
997- roles .add (new SimpleGrantedAuthority (group .toLowerCase ()));
998- roles .add (new SimpleGrantedAuthority (group ));
999- }
1000- return roles ;
1001- } catch (ValidationJsonException ve ) {
1002- // Ignore this error
1003- log .debug ("User being authenticated '{}' is not defined in primary identity provider " , username );
1004- return Collections .emptyList ();
995+ // Check if the user lock status without using cache
996+ final var rawUserOrg = getUserRepository ().toUser (Normalizer .normalize (username ));
997+ final var roles = new HashSet <GrantedAuthority >();
998+ for (String group : CollectionUtils .emptyIfNull (rawUserOrg .getGroups ())) {
999+ roles .add (new SimpleGrantedAuthority (group .toUpperCase ()));
1000+ roles .add (new SimpleGrantedAuthority (group .toLowerCase ()));
1001+ roles .add (new SimpleGrantedAuthority (group ));
10051002 }
1003+ return roles ;
10061004 }
10071005}
0 commit comments