001
014
015 package com.liferay.portlet.documentlibrary.antivirus;
016
017 import com.liferay.portal.kernel.exception.SystemException;
018 import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
019
020 import java.io.File;
021 import java.io.InputStream;
022
023
027 public class AntivirusScannerUtil {
028
029 public static AntivirusScanner getAntivirusScanner() {
030 PortalRuntimePermission.checkGetBeanProperty(
031 AntivirusScannerUtil.class);
032
033 return _antivirusScanner;
034 }
035
036 public static boolean isActive() {
037 AntivirusScanner antivirusScanner = getAntivirusScanner();
038
039 if (antivirusScanner == null) {
040 return false;
041 }
042
043 return antivirusScanner.isActive();
044 }
045
046 public static void scan(byte[] bytes)
047 throws AntivirusScannerException, SystemException {
048
049 if (isActive()) {
050 getAntivirusScanner().scan(bytes);
051 }
052 }
053
054 public static void scan(File file)
055 throws AntivirusScannerException, SystemException {
056
057 if (isActive()) {
058 getAntivirusScanner().scan(file);
059 }
060 }
061
062 public static void scan(InputStream inputStream)
063 throws AntivirusScannerException, SystemException {
064
065 if (isActive()) {
066 getAntivirusScanner().scan(inputStream);
067 }
068 }
069
070 public void setAntivirusScanner(AntivirusScanner antiVirusScanner) {
071 PortalRuntimePermission.checkSetBeanProperty(getClass());
072
073 _antivirusScanner = antiVirusScanner;
074 }
075
076 private static AntivirusScanner _antivirusScanner;
077
078 }