Package java.security

Examples of java.security.KeyPair


      if (password != null) {
        hashedPassword = PasswordHash.doPasswordHash(password);
      }

      // This keypair is for grants etc. The client doesn't (currently) get access to the private key
      KeyPair userRsaKeyPair = RsaUtils.generateRsaKeyPair(RsaUtils.SMALL_KEYSIZE);
      byte[] privateKeyData = RsaUtils.serialize(userRsaKeyPair.getPrivate());
      privateKeyData = FathomdbCrypto.encrypt(userSecretKey, privateKeyData);
      byte[] publicKeyData = RsaUtils.serialize(userRsaKeyPair.getPublic());

      db.insertUser(userName, hashedPassword, secretData, publicKeyData, privateKeyData);

      UserEntity user = findUser(userName);
View Full Code Here


        metadata = FathomdbCrypto.encrypt(projectSecret, metadataPlaintext);

        project = new ProjectEntity();
        project.setProjectSecret(projectSecret);

        KeyPair projectRsaKeyPair = RsaUtils.generateRsaKeyPair(RsaUtils.SMALL_KEYSIZE);
        project.setPublicKey(projectRsaKeyPair.getPublic());
        project.setPrivateKey(projectRsaKeyPair.getPrivate());
      } catch (IOException e) {
        throw new RepositoryException("Error encrypting secrets", e);
      }

      int rows = db.createProject(key, secretData, metadata, project.publicKeyData, project.privateKeyData);
View Full Code Here

    String keyData = findData(projectId, serviceType, keyId);
    if (keyData == null) {
      return null;
    }
    try {
      KeyPair keyPair = KeyPairUtils.deserialize(keyData);

      saveKeypairInDevelopment(projectId, serviceType, keyPair);

      return keyPair;
    } catch (IOException e) {
View Full Code Here

    putKeyPair(projectId, serviceType, METADATA_SSHKEY, sshKeyPair);
  }

  public SshKey getOrCreate(ProjectId projectId, ServiceType serviceType, String sshKeyName, String user)
      throws OpsException {
    KeyPair keyPair = findSshKey(projectId, serviceType);
    if (keyPair == null) {
      keyPair = RsaUtils.generateRsaKeyPair();
      // sshKeyPair = cloud.generateSshKeyPair(sshKeyName);
      storeSshKeyPair(projectId, serviceType, keyPair);
    }
View Full Code Here

            };
    }

    protected KeyPair readKeyPair()
            throws IOException {
        KeyPair kp = null;
        org.bouncycastle.openssl.PasswordFinder pFinder = makeBouncyPasswordFinder();
        PEMReader r = null;
        Object o = null;
        try {
            for (; ; ) {
View Full Code Here

        this.kp = kp;
        type = KeyType.fromKey(kp.getPublic());
    }

    public KeyPairWrapper(PublicKey publicKey, PrivateKey privateKey) {
        this(new KeyPair(publicKey, privateKey));
    }
View Full Code Here

      generator = KeyPairGenerator.getInstance(algorithm);
    } catch (NoSuchAlgorithmException e) {
      throw new IllegalStateException("Error loading crypto provider", e);
    }
    generator.initialize(keysize);
    KeyPair keyPair = generator.generateKeyPair();
    return keyPair;

  }
View Full Code Here

    public void init(BigInteger p, BigInteger g)
            throws GeneralSecurityException {
        this.p = p;
        this.g = g;
        generator.initialize(new DHParameterSpec(p, g));
        final KeyPair kp = generator.generateKeyPair();
        agreement.init(kp.getPrivate());
        e = ((javax.crypto.interfaces.DHPublicKey) kp.getPublic()).getY();
    }
View Full Code Here

    // No key found; let's create a new key
    log.info("No SSL key found; creating a new one under {}", owner);

    {
      X500Principal subject = buildX500(keyId, owner);
      KeyPair keyPair = RsaUtils.generateRsaKeyPair();

      PlatformLayerKey createdPath = ca.createSignedKey(owner, keyId, subject, keyPair);
      ItemBase createdModel = platformLayer.getItem(createdPath);
      ManagedSecretKey created = providers.toInterface(createdModel, ManagedSecretKey.class);
      return created;
View Full Code Here

     * @param pubK Public key as PublicKey
     * @param privK Private key as PrivateKey
     * @return The public key and private key in a KeyPair
     */
    public static KeyPair getKeyPair(PublicKey pubK, PrivateKey privK){
        return new KeyPair(pubK, privK);
    }
View Full Code Here

TOP

Related Classes of java.security.KeyPair

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.