Examples of OAuth2Operations


Examples of org.springframework.social.oauth2.OAuth2Operations

    }
    return oauthOperations.fetchRequestToken(null, requestParameters);       
  }

  private String buildOAuth2Url(OAuth2ConnectionFactory<?> connectionFactory, NativeWebRequest request, MultiValueMap<String, String> additionalParameters) {
    OAuth2Operations oauthOperations = connectionFactory.getOAuthOperations();
    String defaultScope = connectionFactory.getScope();
    OAuth2Parameters parameters = getOAuth2Parameters(request, defaultScope, additionalParameters);
    String state = connectionFactory.generateState();
    parameters.add("state", state);
    sessionStrategy.setAttribute(request, OAUTH2_STATE_ATTRIBUTE, state);
    if (useAuthenticateUrl) {
      return oauthOperations.buildAuthenticateUrl(parameters);
    } else {
      return oauthOperations.buildAuthorizeUrl(parameters);
    }
  }
View Full Code Here

Examples of org.springframework.social.oauth2.OAuth2Operations

  @Test
  public void test() throws Exception {
    @SuppressWarnings("unchecked")
    final OAuth2ConnectionFactory<Object> factory = mock(OAuth2ConnectionFactory.class);
    final OAuth2Operations operations = mock(OAuth2Operations.class);
    final String serverName = "example.com";
    final AccessGrant accessGrant = new AccessGrant("my_token");
    final String code = "code";
    final Connection<Object> connection = DummyConnection.dummy("provider", "user");

    final OAuth2AuthenticationService<Object> authSvc = new OAuth2AuthenticationService<Object>(factory);
    authSvc.getReturnToUrlParameters().add("param");
    authSvc.afterPropertiesSet();

    final MockServletContext context = new MockServletContext();
    final MockHttpSession session = new MockHttpSession(context);

    // mock definitions
    when(factory.getProviderId()).thenReturn(connection.getKey().getProviderId());
    when(factory.getOAuthOperations()).thenReturn(operations);
    when(factory.createConnection(accessGrant)).thenReturn(connection);

    when(
        operations.buildAuthenticateUrl(oAuth2Parameters("http://example.com/auth/foo?param=param_value"))).thenReturn(
        "http://facebook.com/auth");
    when(operations.exchangeForAccess(code, "http://example.com/auth/foo", null)).thenReturn(accessGrant);

    // first phase
    MockHttpServletRequest request = new MockHttpServletRequest(context, "GET", "/auth/foo");
    request.setServerName(serverName);
    request.setSession(session);
View Full Code Here

Examples of org.springframework.social.oauth2.OAuth2Operations

  }
 
  private static class TestOAuth2ServiceProvider implements OAuth2ServiceProvider<TestApi> {

    public OAuth2Operations getOAuthOperations() {
      return new OAuth2Operations() {
        public String buildAuthorizeUrl(GrantType grantType, OAuth2Parameters params) {
          return "https://serviceprovider.com/oauth/authorize" + additionalParametersQuery(params, false);
        }
        public String buildAuthenticateUrl(GrantType grantType, OAuth2Parameters params) {
          return "https://serviceprovider.com/oauth/authenticate" + additionalParametersQuery(params, false);
View Full Code Here

Examples of org.springframework.social.oauth2.OAuth2Operations

  }

  private static class TestFacebookServiceProvider implements OAuth2ServiceProvider<TestFacebookApi> {

    public OAuth2Operations getOAuthOperations() {
      return new OAuth2Operations() {
        public String buildAuthorizeUrl(GrantType grantType, OAuth2Parameters params) {
          return null;
        }
        public String buildAuthenticateUrl(GrantType grantType, OAuth2Parameters params) {
          return null;
View Full Code Here

Examples of org.springframework.social.oauth2.OAuth2Operations

  }

  private static class TestFacebookServiceProvider implements OAuth2ServiceProvider<TestFacebookApi> {

    public OAuth2Operations getOAuthOperations() {
      return new OAuth2Operations() {
        public String buildAuthorizeUrl(GrantType grantType, OAuth2Parameters params) {
          return null;
        }
        public String buildAuthenticateUrl(GrantType grantType, OAuth2Parameters params) {
          return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.