001    /**
002     * Copyright (c) 2000-2013 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.license.util;
016    
017    import com.liferay.portal.kernel.json.JSONObject;
018    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
019    import com.liferay.portal.license.LicenseInfo;
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            public static final int STATE_ABSENT = LicenseManager.STATE_ABSENT;
034    
035            /**
036             * @deprecated As of 6.2.0, replaced by {@link LicenseManager#STATE_EXPIRED}
037             */
038            public static final int STATE_EXPIRED = LicenseManager.STATE_EXPIRED;
039    
040            /**
041             * @deprecated As of 6.2.0, replaced by {@link LicenseManager#STATE_GOOD}
042             */
043            public static final int STATE_GOOD = LicenseManager.STATE_GOOD;
044    
045            /**
046             * @deprecated As of 6.2.0, replaced by {@link
047             *             LicenseManager#STATE_INACTIVE}
048             */
049            public static final int STATE_INACTIVE = LicenseManager.STATE_INACTIVE;
050    
051            /**
052             * @deprecated As of 6.2.0, replaced by {@link LicenseManager#STATE_INVALID}
053             */
054            public static final int STATE_INVALID = LicenseManager.STATE_INVALID;
055    
056            /**
057             * @deprecated As of 6.2.0, replaced by {@link
058             *             LicenseManager#STATE_OVERLOAD}
059             */
060            public static final int STATE_OVERLOAD = LicenseManager.STATE_OVERLOAD;
061    
062            public static void checkLicense(String productId) {
063                    getLicenseManager().checkLicense(productId);
064            }
065    
066            public static List<Map<String, String>> getClusterLicenseProperties(
067                    String clusterNodeId) {
068    
069                    return getLicenseManager().getClusterLicenseProperties(clusterNodeId);
070            }
071    
072            public static String getHostName() {
073                    return getLicenseManager().getHostName();
074            }
075    
076            public static Set<String> getIpAddresses() {
077                    return getLicenseManager().getIpAddresses();
078            }
079    
080            public static LicenseInfo getLicenseInfo(String productId) {
081                    return getLicenseManager().getLicenseInfo(productId);
082            }
083    
084            public static LicenseManager getLicenseManager() {
085                    PortalRuntimePermission.checkGetBeanProperty(LicenseManagerUtil.class);
086    
087                    return _licenseManager;
088            }
089    
090            public static List<Map<String, String>> getLicenseProperties() {
091                    return getLicenseManager().getLicenseProperties();
092            }
093    
094            public static Map<String, String> getLicenseProperties(String productId) {
095                    return getLicenseManager().getLicenseProperties(productId);
096            }
097    
098            public static int getLicenseState(Map<String, String> licenseProperties) {
099                    return getLicenseManager().getLicenseState(licenseProperties);
100            }
101    
102            public static int getLicenseState(String productId) {
103                    return getLicenseManager().getLicenseState(productId);
104            }
105    
106            public static Set<String> getMacAddresses() {
107                    return getLicenseManager().getMacAddresses();
108            }
109    
110            public static void registerLicense(JSONObject jsonObject) throws Exception {
111                    getLicenseManager().registerLicense(jsonObject);
112            }
113    
114            public void setLicenseManager(LicenseManager licenseManager) {
115                    PortalRuntimePermission.checkSetBeanProperty(getClass());
116    
117                    _licenseManager = licenseManager;
118            }
119    
120            private static LicenseManager _licenseManager;
121    
122    }