diff options
Diffstat (limited to 'base/tps-tomcat/src/org/dogtagpki/server/tps/config')
6 files changed, 515 insertions, 0 deletions
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionDatabase.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionDatabase.java new file mode 100644 index 000000000..35eb382ea --- /dev/null +++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionDatabase.java @@ -0,0 +1,145 @@ +// --- 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) 2013 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- + +package org.dogtagpki.server.tps.config; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; + +import com.netscape.certsrv.apps.CMS; +import com.netscape.certsrv.base.EBaseException; +import com.netscape.certsrv.base.IConfigStore; +import com.netscape.cmscore.dbs.CSCfgDatabase; + +/** + * This class provides access to the connections in CS.cfg. + * + * @author Endi S. Dewata + */ +public class ConnectionDatabase extends CSCfgDatabase<ConnectionRecord> { + + IConfigStore configStore = CMS.getConfigStore(); + + public ConnectionDatabase() { + super("Connection", "Subsystem_Connections"); + } + + public ConnectionRecord createConnectionRecord(ConfigDatabase configDatabase, ConfigRecord configRecord, String connectionID) throws EBaseException { + ConnectionRecord connectionRecord = new ConnectionRecord(); + connectionRecord.setID(connectionID); + + String status = getRecordStatus(connectionID); + connectionRecord.setStatus(status); + + Map<String, String> properties = configDatabase.getProperties(configRecord, connectionID); + connectionRecord.setProperties(properties); + return connectionRecord; + } + + @Override + public Collection<ConnectionRecord> getRecords() throws Exception { + + Collection<ConnectionRecord> result = new ArrayList<ConnectionRecord>(); + ConfigDatabase configDatabase = new ConfigDatabase(); + ConfigRecord configRecord = configDatabase.getRecord("Subsystem_Connections"); + + for (String connectionID : configRecord.getKeys()) { + ConnectionRecord connectionRecord = createConnectionRecord(configDatabase, configRecord, connectionID); + result.add(connectionRecord); + } + + return result; + } + + @Override + public ConnectionRecord getRecord(String connectionID) throws Exception { + + ConfigDatabase configDatabase = new ConfigDatabase(); + ConfigRecord configRecord = configDatabase.getRecord(substoreName); + + return createConnectionRecord(configDatabase, configRecord, connectionID); + } + + @Override + public void addRecord(String connectionID, ConnectionRecord connectionRecord) throws Exception { + + CMS.debug("ConnectionDatabase.addRecord(\"" + connectionID + "\")"); + ConfigDatabase configDatabase = new ConfigDatabase(); + ConfigRecord configRecord = configDatabase.getRecord(substoreName); + + // validate new properties + Map<String, String> properties = connectionRecord.getProperties(); + configDatabase.validateProperties(configRecord, connectionID, properties); + + // add new connection + configRecord.addKey(connectionID); + configDatabase.updateRecord(substoreName, configRecord); + + // store new properties + configDatabase.addProperties(configRecord, connectionID, properties); + + // create status + createRecordStatus(connectionID, connectionRecord.getStatus()); + + configDatabase.commit(); + } + + @Override + public void updateRecord(String connectionID, ConnectionRecord connectionRecord) throws Exception { + + CMS.debug("ConnectionDatabase.updateRecord(\"" + connectionID + "\")"); + ConfigDatabase configDatabase = new ConfigDatabase(); + ConfigRecord configRecord = configDatabase.getRecord(substoreName); + + // validate new properties + Map<String, String> properties = connectionRecord.getProperties(); + configDatabase.validateProperties(configRecord, connectionID, properties); + + // remove old properties + configDatabase.removeProperties(configRecord, connectionID); + + // add new properties + configDatabase.addProperties(configRecord, connectionID, properties); + + // update status + setRecordStatus(connectionID, connectionRecord.getStatus()); + + configDatabase.commit(); + } + + @Override + public void removeRecord(String connectionID) throws Exception { + + CMS.debug("ConnectionDatabase.removeRecord(\"" + connectionID + "\")"); + ConfigDatabase configDatabase = new ConfigDatabase(); + ConfigRecord configRecord = configDatabase.getRecord(substoreName); + + // remove properties + configDatabase.removeProperties(configRecord, connectionID); + + // remove connection + configRecord.removeKey(connectionID); + configDatabase.updateRecord(substoreName, configRecord); + + // remove status + removeRecordStatus(connectionID); + + configDatabase.commit(); + } +} diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionRecord.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionRecord.java new file mode 100644 index 000000000..3a2f78037 --- /dev/null +++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionRecord.java @@ -0,0 +1,28 @@ +// --- 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) 2013 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- + +package org.dogtagpki.server.tps.config; + +import com.netscape.cmscore.dbs.CSCfgRecord; + + +/** + * @author Endi S. Dewata + */ +public class ConnectionRecord extends CSCfgRecord { +} diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileDatabase.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileDatabase.java new file mode 100644 index 000000000..6054bf38d --- /dev/null +++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileDatabase.java @@ -0,0 +1,143 @@ +// --- 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) 2013 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- + +package org.dogtagpki.server.tps.config; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; + +import com.netscape.certsrv.apps.CMS; +import com.netscape.certsrv.base.EBaseException; +import com.netscape.cmscore.dbs.CSCfgDatabase; + +/** + * This class provides access to the profiles in CS.cfg. + * + * @author Endi S. Dewata + */ +public class ProfileDatabase extends CSCfgDatabase<ProfileRecord> { + + public ProfileDatabase() { + super("Profile", "Profiles"); + } + + public ProfileRecord createProfileRecord(ConfigDatabase configDatabase, ConfigRecord configRecord, String profileID) throws EBaseException { + ProfileRecord profileRecord = new ProfileRecord(); + profileRecord.setID(profileID); + + String status = getRecordStatus(profileID); + profileRecord.setStatus(status); + + Map<String, String> properties = configDatabase.getProperties(configRecord, profileID); + profileRecord.setProperties(properties); + + return profileRecord; + } + + @Override + public Collection<ProfileRecord> getRecords() throws Exception { + + Collection<ProfileRecord> result = new ArrayList<ProfileRecord>(); + ConfigDatabase configDatabase = new ConfigDatabase(); + ConfigRecord configRecord = configDatabase.getRecord(substoreName); + + for (String profileID : configRecord.getKeys()) { + ProfileRecord profileRecord = createProfileRecord(configDatabase, configRecord, profileID); + result.add(profileRecord); + } + + return result; + } + + @Override + public ProfileRecord getRecord(String profileID) throws Exception { + + ConfigDatabase configDatabase = new ConfigDatabase(); + ConfigRecord configRecord = configDatabase.getRecord(substoreName); + + return createProfileRecord(configDatabase, configRecord, profileID); + } + + @Override + public void addRecord(String profileID, ProfileRecord profileRecord) throws Exception { + + CMS.debug("ProfileDatabase.addRecord(\"" + profileID + "\")"); + ConfigDatabase configDatabase = new ConfigDatabase(); + ConfigRecord configRecord = configDatabase.getRecord(substoreName); + + // validate new properties + Map<String, String> properties = profileRecord.getProperties(); + configDatabase.validateProperties(configRecord, profileID, properties); + + // add new profile + configRecord.addKey(profileID); + configDatabase.updateRecord(substoreName, configRecord); + + // store new properties + configDatabase.addProperties(configRecord, profileID, properties); + + // create status + createRecordStatus(profileID, profileRecord.getStatus()); + + configDatabase.commit(); + } + + @Override + public void updateRecord(String profileID, ProfileRecord profileRecord) throws Exception { + + CMS.debug("ProfileDatabase.updateRecord(\"" + profileID + "\")"); + ConfigDatabase configDatabase = new ConfigDatabase(); + ConfigRecord configRecord = configDatabase.getRecord(substoreName); + + // validate new properties + Map<String, String> properties = profileRecord.getProperties(); + configDatabase.validateProperties(configRecord, profileID, properties); + + // remove old properties + configDatabase.removeProperties(configRecord, profileID); + + // add new properties + configDatabase.addProperties(configRecord, profileID, properties); + + // update status + setRecordStatus(profileID, profileRecord.getStatus()); + + configDatabase.commit(); + } + + @Override + public void removeRecord(String profileID) throws Exception { + + CMS.debug("ProfileDatabase.removeRecord(\"" + profileID + "\")"); + ConfigDatabase configDatabase = new ConfigDatabase(); + ConfigRecord configRecord = configDatabase.getRecord(substoreName); + + // remove properties + configDatabase.removeProperties(configRecord, profileID); + + // remove profile + configRecord.removeKey(profileID); + configDatabase.updateRecord(substoreName, configRecord); + + // remove status + removeRecordStatus(profileID); + + configDatabase.commit(); + } +} diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileMappingDatabase.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileMappingDatabase.java new file mode 100644 index 000000000..dca0beb02 --- /dev/null +++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileMappingDatabase.java @@ -0,0 +1,143 @@ +// --- 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) 2013 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- + +package org.dogtagpki.server.tps.config; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; + +import com.netscape.certsrv.apps.CMS; +import com.netscape.certsrv.base.EBaseException; +import com.netscape.cmscore.dbs.CSCfgDatabase; + +/** + * This class provides access to the profileMappings in CS.cfg. + * + * @author Endi S. Dewata + */ +public class ProfileMappingDatabase extends CSCfgDatabase<ProfileMappingRecord> { + + public ProfileMappingDatabase() { + super("Profile Mapping", "Profile_Mappings"); + } + + public ProfileMappingRecord createProfileMappingRecord(ConfigDatabase configDatabase, ConfigRecord configRecord, String profileMappingID) throws EBaseException { + ProfileMappingRecord profileMappingRecord = new ProfileMappingRecord(); + profileMappingRecord.setID(profileMappingID); + + String status = getRecordStatus(profileMappingID); + profileMappingRecord.setStatus(status); + + Map<String, String> properties = configDatabase.getProperties(configRecord, profileMappingID); + profileMappingRecord.setProperties(properties); + return profileMappingRecord; + } + + @Override + public Collection<ProfileMappingRecord> getRecords() throws Exception { + + Collection<ProfileMappingRecord> result = new ArrayList<ProfileMappingRecord>(); + ConfigDatabase configDatabase = new ConfigDatabase(); + ConfigRecord configRecord = configDatabase.getRecord(substoreName); + + for (String profileMappingID : configRecord.getKeys()) { + ProfileMappingRecord profileMappingRecord = createProfileMappingRecord(configDatabase, configRecord, profileMappingID); + result.add(profileMappingRecord); + } + + return result; + } + + @Override + public ProfileMappingRecord getRecord(String profileMappingID) throws Exception { + + ConfigDatabase configDatabase = new ConfigDatabase(); + ConfigRecord configRecord = configDatabase.getRecord(substoreName); + + return createProfileMappingRecord(configDatabase, configRecord, profileMappingID); + } + + + @Override + public void addRecord(String profileMappingID, ProfileMappingRecord profileMappingRecord) throws Exception { + + CMS.debug("ProfileMappingDatabase.addRecord(\"" + profileMappingID + "\")"); + ConfigDatabase configDatabase = new ConfigDatabase(); + ConfigRecord configRecord = configDatabase.getRecord(substoreName); + + // validate new properties + Map<String, String> properties = profileMappingRecord.getProperties(); + configDatabase.validateProperties(configRecord, profileMappingID, properties); + + // add new profileMapping + configRecord.addKey(profileMappingID); + configDatabase.updateRecord(substoreName, configRecord); + + // store new properties + configDatabase.addProperties(configRecord, profileMappingID, properties); + + // create status + createRecordStatus(profileMappingID, profileMappingRecord.getStatus()); + + configDatabase.commit(); + } + + @Override + public void updateRecord(String profileMappingID, ProfileMappingRecord profileMappingRecord) throws Exception { + + CMS.debug("ProfileMappingDatabase.updateRecord(\"" + profileMappingID + "\")"); + ConfigDatabase configDatabase = new ConfigDatabase(); + ConfigRecord configRecord = configDatabase.getRecord(substoreName); + + // validate new properties + Map<String, String> properties = profileMappingRecord.getProperties(); + configDatabase.validateProperties(configRecord, profileMappingID, properties); + + // remove old properties + configDatabase.removeProperties(configRecord, profileMappingID); + + // add new properties + configDatabase.addProperties(configRecord, profileMappingID, properties); + + // update status + setRecordStatus(profileMappingID, profileMappingRecord.getStatus()); + + configDatabase.commit(); + } + + @Override + public void removeRecord(String profileMappingID) throws Exception { + + CMS.debug("ProfileMappingDatabase.removeRecord(\"" + profileMappingID + "\")"); + ConfigDatabase configDatabase = new ConfigDatabase(); + ConfigRecord configRecord = configDatabase.getRecord(substoreName); + + // remove properties + configDatabase.removeProperties(configRecord, profileMappingID); + + // remove profileMapping + configRecord.removeKey(profileMappingID); + configDatabase.updateRecord(substoreName, configRecord); + + // remove status + removeRecordStatus(profileMappingID); + + configDatabase.commit(); + } +} diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileMappingRecord.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileMappingRecord.java new file mode 100644 index 000000000..92793ce5e --- /dev/null +++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileMappingRecord.java @@ -0,0 +1,28 @@ +// --- 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) 2013 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- + +package org.dogtagpki.server.tps.config; + +import com.netscape.cmscore.dbs.CSCfgRecord; + + +/** + * @author Endi S. Dewata + */ +public class ProfileMappingRecord extends CSCfgRecord { +} diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileRecord.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileRecord.java new file mode 100644 index 000000000..a84b7f5ba --- /dev/null +++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileRecord.java @@ -0,0 +1,28 @@ +// --- 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) 2013 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- + +package org.dogtagpki.server.tps.config; + +import com.netscape.cmscore.dbs.CSCfgRecord; + + +/** + * @author Endi S. Dewata + */ +public class ProfileRecord extends CSCfgRecord { +} |