Skip to content

Commit

Permalink
[New] Don't write roles and groups for remote users in xml file
Browse files Browse the repository at this point in the history
  • Loading branch information
eitch committed Oct 19, 2024
1 parent a00fa99 commit 659891c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ private Certificate internalAuthenticate(String username, char[] password, Strin
// log
logger.info("User {} authenticated with password : {}", username, certificate);
} else {
logger.info("User {} authenticated with basic auth: {}", username, certificate);
logger.info("User {} authenticated with basic auth/sigle use: {}", username, certificate);
}

// return the certificate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package li.strolch.privilege.xml;

import javanet.staxutils.IndentingXMLStreamWriter;
import li.strolch.privilege.model.UserState;
import li.strolch.privilege.model.internal.PasswordCrypt;
import li.strolch.privilege.model.internal.User;
import li.strolch.privilege.model.internal.UserHistory;
Expand Down Expand Up @@ -85,25 +86,29 @@ public void write() throws IOException, XMLStreamException {
if (user.isPasswordChangeRequested())
writeStringElement(xmlWriter, PASSWORD_CHANGE_REQUESTED, "true");

// add all the group elements
if (!user.getGroups().isEmpty()) {
xmlWriter.writeStartElement(GROUPS);
writeStringList(xmlWriter, GROUP, user.getGroups());
xmlWriter.writeEndElement();
// only right groups and roles if not a remote user
if (user.getUserState() != UserState.REMOTE) {

// add all the group elements
if (!user.getGroups().isEmpty()) {
xmlWriter.writeStartElement(GROUPS);
writeStringList(xmlWriter, GROUP, user.getGroups());
xmlWriter.writeEndElement();
}

// add all the role elements
if (!user.getRoles().isEmpty()) {
xmlWriter.writeStartElement(ROLES);
writeStringList(xmlWriter, ROLE, user.getRoles());
xmlWriter.writeEndElement();
}

// add the parameters
Map<String, String> properties = user.getProperties();
if (!properties.isEmpty())
writeStringMapElement(xmlWriter, properties, PROPERTIES, PROPERTY);
}

// add all the role elements
if (!user.getRoles().isEmpty()) {
xmlWriter.writeStartElement(ROLES);
writeStringList(xmlWriter, ROLE, user.getRoles());
xmlWriter.writeEndElement();
}

// add the parameters
Map<String, String> properties = user.getProperties();
if (!properties.isEmpty())
writeStringMapElement(xmlWriter, properties, PROPERTIES, PROPERTY);

if (!user.isHistoryEmpty()) {
UserHistory history = user.getHistory();
xmlWriter.writeStartElement(HISTORY);
Expand Down

0 comments on commit 659891c

Please sign in to comment.