当前位置: 首页>>代码示例>>Java>>正文


Java OAuth1Parameters类代码示例

本文整理汇总了Java中org.springframework.social.oauth1.OAuth1Parameters的典型用法代码示例。如果您正苦于以下问题:Java OAuth1Parameters类的具体用法?Java OAuth1Parameters怎么用?Java OAuth1Parameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


OAuth1Parameters类属于org.springframework.social.oauth1包,在下文中一共展示了OAuth1Parameters类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printWelcome

import org.springframework.social.oauth1.OAuth1Parameters; //导入依赖的package包/类
@RequestMapping(value = "/twitterLogin")
public void printWelcome(HttpServletResponse response,HttpServletRequest request) {
 TwitterConnectionFactory connectionFactoryTwitter = 
		 new TwitterConnectionFactory("<consumer id>","<consumer key>");
 OAuth1Operations oauth1Operations = connectionFactoryTwitter.getOAuthOperations();

  OAuthToken  requestToken = oauth1Operations.fetchRequestToken("http://www.localhost:8080/ch08/erp/twitterAuthentication.html", null);
    String authorizeUrl = oauth1Operations.buildAuthorizeUrl(requestToken.getValue(), OAuth1Parameters.NONE);
    try {
		response.sendRedirect(authorizeUrl);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

      
   }
 
开发者ID:PacktPublishing,项目名称:Spring-MVC-Blueprints,代码行数:18,代码来源:SocialLogin.java

示例2: callback

import org.springframework.social.oauth1.OAuth1Parameters; //导入依赖的package包/类
@RequestMapping(value = "/twitterAuthentication")
 public RedirectView callback(@RequestParam(value = "oauth_token") String oauthToken, @RequestParam(value = "oauth_verifier") String oauthVerifier) {
TwitterConnectionFactory connectionFactoryTwitter = 
		 new TwitterConnectionFactory("<consumer id>","<consumer key>");
OAuth1Operations oauth1Operations = connectionFactoryTwitter.getOAuthOperations();
OAuthToken  requestToken = oauth1Operations.fetchRequestToken("http://www.localhost:8080/ch08/erp/twitterAuthentication.html", null);
RedirectView redirectView = new RedirectView();
redirectView.setContextRelative(true);
   OAuthToken accessToken = oauth1Operations.exchangeForAccessToken(new AuthorizedRequestToken(requestToken, oauthVerifier), OAuth1Parameters.NONE);
   
   if(accessToken.equals("<enter access token here>")){
   	redirectView.setUrl("/erp/paymentmodes.xml");
   }else{
   	redirectView.setUrl("http://www.google.com");
   }
   return redirectView;
 }
 
开发者ID:PacktPublishing,项目名称:Spring-MVC-Blueprints,代码行数:18,代码来源:SocialLogin.java

示例3: authorization

import org.springframework.social.oauth1.OAuth1Parameters; //导入依赖的package包/类
@RequestMapping("/auth")
public Map<String, String> authorization(@RequestParam String callbackUrl,
                                         @RequestParam(required = false) boolean preferRegistration,
                                         @RequestParam(required = false) boolean supportLinkedSandbox) {

	// obtain request token (temporal credential)
	final OAuth1Operations oauthOperations = this.evernoteConnectionFactory.getOAuthOperations();
	final OAuthToken requestToken = oauthOperations.fetchRequestToken(callbackUrl, null); // no additional param

	// construct authorization url with callback url for client to redirect
	final OAuth1Parameters parameters = new OAuth1Parameters();
	if (preferRegistration) {
		parameters.set("preferRegistration", "true");  // create account
	}
	if (supportLinkedSandbox) {
		parameters.set("supportLinkedSandbox", "true");
	}
	final String authorizeUrl = oauthOperations.buildAuthorizeUrl(requestToken.getValue(), parameters);

	final Map<String, String> map = new HashMap<String, String>();
	map.put("authorizeUrl", authorizeUrl);
	map.put("requestTokenValue", requestToken.getValue());
	map.put("requestTokenSecret", requestToken.getSecret());
	return map;
}
 
开发者ID:ttddyy,项目名称:evernote-rest-webapp,代码行数:26,代码来源:OAuthController.java

示例4: testCreateOAuthToken

import org.springframework.social.oauth1.OAuth1Parameters; //导入依赖的package包/类
@Test
public void testCreateOAuthToken() {

	EvernoteOAuth1Template template = new EvernoteOAuth1Template("key", "secret", EvernoteService.SANDBOX);
	MultiValueMap<String, String> response = new OAuth1Parameters();
	response.add("oauth_token", "test_token");
	response.add("oauth_token_secret", "test_secret");
	response.add("edam_shard", "test_shard");
	response.add("edam_userId", "test_userId");
	response.add("edam_expires", "test_expires");
	response.add("edam_noteStoreUrl", "test_noteStoreUrl");
	response.add("edam_webApiUrlPrefix", "test_webApiUrlPrefix");

	OAuthToken token = template.createOAuthToken("tokenValue", "tokenSecret", response);
	assertThat(token, instanceOf(EvernoteOAuthToken.class));

	EvernoteOAuthToken eToken = (EvernoteOAuthToken) token;
	assertThat(eToken.getValue(), is("test_token"));
	assertThat(eToken.getSecret(), is("test_secret"));
	assertThat(eToken.getEdamShard(), is("test_shard"));
	assertThat(eToken.getEdamUserId(), is("test_userId"));
	assertThat(eToken.getEdamExpires(), is("test_expires"));
	assertThat(eToken.getEdamNoteStoreUrl(), is("test_noteStoreUrl"));
	assertThat(eToken.getEdamWebApiUrlPrefix(), is("test_webApiUrlPrefix"));
}
 
开发者ID:ttddyy,项目名称:spring-social-evernote,代码行数:26,代码来源:EvernoteOAuth1TemplateTest.java

示例5: buildOAuth1Url

import org.springframework.social.oauth1.OAuth1Parameters; //导入依赖的package包/类
private String buildOAuth1Url(OAuth1ConnectionFactory<?> connectionFactory, NativeWebRequest request,
    MultiValueMap<String, String> additionalParameters) {
    OAuth1Operations oauthOperations = connectionFactory.getOAuthOperations();
    MultiValueMap<String, String> requestParameters = getRequestParameters(request);
    OAuth1Parameters parameters = getOAuth1Parameters(request, additionalParameters);
    parameters.putAll(requestParameters);
    if (oauthOperations.getVersion() == OAuth1Version.CORE_10) {
        parameters.setCallbackUrl(callbackUrl(request));
    }
    OAuthToken requestToken = fetchRequestToken(request, requestParameters, oauthOperations);
    sessionStrategy.setAttribute(request, OAUTH_TOKEN_ATTRIBUTE, requestToken);
    return buildOAuth1Url(oauthOperations, requestToken.getValue(), parameters);
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:14,代码来源:ConnectSupport.java

示例6: prepare

import org.springframework.social.oauth1.OAuth1Parameters; //导入依赖的package包/类
@Override
public CredentialFlowState prepare(final String connectorId, final URI baseUrl, final URI returnUrl) {
    final OAuth1CredentialFlowState.Builder flowState = new OAuth1CredentialFlowState.Builder().returnUrl(returnUrl)
        .providerId(id);

    final OAuth1Operations oauthOperations = connectionFactory.getOAuthOperations();
    final OAuth1Parameters parameters = new OAuth1Parameters();

    final String stateKey = UUID.randomUUID().toString();
    flowState.key(stateKey);

    final OAuthToken oAuthToken;
    final OAuth1Version oAuthVersion = oauthOperations.getVersion();

    if (oAuthVersion == OAuth1Version.CORE_10) {
        parameters.setCallbackUrl(callbackUrlFor(baseUrl, EMPTY));

        oAuthToken = oauthOperations.fetchRequestToken(null, null);
    } else if (oAuthVersion == OAuth1Version.CORE_10_REVISION_A) {
        oAuthToken = oauthOperations.fetchRequestToken(callbackUrlFor(baseUrl, EMPTY), null);
    } else {
        throw new IllegalStateException("Unsupported OAuth 1 version: " + oAuthVersion);
    }
    flowState.token(oAuthToken);

    final String redirectUrl = oauthOperations.buildAuthorizeUrl(oAuthToken.getValue(), parameters);
    flowState.redirectUrl(redirectUrl);

    flowState.connectorId(connectorId);

    return flowState.build();
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:33,代码来源:OAuth1CredentialProvider.java

示例7: prepare

import org.springframework.social.oauth1.OAuth1Parameters; //导入依赖的package包/类
@Override
public CredentialFlowState prepare(final URI baseUrl, final URI returnUrl) {
    final OAuth1CredentialFlowState.Builder flowState = new OAuth1CredentialFlowState.Builder().returnUrl(returnUrl)
        .providerId(id);

    final OAuth1Operations oauthOperations = connectionFactory.getOAuthOperations();
    final OAuth1Parameters parameters = new OAuth1Parameters();

    final String stateKey = UUID.randomUUID().toString();
    flowState.key(stateKey);

    final OAuthToken oAuthToken;
    final OAuth1Version oAuthVersion = oauthOperations.getVersion();

    if (oAuthVersion == OAuth1Version.CORE_10) {
        parameters.setCallbackUrl(callbackUrlFor(baseUrl, EMPTY));

        oAuthToken = oauthOperations.fetchRequestToken(null, null);
    } else if (oAuthVersion == OAuth1Version.CORE_10_REVISION_A) {
        oAuthToken = oauthOperations.fetchRequestToken(callbackUrlFor(baseUrl, EMPTY), null);
    } else {
        throw new IllegalStateException("Unsupported OAuth 1 version: " + oAuthVersion);
    }
    flowState.token(oAuthToken);

    final String redirectUrl = oauthOperations.buildAuthorizeUrl(oAuthToken.getValue(), parameters);
    flowState.redirectUrl(redirectUrl);

    return flowState.build();
}
 
开发者ID:syndesisio,项目名称:syndesis-rest,代码行数:31,代码来源:OAuth1CredentialProvider.java

示例8: getOAuth1Parameters

import org.springframework.social.oauth1.OAuth1Parameters; //导入依赖的package包/类
@Override
protected OAuth1Parameters getOAuth1Parameters(String callbackUrl)
{
    OAuth1Parameters oAuth1Parameters = new OAuth1Parameters();
    oAuth1Parameters.setCallbackUrl(callbackUrl);
    oAuth1Parameters.set("perms", "delete");
    return oAuth1Parameters;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:9,代码来源:FlickrChannelType.java

示例9: getOAuth1Parameters

import org.springframework.social.oauth1.OAuth1Parameters; //导入依赖的package包/类
private OAuth1Parameters getOAuth1Parameters(NativeWebRequest request,
    MultiValueMap<String, String> additionalParameters) {
    OAuth1Parameters parameters = new OAuth1Parameters(additionalParameters);
    parameters.putAll(getRequestParameters(request));
    return parameters;
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:7,代码来源:ConnectSupport.java

示例10: testBuildAuthenticateUrl

import org.springframework.social.oauth1.OAuth1Parameters; //导入依赖的package包/类
@Test
public void testBuildAuthenticateUrl() {
	EvernoteOAuth1Template template = new EvernoteOAuth1Template("key", "secret", EvernoteService.SANDBOX);
	String authenticateUrl = template.buildAuthenticateUrl("abc", new OAuth1Parameters());
	assertThat(authenticateUrl, is(EvernoteService.SANDBOX.getAuthorizationUrl("abc")));
}
 
开发者ID:ttddyy,项目名称:spring-social-evernote,代码行数:7,代码来源:EvernoteOAuth1TemplateTest.java

示例11: testBuildAuthorizeUrl

import org.springframework.social.oauth1.OAuth1Parameters; //导入依赖的package包/类
@Test
public void testBuildAuthorizeUrl() {
	EvernoteOAuth1Template template = new EvernoteOAuth1Template("key", "secret", EvernoteService.SANDBOX);
	String authorizeUrl = template.buildAuthorizeUrl("abc", new OAuth1Parameters());
	assertThat(authorizeUrl, is(EvernoteService.SANDBOX.getAuthorizationUrl("abc")));
}
 
开发者ID:ttddyy,项目名称:spring-social-evernote,代码行数:7,代码来源:EvernoteOAuth1TemplateTest.java

示例12: testAuthUrlByServiceEnvironment

import org.springframework.social.oauth1.OAuth1Parameters; //导入依赖的package包/类
@Test
public void testAuthUrlByServiceEnvironment() {
	EvernoteOAuth1Operations operations = new EvernoteOAuth1Operations("foo", "bar", evernoteService);
	String url = operations.buildAuthenticateUrl("abc", new OAuth1Parameters());
	assertThat(url, is(evernoteService.getAuthorizationUrl("abc")));
}
 
开发者ID:ttddyy,项目名称:spring-social-evernote,代码行数:7,代码来源:EvernoteOAuth1OperationsByServiceTest.java

示例13: getOAuth1Parameters

import org.springframework.social.oauth1.OAuth1Parameters; //导入依赖的package包/类
/**
 * Override this method to add additonal parameters onto the URL that the user is redirected to 
 * to authorise access to their account. By default, no parameters are added, but this may be useful to
 * specify things such as the permissions being sought, and so on.
 * @param callbackUrl String
 * @return Do not return null. If no parameters are to be added, return {@link OAuth1Parameters#NONE}
 */
protected OAuth1Parameters getOAuth1Parameters(String callbackUrl)
{
    return OAuth1Parameters.NONE;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:12,代码来源:AbstractOAuth1ChannelType.java


注:本文中的org.springframework.social.oauth1.OAuth1Parameters类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。