Skip to content

Commit

Permalink
[refactor] SecurityManager IdFunction
Browse files Browse the repository at this point in the history
Move null check into function sameUserWithSameGroups.
  • Loading branch information
line-o committed Dec 12, 2023
1 parent 0adb4aa commit 5ee14e9
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.exist.xquery.value.Sequence;
import org.exist.xquery.value.Type;

import javax.annotation.Nullable;
import java.util.Arrays;

/**
Expand Down Expand Up @@ -85,8 +86,7 @@ private org.exist.dom.memtree.DocumentImpl functionId() {
}

final Subject effectiveUser = context.getEffectiveUser();
if (effectiveUser != null && (
realUser == null || !sameUserWithSameGroups(realUser, effectiveUser))) {
if (effectiveUser != null && !sameUserWithSameGroups(realUser, effectiveUser)) {
builder.startElement(new QName("effective", SecurityManagerModule.NAMESPACE_URI, SecurityManagerModule.PREFIX), null);
subjectToXml(builder, effectiveUser);
builder.endElement();
Expand All @@ -102,7 +102,10 @@ private org.exist.dom.memtree.DocumentImpl functionId() {
}
}

private static boolean sameUserWithSameGroups(final Subject user1, final Subject user2) {
private static boolean sameUserWithSameGroups(@Nullable final Subject user1, @Nullable final Subject user2) {
if (user1 == null || user2 == null) {
return false;
}
if (user1.getId() != user2.getId()) {
return false;
}
Expand Down

0 comments on commit 5ee14e9

Please sign in to comment.