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            public static void checkLicense(String productId) {
031                    getLicenseManager().checkLicense(productId);
032            }
033    
034            public static List<Map<String, String>> getClusterLicenseProperties(
035                    String clusterNodeId) {
036    
037                    return getLicenseManager().getClusterLicenseProperties(clusterNodeId);
038            }
039    
040            public static String getHostName() {
041                    return getLicenseManager().getHostName();
042            }
043    
044            public static Set<String> getIpAddresses() {
045                    return getLicenseManager().getIpAddresses();
046            }
047    
048            public static LicenseInfo getLicenseInfo(String productId) {
049                    return getLicenseManager().getLicenseInfo(productId);
050            }
051    
052            public static LicenseManager getLicenseManager() {
053                    PortalRuntimePermission.checkGetBeanProperty(LicenseManagerUtil.class);
054    
055                    return _licenseManager;
056            }
057    
058            public static List<Map<String, String>> getLicenseProperties() {
059                    return getLicenseManager().getLicenseProperties();
060            }
061    
062            public static Map<String, String> getLicenseProperties(String productId) {
063                    return getLicenseManager().getLicenseProperties(productId);
064            }
065    
066            public static int getLicenseState(Map<String, String> licenseProperties) {
067                    return getLicenseManager().getLicenseState(licenseProperties);
068            }
069    
070            public static int getLicenseState(String productId) {
071                    return getLicenseManager().getLicenseState(productId);
072            }
073    
074            public static Set<String> getMacAddresses() {
075                    return getLicenseManager().getMacAddresses();
076            }
077    
078            public static void registerLicense(JSONObject jsonObject) throws Exception {
079                    getLicenseManager().registerLicense(jsonObject);
080            }
081    
082            public void setLicenseManager(LicenseManager licenseManager) {
083                    PortalRuntimePermission.checkSetBeanProperty(getClass());
084    
085                    _licenseManager = licenseManager;
086            }
087    
088            private static LicenseManager _licenseManager;
089    
090    }