Skip to content

Commit

Permalink
fix for [BUG] NPE in org.exist.xquery.functions.securitymanager.IdFun…
Browse files Browse the repository at this point in the history
…ction eXist-db#4670
  • Loading branch information
Nico Verwer committed Jan 9, 2023
1 parent 19163f3 commit 9111736
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,20 @@ private org.exist.dom.memtree.DocumentImpl functionId() {

builder.startElement(new QName("id", SecurityManagerModule.NAMESPACE_URI, SecurityManagerModule.PREFIX), null);

builder.startElement(new QName("real", SecurityManagerModule.NAMESPACE_URI, SecurityManagerModule.PREFIX), null);
subjectToXml(builder, context.getRealUser());
builder.endElement();
final Subject realUser = context.getRealUser();
if (realUser != null) {
builder.startElement(new QName("real", SecurityManagerModule.NAMESPACE_URI, SecurityManagerModule.PREFIX), null);
subjectToXml(builder, realUser);
builder.endElement();
}

if (!sameUserWithSameGroups(context.getRealUser(), context.getEffectiveUser())) {
builder.startElement(new QName("effective", SecurityManagerModule.NAMESPACE_URI, SecurityManagerModule.PREFIX), null);
subjectToXml(builder, context.getEffectiveUser());
builder.endElement();
final Subject effectiveUser = context.getEffectiveUser();
if (effectiveUser != null) {
if (realUser == null || !sameUserWithSameGroups(realUser, effectiveUser)) {
builder.startElement(new QName("effective", SecurityManagerModule.NAMESPACE_URI, SecurityManagerModule.PREFIX), null);
subjectToXml(builder, effectiveUser);
builder.endElement();
}
}

builder.endElement();
Expand Down

0 comments on commit 9111736

Please sign in to comment.