Package br.net.woodstock.rockframework.security.cert

Examples of br.net.woodstock.rockframework.security.cert.CertificateException


          issuer = this.getIssuer(issuer.getIssuer(), certificates);
        }
      }
      return Collections.toArray(list, Certificate.class);
    } catch (Exception e) {
      throw new CertificateException(e);
    }
  }
View Full Code Here


      Assert.notEmpty(type, "type");
      CertificateFactory certFactory = CertificateFactory.getInstance(type.getType());
      Certificate certificate = certFactory.generateCertificate(inputStream);
      return certificate;
    } catch (GeneralSecurityException e) {
      throw new CertificateException(e);
    }
  }
View Full Code Here

          list.add(new ValidationError(HierarchyCertificateValidator.VALIDATOR_NAME, "Certificate issuer '" + BouncyCastleProviderHelper.toString(issuer.getSubjectX500Principal()) + "' dont have 'keyCertSign' in key usage"));
        }
      } catch (SignatureException e) {
        list.add(new ValidationError(HierarchyCertificateValidator.VALIDATOR_NAME, "Certificate '" + BouncyCastleProviderHelper.toString(certificate.getSubjectX500Principal()) + "' not signed by '" + BouncyCastleProviderHelper.toString(issuer.getSubjectX500Principal()) + "'"));
      } catch (Exception e) {
        throw new CertificateException(e);
      }
    }

    try {
      if (Conditions.isNotEmpty(this.certificates)) {
        boolean requiredOk = false;
        outer: for (int i = 1; i < chain.length; i++) {
          X509Certificate issuer = (X509Certificate) chain[i];
          for (Certificate required : this.certificates) {
            X509Certificate x509Required = (X509Certificate) required;
            if (Arrays.equals(issuer.getEncoded(), x509Required.getEncoded())) {
              RockFrameworkLogger.getLogger().info("Matches " + BouncyCastleProviderHelper.toString(x509Required.getSubjectX500Principal()));
              requiredOk = true;
              break outer;
            }
          }
        }

        if (!requiredOk) {
          list.add(new ValidationError(HierarchyCertificateValidator.VALIDATOR_NAME, "Certificate chain is invalid, a required certificate could not be found"));
        }
      }
    } catch (CertificateEncodingException e) {
      throw new CertificateException(e);
    }

    return Collections.toArray(list, ValidationError.class);
  }
View Full Code Here

      CMSSignedData signedData = signedDataGenerator.generate(content, false);
      byte[] bytes = signedData.getEncoded();
      outputStream.write(bytes);
    } catch (Exception e) {
      throw new CertificateException(e);
    }
  }
View Full Code Here

    } catch (CertificateExpiredException e) {
      return new ValidationError[] { new ValidationError(DateCertificateValidator.VALIDATOR_NAME, "Certificate expired") };
    } catch (CertificateNotYetValidException e) {
      return new ValidationError[] { new ValidationError(DateCertificateValidator.VALIDATOR_NAME, "Certificate not yet valid") };
    } catch (Exception e) {
      throw new CertificateException(e);
    }
  }
View Full Code Here

        if ((Conditions.isNotEmpty(dataStr)) && (Conditions.isNotEmpty(dataStr.replaceAll("0", "")))) {
          this.setDataNascimento(ICPBrasilHelper.getDateFromString(dataStr));
        }
      }
    } catch (Exception e) {
      throw new CertificateException(e);
    }

  }
View Full Code Here

    try {
      inputStream = new FileInputStream(zipFile);
      this.initFromStream(inputStream);
      inputStream.close();
    } catch (Exception e) {
      throw new CertificateException(e);
    } finally {
      if (inputStream != null) {
        try {
          inputStream.close();
        } catch (IOException e) {
View Full Code Here

  private void initFromUrl(final String zipUrl) {
    try {
      URL url = new URL(zipUrl);
      this.initFromUrl(url);
    } catch (MalformedURLException e) {
      throw new CertificateException(e);
    }
  }
View Full Code Here

    try {
      connection = zipUrl.openConnection();
      inputStream = connection.getInputStream();
      this.initFromStream(inputStream);
    } catch (Exception e) {
      throw new CertificateException(e);
    } finally {
      if (inputStream != null) {
        try {
          inputStream.close();
        } catch (IOException e) {
View Full Code Here

        response = this.buildV1Certificate(bcRequest);
      }

      return response;
    } catch (Exception e) {
      throw new CertificateException(e);
    }
  }
View Full Code Here

TOP

Related Classes of br.net.woodstock.rockframework.security.cert.CertificateException

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.