Package com.google.walkaround.wave.server.auth

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


              new HTTPRequest(targetUrl, HTTPMethod.GET, FetchOptions.Builder.withDefaults()
                  .disallowTruncate()));
      String body = OAuthedFetchService.getUtf8ResponseBody(resp, EXPECTED_CONTENT_TYPE);
      JSONObject jsonObject;
      jsonObject = new JSONObject(body);
      return new AccountStore.Record(new StableUserId(getProviderName().charAt(0)
          + jsonObject.getString("id")), ParticipantId.ofUnsafe(jsonObject.getString("email")),
          null);
    } catch (JSONException e) {
      throw new RuntimeException("Bad Json Format: ", e);
    }
View Full Code Here


    String clientSecret = requireParameter(req, "client_secret");
    AccountStore.Record record = verify(clientId, clientSecret, code);
    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);
      }
View Full Code Here

      throws IOException {
    if (!oAuthProviders.get("google").getClientId().equals(clientId)
        || !oAuthProviders.get("google").getClientSecret().equals(clientSecret)) {
      return null;
    }
    StableUserId userId = authorizedCodes.get(code);
    if (userId == null) {
      return null;
    }
    try {
      return accountStore.get(userId);
View Full Code Here

    if (userId == null || secretToken == null) {
      return false;
    }
    Record record;
    try {
      record = accountStore.get().get(new StableUserId(userId));
      if (record == null || record.getOAuthCredentials() == null
          || record.getOAuthCredentials().getAccessToken() == null) {
        return false;
      }
    } catch (PermanentFailure e) {
      throw new IOException("PermanentFailure getting account information", e);
    }
    userCtx.get().setUserId(new StableUserId(userId));
    try {
      xsrfHelper.get().verify(record.getOAuthCredentials().getAccessToken(), secretToken);
    } catch (XsrfTokenExpiredException e) {
      return false;
    } catch (InvalidSecurityTokenException e) {
View Full Code Here

    // fetch id
    HttpRequestBuilder req = request.get();
    String resp =
        req.authorizeThroughUrlParam().send("https://graph.z.qq.com/moc2/me", HTTPMethod.GET);
    String id = parameterMap(resp).get("openid");
    StableUserId userId = new StableUserId(getProviderName().charAt(0) + id);
    userCtx.get().setUserId(userId);

    // fetch email
    String email = null;
    req = request.get();
View Full Code Here

  public void indexSupplement(SlobId udwId)
      throws PermanentFailure, RetryableFailure, WaveletLockedException {
    log.info("Indexing conversation for participant with udwId " + udwId);
    StateAndVersion raw;
    SlobId convId;
    StableUserId udwOwner;
    CheckedTransaction tx = datastore.beginTransaction();
    try {
      MutationLog l = udwStore.create(tx, udwId);
      ObsoleteWaveletMetadataGsonImpl metadata;
      String metadataString = l.getMetadata();
      try {
        metadata = GsonProto.fromGson(new ObsoleteWaveletMetadataGsonImpl(), metadataString);
      } catch (MessageException e) {
        throw new RuntimeException("Failed to parse obsolete metadata: " + metadataString);
      }
      Assert.check(metadata.hasUdwMetadata(), "Metadata not udw: %s, %s", udwId, metadataString);
      convId = new SlobId(metadata.getUdwMetadata().getAssociatedConvId());
      udwOwner = new StableUserId(metadata.getUdwMetadata().getOwner());
      raw = l.reconstruct(null);
    } finally {
      tx.rollback();
    }
    WaveletName waveletName = IdHack.udwWaveletNameFromConvObjectIdAndUdwObjectId(convId, udwId);
View Full Code Here

    return e;
  }

  ImportTask parseTaskEntity(Entity entity) {
    long taskId = entity.getKey().getId();
    StableUserId userId = new StableUserId(entity.getParent().getName());
    try {
      return new ImportTask(userId, taskId,
          DatastoreUtil.getExistingProperty(entity, TASK_CREATION_TIME_MILLIS_PROPERTY, Long.class),
          GsonProto.fromGson(new ImportTaskPayloadGsonImpl(),
              DatastoreUtil.getExistingProperty(entity, TASK_PAYLOAD_PROPERTY, Text.class)
View Full Code Here

  public void doPost(final HttpServletRequest req, final HttpServletResponse resp)
      throws IOException, ServletException {
    log.info("Received task: queue " + req.getHeader("X-AppEngine-QueueName")
        + ", task name " + req.getHeader("X-AppEngine-TaskName")
        + ", retry count " + req.getHeader("X-AppEngine-TaskRetryCount"));
    final StableUserId userId = new StableUserId(requireParameter(req, USER_ID_HEADER));
    final long taskId;
    try {
      taskId = Long.parseLong(requireParameter(req, TASK_ID_HEADER));
    } catch (NumberFormatException e) {
      throw new BadRequestException("Bad task id");
View Full Code Here

      int space = key.indexOf(' ');
      if (space == -1 || space != key.lastIndexOf(' ')) {
        throw new InvalidPropertyException(e, "key");
      }
      SlobId convObjectId = parseObjectId(e, "key", key.substring(0, space));
      StableUserId userId = new StableUserId(key.substring(space + 1));
      SlobId udwId = parseObjectId(e, UDW_ID_PROPERTY,
          DatastoreUtil.getExistingProperty(e, UDW_ID_PROPERTY, String.class));
      return new ConvUdwMapping(new Key(convObjectId, userId), udwId);
    }
View Full Code Here

TOP

Related Classes of com.google.walkaround.wave.server.auth.StableUserId

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.