001
014
015 package com.liferay.portal.oauth;
016
017 import com.liferay.portal.kernel.oauth.OAuthException;
018 import com.liferay.portal.kernel.oauth.OAuthFactory;
019 import com.liferay.portal.kernel.oauth.OAuthManager;
020 import com.liferay.portal.kernel.oauth.OAuthRequest;
021 import com.liferay.portal.kernel.oauth.Token;
022 import com.liferay.portal.kernel.oauth.Verb;
023 import com.liferay.portal.kernel.oauth.Verifier;
024 import com.liferay.portal.kernel.security.pacl.DoPrivileged;
025
026
029 @DoPrivileged
030 public class OAuthFactoryImpl implements OAuthFactory {
031
032 @Override
033 public OAuthManager createOAuthManager(
034 String key, String secret, String accessURL, String requestURL,
035 String callbackURL, String scope)
036 throws OAuthException {
037
038 try {
039 return new OAuthManagerImpl(
040 key, secret, accessURL, requestURL, callbackURL, scope);
041 }
042 catch (Exception e) {
043 throw new OAuthException(e);
044 }
045 }
046
047 @Override
048 public OAuthRequest createOAuthRequest(Verb verb, String url)
049 throws OAuthException {
050
051 try {
052 return new OAuthRequestImpl(
053 new org.scribe.model.OAuthRequest(
054 VerbTranslator.translate(verb), url));
055 }
056 catch (Exception e) {
057 throw new OAuthException(e);
058 }
059 }
060
061 @Override
062 public Token createToken(String token, String secret)
063 throws OAuthException {
064
065 try {
066 return new TokenImpl(new org.scribe.model.Token(token, secret));
067 }
068 catch (Exception e) {
069 throw new OAuthException(e);
070 }
071 }
072
073 @Override
074 public Verifier createVerifier(String verifier) throws OAuthException {
075 try {
076 return new VerifierImpl(new org.scribe.model.Verifier(verifier));
077 }
078 catch (Exception e) {
079 throw new OAuthException(e);
080 }
081 }
082
083 }