Ejemplo n.º 1
0
 /**
  * Validate column names and return a string if there's a validation warning.
  *
  * @param dao Data access object to validate columns for
  * @return A validation warning or null
  */
 public static String validateColumns(DataAccessObject dao) {
   HashSet<String> uniqueHeaders = new HashSet<String>();
   String warning = null;
   for (String header : dao.getColumnNames()) {
     if (header == null || header.length() == 0) {
       warning = Messages.getString("RowUtil.warningEmptyColumn"); // $NON-NLS-1$
       break;
     } else if (uniqueHeaders.contains(header)) {
       warning =
           Messages.getFormattedString("RowUtil.warningDuplicateColumn", header); // $NON-NLS-1$
       break;
     }
     uniqueHeaders.add(header);
   }
   if (warning != null) {
     logger.warn(warning);
   }
   return warning;
 }
Ejemplo n.º 2
0
  void start()
      throws KeyStoreException, NoSuchAlgorithmException, IOException, UnsupportedCallbackException,
          UnrecoverableKeyException, InvalidKeyException, SignatureException {
    if (Configuration.DEBUG) log.entering(this.getClass().getName(), "start"); // $NON-NLS-1$
    // 1. get the key entry and certificate chain associated to alias
    Key privateKey = getAliasPrivateKey();
    Certificate[] chain = store.getCertificateChain(alias);

    // 2. get alias's DN and public key to use in the CSR
    X509Certificate bottomCertificate = (X509Certificate) chain[0];
    X500Principal aliasName = bottomCertificate.getIssuerX500Principal();
    PublicKey publicKey = bottomCertificate.getPublicKey();

    // 3. generate the CSR
    setSignatureAlgorithmParam(_sigAlgorithm, privateKey);
    byte[] derBytes = getCSR(aliasName, publicKey, (PrivateKey) privateKey);

    // 4. encode it in base-64 and write it to outStream
    String encoded = Base64.encode(derBytes, 0, derBytes.length, true);
    PrintWriter writer = new PrintWriter(outStream, true);
    writer.println("-----BEGIN NEW CERTIFICATE REQUEST-----"); // $NON-NLS-1$
    writer.println(encoded);
    writer.println("-----END NEW CERTIFICATE REQUEST-----"); // $NON-NLS-1$

    if (verbose) {
      if (!systemOut)
        System.out.println(
            Messages.getFormattedString(
                "CertReqCmd.27", //$NON-NLS-1$
                _certReqFileName));
      System.out.println(Messages.getString("CertReqCmd.28")); // $NON-NLS-1$
    }

    writer.close();
    if (Configuration.DEBUG) log.exiting(this.getClass().getName(), "start"); // $NON-NLS-1$
  }