Package com.google.k2crypto.keyversions

Examples of com.google.k2crypto.keyversions.KeyVersion$Builder


  @Test
  public void testCreateAddKeyVersionToKey() throws BuilderException {
    // create a key modifier
    KeyModifier keymod = new KeyModifier();
    // create a new KeyVersion and add it to the Key
    KeyVersion keyversion = keymod.addKeyVersion();
    // get the primary key version from the Key using the KeyModifier
    KeyVersion primary = keymod.getPrimary();
    // check that the primary key version is equal to the key version we created and added to the
    // Key
    assertEquals(keyversion, primary);
  }
View Full Code Here


  public void testAddOneKeyVersionToKey() throws BuilderException, KeyModifierException {
    // create a key modifier
    KeyModifier keymod = new KeyModifier();

    // create and add a KeyVersion and add it to the Key
    KeyVersion keyversion1 = keymod.addKeyVersion();

    // create and add another KeyVersion and add it to the Key
    KeyVersion keyversion2 = keymod.addKeyVersion();
   
    // Set the second key version as primary
    keymod.setPrimary(keyversion2);
   
    // remove the first keyversion from the key
View Full Code Here

  public void testRemoveKeyVersionToKey() throws BuilderException, KeyModifierException {
    // create a key modifier
    KeyModifier keymod = new KeyModifier();

    // create and add a KeyVersion and add it to the Key
    KeyVersion keyversion1 = keymod.addKeyVersion();

    // create and add another KeyVersion and add it to the Key
    KeyVersion keyversion2 = keymod.addKeyVersion();

    // now remove the second KeyVersion from the Key
    keymod.removeKeyVersion(keyversion2);

    // now check that it has in fact been removed
View Full Code Here

  public void testRemovePrimary() throws BuilderException, KeyModifierException {
    // create a key modifier
    KeyModifier keymod = new KeyModifier();

    // create and add a KeyVersion and add it to the Key
    KeyVersion keyversion = keymod.addKeyVersion();
   
    // now attempt to remove the primary KeyVersion from the Key
    // this SHOULD RAISE AN EXCEPTION
    keymod.removeKeyVersion(keyversion);
  }
View Full Code Here

  @Test
  public void setPrimary() throws BuilderException {
    // create a key modifier
    KeyModifier keymod = new KeyModifier();
    // create and add a KeyVersion and add it to the Key
    KeyVersion keyversion1 = keymod.addKeyVersion();

    // set the first keyversion as the primary
    keymod.setPrimary(keyversion1);
   
    // create and add another KeyVersion and add it to the Key
    KeyVersion keyversion2 = keymod.addKeyVersion();

    // check that the primary key version is equal to the key version we created and added to the
    // Key
    assertEquals(keyversion1, keymod.getPrimary());
View Full Code Here

        // Type field is required
        throw new InvalidKeyDataException(
            InvalidKeyDataException.Reason.PROTO_PARSE, null);
      }
      try {
        KeyVersion kv = registry.newBuilder(kvData.getType())
            .withData(kvData, protoRegistry).build();
        keyVersions.add(kv);
      } catch (InvalidProtocolBufferException ex) {
        // Throw proto parsing exceptions immediately
        throw new InvalidKeyDataException(
View Full Code Here

    KeyData.Builder builder = KeyData.newBuilder();
    builder.setCore(getCore());
    List<KeyVersion> keyVersions = this.keyVersions;
    final int size = keyVersions.size();
    for (int i = 0; i < size; ++i) {
      KeyVersion kv = keyVersions.get(i);
      builder.addKeyVersion(kv.buildData());
      if (kv == primary) {
        builder.setPrimary(i);
      }
    }
    if (size > 0 && !builder.hasPrimary()) {
View Full Code Here

TOP

Related Classes of com.google.k2crypto.keyversions.KeyVersion$Builder

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.