当前位置: 首页>>代码示例>>Java>>正文


Java ExtendedJSONObject.put方法代码示例

本文整理汇总了Java中org.mozilla.gecko.sync.ExtendedJSONObject.put方法的典型用法代码示例。如果您正苦于以下问题:Java ExtendedJSONObject.put方法的具体用法?Java ExtendedJSONObject.put怎么用?Java ExtendedJSONObject.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mozilla.gecko.sync.ExtendedJSONObject的用法示例。


在下文中一共展示了ExtendedJSONObject.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseCertificate

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
/**
 * For debugging only!
 *
 * @param input
 *          certificate to dump.
 * @return non-null object with keys header, payload, signature if the
 *         certificate is well-formed.
 */
public static ExtendedJSONObject parseCertificate(String input) {
  try {
    String[] parts = input.split("\\.");
    if (parts.length != 3) {
      return null;
    }
    String cHeader = new String(Base64.decodeBase64(parts[0]),
            org.mozilla.gecko.util.StringUtils.UTF_8);
    String cPayload = new String(Base64.decodeBase64(parts[1]),
            org.mozilla.gecko.util.StringUtils.UTF_8);
    String cSignature = Utils.byte2Hex(Base64.decodeBase64(parts[2]));
    ExtendedJSONObject o = new ExtendedJSONObject();
    o.put("header", new ExtendedJSONObject(cHeader));
    o.put("payload", new ExtendedJSONObject(cPayload));
    o.put("signature", cSignature);
    return o;
  } catch (Exception e) {
    return null;
  }
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:29,代码来源:JSONWebTokenUtils.java

示例2: ClientReadingListRecord

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
public ClientReadingListRecord(String url, String title, String addedBy, long lastModified, boolean isDeleted, boolean isArchived) {
  super(null);

  // Required.
  if (url == null) {
    throw new IllegalArgumentException("url must be provided.");
  }

  final ExtendedJSONObject f = new ExtendedJSONObject();
  f.put("url", url);
  f.put("title", title == null ? "" : title);
  f.put("added_by", addedBy == null ? getDefaultAddedBy() : addedBy);

  this.fields = f;
  this.clientMetadata = new ClientMetadata(-1L, lastModified, isDeleted, isArchived);
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:17,代码来源:ClientReadingListRecord.java

示例3: parseCertificate

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
/**
 * For debugging only!
 *
 * @param input
 *          certificate to dump.
 * @return non-null object with keys header, payload, signature if the
 *         certificate is well-formed.
 */
public static ExtendedJSONObject parseCertificate(String input) {
  try {
    String[] parts = input.split("\\.");
    if (parts.length != 3) {
      return null;
    }
    String cHeader = new String(Base64.decodeBase64(parts[0]));
    String cPayload = new String(Base64.decodeBase64(parts[1]));
    String cSignature = Utils.byte2Hex(Base64.decodeBase64(parts[2]));
    ExtendedJSONObject o = new ExtendedJSONObject();
    o.put("header", new ExtendedJSONObject(cHeader));
    o.put("payload", new ExtendedJSONObject(cPayload));
    o.put("signature", cSignature);
    return o;
  } catch (Exception e) {
    return null;
  }
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:27,代码来源:JSONWebTokenUtils.java

示例4: doTestEncodeDecode

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
public void doTestEncodeDecode(BrowserIDKeyPair keyPair) throws Exception {
  SigningPrivateKey privateKey = keyPair.getPrivate();
  VerifyingPublicKey publicKey = keyPair.getPublic();

  ExtendedJSONObject o = new ExtendedJSONObject();
  o.put("key", Utils.generateGuid());

  String token = JSONWebTokenUtils.encode(o.toJSONString(), privateKey);
  assertNotNull(token);

  String payload = JSONWebTokenUtils.decode(token, publicKey);
  assertEquals(o.toJSONString(), payload);

  try {
    JSONWebTokenUtils.decode(token + "x", publicKey);
    fail("Expected exception.");
  } catch (GeneralSecurityException e) {
    // Do nothing.
  }
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:21,代码来源:TestBrowserIDKeyPairGeneration.java

示例5: verify

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
@Override
public void verify(String audience, String assertion, final BrowserIDVerifierDelegate delegate) {
  if (audience == null) {
    throw new IllegalArgumentException("audience cannot be null.");
  }
  if (assertion == null) {
    throw new IllegalArgumentException("assertion cannot be null.");
  }
  if (delegate == null) {
    throw new IllegalArgumentException("delegate cannot be null.");
  }

  BaseResource r = new BaseResource(verifierUri);
  r.delegate = new RemoteVerifierResourceDelegate(r, delegate);

  final ExtendedJSONObject requestBody = new ExtendedJSONObject();
  requestBody.put(JSON_KEY_AUDIENCE, audience);
  requestBody.put(JSON_KEY_ASSERTION, assertion);

  try {
    r.post(requestBody);
  } catch (Exception e) {
    delegate.handleError(e);
  }
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:26,代码来源:BrowserIDRemoteVerifierClient20.java

示例6: fillGingerbread

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private final void fillGingerbread(ExtendedJSONObject o, Cursor c, String f, int i) {
  if (!(c instanceof AbstractWindowedCursor)) {
    throw new IllegalStateException("Unable to handle cursors that don't have a CursorWindow!");
  }

  final AbstractWindowedCursor sqc = (AbstractWindowedCursor) c;
  final CursorWindow w = sqc.getWindow();
  final int pos = c.getPosition();
  if (w.isNull(pos, i)) {
    putNull(o, f);
  } else if (w.isString(pos, i)) {
    put(o, f, c.getString(i));
  } else if (w.isLong(pos, i)) {
    put(o, f, c.getLong(i));
  } else if (w.isFloat(pos, i)) {
    o.put(f, c.getDouble(i));
  } else if (w.isBlob(pos, i)) {
    // TODO: this probably doesn't serialize correctly.
    o.put(f, c.getBlob(i));
  }
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:23,代码来源:ReadingListClientRecordFactory.java

示例7: deleteToken

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
public void deleteToken(final String token, final RequestDelegate<Void> delegate) {
  final BaseResource resource;
  try {
    resource = new BaseResource(new URI(serverURI + "destroy"));
  } catch (URISyntaxException e) {
    invokeHandleError(delegate, e);
    return;
  }

  resource.delegate = new ResourceDelegate<Void>(resource, delegate) {
    @Override
    public void handleSuccess(int status, HttpResponse response, ExtendedJSONObject body) {
      try {
        delegate.handleSuccess(null);
        return;
      } catch (Exception e) {
        delegate.handleError(e);
        return;
      }
    }
  };

  final ExtendedJSONObject requestBody = new ExtendedJSONObject();
  requestBody.put(JSON_KEY_TOKEN, token);
  post(resource, requestBody, delegate);
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:27,代码来源:FxAccountOAuthClient10.java

示例8: decrementObsoleteId

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
protected void decrementObsoleteId(ExtendedJSONObject ids, String id) {
  if (!ids.containsKey(id)) {
    return;
  }
  try {
    Long attempts = ids.getLong(id);
    if (attempts == null || --attempts < 1) {
      ids.remove(id);
    } else {
      ids.put(id, attempts);
    }
  } catch (ClassCastException e) {
    ids.remove(id);
    Logger.info(LOG_TAG, "Got exception decrementing obsolete ids counter.", e);
  }
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:17,代码来源:ObsoleteDocumentTracker.java

示例9: limitObsoleteIds

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
/**
 * We want cleaning up documents on the server to be best effort. Purge badly
 * formed IDs and cap the number of times we try to delete so that the queue
 * doesn't take too long.
 */
public void limitObsoleteIds() {
  ExtendedJSONObject ids = getObsoleteIds();

  Set<String> keys = new HashSet<String>(ids.keySet()); // Avoid invalidating an iterator.
  for (String key : keys) {
    Object o = ids.get(key);
    if (!(o instanceof Long)) {
      continue;
    }
    if ((Long) o > HealthReportConstants.DELETION_ATTEMPTS_PER_OBSOLETE_DOCUMENT_ID) {
      ids.put(key, HealthReportConstants.DELETION_ATTEMPTS_PER_OBSOLETE_DOCUMENT_ID);
    }
  }
  setObsoleteIds(ids);
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:21,代码来源:ObsoleteDocumentTracker.java

示例10: toJSONObject

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
/**
 * Serialize to a JSON object.
 * <p>
 * Parameters are serialized as hex strings. Hex-versus-decimal was
 * reverse-engineered from what the Persona public verifier accepted.
 */
@Override
public ExtendedJSONObject toJSONObject() {
  DSAParams params = publicKey.getParams();
  ExtendedJSONObject o = new ExtendedJSONObject();
  o.put("algorithm", "DS");
  o.put("y", publicKey.getY().toString(SERIALIZATION_BASE));
  o.put("g", params.getG().toString(SERIALIZATION_BASE));
  o.put("p", params.getP().toString(SERIALIZATION_BASE));
  o.put("q", params.getQ().toString(SERIALIZATION_BASE));
  return o;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:18,代码来源:DSACryptoImplementation.java

示例11: encode

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
public static String encode(String payload, SigningPrivateKey privateKey) throws UnsupportedEncodingException, GeneralSecurityException  {
  final ExtendedJSONObject header = new ExtendedJSONObject();
  header.put("alg", privateKey.getAlgorithm());
  String encodedHeader  = Base64.encodeBase64URLSafeString(header.toJSONString().getBytes("UTF-8"));
  String encodedPayload = Base64.encodeBase64URLSafeString(payload.getBytes("UTF-8"));
  ArrayList<String> segments = new ArrayList<String>();
  segments.add(encodedHeader);
  segments.add(encodedPayload);
  byte[] message = Utils.toDelimitedString(".", segments).getBytes("UTF-8");
  byte[] signature = privateKey.signMessage(message);
  segments.add(Base64.encodeBase64URLSafeString(signature));
  return Utils.toDelimitedString(".", segments);
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:14,代码来源:JSONWebTokenUtils.java

示例12: getCertificatePayloadString

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
protected static String getCertificatePayloadString(VerifyingPublicKey publicKeyToSign, String email) throws NonObjectJSONException, IOException  {
  ExtendedJSONObject payload = new ExtendedJSONObject();
  ExtendedJSONObject principal = new ExtendedJSONObject();
  principal.put("email", email);
  payload.put("principal", principal);
  payload.put("public-key", publicKeyToSign.toJSONObject());
  return payload.toJSONString();
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:9,代码来源:JSONWebTokenUtils.java

示例13: parseAssertion

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
/**
 * For debugging only!
 *
 * @param input assertion to dump.
 * @return true if the assertion is well-formed.
 */
public static ExtendedJSONObject parseAssertion(String input) {
  try {
    String[] parts = input.split("~");
    if (parts.length != 2) {
      return null;
    }
    String certificate = parts[0];
    String assertion = parts[1];
    parts = assertion.split("\\.");
    if (parts.length != 3) {
      return null;
    }
    String aHeader = new String(Base64.decodeBase64(parts[0]),
            org.mozilla.gecko.util.StringUtils.UTF_8);
    String aPayload = new String(Base64.decodeBase64(parts[1]),
            org.mozilla.gecko.util.StringUtils.UTF_8);
    String aSignature = Utils.byte2Hex(Base64.decodeBase64(parts[2]));
    // We do all the assertion parsing *before* dumping the certificate in
    // case there's a malformed assertion.
    ExtendedJSONObject o = new ExtendedJSONObject();
    o.put("header", new ExtendedJSONObject(aHeader));
    o.put("payload", new ExtendedJSONObject(aPayload));
    o.put("signature", aSignature);
    o.put("certificate", certificate);
    return o;
  } catch (Exception e) {
    return null;
  }
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:36,代码来源:JSONWebTokenUtils.java

示例14: toJSONObject

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
/**
 * Serialize to a JSON object.
 * <p>
 * Parameters are serialized as decimal strings. Hex-versus-decimal was
 * reverse-engineered from what the Persona public verifier accepted.
 */
@Override
public ExtendedJSONObject toJSONObject() {
  ExtendedJSONObject o = new ExtendedJSONObject();
  o.put("algorithm", "RS");
  o.put("n", publicKey.getModulus().toString(SERIALIZATION_BASE));
  o.put("e", publicKey.getPublicExponent().toString(SERIALIZATION_BASE));
  return o;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:15,代码来源:RSACryptoImplementation.java

示例15: toJSONObject

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
@Override
public ExtendedJSONObject toJSONObject() {
  ExtendedJSONObject o = super.toJSONObject();
  // Fields are non-null by constructor.
  o.put("sessionToken", Utils.byte2Hex(sessionToken));
  o.put("kA", Utils.byte2Hex(kA));
  o.put("kB", Utils.byte2Hex(kB));
  o.put("keyPair", keyPair.toJSONObject());
  return o;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:11,代码来源:TokensAndKeysState.java


注:本文中的org.mozilla.gecko.sync.ExtendedJSONObject.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。