Package com.google.k2crypto.exceptions

Examples of com.google.k2crypto.exceptions.BuilderException


      // use the key generator to generate a key pair and return it
      return (keyGenerator.generateKeyPair());

    } catch (GeneralSecurityException e) {
      // catch and propagate any exceptions
      throw new BuilderException("Failed to build DSA key pair", e);
    }
  }
View Full Code Here


    super(builder);

    // check that we actually have a public key part otherwise throw an exception (cannot generate
    // public key without corresponding private key)
    if (builder.publicKeyPart == null) {
      throw new BuilderException(
          "Cannot initialize DSAPublicKeyVersion without PublicKey being set in the Builder");
    }

    // set the public key part
    this.publicKeyPart = builder.publicKeyPart;
View Full Code Here

          // and the initialization vector
          encryptingCipher.init(Cipher.ENCRYPT_MODE, this.secretKey,
              new IvParameterSpec(this.initVector));
          break;
        default:
          throw new BuilderException("Unrecognized mode");
      }

      // make an AES cipher that we can use for decryption
      this.decryptingCipher = Cipher.getInstance(this.algModePadding);

      // initialize the decrypting cipher
      switch (this.mode) {
        case ECB:
          // Initialize the cipher using the secret key -
          // ECB does NOT use an initialization vector
          decryptingCipher.init(Cipher.DECRYPT_MODE, secretKey);
          break;
        case CBC:
        case OFB:
        case CFB:
        case CTR:
          // Initialize the cipher using the secret key of this class
          // and the initialization vector
          decryptingCipher.init(
              Cipher.DECRYPT_MODE, secretKey, new IvParameterSpec(initVector));
          break;
        default:
          throw new BuilderException("Unrecognized mode");
      }

      // Catch all exceptions
    } catch (Exception e) {
      // Propagate the exception up using BuilderException
      throw new BuilderException("Building AESKeyVersion failed", e);
    }
  }
View Full Code Here

    @Override
    public AESKeyVersion build() throws BuilderException {
      try {
        return new AESKeyVersion(this);
      } catch (Exception e) {
        throw new BuilderException("Building AESKeyVersion failed", e);
      }
    }
View Full Code Here

    @Override
    public HMACKeyVersion build() throws BuilderException {
      try {
        return new HMACKeyVersion(this);
      } catch (Exception e) {
        throw new BuilderException("Building HMACKeyVersion failed", e);
      }
    }
View Full Code Here

TOP

Related Classes of com.google.k2crypto.exceptions.BuilderException

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.