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.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    }