Package org.springframework.social.oauth2

Examples of org.springframework.social.oauth2.OAuth2TemplateTest


    @PermitAll
    @Path("login/{providerId}")
    @POST
    public Response socialLogin(@PathParam("providerId") String providerId, OAuth2Request request) {
        OAuth2ConnectionFactory<?> connectionFactory = (OAuth2ConnectionFactory<?>) connectionFactoryLocator.getConnectionFactory(providerId);
        Connection<?> connection = connectionFactory.createConnection(new AccessGrant(request.getAccessToken()));
        AuthenticatedUserToken token = userService.socialLogin(connection);
        return getLoginResponse(token);
    }
View Full Code Here


    try {
      response2 = mapper.readValue(jsonString, Map.class);
    } catch (Exception e) {
     
    }
        return new AccessGrant(response2.get("access_token"), null, null, null);
    }
View Full Code Here

      verifyStateParameter(request);
    }
   
    String code = request.getParameter("code");
    try {
      AccessGrant accessGrant = connectionFactory.getOAuthOperations().exchangeForAccess(code, callbackUrl(request), null);
      return connectionFactory.createConnection(accessGrant);
    } catch (HttpClientErrorException e) {
      logger.warn("HttpClientErrorException while completing connection: " + e.getMessage());
      logger.warn("      Response body: " + e.getResponseBodyAsString());
      throw e;
View Full Code Here

    }
  }

  public void refresh() {
    synchronized (getMonitor()) {
      AccessGrant accessGrant = serviceProvider.getOAuthOperations().refreshAccess(refreshToken, null);
      initAccessTokens(accessGrant.getAccessToken(), accessGrant.getRefreshToken(), accessGrant.getExpireTime());
      initApi();
    }
  }
View Full Code Here

  public AccessGrant exchangeForAccess(String authorizationCode, String redirectUri, MultiValueMap<String, String> additionalParameters) {
    if (behavior == THROW_EXCEPTION) {
      throw new HttpClientErrorException(BAD_REQUEST);
    }
   
    return new AccessGrant("accessToken");
  }
View Full Code Here

  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");
View Full Code Here

        }
        public AccessGrant exchangeForAccess(String authorizationGrant, String redirectUri, MultiValueMap<String, String> additionalParameters) {
          assertEquals("authorization-grant", authorizationGrant);
          assertEquals("http://somesite.com/connect/someprovider", redirectUri);
          assertNull(additionalParameters);
          return new AccessGrant("access-token");
        }
        public AccessGrant exchangeCredentialsForAccess(String username, String password, MultiValueMap<String, String> additionalParameters) {
          return null;
        }       
        @Deprecated
View Full Code Here

  public String buildAuthenticateUrl(OAuth2Parameters parameters) {
    return buildAuthorizeUrl(parameters);
  }

  public AccessGrant exchangeForAccess(String authorizationGrant, String redirectUri, MultiValueMap<String, String> additionalParameters) {
    return new AccessGrant("12345", null, "23456", 3600L);
  }
View Full Code Here

  public AccessGrant exchangeForAccess(String authorizationGrant, String redirectUri, MultiValueMap<String, String> additionalParameters) {
    return new AccessGrant("12345", null, "23456", 3600L);
  }
 
  public AccessGrant exchangeCredentialsForAccess(String username, String password, MultiValueMap<String, String> additionalParameters) {
    return new AccessGrant("12345", null, "23456", 3600L);
  }
View Full Code Here

  public AccessGrant exchangeCredentialsForAccess(String username, String password, MultiValueMap<String, String> additionalParameters) {
    return new AccessGrant("12345", null, "23456", 3600L);
  }
 
  public AccessGrant refreshAccess(String refreshToken, MultiValueMap<String, String> additionalParameters) {
    return new AccessGrant("12345", null,  "23456", 3600L);
  }
View Full Code Here

TOP

Related Classes of org.springframework.social.oauth2.OAuth2TemplateTest

Copyright © 2018 www.massapicom. 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.