@Override public void addRequestor(MgmtEntry.Requestor requestorEntry) throws CaMgmtException { Args.notNull(requestorEntry, "requestorEntry"); asssertMasterMode(); String name = requestorEntry.getIdent().getName(); if (requestorDbEntries.containsKey(name)) { throw new CaMgmtException(concat("Requestor named ", name, " exists")); } // encrypt the password PasswordResolver pwdResolver = securityFactory.getPasswordResolver(); if (MgmtEntry.Requestor.TYPE_PBM.equalsIgnoreCase(requestorEntry.getType())) { String conf = requestorEntry.getConf(); if (!StringUtil.startsWithIgnoreCase(conf, "PBE:")) { String encryptedPassword; try { encryptedPassword = pwdResolver.protectPassword("PBE", conf.toCharArray()); } catch (PasswordResolverException ex) { throw new CaMgmtException("could not encrypt requestor " + name, ex); } requestorEntry = new MgmtEntry.Requestor(requestorEntry.getIdent(), requestorEntry.getType(), encryptedPassword); } } RequestorEntryWrapper requestor = new RequestorEntryWrapper(); requestor.setDbEntry(requestorEntry, pwdResolver); queryExecutor.addRequestor(requestorEntry); idNameMap.addRequestor(requestorEntry.getIdent()); requestorDbEntries.put(name, requestorEntry); requestors.put(name, requestor); } // method addRequestor
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; } // method changeRequestor