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.kernel.oauth;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    
019    /**
020     * @author Brian Wing Shun Chan
021     */
022    public class OAuthFactoryUtil {
023    
024            public static OAuthManager createOAuthManager(
025                            String key, String secret, String accessURL, String requestURL,
026                            String callbackURL, String scope)
027                    throws OAuthException {
028    
029                    return getOAuthFactory().createOAuthManager(
030                            key, secret, accessURL, requestURL, callbackURL, scope);
031            }
032    
033            public static OAuthRequest createOAuthRequest(Verb verb, String url)
034                    throws OAuthException {
035    
036                    return getOAuthFactory().createOAuthRequest(verb, url);
037            }
038    
039            public static Token createToken(String token, String secret)
040                    throws OAuthException {
041    
042                    return getOAuthFactory().createToken(token, secret);
043            }
044    
045            public static Verifier createVerifier(String verifier)
046                    throws OAuthException {
047    
048                    return getOAuthFactory().createVerifier(verifier);
049            }
050    
051            public static OAuthFactory getOAuthFactory() {
052                    PortalRuntimePermission.checkGetBeanProperty(OAuthFactoryUtil.class);
053    
054                    return _oAuthFactory;
055            }
056    
057            public void setOAuthFactory(OAuthFactory oAuthFactory) {
058                    PortalRuntimePermission.checkSetBeanProperty(getClass());
059    
060                    _oAuthFactory = oAuthFactory;
061            }
062    
063            private static OAuthFactory _oAuthFactory;
064    
065    }