本文整理汇总了Java中net.oauth.OAuthServiceProvider类的典型用法代码示例。如果您正苦于以下问题:Java OAuthServiceProvider类的具体用法?Java OAuthServiceProvider怎么用?Java OAuthServiceProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OAuthServiceProvider类属于net.oauth包,在下文中一共展示了OAuthServiceProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DataApiOAuthServlet
import net.oauth.OAuthServiceProvider; //导入依赖的package包/类
@Inject
public DataApiOAuthServlet(@Named("request_token_path") String requestTokenPath,
@Named("authorize_token_path") String authorizeTokenPath,
@Named("access_token_path") String accessTokenPath,
@Named("all_tokens_path") String allTokensPath,
OAuthServiceProvider serviceProvider,
OAuthValidator validator, DataApiTokenContainer tokenContainer,
SessionManager sessionManager, TokenGenerator tokenGenerator) {
this.requestTokenPath = requestTokenPath;
this.authorizeTokenPath = authorizeTokenPath;
this.accessTokenPath = accessTokenPath;
this.allTokensPath = allTokensPath;
this.serviceProvider = serviceProvider;
this.validator = validator;
this.tokenContainer = tokenContainer;
this.sessionManager = sessionManager;
this.tokenGenerator = tokenGenerator;
this.xsrfTokens =
CacheBuilder.newBuilder()
.expireAfterWrite(XSRF_TOKEN_TIMEOUT_HOURS, TimeUnit.HOURS)
.<ParticipantId, String>build().asMap();
}
示例2: testGetConsumerKeyAndSecret
import net.oauth.OAuthServiceProvider; //导入依赖的package包/类
@Test
public void testGetConsumerKeyAndSecret() throws Exception {
OAuthConsumerStore consumerStore = new OAuthConsumerStoreImpl();
consumerStore.setGadgetUri(GADGET_URI);
consumerStore.setConsumerKey("gadgetConsumer");
consumerStore.setConsumerSecret(CONSUMER_SECRET);
consumerStore.setKeyType(OAuthConsumerStore.KeyType.HMAC_SYMMETRIC);
OAuthServiceProvider provider = new OAuthServiceProvider(null, null, null);
expect(consumerStoreService.findByUriAndServiceName(GADGET_URI, SERVICE_NAME))
.andReturn(consumerStore);
replay(consumerStoreService);
final OAuthStore.ConsumerInfo keyAndSecret =
oAuthStore.getConsumerKeyAndSecret(token, SERVICE_NAME, provider);
assertNotNull(keyAndSecret);
assertEquals(OAuth.HMAC_SHA1, keyAndSecret.getConsumer().getProperty(
OAuth.OAUTH_SIGNATURE_METHOD));
verify(consumerStoreService);
}
示例3: testcreateOAuthAccessor
import net.oauth.OAuthServiceProvider; //导入依赖的package包/类
/**
* Test method for
* {@link com.davide.parise.pesapal.post.PostRequest#getURL()}.
*
* @throws PostRequestException
*/
@Test
public void testcreateOAuthAccessor() {
String consumerKey = props.getProperty("pesapal.consumerKey");
String callbackUrl = props.getProperty("pesapal.callbackURL");
String consumerSecret = props.getProperty("pesapal.consumerSecret");
String reqUrl = props.getProperty("pesapal.serviceProvider.PostPesapalDirectOrderV4");
OAuthServiceProvider provider = new OAuthServiceProvider(reqUrl,
reqUrl, reqUrl);
OAuthConsumer consumer = new OAuthConsumer(callbackUrl, consumerKey,
consumerSecret, provider);
OAuthAccessor oa = new OAuthAccessor(consumer);
assertNotNull(oa);
}
示例4: createOAuthAccessor
import net.oauth.OAuthServiceProvider; //导入依赖的package包/类
private OAuthAccessor createOAuthAccessor(){
String consumerKey = props.getProperty("consumerKey");
String callbackUrl = null;
String consumerSecret = props.getProperty("consumerSecret");
String reqUrl = props.getProperty("requestUrl");
String authzUrl = props.getProperty("authorizationUrl");
String accessUrl = props.getProperty("accessUrl");
OAuthServiceProvider provider
= new OAuthServiceProvider(reqUrl, authzUrl, accessUrl);
OAuthConsumer consumer
= new OAuthConsumer(callbackUrl, consumerKey,
consumerSecret, provider);
return new OAuthAccessor(consumer);
}
示例5: main
import net.oauth.OAuthServiceProvider; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
DesktopClient client = new DesktopClient(new OAuthConsumer(null //
, "7y0Wxw7B9kLIVNdPAEv47g" // consumer key
, "F34HyfNIvLTXJNgUpLSyRRdQBYYllWIMXyim6NzPQ" // consumer secret
, new OAuthServiceProvider( //
"http://twitter.com/oauth/request_token", //
"http://twitter.com/oauth/authorize", //
"http://twitter.com/oauth/access_token")));
client.setOAuthClient(new OAuthClient(new HttpClient4()));
OAuthMessage response = client.access(OAuthMessage.GET,
"http://twitter.com/statuses/friends_timeline.xml", null);
// That is, the 20 most recent statuses posted by the authenticating
// user and that user's friends.
// http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-friends_timeline
System.out.println(response.readBodyAsString());
}
示例6: loadProgrammaticConfig
import net.oauth.OAuthServiceProvider; //导入依赖的package包/类
private OAuthServiceProvider loadProgrammaticConfig(OAuthArguments arguments,
AccessorInfoBuilder accessorBuilder, OAuthResponseParams responseParams)
throws OAuthRequestException {
try {
String paramLocationStr = arguments.getRequestOption(OAuthArguments.PARAM_LOCATION_PARAM, "");
Location l = Location.parse(paramLocationStr);
accessorBuilder.setParameterLocation(getStoreLocation(l, responseParams));
String requestMethod = arguments.getRequestOption(OAuthArguments.REQUEST_METHOD_PARAM, "GET");
Method m = Method.parse(requestMethod);
accessorBuilder.setMethod(getStoreMethod(m, responseParams));
String requestTokenUrl = arguments.getRequestOption(OAuthArguments.REQUEST_TOKEN_URL_PARAM);
verifyUrl(requestTokenUrl, responseParams);
String accessTokenUrl = arguments.getRequestOption(OAuthArguments.ACCESS_TOKEN_URL_PARAM);
verifyUrl(accessTokenUrl, responseParams);
String authorizationUrl = arguments.getRequestOption(OAuthArguments.AUTHORIZATION_URL_PARAM);
verifyUrl(authorizationUrl, responseParams);
return new OAuthServiceProvider(requestTokenUrl, authorizationUrl, accessTokenUrl);
} catch (SpecParserException e) {
// these exceptions have decent programmer readable messages
throw responseParams.oauthRequestException(OAuthError.BAD_OAUTH_CONFIGURATION,
e.getMessage());
}
}
示例7: testInit
import net.oauth.OAuthServiceProvider; //导入依赖的package包/类
@Test
public void testInit() throws Exception {
FakeGadgetToken t = new FakeGadgetToken();
t.setAppUrl("http://localhost:8080/gadgets/files/samplecontainer/examples/oauth.xml");
OAuthServiceProvider provider = new OAuthServiceProvider("req", "authorize", "access");
ConsumerInfo consumerInfo = store.getConsumerKeyAndSecret(t, "", provider);
OAuthConsumer consumer = consumerInfo.getConsumer();
assertEquals("gadgetConsumer", consumer.consumerKey);
assertEquals("gadgetSecret", consumer.consumerSecret);
assertEquals("HMAC-SHA1", consumer.getProperty("oauth_signature_method"));
assertEquals(provider, consumer.serviceProvider);
assertNull(consumerInfo.getKeyName());
assertEquals("default callback", consumerInfo.getCallbackUrl());
t.setAppUrl("http://rsagadget/test.xml");
consumerInfo = store.getConsumerKeyAndSecret(t, "", provider);
consumer = consumerInfo.getConsumer();
assertEquals("rsaconsumer", consumer.consumerKey);
assertNull(consumer.consumerSecret);
assertEquals("RSA-SHA1", consumer.getProperty("oauth_signature_method"));
assertEquals(provider, consumer.serviceProvider);
assertEquals("rsaprivate", consumer.getProperty(RSA_SHA1.PRIVATE_KEY));
assertNull(consumerInfo.getKeyName());
assertEquals("callback", consumerInfo.getCallbackUrl());
}
示例8: threeLeggedOAuth
import net.oauth.OAuthServiceProvider; //导入依赖的package包/类
/**
* Performs 3-legged OAuth authorization through Data API.
*
* @param service wave service.
*/
public String threeLeggedOAuth(WaveService service) throws IOException {
Console.println("Paste this URL in your browser:\n" + serverUrl + GET_ALL_TOKENS_URL_POSTFIX);
Console.println("Type the code you received here: ");
String authorizationCode = new String(
Base64.decodeBase64(Console.readLine().getBytes("UTF-8")), "UTF-8");
StringTokenizer st = new StringTokenizer(authorizationCode);
String requestToken = st.nextToken();
String accessToken = st.nextToken();
String tokenSecret = st.nextToken();
String requestUrl = serverUrl + REQUEST_URL_POSTFIX;
String authUrl = serverUrl + AUTH_URL_POSTFIX;
String accessUrl = serverUrl + ACCESS_URL_POSTFIX;
OAuthServiceProvider provider = new OAuthServiceProvider(requestUrl
+ "?scope=" + URLEncoder.encode("", "utf-8"), authUrl, accessUrl);
OAuthConsumer consumer = new OAuthConsumer("", THREE_LEGGED_API_CONSUMER_KEY,
THREE_LEGGED_API_CONSUMER_SECRET, provider);
OAuthAccessor accessor = new OAuthAccessor(consumer);
accessor.requestToken = requestToken;
accessor.accessToken = accessToken;
accessor.tokenSecret = tokenSecret;
String rpcServerUrl = serverUrl + DATA_API_RPC_URL_POSTFIX;
service.setupOAuth(accessor, rpcServerUrl);
return rpcServerUrl;
}
示例9: ActiveApiServlet
import net.oauth.OAuthServiceProvider; //导入依赖的package包/类
@Inject
public ActiveApiServlet(RobotSerializer robotSerializer,
EventDataConverterManager converterManager, WaveletProvider waveletProvider,
@Named("ActiveApiRegistry") OperationServiceRegistry operationRegistry,
ConversationUtil conversationUtil, OAuthServiceProvider oAuthServiceProvider,
OAuthValidator validator, AccountStore accountStore, AttachmentService attachmentService) {
super(robotSerializer, converterManager, waveletProvider, operationRegistry, conversationUtil, validator, attachmentService);
this.oauthServiceProvider = oAuthServiceProvider;
this.accountStore = accountStore;
}
示例10: provideOAuthServiceProvider
import net.oauth.OAuthServiceProvider; //导入依赖的package包/类
@Provides
@Singleton
protected OAuthServiceProvider provideOAuthServiceProvider(
@Named(CoreSettings.HTTP_FRONTEND_PUBLIC_ADDRESS) String publicAddress) {
// Three urls, first is to get an unauthorized request token, second is to
// authorize the request token, third is to exchange the authorized request
// token with an access token.
String requestTokenUrl = getOAuthUrl(publicAddress, REQUEST_TOKEN_PATH);
String authorizeTokenUrl = getOAuthUrl(publicAddress, AUTHORIZE_TOKEN_PATH);
String accessTokenUrl = getOAuthUrl(publicAddress, ACCESS_TOKEN_PATH);
return new OAuthServiceProvider(requestTokenUrl, authorizeTokenUrl, accessTokenUrl);
}
示例11: setUp
import net.oauth.OAuthServiceProvider; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
robotSerializer = mock(RobotSerializer.class);
operationRegistry = mock(OperationServiceRegistry.class);
validator = mock(OAuthValidator.class);
EventDataConverterManager converterManager = mock(EventDataConverterManager.class);
WaveletProvider waveletProvider = mock(WaveletProvider.class);
ConversationUtil conversationUtil = mock(ConversationUtil.class);
OAuthServiceProvider oAuthServiceProvider = mock(OAuthServiceProvider.class);
AccountStore accountStore = mock(AccountStore.class);
when(accountStore.getAccount(ROBOT)).thenReturn(
new RobotAccountDataImpl(ROBOT, "", "secret", null, true));
req = mock(HttpServletRequest.class);
when(req.getRequestURL()).thenReturn(new StringBuffer("www.example.com/robot"));
when(req.getHeaderNames()).thenReturn(
convertRawEnumerationToGeneric(new StringTokenizer("Authorization")));
when(req.getReader()).thenReturn(new BufferedReader(new StringReader("")));
resp = mock(HttpServletResponse.class);
outputWriter = new StringWriter();
when(resp.getWriter()).thenReturn(new PrintWriter(outputWriter));
AttachmentService attachments = mock(AttachmentService.class);
servlet =
new ActiveApiServlet(robotSerializer, converterManager, waveletProvider, operationRegistry,
conversationUtil, oAuthServiceProvider, validator, accountStore, attachments);
}
示例12: setUp
import net.oauth.OAuthServiceProvider; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
TokenGenerator tokenGenerator = mock(TokenGenerator.class);
when(tokenGenerator.generateToken(anyInt())).thenReturn(FAKE_TOKEN);
container = new DataApiTokenContainer(tokenGenerator);
OAuthServiceProvider serviceProvider = new OAuthServiceProvider("", "", "");
consumer = new OAuthConsumer("", "consumerkey", "consumersecret", serviceProvider);
}
示例13: setUp
import net.oauth.OAuthServiceProvider; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
robotSerializer = mock(RobotSerializer.class);
converterManager = mock(EventDataConverterManager.class);
waveletProvider = mock(WaveletProvider.class);
operationRegistry = mock(OperationServiceRegistry.class);
ConversationUtil conversationUtil = mock(ConversationUtil.class);
validator = mock(OAuthValidator.class);
TokenGenerator tokenGenerator = mock(TokenGenerator.class);
when(tokenGenerator.generateToken(anyInt())).thenReturn(FAKE_TOKEN);
tokenContainer = new DataApiTokenContainer(tokenGenerator);
OAuthServiceProvider serviceProvider = new OAuthServiceProvider("", "", "");
consumer = new OAuthConsumer("", "consumerkey", "consumersecret", serviceProvider);
req = mock(HttpServletRequest.class);
when(req.getRequestURL()).thenReturn(new StringBuffer("www.example.com"));
when(req.getReader()).thenReturn(new BufferedReader(new StringReader("")));
when(req.getMethod()).thenReturn("POST");
resp = mock(HttpServletResponse.class);
stringWriter = new StringWriter();
PrintWriter writer = new PrintWriter(stringWriter);
when(resp.getWriter()).thenReturn(writer);
AttachmentService attachments = mock(AttachmentService.class);
servlet =
new DataApiServlet(robotSerializer, converterManager, waveletProvider, operationRegistry,
conversationUtil, validator, tokenContainer, attachments);
}
示例14: setUp
import net.oauth.OAuthServiceProvider; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
validator = mock(OAuthValidator.class);
sessionManager = mock(SessionManager.class);
TokenGenerator tokenGenerator = mock(TokenGenerator.class);
when(tokenGenerator.generateToken(anyInt())).thenReturn(FAKE_TOKEN);
tokenContainer = new DataApiTokenContainer(tokenGenerator);
req = mock(HttpServletRequest.class);
when(req.getRequestURL()).thenReturn(new StringBuffer("www.example.com/robot"));
when(req.getLocale()).thenReturn(Locale.ENGLISH);
HttpSession sessionMock = mock(HttpSession.class);
when(req.getSession()).thenReturn(sessionMock);
when(req.getSession(anyBoolean())).thenReturn(sessionMock);
resp = mock(HttpServletResponse.class);
outputStream = new ServletOutputStreamStub();
when(resp.getOutputStream()).thenReturn(outputStream);
outputWriter = new StringWriter();
when(resp.getWriter()).thenReturn(new PrintWriter(outputWriter));
OAuthServiceProvider serviceProvider = new OAuthServiceProvider("", "", "");
consumer = new OAuthConsumer("", "consumerkey", "consumersecret", serviceProvider);
servlet =
new DataApiOAuthServlet(REQUEST_TOKEN_PATH,
AUTHORIZE_TOKEN_PATH, ACCESS_TOKEN_PATH, GET_ALL_TOKENS_PATH,
serviceProvider, validator, tokenContainer, sessionManager, tokenGenerator);
}
示例15: buildAccessor
import net.oauth.OAuthServiceProvider; //导入依赖的package包/类
private OAuthAccessor buildAccessor(String consumerKey,
String consumerSecret, String requestTokenUrl, String authorizeUrl,
String callbackUrl, String accessTokenUrl) {
OAuthServiceProvider provider =
new OAuthServiceProvider(requestTokenUrl, authorizeUrl, accessTokenUrl);
OAuthConsumer consumer =
new OAuthConsumer(callbackUrl, consumerKey, consumerSecret, provider);
OAuthAccessor accessor = new OAuthAccessor(consumer);
return accessor;
}