Examples of PEMReader


Examples of org.bouncycastle.util.io.pem.PemReader

      if (algorithm == null) {
        throw new IllegalStateException("Could not read key pair algorithm");
      }

      if (privateKeyText.length() > 0) {
        PemReader reader = new PemReader(new StringReader(privateKeyText.toString()));
        PemObject obj = reader.readPemObject();
        reader.close();

        PrivateKeyInfo privateKeyInfo = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, null), RSAPrivateKey.getInstance(obj.getContent()));
        byte[] encoded = privateKeyInfo.getEncoded();

        privateKey = Keys.getPrivateKeyFromPKCS8File(encoded, KeyPairType.RSA);
      }

      if (publicKeyText.length() > 0) {
        PemReader reader = new PemReader(new StringReader(publicKeyText.toString()));
        PemObject obj = reader.readPemObject();
        reader.close();

        byte[] publicKeyBytes = obj.getContent();
        publicKey = Keys.getPublicKeyFromX509File(publicKeyBytes, KeyPairType.RSA);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.