RequestorEntryWrapper changeRequestor(NameId nameId, String type, String conf,
PasswordResolver passwordResolver) throws CaMgmtException {
Args.notNull(nameId, "nameId");
RequestorEntryWrapper requestor = new RequestorEntryWrapper();
if (MgmtEntry.Requestor.TYPE_PBM.equalsIgnoreCase(type)) {
if (!StringUtil.startsWithIgnoreCase(conf, "PBE:")) {
try {
conf = passwordResolver.protectPassword("PBE", conf.toCharArray());
} catch (PasswordResolverException ex) {
throw new CaMgmtException("could not encrypt requestor " + nameId.getName(), ex);
}
}
}
requestor.setDbEntry(new MgmtEntry.Requestor(nameId, type, conf), passwordResolver);
if (requestor.getDbEntry().isFaulty()) {
throw new CaMgmtException("invalid requestor configuration");
}
changeIfNotNull("REQUESTOR", col(INT, "ID", nameId.getId()),
col(STRING, "TYPE", type), col(STRING, "CONF", conf));
return requestor;
}