in src/main/java/org/apache/sling/auth/core/impl/AuthenticationRequirementsManager.java [396:437]
private void modifiedService(final ResourceMapper mapper, final ServiceReference<?> ref) {
final String[] authReqPaths = Converters.standardConverter().convert(ref.getProperty(AuthConstants.AUTH_REQUIREMENTS)).to(String[].class);
final Long id = (Long)ref.getProperty(Constants.SERVICE_ID);
if ( authReqPaths.length > 0 ) {
final Set<String> oldPaths = regProps.get(id);
if ( oldPaths == null ) {
addService(mapper, ref);
} else {
final Set<String> paths = buildPathsSet(mapper, authReqPaths);
if ( paths.isEmpty() ) {
removeService(id);
} else {
final List<AuthenticationRequirementHolder> authReqs = props.get(id);
// compare sets
for(final String oldPath : oldPaths) {
if (oldPath == null || oldPath.isEmpty()) {
continue;
} else if ( !paths.contains(oldPath) ) {
// remove
final AuthenticationRequirementHolder holder = AuthenticationRequirementHolder.fromConfig(oldPath, ref);
authReqs.remove(holder);
this.removeHolder(holder);
}
}
for(final String path : paths) {
if (path == null || path.isEmpty()) {
logger.warn("Ignoring null/empty path while updating the auth requirements for service {}", id);
} else if ( !oldPaths.contains(path) ) {
// add
final AuthenticationRequirementHolder holder = AuthenticationRequirementHolder.fromConfig(path, ref);
authReqs.add(holder);
this.addHolder(holder);
}
}
regProps.put(id, paths);
logger.debug("Updated auth requirements for service {} : {}", id, paths);
}
}
} else {
removeService(id);
}
}