public void checkSearchPermission(String filter, String searchPermission) {
if (filter == null || filter.equals("*") || filter.isEmpty()) {
checkPermission(searchPermission);
} else {
if(!filter.startsWith("streams:")) {
throw new ForbiddenException("Not allowed to search with filter: [" + filter + "]");
}
String[] parts = filter.split(":");
if (parts.length <= 1) {
throw new ForbiddenException("Not allowed to search with filter: [" + filter + "]");
}
String streamList = parts[1];
String[] streams = streamList.split(",");
if (streams.length == 0 ) {
throw new ForbiddenException("Not allowed to search with filter: [" + filter + "]");
}
for(String streamId : streams) {
if (!isPermitted(RestPermissions.STREAMS_READ, streamId)) {
LOG.warn("Not allowed to search with filter: [" + filter + "]. (Forbidden stream: " + streamId + ")");
throw new ForbiddenException();
}
}
}
}