Permalink
Browse files

Enable full size images preview for users with extended search rights

  • Loading branch information...
luccioman committed Dec 22, 2017
1 parent d42c177 commit f52217c9397a88385ba8cf58478545c20ee4b70c
Showing with 15 additions and 3 deletions.
  1. +15 −3 source/net/yacy/visualization/ImageViewer.java
@@ -47,6 +47,7 @@
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 InputStream openInputStream(final serverObjects post, final LoaderDispatc
* @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()));
}
/**

0 comments on commit f52217c

Please sign in to comment.