Package org.bouncycastle.openssl

Examples of org.bouncycastle.openssl.PEMParser.readObject()


    @Override
    public PublicKey readPublicKey(String algorithm, Reader rdr) throws CryptoException, IOException
    {
        PEMParser pp = new PEMParser(rdr);
        try {
            Object po = pp.readObject();
            if (log.isDebugEnabled()) {
                log.debug("Trying to read an {} public key and got {}", algorithm, po);
            }

            if (po instanceof SubjectPublicKeyInfo) {
View Full Code Here


    public PublicKey readPublicKey(String algorithm, Reader rdr)
        throws CryptoException, IOException
    {
        PEMParser pp = new PEMParser(rdr);
        try {
            Object po = pp.readObject();
            if (log.isDebugEnabled()) {
                log.debug("Trying to read an {} public key and got {}", algorithm, po);
            }

            if (po instanceof SubjectPublicKeyInfo) {
View Full Code Here

        return KeyFactory.getInstance("RSA").generatePrivate(keySpec);
    }

    private static <T> T loadPEM(String keyPath) throws IOException {
        PEMParser parser = new PEMParser(new BufferedReader(new FileReader(keyPath)));
        return (T) parser.readObject();
    }

    private static void addCA(KeyStore keyStore, String caPath) throws KeyStoreException, FileNotFoundException, CertificateException {
        for (Certificate cert : loadCertificates(caPath)) {
            X509Certificate crt = (X509Certificate) cert;
View Full Code Here

  private final RSASha1SignatureService signatureService;

  public XeroOAuthService(Reader reader) {
    Security.addProvider(new BouncyCastleProvider());
    try (PEMParser pemParser = new PEMParser(reader)) {
      PEMKeyPair pair = (PEMKeyPair) pemParser.readObject();
      byte[] encodedPrivateKey = pair.getPrivateKeyInfo().getEncoded();
      KeyFactory keyFactory = KeyFactory.getInstance("RSA");
      PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(encodedPrivateKey);
      PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec);
      signatureService = new RSASha1SignatureService(privateKey);
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.