diff options
author | mharmsen <mharmsen@c9f7a03b-bd48-0410-a16d-cbbf54688b0b> | 2011-10-29 04:43:21 +0000 |
---|---|---|
committer | mharmsen <mharmsen@c9f7a03b-bd48-0410-a16d-cbbf54688b0b> | 2011-10-29 04:43:21 +0000 |
commit | db615a895b644af038308ae71b680f1d93f78f70 (patch) | |
tree | 6d1a4510d625fd4d6afe2848b8de686af74a118a /pki/base/common/src/com/netscape/certsrv/dbs/keydb | |
parent | a8a64c7f1dcaf3012fa8d3cd164c890ceb146d0d (diff) | |
download | pki-DOGTAG_9_0_FEDORA_15_16_17_20111028.tar.gz pki-DOGTAG_9_0_FEDORA_15_16_17_20111028.tar.xz pki-DOGTAG_9_0_FEDORA_15_16_17_20111028.zip |
Bugzilla Bug #737761 - Update Dogtag Packages for Fedora 16DOGTAG_9_0_FEDORA_15_16_17_20111028
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/pki/tags/DOGTAG_9_0_FEDORA_15_16_17_20111028@2279 c9f7a03b-bd48-0410-a16d-cbbf54688b0b
Diffstat (limited to 'pki/base/common/src/com/netscape/certsrv/dbs/keydb')
4 files changed, 458 insertions, 0 deletions
diff --git a/pki/base/common/src/com/netscape/certsrv/dbs/keydb/IKeyRecord.java b/pki/base/common/src/com/netscape/certsrv/dbs/keydb/IKeyRecord.java new file mode 100644 index 000000000..f795ff9a6 --- /dev/null +++ b/pki/base/common/src/com/netscape/certsrv/dbs/keydb/IKeyRecord.java @@ -0,0 +1,125 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.certsrv.dbs.keydb; + + +import java.util.*; +import java.math.*; +import com.netscape.certsrv.base.*; + + +/** + * An interface contains constants for key record. + * + * @version $Revision$, $Date$ + */ +public interface IKeyRecord { + public static final String ATTR_ID = "keySerialNumber"; + public static final String ATTR_STATE = "keyState"; + public static final String ATTR_ALGORITHM = "algorithm"; + public static final String ATTR_KEY_SIZE = "keySize"; + public static final String ATTR_OWNER_NAME = "keyOwnerName"; + public static final String ATTR_PRIVATE_KEY_DATA = "privateKey"; + public static final String ATTR_PUBLIC_KEY_DATA = "publicKey"; + public static final String ATTR_DATE_OF_RECOVERY = "dateOfRecovery"; + public static final String ATTR_CREATE_TIME = "keyCreateTime"; + public static final String ATTR_MODIFY_TIME = "keyModifyTime"; + public static final String ATTR_META_INFO = "keyMetaInfo"; + public static final String ATTR_ARCHIVED_BY = "keyArchivedBy"; + + // key state + public static final String STATUS_ANY = "ANY"; + public static final String STATUS_VALID = "VALID"; + public static final String STATUS_INVALID = "INVALID"; + + /** + * Retrieves the state of the key. + * + * @return key state + * @exception EBaseException failed to retrieve state of the key + */ + public KeyState getState() throws EBaseException; + + /** + * Retrieves key identifier. + * + * @return key id + * @exception EBaseException failed to retrieve key id + */ + public BigInteger getSerialNumber() throws EBaseException; + + /** + * Retrieves key owner name. + * + * @return key owner name + * @exception EBaseException failed to retrieve key owner name + */ + public String getOwnerName() throws EBaseException; + + /** + * Retrieves key algorithm. + * + * @return key algorithm + */ + public String getAlgorithm(); + + /** + * Retrieves key length. + * + * @return key length + * @exception EBaseException failed to retrieve key length + */ + public Integer getKeySize() throws EBaseException; + + /** + * Retrieves archiver identifier. + * + * @return archiver uid + */ + public String getArchivedBy(); + + /** + * Retrieves creation time. + * + * @return creation time + */ + public Date getCreateTime(); + + /** + * Retrieves last modification time. + * + * @return modification time + */ + public Date getModifyTime(); + + /** + * Retrieves dates of recovery. + * + * @return recovery history + * @exception EBaseException failed to retrieve recovery history + */ + public Date[] getDateOfRevocation() throws EBaseException; + + /** + * Retrieves public key data. + * + * @return public key data + * @exception EBaseException failed to retrieve public key data + */ + public byte[] getPublicKeyData() throws EBaseException; +} diff --git a/pki/base/common/src/com/netscape/certsrv/dbs/keydb/IKeyRecordList.java b/pki/base/common/src/com/netscape/certsrv/dbs/keydb/IKeyRecordList.java new file mode 100644 index 000000000..aced5cc1f --- /dev/null +++ b/pki/base/common/src/com/netscape/certsrv/dbs/keydb/IKeyRecordList.java @@ -0,0 +1,54 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.certsrv.dbs.keydb; + + +import java.util.*; +import java.io.*; +import java.math.*; +import com.netscape.certsrv.base.*; +import com.netscape.certsrv.dbs.*; +import com.netscape.certsrv.dbs.repository.*; + + +/** + * A class represents a list of key records. + * <P> + * + * @version $Revision$, $Date$ + */ +public interface IKeyRecordList { + + /** + * Retrieves the size of key list. + * + * @return size of key list + */ + public int getSize(); + + /** + * Retrieves key records. + * + * @param startidx start index + * @param endidx end index + * @return key records + * @exception EBaseException failed to retrieve key records + */ + public Enumeration getKeyRecords(int startidx, int endidx) + throws EBaseException; +} diff --git a/pki/base/common/src/com/netscape/certsrv/dbs/keydb/IKeyRepository.java b/pki/base/common/src/com/netscape/certsrv/dbs/keydb/IKeyRepository.java new file mode 100644 index 000000000..324a7df17 --- /dev/null +++ b/pki/base/common/src/com/netscape/certsrv/dbs/keydb/IKeyRepository.java @@ -0,0 +1,177 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.certsrv.dbs.keydb; + + +import java.math.*; +import java.io.*; +import java.util.*; +import java.security.*; +import java.security.cert.*; +import netscape.security.x509.*; +import netscape.ldap.*; +import com.netscape.certsrv.*; +import com.netscape.certsrv.base.*; +import com.netscape.certsrv.dbs.*; +import com.netscape.certsrv.dbs.repository.*; + + +/** + * An interface represents a Key repository. This is the + * container of archived keys. + * <P> + * + * @version $Revision$, $Date$ + */ +public interface IKeyRepository extends IRepository { + + /** + * Archives a key to the repository. + * <P> + * + * @param record key record + * @exception EBaseException failed to archive key + */ + public void addKeyRecord(IKeyRecord record) throws EBaseException; + + /** + * Reads an archived key by serial number. + * <P> + * + * @param serialNo serial number + * @return key record + * @exception EBaseException failed to recover key + */ + public IKeyRecord readKeyRecord(BigInteger serialNo) + throws EBaseException; + + /** + * Reads an archived key by b64 encoded cert. + * <P> + * + * @param cert b64 encoded cert + * @return key record + * @exception EBaseException failed to recover key + */ + public IKeyRecord readKeyRecord(String cert) + throws EBaseException; + + /** + * Reads an archived key by owner name. + * <P> + * + * @param ownerName owner name + * @return key record + * @exception EBaseException failed to recover key + */ + public IKeyRecord readKeyRecord(X500Name ownerName) + throws EBaseException; + + /** + * Reads archived key using public key. + * + * @param publicKey public key that is corresponding + * to the private key + * @return key record + * @exception EBaseException failed to read key + */ + public IKeyRecord readKeyRecord(PublicKey publicKey) + throws EBaseException; + + /** + * Searches for private keys. + * + * @param filter LDAP filter for the search + * @param maxSize maximium number of entries to be returned + * @return a list of private key records + * @exception EBaseException failed to search keys + */ + public Enumeration searchKeys(String filter, int maxSize) + throws EBaseException; + + /** + * Searches for private keys. + * + * @param filter LDAP filter for the search + * @param maxSize maximium number of entries to be returned + * @param timeLimt timeout value + * @return a list of private key records + * @exception EBaseException failed to search keys + */ + public Enumeration searchKeys(String filter, int maxSize, int timeLimt) + throws EBaseException; + + /** + * Deletes a key record. + * + * @param serialno key identifier + * @exception EBaseException failed to delete key record + */ + public void deleteKeyRecord(BigInteger serialno) + throws EBaseException; + + /** + * Modifies key record in this repository. + * + * @param serialNo key identifier + * @param mods modification of key records + * @exception EBaseException failed to modify key record + */ + public void modifyKeyRecord(BigInteger serialNo, + ModificationSet mods) throws EBaseException; + + /** + * Searchs for a list of key records. + * Here is a list of supported filter attributes: + * <pre> + * keySerialNumber + * keyState + * algorithm + * keySize + * keyOwnerName + * privateKey + * publicKey + * dateOfRecovery + * keyCreateTime + * keyModifyTime + * keyMetaInfo + * </pre> + * + * @param filter search filter + * @param attrs list of attributes to be returned + * @param pageSize virtual list page size + * @return list of key records + * @exception EBaseException failed to search key records + */ + public IKeyRecordList findKeyRecordsInList(String filter, + String attrs[], int pageSize) throws EBaseException; + + /** + * Searchs for a list of key records. + * + * @param filter search filter + * @param attrs list of attributes to be returned + * @param sortKey name of attribute that the list should be sorted by + * @param pageSize virtual list page size + * @return list of key records + * @exception EBaseException failed to search key records + */ + public IKeyRecordList findKeyRecordsInList(String filter, + String attrs[], String sortKey, int pageSize) + throws EBaseException; +} diff --git a/pki/base/common/src/com/netscape/certsrv/dbs/keydb/KeyState.java b/pki/base/common/src/com/netscape/certsrv/dbs/keydb/KeyState.java new file mode 100644 index 000000000..a6b7fa031 --- /dev/null +++ b/pki/base/common/src/com/netscape/certsrv/dbs/keydb/KeyState.java @@ -0,0 +1,102 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.certsrv.dbs.keydb; + + +import java.util.*; +import java.io.*; +import netscape.security.x509.*; +import com.netscape.certsrv.base.*; + + +/** + * A class represents key state. This object is to + * encapsulate the life cycle of a key. + * <P> + * + * @version $Revision$, $Date$ + */ +public final class KeyState implements Serializable { + + private int mStateCode; + + /** + * Constructs a key state. + */ + private KeyState(int code) { + mStateCode = code; + } + + /** + * Request state. + */ + public final static KeyState ANY = new KeyState(-1); + public final static KeyState VALID = new KeyState(0); + public final static KeyState INVALID = new KeyState(1); + + /** + * Checks if the given object equals to this object. + * + * @param other object to be compared + * @return true if both objects are the same + */ + public boolean equals(Object other) { + if (this == other) + return true; + else if (other instanceof KeyState) + return ((KeyState) other).mStateCode == mStateCode; + else + return false; + } + + /** + * Returns the hash code. + * + * @return hash code + */ + public int hashCode() { + return mStateCode; + } + + /** + * Return the string-representation of this object. + * + * @return string value + */ + public String toString() { + if (mStateCode == -1) return "ANY"; + if (mStateCode == 0) return "VALID"; + if (mStateCode == 1) return "INVAILD"; + return "[UNDEFINED]"; + + } + + /** + * Converts a string into a key state object. + * + * @param state state in string-representation + * @return key state object + */ + public static KeyState toKeyState(String state) { + if (state.equalsIgnoreCase("ANY")) return ANY; + if (state.equalsIgnoreCase("VALID")) return VALID; + if (state.equalsIgnoreCase("INVALID")) return INVALID; + return null; + } +} + |