Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

Enable full size images preview for users with extended search rights

lucciomanf52217c9397a
diff --git a/source/net/yacy/visualization/ImageViewer.java b/source/net/yacy/visualization/ImageViewer.java
index e6b4dcb88..b73c26465 100644
--- a/source/net/yacy/visualization/ImageViewer.java
+++ b/source/net/yacy/visualization/ImageViewer.java
@@ -47,6 +47,7 @@ import net.yacy.cora.util.ConcurrentLog;
import net.yacy.crawler.retrieval.StreamResponse;
import net.yacy.data.InvalidURLLicenceException;
import net.yacy.data.URLLicense;
+import net.yacy.data.UserDB;
import net.yacy.http.servlets.TemplateMissingParameterException;
import net.yacy.peers.graphics.EncodedImage;
import net.yacy.repository.Blacklist.BlacklistType;
@@ -146,9 +147,20 @@ public class ImageViewer {
* @param sb switchboard instance.
* @return true when full image view is allowed for this request
*/
- public static boolean hasFullViewingRights(final RequestHeader header, Switchboard sb) {
- return header != null && (Domains.isLocalhost(header.getRemoteAddr())
- || (sb != null && sb.verifyAuthentication(header)));
+ public static boolean hasFullViewingRights(final RequestHeader header, final Switchboard sb) {
+ boolean extendedSearchRights = false;
+ if(sb != null && header != null) {
+ final boolean adminAuthenticated = sb.verifyAuthentication(header);
+ if (adminAuthenticated) {
+ extendedSearchRights = true;
+ } else {
+ final UserDB.Entry user = sb.userDB != null ? sb.userDB.getUser(header) : null;
+ if (user != null) {
+ extendedSearchRights = user.hasRight(UserDB.AccessRight.EXTENDED_SEARCH_RIGHT);
+ }
+ }
+ }
+ return header != null && (extendedSearchRights || Domains.isLocalhost(header.getRemoteAddr()));
}
/**