protected boolean setAnonymousUserEnabled(final String anonymousUsername, final boolean enabled)
throws InvalidConfigurationException
{
try {
final User anonymousUser = getSecuritySystem().getUser(anonymousUsername, SecurityXmlUserManager.SOURCE);
final UserStatus oldStatus = anonymousUser.getStatus();
if (enabled) {
anonymousUser.setStatus(UserStatus.active);
}
else {
anonymousUser.setStatus(UserStatus.disabled);
}
getSecuritySystem().updateUser(anonymousUser);
return !oldStatus.equals(anonymousUser.getStatus());
}
catch (UserNotFoundException e) {
// ignore, anon user maybe manually deleted from XML realm by Nexus admin, is okay (kinda expected)
log.debug(
"Anonymous user not found while trying to disable it (as part of disabling anonymous access)!", e);