Skip to content

Commit

Permalink
Split the redix options beteween request and cert
Browse files Browse the repository at this point in the history
The just introduced option `dbs.numberRangeRadix` has been splitted in:
- `dbs.cert.id.radix`
- `dbs.request.id.radix`

If they are not present the default value of 16 for cert and 10 for
request will be used.
  • Loading branch information
fmarco76 committed Oct 18, 2024
1 parent 79e07e7 commit 125b477
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 27 deletions.
1 change: 0 additions & 1 deletion base/ca/shared/conf/CS.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,6 @@ dbs.replicaDN=ou=replica
dbs.replicaRangeDN=ou=replica, ou=ranges
dbs.ldap=internaldb
dbs.newSchemaEntryAdded=true
dbs.numberRangeRadix=-1
debug.level=10
features.authority.description=Lightweight CAs
features.authority.enabled=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class CRLRepository extends Repository {
* Constructs a CRL repository.
*/
public CRLRepository(DBSubsystem dbSubsystem) {
super(dbSubsystem, 10);
super(dbSubsystem, DEC);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public class CertificateRepository extends Repository {
private static final BigInteger BI_MINUS_ONE = BigInteger.ONE.negate();

public static final String PROP_CERT_ID_GENERATOR = "cert.id.generator";
public static final String PROP_CERT_ID_RADIX = "cert.id.radix";
public static final String DEFAULT_CERT_ID_GENERATOR = "legacy";

public static final String PROP_CERT_ID_LENGTH = "cert.id.length";
Expand All @@ -103,8 +104,15 @@ public CertificateRepository(
SecureRandom secureRandom,
DBSubsystem dbSubsystem) {

super(dbSubsystem, 16);

super(dbSubsystem, HEX);
DatabaseConfig dbc = dbSubsystem.getDBConfigStore();
try {
this.mRadix = dbc.getInteger(PROP_CERT_ID_RADIX, HEX);
logger.debug("CertificateRepository: number radix {}", this.mRadix);

} catch (EBaseException ex) {
logger.debug("CertificateRepository: error reading number radix config, using default {} for ", HEX);
}
this.secureRandom = secureRandom;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class KeyRepository extends Repository {
public static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(KeyRepository.class);

public static final String PROP_KEY_ID_GENERATOR = "key.id.generator";
public static final String PROP_CERT_ID_RADIX = "key.id.radix";
public static final String DEFAULT_KEY_ID_GENERATOR = "legacy";

public static final String PROP_KEY_ID_LENGTH = "key.id.length";
Expand All @@ -62,7 +63,15 @@ public KeyRepository(
SecureRandom secureRandom,
DBSubsystem dbSubsystem) {

super(dbSubsystem, 16);
super(dbSubsystem, HEX);
DatabaseConfig dbc = dbSubsystem.getDBConfigStore();
try {
this.mRadix = dbc.getInteger(PROP_CERT_ID_RADIX, HEX);
logger.debug("KeyRepository: number radix {}", this.mRadix);

} catch (EBaseException ex) {
logger.debug("KeyRepository: error reading number radix config, using default {} for ", HEX);
}

this.secureRandom = secureRandom;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@ protected void process(CMSRequest cmsReq) throws EBaseException {
nextEndConfig = "nextEndReplicaNumber";
}

if (dbConfig.getNumberRangeRadix() > 0) {
radix = dbConfig.getNumberRangeRadix();
}

/* UpdateNumberRange transfers a portion of this instance's
* number range to a clone.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ public class DatabaseConfig extends ConfigStore {
public static final String INFINITE_REQUEST_NUMBER = "1000000000";
public static final String INFINITE_REPLICA_NUMBER = "1000";

public static final String NUMBER_RANGE_RADIX = "numberRangeRadix";

public static final String ENABLE_SERIAL_MGMT = "enableSerialManagement";

public DatabaseConfig(ConfigStorage storage) {
Expand Down Expand Up @@ -320,10 +318,6 @@ public void setReplicaIncrement(String replicaIncrement) {
putString(REPLICA_INCREMENT, replicaIncrement);
}

public int getNumberRangeRadix() throws EBaseException {
return getInteger(NUMBER_RANGE_RADIX, -1);
}

public LDAPConfig getLDAPConfig() throws EBaseException {
return getSubStore("ldap", LDAPConfig.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class ReplicaIDRepository extends Repository {
* Constructs a certificate repository.
*/
public ReplicaIDRepository(DBSubsystem dbSubsystem) {
super(dbSubsystem, 10);
super(dbSubsystem, DEC);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public abstract class Repository {
public static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Repository.class);

public static final int HEX = 16;
public static final int DEC = 10;

public enum IDGenerator {
LEGACY_2("legacy2"),
Expand Down Expand Up @@ -118,15 +119,7 @@ public static IDGenerator fromString(String name) {
*/
public Repository(DBSubsystem dbSubsystem, int radix) {
this.dbSubsystem = dbSubsystem;
DatabaseConfig dbc = dbSubsystem.getDBConfigStore();
int cRadix = 0;
try {
cRadix = dbc.getNumberRangeRadix();
} catch (EBaseException ex) {
logger.debug("Repository: error reading number radix config, using default {} for {}", radix, this.getClass().getName());
}
this.mRadix = cRadix > 0 ? cRadix : radix;
logger.debug("Repository: number radix {} for {}", this.mRadix, this.getClass().getName());
this.mRadix = radix;
}

public CMSEngine getCMSEngine() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class RequestRepository extends Repository {
public static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(RequestRepository.class);

public static final String PROP_REQUEST_ID_GENERATOR = "request.id.generator";
public static final String PROP_REQUEST_ID_RADIX = "request.id.radix";
public static final String DEFAULT_REQUEST_ID_GENERATOR = "legacy";

public static final String PROP_REQUEST_ID_LENGTH = "request.id.length";
Expand All @@ -77,8 +78,15 @@ public RequestRepository(
DBSubsystem dbSubsystem,
String filter) {

super(dbSubsystem, 10);

super(dbSubsystem, DEC);
DatabaseConfig dbc = dbSubsystem.getDBConfigStore();
try {
this.mRadix = dbc.getInteger(PROP_REQUEST_ID_RADIX, DEC);
logger.debug("CertificateRepository: number radix {}", this.mRadix);

} catch (EBaseException ex) {
logger.debug("CertificateRepository: error reading number radix config, using default {} for ", HEX);
}
this.secureRandom = secureRandom;
this.filter = filter;
}
Expand Down

0 comments on commit 125b477

Please sign in to comment.