Enable full size images preview for users with extended search rights

This commit is contained in:
luccioman 2017-12-22 11:39:30 +01:00
parent d42c1773c8
commit f52217c939

View File

@ -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()));
}
/**