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.security.auth;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    
019    import java.util.Set;
020    
021    /**
022     * @author Tomas Polesovsky
023     * @author Raymond Aug??
024     */
025    public class AuthTokenWhitelistUtil {
026    
027            public static AuthTokenWhitelist getAuthTokenWhitelist() {
028                    PortalRuntimePermission.checkGetBeanProperty(AuthTokenWhitelist.class);
029    
030                    return _authTokenWhitelist;
031            }
032    
033            public static Set<String> getPortletCSRFWhitelist() {
034                    return getAuthTokenWhitelist().getPortletCSRFWhitelist();
035            }
036    
037            public static Set<String> getPortletCSRFWhitelistActions() {
038                    return getAuthTokenWhitelist().getPortletCSRFWhitelistActions();
039            }
040    
041            public static Set<String> getPortletInvocationWhitelist() {
042                    return getAuthTokenWhitelist().getPortletInvocationWhitelist();
043            }
044    
045            public static Set<String> getPortletInvocationWhitelistActions() {
046                    return getAuthTokenWhitelist().getPortletInvocationWhitelistActions();
047            }
048    
049            public static boolean isCSRFOrigintWhitelisted(
050                    long companyId, String origin) {
051    
052                    return getAuthTokenWhitelist().isOriginCSRFWhitelisted(
053                            companyId, origin);
054            }
055    
056            public static boolean isPortletCSRFWhitelisted(
057                    long companyId, String portletId, String strutsAction) {
058    
059                    return getAuthTokenWhitelist().isPortletCSRFWhitelisted(
060                            companyId, portletId, strutsAction);
061            }
062    
063            public static boolean isPortletInvocationWhitelisted(
064                    long companyId, String portletId, String strutsAction) {
065    
066                    return getAuthTokenWhitelist().isPortletInvocationWhitelisted(
067                            companyId, portletId, strutsAction);
068            }
069    
070            public static boolean isValidSharedSecret(String sharedSecret) {
071                    return getAuthTokenWhitelist().isValidSharedSecret(sharedSecret);
072            }
073    
074            public static Set<String> resetOriginCSRFWhitelist() {
075                    return getAuthTokenWhitelist().resetOriginCSRFWhitelist();
076            }
077    
078            public static Set<String> resetPortletCSRFWhitelist() {
079                    return getAuthTokenWhitelist().resetPortletCSRFWhitelist();
080            }
081    
082            public static Set<String> resetPortletCSRFWhitelistActions() {
083                    return getAuthTokenWhitelist().resetPortletCSRFWhitelistActions();
084            }
085    
086            public static Set<String> resetPortletInvocationWhitelist() {
087                    return getAuthTokenWhitelist().resetPortletInvocationWhitelist();
088            }
089    
090            public static Set<String> resetPortletInvocationWhitelistActions() {
091                    return getAuthTokenWhitelist().resetPortletInvocationWhitelistActions();
092            }
093    
094            public void setAuthTokenWhitelist(AuthTokenWhitelist authTokenWhitelist) {
095                    PortalRuntimePermission.checkSetBeanProperty(getClass());
096    
097                    _authTokenWhitelist = authTokenWhitelist;
098            }
099    
100            private static AuthTokenWhitelist _authTokenWhitelist;
101    
102    }