>From 93c276e162194c25588c72165b656e4afae84d01 Mon Sep 17 00:00:00 2001
From: Christina Fu <cfu@redhat.com>
Date: Tue, 3 Jun 2014 16:42:10 -0700
Subject: [PATCH] TPS Token Profile Resolver Framework - part2

---
 base/server/etc/default.cfg                                         | 1 +
 base/server/python/pki/server/deployment/pkiparser.py               | 4 ++++
 .../python/pki/server/deployment/scriptlets/slot_substitution.py    | 3 +++
 .../src/org/dogtagpki/server/tps/profile/TokenProfileParams.java    | 6 +++---
 4 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/base/server/etc/default.cfg b/base/server/etc/default.cfg
index 9f6859b76eb75792093656aa5c90fedf873785de..87c197baa59f2880c8079741f3daceaf4326cfcd 100644
--- a/base/server/etc/default.cfg
+++ b/base/server/etc/default.cfg
@@ -607,6 +607,7 @@ pki_import_shared_secret=False
 pki_share_db=True
 pki_share_dbuser_dn=uid=pkidbuser,ou=people,o=%(pki_instance_name)s-CA
 pki_source_phone_home_xml=/usr/share/pki/%(pki_subsystem_type)s/conf/phoneHome.xml
+pki_source_registry_cfg=%(pki_source_conf_path)s/registry.cfg
 
 # Paths
 # These are used in the processing of pkispawn and are not supposed
diff --git a/base/server/python/pki/server/deployment/pkiparser.py b/base/server/python/pki/server/deployment/pkiparser.py
index 8fb29dedc16e3853f15190678a368b287f1c6ef1..2759ceeefd928c387e3d8fcf23d468640b7af41a 100644
--- a/base/server/python/pki/server/deployment/pkiparser.py
+++ b/base/server/python/pki/server/deployment/pkiparser.py
@@ -712,6 +712,10 @@ class PKIConfigParser:
                                      ['pki_subsystem_configuration_path'],
                                      "transportCert.profile")
                 elif self.pki_master_dict['pki_subsystem'] == "TPS":
+                    self.pki_master_dict['pki_target_registry_cfg'] = \
+                        os.path.join(self.pki_master_dict\
+                                     ['pki_subsystem_configuration_path'],
+                                     "registry.cfg")
                     self.pki_master_dict['pki_target_phone_home_xml'] = \
                         os.path.join(
                             self.pki_master_dict['pki_subsystem_configuration_path'],
diff --git a/base/server/python/pki/server/deployment/scriptlets/slot_substitution.py b/base/server/python/pki/server/deployment/scriptlets/slot_substitution.py
index 1c13bdbd1db1f37ef515b628e99d0345cfb41b8c..88bdf94b78b9cfc06df488c4898c8fccab1762f3 100644
--- a/base/server/python/pki/server/deployment/scriptlets/slot_substitution.py
+++ b/base/server/python/pki/server/deployment/scriptlets/slot_substitution.py
@@ -94,6 +94,9 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                     deployer.master_dict['pki_target_profileselect_template'])
             elif deployer.master_dict['pki_subsystem'] == "TPS":
                 deployer.file.copy_with_slot_substitution(
+                    deployer.master_dict['pki_source_registry_cfg'],
+                    deployer.master_dict['pki_target_registry_cfg'])
+                deployer.file.copy_with_slot_substitution(
                     deployer.master_dict['pki_source_phone_home_xml'],
                     deployer.master_dict['pki_target_phone_home_xml'])
         return self.rv
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/profile/TokenProfileParams.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/profile/TokenProfileParams.java
index b4789373eb9583674936118ef0897ddea7670d75..1dda47ad84fef76a66b148b80503c73d624855b9 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/profile/TokenProfileParams.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/profile/TokenProfileParams.java
@@ -80,7 +80,7 @@ public class TokenProfileParams {
             CMS.debug("TokenProfileParams.getString: param null:"+ name);
             throw new TPSException (
                     "TokenProfileParams.getString: param null:"+ name,
-                    TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND);
+                    TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_PARAMS_NOT_FOUND);
         }
         return val;
     }
@@ -98,7 +98,7 @@ public class TokenProfileParams {
             CMS.debug("TokenProfileParams.getInt: param null:"+ name);
             throw new TPSException (
                     "TokenProfileParams.getInt: param null:"+ name,
-                    TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND);
+                    TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_PARAMS_NOT_FOUND);
         }
         try {
             int intVal = Integer.parseInt(val);
@@ -107,7 +107,7 @@ public class TokenProfileParams {
             CMS.debug("TokenProfileParams.getInt: param "+ name + "=" + val + e);
             throw new TPSException (
                     "TokenProfileParams.getInt: param major_version:"+ e,
-                    TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND);
+                    TPSStatus.STATUS_ERROR_MISCONFIGURATION);
         }
     }
 
-- 
1.8.4.2

