Examples of OAuthCredentials


Examples of com.google.walkaround.wave.server.auth.OAuthCredentials

    log.info("code=" + code + ", state=" + state);
    String[] split = state.split(" ");
    if (split.length != 2) {
      throw new BadRequestException("state格式错误: " + state);
    }
    OAuthCredentials credentials;
    try {
      credentials = oAuthProviderHelp.exchangeCodeForToken(split[0], code);
    } catch (IOException e) {
      log.log(Level.WARNING, "Failed attempt, trying again", e);
      if (e instanceof HttpResponseException) {
View Full Code Here

Examples of com.google.walkaround.wave.server.auth.OAuthCredentials

    JSONObject toRtn = new JSONObject();
    if (record != null) {
      try {
        StableUserId userId = record.getUserId();
        ParticipantId participantId = record.getParticipantId();
        OAuthCredentials oAuthCredentials = record.getOAuthCredentials();
        userContext.setUserId(userId);
        userContext.setParticipantId(participantId);
        userContext.setOAuthCredentials(oAuthCredentials);

        toRtn.put(TokenBasedAccountLookup.USER_ID_KEY, userId.getId());
        toRtn.put("participantId", participantId.getAddress());
        toRtn.put("access_token", xsrfHelper.get().createToken(oAuthCredentials.getAccessToken()));
      } catch (JSONException e) {
        throw new RuntimeException("Bad JSON: " + toRtn, e);
      }
    }
    resp.setStatus(200);
View Full Code Here

Examples of com.google.walkaround.wave.server.auth.OAuthCredentials

    @Inject Provider<HttpRequestBuilder> postRequest;

    public OAuthCredentials exchangeCodeForToken(String providerName, String authorizationCode)
        throws IOException {
      Pair<String, String> pair = exchangeCodeForToken(providerName, authorizationCode, false);
      OAuthCredentials credentials =
          new OAuthCredentials(pair.second == null ? "" : pair.second, pair.first);
      return credentials;
    }
View Full Code Here

Examples of com.google.walkaround.wave.server.auth.OAuthCredentials

  }

  @Override
  public void refreshToken() throws IOException {

    OAuthCredentials oldCredentials = getCredentials();

    String refreshToken = oldCredentials.getRefreshToken();
    if (refreshToken == null || refreshToken.isEmpty()) {
      return;
    }
    String newAccessToken =
        oAuthProvider.refreshToken(userContext.getOAuthProvider().getProviderName(), refreshToken);

    log.info("New access token: " + newAccessToken);
    userContext.setOAuthCredentials(new OAuthCredentials(refreshToken, newAccessToken));
    log.info("Successfully refreshed token: " + userContext);
  }
View Full Code Here

Examples of org.jclouds.oauth.v2.domain.OAuthCredentials

   }


   public void testLoadPKString() throws IOException, NoSuchAlgorithmException, KeyStoreException,
           CertificateException, UnrecoverableKeyException, InvalidKeySpecException {
      OAuthCredentials creds = loadOAuthCredentials();
      assertNotNull(creds);
      assertEquals(creds.identity, "foo");
      assertNotNull(creds.privateKey);
   }
View Full Code Here

Examples of org.jclouds.oauth.v2.domain.OAuthCredentials

   }


   public void testLoadPKString() throws IOException, NoSuchAlgorithmException, KeyStoreException,
           CertificateException, UnrecoverableKeyException, InvalidKeySpecException {
      OAuthCredentials creds = loadOAuthCredentials();
      assertNotNull(creds);
      assertEquals(creds.identity, "foo");
      assertNotNull(creds.privateKey);
   }
View Full Code Here

Examples of org.pac4j.oauth.credentials.OAuthCredentials

      assertEquals("No credential found", e.getMessage());
    }
  }

  public void testOk() throws RequiresHttpAction {
    final OAuthCredentials oauthCredential = (OAuthCredentials) getClient().getCredentials(
        MockWebContext.create().addRequestParameter(BaseOAuth20Client.OAUTH_CODE, CODE));
    assertNotNull(oauthCredential);
    assertEquals(CODE, oauthCredential.getVerifier());
  }
View Full Code Here

Examples of org.pac4j.oauth.credentials.OAuthCredentials

            assertEquals("No credential found", e.getMessage());
        }
    }
   
    public void testOk() throws RequiresHttpAction {
        final OAuthCredentials credentials = (OAuthCredentials) getClient()
            .getCredentials(MockWebContext
                                .create()
                                .addRequestParameter(BaseOAuth10Client.OAUTH_VERIFIER, VERIFIER)
                                .addRequestParameter(BaseOAuth10Client.OAUTH_TOKEN, TOKEN)
                                .addSessionAttribute(getClient().getName() + "#" + BaseOAuth10Client.REQUEST_TOKEN,
                                                     new Token(TOKEN, SECRET)));
        assertNotNull(credentials);
        assertEquals(TOKEN, credentials.getToken());
        assertEquals(VERIFIER, credentials.getVerifier());
        final Token tokenRequest = credentials.getRequestToken();
        assertEquals(TOKEN, tokenRequest.getToken());
        assertEquals(SECRET, tokenRequest.getSecret());
    }
View Full Code Here

Examples of org.pac4j.oauth.credentials.OAuthCredentials

            assertEquals("No credential found", e.getMessage());
        }
    }
   
    public void testOk() throws RequiresHttpAction {
        final OAuthCredentials oauthCredential = (OAuthCredentials) getClient()
            .getCredentials(MockWebContext.create().addRequestParameter(BaseOAuth20Client.OAUTH_CODE, CODE));
        assertNotNull(oauthCredential);
        assertEquals(CODE, oauthCredential.getVerifier());
    }
View Full Code Here

Examples of org.pac4j.oauth.credentials.OAuthCredentials

        final String verifierParameter = context.getRequestParameter(OAUTH_CODE);
        if (verifierParameter != null) {
            final String verifier = OAuthEncoder.decode(verifierParameter);
            logger.debug("verifier : {}", verifier);
            return new OAuthCredentials(verifier, getName());
        } else {
            final String message = "No credential found";
            logger.error(message);
            throw new OAuthCredentialsException(message);
        }
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.