Package com.netscape.cmscore.dbs
Class Repository
java.lang.Object
com.netscape.cmscore.dbs.Repository
- Direct Known Subclasses:
ReplicaIDRepository
,RequestRepository
A class represents a generic repository. It maintains unique
serial number within repository.
To build domain specific repository, subclass should be created.
- Author:
- galperin, thomask
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DBSubsystem
protected CMSEngine
protected Repository.IDGenerator
protected int
static org.slf4j.Logger
protected String
protected String
protected BigInteger
protected BigInteger
protected String
protected BigInteger
protected BigInteger
protected BigInteger
protected BigInteger
protected BigInteger
protected int
protected String
protected String
protected String
protected SecureRandom
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Checks if the given number is in the current range.void
Checks to see if a new range is needed, or if we have reached the end of the current range, or if a range conflict has occurred.Get the LDAP base DN for this repository.abstract BigInteger
getLastSerialNumberInRange
(BigInteger serial_low_bound, BigInteger serial_upper_bound) Get the maximum serial number.Get the minimum serial number.Get the maximum serial number in next range.Gets start of next range from database.Retrieves the next serial number, and also increase the serial number by one.int
getRadix()
getRandomLimit
(BigInteger rangeLength) boolean
Determines if a range conflict has been observed in database.void
init()
protected void
init serial number cachePeek at the next serial number in cache (does not consume the number).void
setCMSEngine
(CMSEngine engine) void
setEnableSerialMgmt
(boolean value) Sets whether serial number management is enabled for certs and requests.protected void
setIDGenerator
(Repository.IDGenerator idGenerator) protected void
setIDGenerator
(String idGenerator) protected void
setLastSerialNo
(BigInteger lastSN) void
setMaxSerial
(BigInteger serial) Set the maximum serial number.void
Sets maximum serial number limit in config filevoid
Sets minimum serial number limit in config filevoid
setNextMaxSerial
(BigInteger serial) Set the maximum serial number in next rangevoid
Sets maximum serial number limit for next range in config filevoid
Sets minimum serial number limit for next range in config filevoid
Updates the serial number to the specified in db and cache.
-
Field Details
-
logger
public static org.slf4j.Logger logger -
engine
-
minSerialName
-
mMinSerialNo
-
maxSerialName
-
mMaxSerialNo
-
nextMinSerialName
-
mNextMinSerialNo
-
nextMaxSerialName
-
mNextMaxSerialNo
-
mCounter
-
mIncrementNo
-
mLowWaterMarkNo
-
dbSubsystem
-
mBaseDN
-
rangeDN
-
mRadix
protected int mRadix -
repositoryConfig
-
idGenerator
-
idLength
protected int idLength -
secureRandom
-
-
Constructor Details
-
Repository
Constructs a repository.
-
-
Method Details
-
getCMSEngine
-
setCMSEngine
-
init
- Throws:
Exception
-
getBaseDN
Get the LDAP base DN for this repository. This value can be used by the request queue to create the name for the request records themselves.- Returns:
- the LDAP base DN.
-
getRadix
public int getRadix() -
getMaxSerial
Get the maximum serial number.- Returns:
- maximum serial number
-
setMaxSerial
Set the maximum serial number.- Parameters:
serial
- maximum number- Throws:
EBaseException
- failed to set maximum serial number
-
getNextMaxSerial
Get the maximum serial number in next range.- Returns:
- maximum serial number in next range
-
setNextMaxSerial
Set the maximum serial number in next range- Parameters:
serial
- maximum number in next range- Throws:
EBaseException
- failed to set maximum serial number in next range
-
getMinSerial
Get the minimum serial number.- Returns:
- minimum serial number
-
setLastSerialNo
-
getIDGenerator
-
setIDGenerator
-
setIDGenerator
-
initCache
init serial number cache- Throws:
EBaseException
-
peekNextSerialNumber
Peek at the next serial number in cache (does not consume the number). The returned number is not necessarily the previously emitted serial number plus one, i.e. if we are going to roll into the next range. This method does not actually switch the range. Returns null if the next number exceeds the current range and there is not a next range.- Returns:
- serial number
- Throws:
EBaseException
- failed to retrieve next serial number
-
setTheSerialNumber
Updates the serial number to the specified in db and cache.- Parameters:
num
- serial number- Throws:
EBaseException
-
getNextSerialNumber
Retrieves the next serial number, and also increase the serial number by one.- Returns:
- serial number
- Throws:
EBaseException
- failed to retrieve next serial number
-
getRangeLength
-
getRandomLimit
-
checkRange
Checks if the given number is in the current range. If it does not exceed the current range, return cleanly. If it exceeds the given range, and there is a next range, switch the range. If it exceeds the given range, and there is not a next range, throw EDBException. Precondition: the serial number should already have been advanced. This method will detect that and switch to the next range, including resetting mLastSerialNo to the start of the new (now current) range. Postcondition: the caller should again read mLastSerialNo after calling checkRange(), in case checkRange switched the range and the new range is not adjacent to the current range.- Throws:
EDBException
- thrown when range switch is needed but next range is not allocatedEBaseException
-
setMinSerialConfig
Sets minimum serial number limit in config file- Throws:
EBaseException
- failed to set
-
setMaxSerialConfig
Sets maximum serial number limit in config file- Throws:
EBaseException
- failed to set
-
setNextMinSerialConfig
Sets minimum serial number limit for next range in config file- Throws:
EBaseException
- failed to set
-
setNextMaxSerialConfig
Sets maximum serial number limit for next range in config file- Throws:
EBaseException
- failed to set
-
getNextRange
Gets start of next range from database. Increments the nextRange attribute and allocates this range to the current instance by creating a pkiRange object.- Returns:
- start of next range
- Throws:
EBaseException
-
hasRangeConflict
Determines if a range conflict has been observed in database. If so, delete the conflicting entries and remove the next range. When the next number is requested, if the number of certs is still below the low water mark, then a new range will be requested.- Returns:
- true if range conflict, false otherwise
- Throws:
EBaseException
-
getNumbersInRange
-
checkRanges
Checks to see if a new range is needed, or if we have reached the end of the current range, or if a range conflict has occurred.- Throws:
EBaseException
- failed to check next range for conflicts
-
setEnableSerialMgmt
Sets whether serial number management is enabled for certs and requests.- Parameters:
value
- true/false- Throws:
EBaseException
- failed to set
-
getLastSerialNumberInRange
public abstract BigInteger getLastSerialNumberInRange(BigInteger serial_low_bound, BigInteger serial_upper_bound) throws EBaseException - Throws:
EBaseException
-