Class KeyRepository

  • All Implemented Interfaces:
    com.netscape.certsrv.dbs.keydb.IKeyRepository, com.netscape.certsrv.dbs.repository.IRepository

    public class KeyRepository
    extends Repository
    implements com.netscape.certsrv.dbs.keydb.IKeyRepository
    A class represents a Key repository. This is the container of archived keys.

    Version:
    $Revision$, $Date$
    Author:
    thomask
    • Field Detail

      • logger

        public static org.slf4j.Logger logger
      • mKeyStatusUpdateTask

        public com.netscape.cmscore.dbs.KeyStatusUpdateTask mKeyStatusUpdateTask
    • Constructor Detail

      • KeyRepository

        public KeyRepository​(DBSubsystem dbSubsystem,
                             int increment,
                             java.lang.String baseDN)
                      throws com.netscape.certsrv.dbs.EDBException
        Constructs a key repository. It checks if the key repository does exist. If not, it creates the repository.

        Parameters:
        service - db service
        Throws:
        EBaseException - failed to setup key repository
        com.netscape.certsrv.dbs.EDBException
    • Method Detail

      • setKeyStatusUpdateInterval

        public void setKeyStatusUpdateInterval​(com.netscape.certsrv.dbs.repository.IRepository requestRepo,
                                               int interval)
      • updateKeyStatus

        public void updateKeyStatus()
        This method blocks when another thread is running
      • getDN

        public java.lang.String getDN()
        Retrieves the DN of this repository.
      • addKeyRecord

        public void addKeyRecord​(com.netscape.certsrv.dbs.keydb.IKeyRecord record)
                          throws EBaseException
        Archives a key to the repository.

        Specified by:
        addKeyRecord in interface com.netscape.certsrv.dbs.keydb.IKeyRepository
        Parameters:
        record - key record
        Throws:
        EBaseException - failed to archive key
      • readKeyRecord

        public com.netscape.certsrv.dbs.keydb.IKeyRecord readKeyRecord​(java.math.BigInteger serialNo)
                                                                throws EBaseException
        Recovers an archived key by serial number.

        Specified by:
        readKeyRecord in interface com.netscape.certsrv.dbs.keydb.IKeyRepository
        Parameters:
        serialNo - serial number
        Returns:
        key record
        Throws:
        EBaseException - failed to recover key
      • readKeyRecord

        public com.netscape.certsrv.dbs.keydb.IKeyRecord readKeyRecord​(org.mozilla.jss.netscape.security.x509.X500Name ownerName)
                                                                throws EBaseException
        Recovers an archived key by owner name.

        Specified by:
        readKeyRecord in interface com.netscape.certsrv.dbs.keydb.IKeyRepository
        Parameters:
        ownerName - owner name
        Returns:
        key record
        Throws:
        EBaseException - failed to recover key
      • readKeyRecord

        public com.netscape.certsrv.dbs.keydb.IKeyRecord readKeyRecord​(java.security.PublicKey publicKey)
                                                                throws EBaseException
        Recovers archived key using public key.
        Specified by:
        readKeyRecord in interface com.netscape.certsrv.dbs.keydb.IKeyRepository
        Parameters:
        publicKey - public key that is corresponding to the private key
        Returns:
        key record
        Throws:
        EBaseException - failed to read key
      • readKeyRecord

        public com.netscape.certsrv.dbs.keydb.IKeyRecord readKeyRecord​(java.lang.String cert)
                                                                throws EBaseException
        Recovers archived key using b64 encoded cert
        Specified by:
        readKeyRecord in interface com.netscape.certsrv.dbs.keydb.IKeyRepository
        Parameters:
        cert - b64 encoded cert
        Returns:
        key record
        Throws:
        EBaseException - failed to recover key
      • modifyKeyRecord

        public void modifyKeyRecord​(java.math.BigInteger serialNo,
                                    com.netscape.certsrv.dbs.ModificationSet mods)
                             throws EBaseException
        Modifies key record.
        Specified by:
        modifyKeyRecord in interface com.netscape.certsrv.dbs.keydb.IKeyRepository
        Parameters:
        serialNo - key identifier
        mods - modification of key records
        Throws:
        EBaseException - failed to modify key record
      • deleteKeyRecord

        public void deleteKeyRecord​(java.math.BigInteger serialNo)
                             throws EBaseException
        Description copied from interface: com.netscape.certsrv.dbs.keydb.IKeyRepository
        Deletes a key record.
        Specified by:
        deleteKeyRecord in interface com.netscape.certsrv.dbs.keydb.IKeyRepository
        Parameters:
        serialNo - key identifier
        Throws:
        EBaseException - failed to delete key record
      • escapeBinaryData

        public static java.lang.String escapeBinaryData​(byte[] data)
        Read RFC-2254
      • searchKeys

        public java.util.Enumeration<com.netscape.certsrv.dbs.keydb.IKeyRecord> searchKeys​(java.lang.String filter,
                                                                                           int maxSize)
                                                                                    throws EBaseException
        Description copied from interface: com.netscape.certsrv.dbs.keydb.IKeyRepository
        Searches for private keys.
        Specified by:
        searchKeys in interface com.netscape.certsrv.dbs.keydb.IKeyRepository
        Parameters:
        filter - LDAP filter for the search
        maxSize - maximium number of entries to be returned
        Returns:
        a list of private key records
        Throws:
        EBaseException - failed to search keys
      • searchKeys

        public java.util.Enumeration<com.netscape.certsrv.dbs.keydb.IKeyRecord> searchKeys​(java.lang.String filter,
                                                                                           int maxSize,
                                                                                           int timeLimit)
                                                                                    throws EBaseException
        Description copied from interface: com.netscape.certsrv.dbs.keydb.IKeyRepository
        Searches for private keys.
        Specified by:
        searchKeys in interface com.netscape.certsrv.dbs.keydb.IKeyRepository
        Parameters:
        filter - LDAP filter for the search
        maxSize - maximium number of entries to be returned
        timeLimit - timeout value
        Returns:
        a list of private key records
        Throws:
        EBaseException - failed to search keys
      • findKeyRecordsInList

        public com.netscape.certsrv.dbs.keydb.IKeyRecordList findKeyRecordsInList​(java.lang.String filter,
                                                                                  java.lang.String[] attrs,
                                                                                  int pageSize)
                                                                           throws EBaseException
        Retrieves key record list.
        Specified by:
        findKeyRecordsInList in interface com.netscape.certsrv.dbs.keydb.IKeyRepository
        Parameters:
        filter - search filter
        attrs - list of attributes to be returned
        pageSize - virtual list page size
        Returns:
        list of key records
        Throws:
        EBaseException - failed to search key records
      • findKeyRecordsInList

        public com.netscape.certsrv.dbs.keydb.IKeyRecordList findKeyRecordsInList​(java.lang.String filter,
                                                                                  java.lang.String[] attrs,
                                                                                  java.lang.String sortKey,
                                                                                  int pageSize)
                                                                           throws EBaseException
        Description copied from interface: com.netscape.certsrv.dbs.keydb.IKeyRepository
        Searchs for a list of key records.
        Specified by:
        findKeyRecordsInList in interface com.netscape.certsrv.dbs.keydb.IKeyRepository
        Parameters:
        filter - search filter
        attrs - list of attributes to be returned
        sortKey - name of attribute that the list should be sorted by
        pageSize - virtual list page size
        Returns:
        list of key records
        Throws:
        EBaseException - failed to search key records
      • findKeyRecordsInList

        public com.netscape.certsrv.dbs.keydb.IKeyRecordList findKeyRecordsInList​(java.lang.String filter,
                                                                                  java.lang.String[] attrs,
                                                                                  java.lang.String jumpTo,
                                                                                  java.lang.String sortKey,
                                                                                  int pageSize)
                                                                           throws EBaseException
        Throws:
        EBaseException
      • shutdown

        public void shutdown()