001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.security.auth;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
019    
020    import javax.servlet.http.HttpServletRequest;
021    
022    /**
023     * @author Amos Fong
024     */
025    public class AuthTokenUtil {
026    
027            public static void check(HttpServletRequest request)
028                    throws PortalException {
029    
030                    getAuthToken().check(request);
031            }
032    
033            public static AuthToken getAuthToken() {
034                    PortalRuntimePermission.checkGetBeanProperty(AuthTokenUtil.class);
035    
036                    return _authToken;
037            }
038    
039            public static String getToken(HttpServletRequest request) {
040                    return getAuthToken().getToken(request);
041            }
042    
043            public static String getToken(
044                    HttpServletRequest request, long plid, String portletId) {
045    
046                    return getAuthToken().getToken(request, plid, portletId);
047            }
048    
049            public void setAuthToken(AuthToken authToken) {
050                    PortalRuntimePermission.checkSetBeanProperty(getClass());
051    
052                    _authToken = authToken;
053            }
054    
055            private static AuthToken _authToken;
056    
057    }