Java Code Examples for com.google.ipc.invalidation.external.client.SystemResources.Logger#severe()

The following examples show how to use com.google.ipc.invalidation.external.client.SystemResources.Logger#severe() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PersistenceUtils.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Deserializes a Ticl state blob. Returns either the parsed state or {@code null}
 * if it could not be parsed.
 */
public static PersistentTiclState deserializeState(Logger logger, byte[] stateBlobBytes,
    DigestFunction digestFn) {
  PersistentStateBlob stateBlob;
  try {
    // Try parsing the envelope protocol buffer.
    stateBlob = PersistentStateBlob.parseFrom(stateBlobBytes);
  } catch (ValidationException exception) {
    logger.severe("Failed deserializing Ticl state: %s", exception.getMessage());
    return null;
  }

  // Check the mac in the envelope against the recomputed mac from the state.
  PersistentTiclState ticlState = stateBlob.getTiclState();
  Bytes mac = generateMac(ticlState, digestFn);
  if (!TypedUtil.<Bytes>equals(mac, stateBlob.getAuthenticationCode())) {
    logger.warning("Ticl state failed MAC check: computed %s vs %s", mac,
        stateBlob.getAuthenticationCode());
    return null;
  }
  return ticlState;
}
 
Example 2
Source File: PersistenceUtils.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Deserializes a Ticl state blob. Returns either the parsed state or {@code null}
 * if it could not be parsed.
 */
public static PersistentTiclState deserializeState(Logger logger, byte[] stateBlobBytes,
    DigestFunction digestFn) {
  PersistentStateBlob stateBlob;
  try {
    // Try parsing the envelope protocol buffer.
    stateBlob = PersistentStateBlob.parseFrom(stateBlobBytes);
  } catch (InvalidProtocolBufferException exception) {
    logger.severe("Failed deserializing Ticl state: %s", exception.getMessage());
    return null;
  }

  // Check the mac in the envelope against the recomputed mac from the state.
  PersistentTiclState ticlState = stateBlob.getTiclState();
  ByteString mac = generateMac(ticlState, digestFn);
  if (!TypedUtil.<ByteString>equals(mac, stateBlob.getAuthenticationCode())) {
    logger.warning("Ticl state failed MAC check: computed %s vs %s", mac,
        stateBlob.getAuthenticationCode());
    return null;
  }
  return ticlState;
}
 
Example 3
Source File: PersistenceUtils.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Deserializes a Ticl state blob. Returns either the parsed state or {@code null}
 * if it could not be parsed.
 */
public static PersistentTiclState deserializeState(Logger logger, byte[] stateBlobBytes,
    DigestFunction digestFn) {
  PersistentStateBlob stateBlob;
  try {
    // Try parsing the envelope protocol buffer.
    stateBlob = PersistentStateBlob.parseFrom(stateBlobBytes);
  } catch (InvalidProtocolBufferException exception) {
    logger.severe("Failed deserializing Ticl state: %s", exception.getMessage());
    return null;
  }

  // Check the mac in the envelope against the recomputed mac from the state.
  PersistentTiclState ticlState = stateBlob.getTiclState();
  ByteString mac = generateMac(ticlState, digestFn);
  if (!TypedUtil.<ByteString>equals(mac, stateBlob.getAuthenticationCode())) {
    logger.warning("Ticl state failed MAC check: computed %s vs %s", mac,
        stateBlob.getAuthenticationCode());
    return null;
  }
  return ticlState;
}