- Notary.writeUserAgreement(owner, "CCA", "issue certificate", "", true, 0);
-
- GigiPreparedStatement inserter = DatabaseConnection.getInstance().prepare("INSERT INTO certs SET md=?, csr_type=?, crt_name='', memid=?, profile=?");
- inserter.setString(1, md);
- inserter.setString(2, csrType.toString());
- inserter.setInt(3, owner.getId());
- inserter.setInt(4, profile.getId());
- inserter.execute();
- id = inserter.lastInsertId();
-
- GigiPreparedStatement san = DatabaseConnection.getInstance().prepare("INSERT INTO subjectAlternativeNames SET certId=?, contents=?, type=?");
- for (SubjectAlternateName subjectAlternateName : sans) {
- san.setInt(1, id);
- san.setString(2, subjectAlternateName.getName());
- san.setString(3, subjectAlternateName.getType().getOpensslName());
- san.execute();
- }
-
- GigiPreparedStatement insertAVA = DatabaseConnection.getInstance().prepare("INSERT certAvas SET certid=?, name=?, value=?");
- insertAVA.setInt(1, id);
- for (Entry<String, String> e : dn.entrySet()) {
- insertAVA.setString(2, e.getKey());
- insertAVA.setString(3, e.getValue());
- insertAVA.execute();
- }
- File csrFile = KeyStorage.locateCsr(id);
- csrName = csrFile.getPath();
- FileOutputStream fos = new FileOutputStream(csrFile);
- fos.write(csr.getBytes());
- fos.close();
-
- GigiPreparedStatement updater = DatabaseConnection.getInstance().prepare("UPDATE certs SET csr_name=? WHERE id=?");
- updater.setString(1, csrName);
- updater.setInt(2, id);
- updater.execute();