Class Repository

  • All Implemented Interfaces:
    com.netscape.certsrv.dbs.repository.IRepository
    Direct Known Subclasses:
    CertificateRepository, CRLRepository, KeyRepository, ReplicaIDRepository

    public abstract class Repository
    extends java.lang.Object
    implements com.netscape.certsrv.dbs.repository.IRepository
    A class represents a generic repository. It maintains unique serial number within repository.

    To build domain specific repository, subclass should be created.

    Version:
    $Revision: 1.4 $, $Date$
    Author:
    galperin, thomask
    • Constructor Summary

      Constructors 
      Constructor Description
      Repository​(DBSubsystem dbSubsystem, int increment, java.lang.String baseDN)
      Constructs a repository.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void checkRange()
      Checks if the given number is in the current range.
      void 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.
      abstract java.math.BigInteger getLastSerialNumberInRange​(java.math.BigInteger serial_low_bound, java.math.BigInteger serial_upper_bound)  
      java.lang.String getMaxSerial()
      Get the maximum serial number.
      java.lang.String getMinSerial()
      Get the minimum serial number.
      java.lang.String getNextMaxSerial()
      Get the maximum serial number in next range.
      java.math.BigInteger getNextSerialNumber()
      Retrieves the next serial number, and also increase the serial number by one.
      protected java.math.BigInteger getSerialNumber()
      Retrieves the next serial number attr in db.
      protected void initCacheIfNeeded()  
      java.math.BigInteger peekNextSerialNumber()
      Peek at the next serial number in cache (does not consume the number).
      void resetSerialNumber​(java.math.BigInteger serial)
      Resets serial number.
      void setEnableSerialMgmt​(boolean value)
      Sets whether serial number management is enabled for certs and requests.
      protected void setLastSerialNo​(java.math.BigInteger lastSN)  
      void setMaxSerial​(java.lang.String serial)
      Set the maximum serial number.
      void setNextMaxSerial​(java.lang.String serial)
      Set the maximum serial number in next range
      protected void setSerialNumber​(java.math.BigInteger num)
      Updates the serial number to the specified in db.
      void setTheSerialNumber​(java.math.BigInteger num)
      Updates the serial number to the specified in db and cache.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        public static org.slf4j.Logger logger
      • mEnableRandomSerialNumbers

        protected boolean mEnableRandomSerialNumbers
      • mCounter

        protected java.math.BigInteger mCounter
      • mMinSerialNo

        protected java.math.BigInteger mMinSerialNo
      • mMaxSerialNo

        protected java.math.BigInteger mMaxSerialNo
    • Constructor Detail

      • Repository

        public Repository​(DBSubsystem dbSubsystem,
                          int increment,
                          java.lang.String baseDN)
                   throws com.netscape.certsrv.dbs.EDBException
        Constructs a repository.

        Throws:
        com.netscape.certsrv.dbs.EDBException
    • Method Detail

      • resetSerialNumber

        public void resetSerialNumber​(java.math.BigInteger serial)
                               throws EBaseException
        Resets serial number.
        Specified by:
        resetSerialNumber in interface com.netscape.certsrv.dbs.repository.IRepository
        Throws:
        EBaseException
      • getSerialNumber

        protected java.math.BigInteger getSerialNumber()
                                                throws EBaseException
        Retrieves the next serial number attr in db.

        Returns:
        next serial number
        Throws:
        EBaseException
      • setSerialNumber

        protected void setSerialNumber​(java.math.BigInteger num)
                                throws EBaseException
        Updates the serial number to the specified in db.

        Parameters:
        num - serial number
        Throws:
        EBaseException
      • getMaxSerial

        public java.lang.String getMaxSerial()
        Get the maximum serial number.
        Returns:
        maximum serial number
      • setMaxSerial

        public void setMaxSerial​(java.lang.String serial)
                          throws EBaseException
        Set the maximum serial number.
        Specified by:
        setMaxSerial in interface com.netscape.certsrv.dbs.repository.IRepository
        Parameters:
        serial - maximum number
        Throws:
        EBaseException - failed to set maximum serial number
      • getNextMaxSerial

        public java.lang.String getNextMaxSerial()
        Get the maximum serial number in next range.
        Returns:
        maximum serial number in next range
      • setNextMaxSerial

        public void setNextMaxSerial​(java.lang.String serial)
                              throws EBaseException
        Set the maximum serial number in next range
        Specified by:
        setNextMaxSerial in interface com.netscape.certsrv.dbs.repository.IRepository
        Parameters:
        serial - maximum number in next range
        Throws:
        EBaseException - failed to set maximum serial number in next range
      • getMinSerial

        public java.lang.String getMinSerial()
        Get the minimum serial number.
        Returns:
        minimum serial number
      • setLastSerialNo

        protected void setLastSerialNo​(java.math.BigInteger lastSN)
      • peekNextSerialNumber

        public java.math.BigInteger peekNextSerialNumber()
                                                  throws EBaseException
        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.
        Specified by:
        peekNextSerialNumber in interface com.netscape.certsrv.dbs.repository.IRepository
        Returns:
        serial number
        Throws:
        EBaseException - failed to retrieve next serial number
      • setTheSerialNumber

        public void setTheSerialNumber​(java.math.BigInteger num)
                                throws EBaseException
        Updates the serial number to the specified in db and cache.

        Parameters:
        num - serial number
        Throws:
        EBaseException
      • getNextSerialNumber

        public java.math.BigInteger getNextSerialNumber()
                                                 throws EBaseException
        Retrieves the next serial number, and also increase the serial number by one.

        Specified by:
        getNextSerialNumber in interface com.netscape.certsrv.dbs.repository.IRepository
        Returns:
        serial number
        Throws:
        EBaseException - failed to retrieve next serial number
      • checkRange

        protected void checkRange()
                           throws EBaseException
        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:
        com.netscape.certsrv.dbs.EDBException - thrown when range switch is needed but next range is not allocated
        EBaseException
      • checkRanges

        public void checkRanges()
                         throws EBaseException
        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.
        Specified by:
        checkRanges in interface com.netscape.certsrv.dbs.repository.IRepository
        Throws:
        EBaseException - failed to check next range for conflicts
      • setEnableSerialMgmt

        public void setEnableSerialMgmt​(boolean value)
                                 throws EBaseException
        Sets whether serial number management is enabled for certs and requests.
        Specified by:
        setEnableSerialMgmt in interface com.netscape.certsrv.dbs.repository.IRepository
        Parameters:
        value - true/false
        Throws:
        EBaseException - failed to set
      • getLastSerialNumberInRange

        public abstract java.math.BigInteger getLastSerialNumberInRange​(java.math.BigInteger serial_low_bound,
                                                                        java.math.BigInteger serial_upper_bound)
                                                                 throws EBaseException
        Throws:
        EBaseException