void addSigner(MgmtEntry.Signer dbEntry) throws CaMgmtException { Args.notNull(dbEntry, "dbEntry"); final String sql = "INSERT INTO SIGNER (NAME,TYPE,CERT,CONF) VALUES (?,?,?,?)"; PreparedStatement ps = null; try { ps = prepareStatement(sql); int idx = 1; ps.setString(idx++, dbEntry.getName()); ps.setString(idx++, dbEntry.getType()); ps.setString(idx++, dbEntry.getBase64Cert()); ps.setString(idx++, dbEntry.getConf()); if (ps.executeUpdate() == 0) { throw new CaMgmtException("could not add signer " + dbEntry.getName()); } LOG.info("added signer: {}", dbEntry.toString(false, true)); } catch (SQLException ex) { throw new CaMgmtException(datasource.translate(sql, ex)); } finally { datasource.releaseResources(ps, null); } } // method addSigner
@Override public void addSigner(MgmtEntry.Signer signerEntry) throws CaMgmtException { Args.notNull(signerEntry, "signerEntry"); asssertMasterMode(); String name = signerEntry.getName(); if (signerDbEntries.containsKey(name)) { throw new CaMgmtException(concat("Signer named ", name, " exists")); } String conf = signerEntry.getConf(); if (conf != null) { String newConf = canonicalizeSignerConf(signerEntry.getType(), conf, null, securityFactory); if (!conf.equals(newConf)) { signerEntry.setConf(newConf); } } SignerEntryWrapper signer = createSigner(signerEntry); queryExecutor.addSigner(signerEntry); signers.put(name, signer); signerDbEntries.put(name, signerEntry); } // method addResponder
conf.setName(name); conf.setType(entry.getType()); conf.setConf(createFileOrValue(zipStream, entry.getConf(), concat("files/signer-", name, ".conf"))); conf.setCert(createFileOrBase64Value(zipStream, entry.getBase64Cert(),
public void initSigner(SecurityFactory securityFactory) throws ObjectCreationException { Args.notNull(securityFactory, "securityFactory"); if (signer != null) { return; } if (dbEntry == null) { throw new ObjectCreationException("dbEntry is null"); } X509Certificate responderCert = dbEntry.getCertificate(); dbEntry.setConfFaulty(true); signer = securityFactory.createSigner(dbEntry.getType(), new SignerConf(dbEntry.getConf()), responderCert); if (signer.getCertificate() == null) { throw new ObjectCreationException("signer without certificate is not allowed"); } dbEntry.setConfFaulty(false); if (dbEntry.getBase64Cert() == null) { dbEntry.setCertificate(signer.getCertificate()); subjectAsX500Name = X500Name.getInstance(signer.getBcCertificate().getSubject()); subjectAsGeneralName = new GeneralName(subjectAsX500Name); } } // method initSigner
SignerEntryWrapper changeSigner(String name, String type, String conf, String base64Cert, CaManagerImpl caManager, SecurityFactory securityFactory) throws CaMgmtException { Args.notBlank(name, "name"); Args.notNull(caManager, "caManager"); MgmtEntry.Signer dbEntry = createSigner(name); String tmpType = (type == null ? dbEntry.getType() : type); if (conf != null) { conf = CaManagerImpl.canonicalizeSignerConf(tmpType, conf, null, securityFactory); } MgmtEntry.Signer newDbEntry = new MgmtEntry.Signer(name, tmpType, (conf == null ? dbEntry.getConf() : conf), (base64Cert == null ? dbEntry.getBase64Cert() : base64Cert)); SignerEntryWrapper responder = caManager.createSigner(newDbEntry); changeIfNotNull("SIGNER", col(STRING, "NAME", name), col(STRING, "TYPE", type), col(STRING, "CERT", base64Cert), col(STRING, "CONF", conf, false, true)); return responder; } // method changeSigner
public SignerEntryWrapper(MgmtEntry.Signer signerEntry) { this.name = signerEntry.getName(); this.type = signerEntry.getType(); this.conf = signerEntry.getConf(); this.faulty = signerEntry.isFaulty(); if (signerEntry.getBase64Cert() != null) { this.encodedCert = Base64.decode(signerEntry.getBase64Cert()); } }