Examples of AccessToken


Examples of co.cask.cdap.security.auth.AccessToken

    long issueTime = System.currentTimeMillis();
    long expireTime = issueTime + tokenValidity;
    // Create and sign a new AccessTokenIdentifier to generate the AccessToken.
    AccessTokenIdentifier tokenIdentifier = new AccessTokenIdentifier(username, userGroups, issueTime, expireTime);
    AccessToken token = tokenManager.signIdentifier(tokenIdentifier);
    LOG.debug("Issued token for user {}", username);

    // Set response headers
    response.setContentType("application/json;charset=UTF-8");
    response.addHeader("Cache-Control", "no-store");
View Full Code Here

Examples of co.cask.cdap.security.authentication.client.AccessToken

  public void getEvents(String streamId, long startTime, long endTime, int limit,
                        Function<? super StreamEvent, Boolean> callback) throws IOException, StreamNotFoundException {
    URL url = config.resolveURL(String.format("streams/%s/events?start=%d&end=%d&limit=%d",
                                              streamId, startTime, endTime, limit));
    HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
    AccessToken accessToken = config.getAccessToken();
    if (accessToken != null) {
      urlConn.setRequestProperty(HttpHeaders.AUTHORIZATION, accessToken.getTokenType() + " " + accessToken.getValue());
    }

    if (urlConn instanceof HttpsURLConnection && !config.getDefaultConfig().isVerifySSLCert()) {
      try {
        HttpRequests.disableCertCheck((HttpsURLConnection) urlConn);
View Full Code Here

Examples of com.dongxuexidu.douban4j.model.app.AccessToken

      System.out.println(oauth.getGetCodeRedirectUrl());
      System.out.print("Put the code you got here.[Enter]:");
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String code = br.readLine();
      System.out.println("code : " + code);
      AccessToken at = oauth.tradeAccessTokenWithCode(code);
      System.out.println("at : " + at.getAccessToken());
      System.out.println("uid : " + at.getDoubanUserId());
      return at.getAccessToken();
    } catch (DoubanException ex) {
      Logger.getLogger(PlayGround.class.getName()).log(Level.SEVERE, null, ex);
      return null;
    } catch (IOException ex) {
      Logger.getLogger(PlayGround.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

Examples of com.dongxuexidu.douban4j.model.app.AccessToken

      throw ErrorHandler.cannotGetAccessToken();
    }
    System.out.println("got result !");
    System.out.println(responseStr);
    JSONObject jObj = Converters.toJsonObj(responseStr);
    AccessToken token = new AccessToken();
    if (jObj.containsKey("access_token")) {
      String accessToken = jObj.getString("access_token");
      token.setAccessToken(accessToken);
    } else {
      throw ErrorHandler.cannotGetAccessToken();
    }
    if (jObj.containsKey("expires_in")) {
      int expiresIn = jObj.getInt("expires_in");
      token.setExpiresIn(expiresIn);
    } else {
      throw ErrorHandler.cannotGetAccessToken();
    }
    if (jObj.containsKey("refresh_token")) {
      String refreshToken = jObj.getString("refresh_token");
      token.setRefreshToken(refreshToken);
    }
    if (jObj.containsKey("douban_user_id")) {
      String doubanUserId = jObj.getString("douban_user_id");
      token.setDoubanUserId(doubanUserId);
    }
    return token;
  }
View Full Code Here

Examples of com.fitbit.api.client.http.AccessToken

        if (tempToken == null || tempTokenSecret == null) {
            throw new FitbitAPIException("Resource credentials for resource " + user.getUserId() + " are in an invalid state: temporary token or secret is null.");
        }

        // Get and save token credentials:
        AccessToken accessToken = client.getOAuthAccessToken(tempToken, tempTokenSecret, resourceCredentials.getTempTokenVerifier());
        resourceCredentials.setAccessToken(accessToken.getToken());
        resourceCredentials.setAccessTokenSecret(accessToken.getTokenSecret());
        resourceCredentials.setResourceId(accessToken.getEncodedUserId());
    }
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.consumer.AccessToken

    }
   
    @Override
  public AccessToken loadAccessToken(String appId, String serviceName, String consumerKey, String moduleId, String tokenName, String userId) throws OAuthException {
      String key = getUserKey( appId, serviceName, consumerKey, moduleId, tokenName, userId );
        AccessToken tk = userTokens.get(key);
        if(tk==null) {
          tk = createDefaultAccessToken(appId, serviceName, consumerKey, moduleId, tokenName, userId);
        }
        return tk;
    }
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.consumer.AccessToken

    @Override
    protected AccessToken createDefaultAccessToken(String appId, String serviceName, String consumerKey, String moduleId, String tokenName, String userId) throws OAuthException {
      Date expiresIn = new Date(System.currentTimeMillis()+10*24*60*60*1000); // 10 days...
      Date authorizationExpiresIn = new Date(System.currentTimeMillis()+10*24*60*60*1000); // 10 days...
      String sessionHandle = ""; // None...
      return new AccessToken(appId, serviceName, consumerKey, getAccessKey(), getAccessSecret(), userId, expiresIn, authorizationExpiresIn, sessionHandle);
    }
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.consumer.AccessToken

      String oauth_verifier = (String) context.getRequestParameterMap().get(OAConstants.OAUTH_VERIFIER);
     
      oAuthHandler.setAccessToken(oauth_token);
      oAuthHandler.setVerifierCode(oauth_verifier);
     
      AccessToken tk = oAuthHandler.readToken(oauth_token, oauth_verifier);
      if (tk == null) {
        // should not happen
        throw new ServletException("Missing OAuth token");
      }
      // Store the new key
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.consumer.AccessToken

   
    String authcode = extractAuthorizationToken(request);
    oAuthHandler.setAuthorization_code(authcode);
    try {
      oAuthHandler.getAccessTokenForAuthorizedUser(); // This retrieves and sets all authentication information in OAuth2Handler
      AccessToken token = oAuthHandler.createToken(oAuthHandler.getAppId(),oAuthHandler.getServiceName());
            // Store the new key
      oAuthHandler.setAccessTokenObject(token);
          if(!context.isCurrentUserAnonymous()) {
            CredentialStore credStore = CredentialStoreFactory.getCredentialStore(oAuthHandler.getCredentialStore());
            if(credStore!=null) {
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.consumer.AccessToken

  }

  @Override
  public void initialize(DefaultHttpClient httpClient) throws ClientServicesException {
    try {
      AccessToken token = oAuthHandler.acquireToken(false);
      if ((token != null) && (oAuthHandler != null)) {
        HttpRequestInterceptor oauthInterceptor = new OAuthInterceptor(token, super.getUrl(),oAuthHandler);
        httpClient.addRequestInterceptor(oauthInterceptor, 0);
      }
    } catch (OAuthException ex) {
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.