class DBService implements RolesProvider {

    void executePutPublicKeyEntry(ResourceContext ctx, String domainName, String serviceName,
            PublicKeyEntry keyEntry, String auditRef, String caller) {

        // our exception handling code does the check for retry count
        // and throws the exception it had received when the retry
        // count reaches 0

        for (int retryCount = defaultRetryCount; ; retryCount--) {

            try (ObjectStoreConnection con = store.getConnection(false, true)) {

                // first verify that auditing requirements are met

                checkDomainAuditEnabled(con, domainName, auditRef, caller, getPrincipalName(ctx), AUDIT_TYPE_SERVICE);

                // check to see if this key already exists or not

                PublicKeyEntry originalKeyEntry = con.getPublicKeyEntry(domainName, serviceName,
                        keyEntry.getId(), false);

                // now we need verify our quota check if we know that
                // that we'll be adding another public key

                if (originalKeyEntry == null) {
                    quotaCheck.checkServiceIdentityPublicKeyQuota(con, domainName, serviceName, caller);
                }

                // now process the request

                boolean requestSuccess;
                StringBuilder auditDetails = new StringBuilder(ZMSConsts.STRING_BLDR_SIZE_DEFAULT);

                if (originalKeyEntry == null) {
                    requestSuccess = con.insertPublicKeyEntry(domainName, serviceName, keyEntry);
                    auditDetails.append("{\"added-publicKeys\": [");
                } else {
                    requestSuccess = con.updatePublicKeyEntry(domainName, serviceName, keyEntry);
                    auditDetails.append("{\"updated-publicKeys\": [");
                }

                if (!requestSuccess) {
                    con.rollbackChanges();
                    throw ZMSUtils.internalServerError("unable to put public key: " + keyEntry.getId() +
                            " in service " + ZMSUtils.serviceResourceName(domainName, serviceName), caller);
                }

                // update our service and domain time-stamp and save changes

                con.updateServiceIdentityModTimestamp(domainName, serviceName);
                saveChanges(con, domainName);

                // audit log the request

                auditLogPublicKeyEntry(auditDetails, keyEntry, true);
                auditDetails.append("]}");

                auditLogRequest(ctx, domainName, auditRef, caller, ZMSConsts.HTTP_PUT,
                        serviceName, auditDetails.toString());

                return;

            } catch (ResourceException ex) {
                if (!shouldRetryOperation(ex, retryCount)) {
                    throw ex;
                }
            }
        }
    }

    public  DBService(ObjectStore store, AuditLogger auditLogger, ZMSConfig zmsConfig, AuditReferenceValidator auditReferenceValidator);

}