private final AntPathMatcher shiroAntPathMatcher = new AntPathMatcher();
@Override
protected void handlePlexusResourceSecurity(PlexusResource resource) {
PathProtectionDescriptor descriptor = resource.getResourceProtection();
if (descriptor == null) {
return;
}
// sanity check: path protection descriptor path and resource URI must align
if (!shiroAntPathMatcher.match(descriptor.getPathPattern(), resource.getResourceUri())) {
throw new IllegalStateException(String.format(
"Plexus resource %s would attach to URI=%s but protect path=%s that does not matches URI!",
resource.getClass().getName(), resource.getResourceUri(),
descriptor.getPathPattern()));
}
String filterExpression = descriptor.getFilterExpression();
if (filterExpression != null && !filterExpression.contains("authcNxBasic")) {
// don't create session unless the user logs in from the UI
filterExpression = "noSessionCreation," + filterExpression;
}
this.protectedPathManager.addProtectedResource("/service/local" + descriptor.getPathPattern(), filterExpression);
}