001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.license.util;
016    
017    import com.liferay.portal.kernel.json.JSONObject;
018    import com.liferay.portal.kernel.license.LicenseInfo;
019    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
020    
021    import java.util.List;
022    import java.util.Map;
023    import java.util.Set;
024    
025    /**
026     * @author Amos Fong
027     */
028    public class LicenseManagerUtil {
029    
030            /**
031             * @deprecated As of 6.2.0, replaced by {@link LicenseManager#STATE_ABSENT}
032             */
033            @Deprecated
034            public static final int STATE_ABSENT = LicenseManager.STATE_ABSENT;
035    
036            /**
037             * @deprecated As of 6.2.0, replaced by {@link LicenseManager#STATE_EXPIRED}
038             */
039            @Deprecated
040            public static final int STATE_EXPIRED = LicenseManager.STATE_EXPIRED;
041    
042            /**
043             * @deprecated As of 6.2.0, replaced by {@link LicenseManager#STATE_GOOD}
044             */
045            @Deprecated
046            public static final int STATE_GOOD = LicenseManager.STATE_GOOD;
047    
048            /**
049             * @deprecated As of 6.2.0, replaced by {@link
050             *             LicenseManager#STATE_INACTIVE}
051             */
052            @Deprecated
053            public static final int STATE_INACTIVE = LicenseManager.STATE_INACTIVE;
054    
055            /**
056             * @deprecated As of 6.2.0, replaced by {@link LicenseManager#STATE_INVALID}
057             */
058            @Deprecated
059            public static final int STATE_INVALID = LicenseManager.STATE_INVALID;
060    
061            /**
062             * @deprecated As of 6.2.0, replaced by {@link
063             *             LicenseManager#STATE_OVERLOAD}
064             */
065            @Deprecated
066            public static final int STATE_OVERLOAD = LicenseManager.STATE_OVERLOAD;
067    
068            public static void checkLicense(String productId) {
069                    getLicenseManager().checkLicense(productId);
070            }
071    
072            public static List<Map<String, String>> getClusterLicenseProperties(
073                    String clusterNodeId) {
074    
075                    return getLicenseManager().getClusterLicenseProperties(clusterNodeId);
076            }
077    
078            public static String getHostName() {
079                    return getLicenseManager().getHostName();
080            }
081    
082            public static Set<String> getIpAddresses() {
083                    return getLicenseManager().getIpAddresses();
084            }
085    
086            public static LicenseInfo getLicenseInfo(String productId) {
087                    return getLicenseManager().getLicenseInfo(productId);
088            }
089    
090            public static LicenseManager getLicenseManager() {
091                    PortalRuntimePermission.checkGetBeanProperty(LicenseManagerUtil.class);
092    
093                    return _licenseManager;
094            }
095    
096            public static List<Map<String, String>> getLicenseProperties() {
097                    return getLicenseManager().getLicenseProperties();
098            }
099    
100            public static Map<String, String> getLicenseProperties(String productId) {
101                    return getLicenseManager().getLicenseProperties(productId);
102            }
103    
104            public static int getLicenseState(Map<String, String> licenseProperties) {
105                    return getLicenseManager().getLicenseState(licenseProperties);
106            }
107    
108            public static int getLicenseState(String productId) {
109                    return getLicenseManager().getLicenseState(productId);
110            }
111    
112            public static Set<String> getMacAddresses() {
113                    return getLicenseManager().getMacAddresses();
114            }
115    
116            public static void registerLicense(JSONObject jsonObject) throws Exception {
117                    getLicenseManager().registerLicense(jsonObject);
118            }
119    
120            public void setLicenseManager(LicenseManager licenseManager) {
121                    PortalRuntimePermission.checkSetBeanProperty(getClass());
122    
123                    _licenseManager = licenseManager;
124            }
125    
126            private static LicenseManager _licenseManager;
127    
128    }