Search in sources :

Example 1 with Cas

use of org.xipki.ca.dbtool.jaxb.ca.CAConfigurationType.Cas in project xipki by xipki.

the class CaConfigurationDbExporter method exportCa.

// method exportProfile
private void exportCa(CAConfigurationType caconf) throws DataAccessException, IOException {
    System.out.println("exporting table CA");
    Cas cas = new Cas();
    String sql = "SELECT ID,NAME,SN_SIZE,STATUS,CRL_URIS,OCSP_URIS,MAX_VALIDITY,CERT,SIGNER_TYPE," + "SIGNER_CONF,CRLSIGNER_NAME,PERMISSION,NUM_CRLS,EXPIRATION_PERIOD,KEEP_EXPIRED_CERT_DAYS," + "REV,RR,RT,RIT,DUPLICATE_KEY,DUPLICATE_SUBJECT,SAVE_REQ,DELTACRL_URIS,VALIDITY_MODE," + "CACERT_URIS,ART,NEXT_CRLNO,RESPONDER_NAME,CMPCONTROL_NAME,EXTRA_CONTROL FROM CA";
    Statement stmt = null;
    ResultSet rs = null;
    try {
        stmt = createStatement();
        rs = stmt.executeQuery(sql);
        while (rs.next()) {
            String name = rs.getString("NAME");
            CaType ca = new CaType();
            ca.setId(rs.getInt("ID"));
            ca.setName(name);
            ca.setArt(rs.getInt("ART"));
            ca.setSnSize(rs.getInt("SN_SIZE"));
            ca.setNextCrlNo(rs.getLong("NEXT_CRLNO"));
            ca.setStatus(rs.getString("STATUS"));
            ca.setCrlUris(rs.getString("CRL_URIS"));
            ca.setDeltacrlUris(rs.getString("DELTACRL_URIS"));
            ca.setOcspUris(rs.getString("OCSP_URIS"));
            ca.setCacertUris(rs.getString("CACERT_URIS"));
            ca.setMaxValidity(rs.getString("MAX_VALIDITY"));
            ca.setCert(buildFileOrBase64Binary(rs.getString("CERT"), "ca-conf/cert-ca-" + name + ".der"));
            ca.setSignerType(rs.getString("SIGNER_TYPE"));
            ca.setSignerConf(buildFileOrValue(rs.getString("SIGNER_CONF"), "ca-conf/signerconf-ca-" + name));
            ca.setCrlsignerName(rs.getString("CRLSIGNER_NAME"));
            ca.setResponderName(rs.getString("RESPONDER_NAME"));
            ca.setCmpcontrolName(rs.getString("CMPCONTROL_NAME"));
            ca.setDuplicateKey(rs.getInt("DUPLICATE_KEY"));
            ca.setDuplicateSubject(rs.getInt("DUPLICATE_SUBJECT"));
            ca.setSaveReq(rs.getInt("SAVE_REQ"));
            ca.setPermission(rs.getInt("PERMISSION"));
            ca.setExpirationPeriod(rs.getInt("EXPIRATION_PERIOD"));
            ca.setKeepExpiredCertDays(rs.getInt("KEEP_EXPIRED_CERT_DAYS"));
            ca.setValidityMode(rs.getString("VALIDITY_MODE"));
            ca.setExtraControl(rs.getString("EXTRA_CONTROL"));
            ca.setNumCrls(rs.getInt("NUM_CRLS"));
            boolean revoked = rs.getBoolean("REV");
            ca.setRevoked(revoked);
            if (revoked) {
                ca.setRevReason(rs.getInt("RR"));
                ca.setRevTime(rs.getLong("RT"));
                ca.setRevInvTime(rs.getLong("RIT"));
            }
            cas.getCa().add(ca);
        }
    } catch (SQLException ex) {
        throw translate(sql, ex);
    } finally {
        releaseResources(stmt, rs);
    }
    caconf.setCas(cas);
    System.out.println(" exported table CA");
}
Also used : Cas(org.xipki.ca.dbtool.jaxb.ca.CAConfigurationType.Cas) SQLException(java.sql.SQLException) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) CaType(org.xipki.ca.dbtool.jaxb.ca.CaType)

Aggregations

ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 Cas (org.xipki.ca.dbtool.jaxb.ca.CAConfigurationType.Cas)1 CaType (org.xipki.ca.dbtool.jaxb.ca.CaType)1