Package com.netscape.cmscore.dbs
Class KeyRepository
- java.lang.Object
-
- com.netscape.cmscore.dbs.Repository
-
- com.netscape.cmscore.dbs.KeyRepository
-
- All Implemented Interfaces:
IKeyRepository
,IRepository
public class KeyRepository extends Repository implements IKeyRepository
A class represents a Key repository. This is the container of archived keys.- Version:
- $Revision$, $Date$
- Author:
- thomask
-
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.Logger
logger
protected IDBSubsystem
mDBService
com.netscape.cmscore.dbs.KeyStatusUpdateTask
mKeyStatusUpdateTask
-
Fields inherited from class com.netscape.cmscore.dbs.Repository
mCounter, mEnableRandomSerialNumbers, mMaxSerialNo, mMinSerialNo
-
-
Constructor Summary
Constructors Constructor Description KeyRepository(IDBSubsystem service, int increment, java.lang.String baseDN)
Constructs a key repository.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addKeyRecord(IKeyRecord record)
Archives a key to the repository.void
deleteKeyRecord(java.math.BigInteger serialNo)
Deletes a key record.static java.lang.String
escapeBinaryData(byte[] data)
Read RFC-2254IKeyRecordList
findKeyRecordsInList(java.lang.String filter, java.lang.String[] attrs, int pageSize)
Retrieves key record list.IKeyRecordList
findKeyRecordsInList(java.lang.String filter, java.lang.String[] attrs, java.lang.String sortKey, int pageSize)
Searchs for a list of key records.IKeyRecordList
findKeyRecordsInList(java.lang.String filter, java.lang.String[] attrs, java.lang.String jumpTo, java.lang.String sortKey, int pageSize)
IDBSubsystem
getDBSubsystem()
java.lang.String
getDN()
Retrieves the DN of this repository.java.math.BigInteger
getLastSerialNumberInRange(java.math.BigInteger serial_low_bound, java.math.BigInteger serial_upper_bound)
void
modifyKeyRecord(java.math.BigInteger serialNo, ModificationSet mods)
Modifies key record.IKeyRecord
readKeyRecord(java.lang.String cert)
Recovers archived key using b64 encoded certIKeyRecord
readKeyRecord(java.math.BigInteger serialNo)
Recovers an archived key by serial number.IKeyRecord
readKeyRecord(java.security.PublicKey publicKey)
Recovers archived key using public key.IKeyRecord
readKeyRecord(org.mozilla.jss.netscape.security.x509.X500Name ownerName)
Recovers an archived key by owner name.void
removeAllObjects()
Removes all objects with this repository.java.util.Enumeration<IKeyRecord>
searchKeys(java.lang.String filter, int maxSize)
Searches for private keys.java.util.Enumeration<IKeyRecord>
searchKeys(java.lang.String filter, int maxSize, int timeLimit)
Searches for private keys.void
setKeyStatusUpdateInterval(IRepository requestRepo, int interval)
void
shutdown()
void
updateKeyStatus()
This method blocks when another thread is running-
Methods inherited from class com.netscape.cmscore.dbs.Repository
checkRange, checkRanges, getMaxSerial, getMinSerial, getNextMaxSerial, getNextSerialNumber, getSerialNumber, initCacheIfNeeded, peekNextSerialNumber, resetSerialNumber, setEnableSerialMgmt, setLastSerialNo, setMaxSerial, setNextMaxSerial, setSerialNumber, setTheSerialNumber
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.netscape.certsrv.dbs.repository.IRepository
checkRanges, getNextSerialNumber, peekNextSerialNumber, resetSerialNumber, setEnableSerialMgmt, setMaxSerial, setNextMaxSerial
-
-
-
-
Field Detail
-
logger
public static org.slf4j.Logger logger
-
mKeyStatusUpdateTask
public com.netscape.cmscore.dbs.KeyStatusUpdateTask mKeyStatusUpdateTask
-
mDBService
protected IDBSubsystem mDBService
-
-
Constructor Detail
-
KeyRepository
public KeyRepository(IDBSubsystem service, int increment, java.lang.String baseDN) throws 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 repositoryEDBException
-
-
Method Detail
-
setKeyStatusUpdateInterval
public void setKeyStatusUpdateInterval(IRepository requestRepo, int interval)
-
updateKeyStatus
public void updateKeyStatus()
This method blocks when another thread is running
-
getDBSubsystem
public IDBSubsystem getDBSubsystem()
-
getDN
public java.lang.String getDN()
Retrieves the DN of this repository.
-
removeAllObjects
public void removeAllObjects() throws EBaseException
Removes all objects with this repository.- Throws:
EBaseException
-
addKeyRecord
public void addKeyRecord(IKeyRecord record) throws EBaseException
Archives a key to the repository.- Specified by:
addKeyRecord
in interfaceIKeyRepository
- Parameters:
record
- key record- Throws:
EBaseException
- failed to archive key
-
readKeyRecord
public IKeyRecord readKeyRecord(java.math.BigInteger serialNo) throws EBaseException
Recovers an archived key by serial number.- Specified by:
readKeyRecord
in interfaceIKeyRepository
- Parameters:
serialNo
- serial number- Returns:
- key record
- Throws:
EBaseException
- failed to recover key
-
readKeyRecord
public IKeyRecord readKeyRecord(org.mozilla.jss.netscape.security.x509.X500Name ownerName) throws EBaseException
Recovers an archived key by owner name.- Specified by:
readKeyRecord
in interfaceIKeyRepository
- Parameters:
ownerName
- owner name- Returns:
- key record
- Throws:
EBaseException
- failed to recover key
-
readKeyRecord
public IKeyRecord readKeyRecord(java.security.PublicKey publicKey) throws EBaseException
Recovers archived key using public key.- Specified by:
readKeyRecord
in interfaceIKeyRepository
- Parameters:
publicKey
- public key that is corresponding to the private key- Returns:
- key record
- Throws:
EBaseException
- failed to read key
-
readKeyRecord
public IKeyRecord readKeyRecord(java.lang.String cert) throws EBaseException
Recovers archived key using b64 encoded cert- Specified by:
readKeyRecord
in interfaceIKeyRepository
- Parameters:
cert
- b64 encoded cert- Returns:
- key record
- Throws:
EBaseException
- failed to recover key
-
modifyKeyRecord
public void modifyKeyRecord(java.math.BigInteger serialNo, ModificationSet mods) throws EBaseException
Modifies key record.- Specified by:
modifyKeyRecord
in interfaceIKeyRepository
- Parameters:
serialNo
- key identifiermods
- 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:IKeyRepository
Deletes a key record.- Specified by:
deleteKeyRecord
in interfaceIKeyRepository
- 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<IKeyRecord> searchKeys(java.lang.String filter, int maxSize) throws EBaseException
Description copied from interface:IKeyRepository
Searches for private keys.- Specified by:
searchKeys
in interfaceIKeyRepository
- Parameters:
filter
- LDAP filter for the searchmaxSize
- 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<IKeyRecord> searchKeys(java.lang.String filter, int maxSize, int timeLimit) throws EBaseException
Description copied from interface:IKeyRepository
Searches for private keys.- Specified by:
searchKeys
in interfaceIKeyRepository
- Parameters:
filter
- LDAP filter for the searchmaxSize
- maximium number of entries to be returnedtimeLimit
- timeout value- Returns:
- a list of private key records
- Throws:
EBaseException
- failed to search keys
-
findKeyRecordsInList
public IKeyRecordList findKeyRecordsInList(java.lang.String filter, java.lang.String[] attrs, int pageSize) throws EBaseException
Retrieves key record list.- Specified by:
findKeyRecordsInList
in interfaceIKeyRepository
- Parameters:
filter
- search filterattrs
- list of attributes to be returnedpageSize
- virtual list page size- Returns:
- list of key records
- Throws:
EBaseException
- failed to search key records
-
findKeyRecordsInList
public IKeyRecordList findKeyRecordsInList(java.lang.String filter, java.lang.String[] attrs, java.lang.String sortKey, int pageSize) throws EBaseException
Description copied from interface:IKeyRepository
Searchs for a list of key records.- Specified by:
findKeyRecordsInList
in interfaceIKeyRepository
- Parameters:
filter
- search filterattrs
- list of attributes to be returnedsortKey
- name of attribute that the list should be sorted bypageSize
- virtual list page size- Returns:
- list of key records
- Throws:
EBaseException
- failed to search key records
-
findKeyRecordsInList
public IKeyRecordList findKeyRecordsInList(java.lang.String filter, java.lang.String[] attrs, java.lang.String jumpTo, java.lang.String sortKey, int pageSize) throws EBaseException
- Throws:
EBaseException
-
getLastSerialNumberInRange
public java.math.BigInteger getLastSerialNumberInRange(java.math.BigInteger serial_low_bound, java.math.BigInteger serial_upper_bound) throws EBaseException
- Specified by:
getLastSerialNumberInRange
in classRepository
- Throws:
EBaseException
-
shutdown
public void shutdown()
-
-