>From 428e39db89f1b1c9a636be2c75c5ed4d4765d59b Mon Sep 17 00:00:00 2001
From: Christina Fu <cfu@redhat.com>
Date: Wed, 13 May 2015 08:35:34 -0700
Subject: [PATCH] Ticket 1307 (part1 refactoring) [RFE] Support multiple
 keySets for different cards for ExternalReg This patch is mainly refactoring
 the names of the Mapping Resolver framework  in preparation for ticket 1307
 to support keySet mapping in addition to the  original purpose of resolving
 tokenType mapping. The reason to separate out  refactoring from the real code
 is for ease of reviewing. TPS is currently a  Tech Preview feature, so
 upgrade is not of consideration at the moment.

---
 .../common/src/org/dogtagpki/tps/msg/EndOpMsg.java |   8 +-
 base/tps/shared/conf/CS.cfg.in                     | 174 ++++++++++-----------
 base/tps/shared/conf/registry.cfg                  |  10 +-
 .../src/org/dogtagpki/server/tps/TPSSubsystem.java |  12 +-
 .../org/dogtagpki/server/tps/engine/TPSEngine.java |   2 +-
 .../BaseMappingResolver.java}                      |  12 +-
 .../FilterMappingParams.java}                      |  38 ++---
 .../FilterMappingResolver.java}                    | 141 +++++++++--------
 .../MappingResolverManager.java}                   |  68 ++++----
 .../server/tps/processor/TPSProcessor.java         |  30 ++--
 10 files changed, 249 insertions(+), 246 deletions(-)
 rename base/tps/src/org/dogtagpki/server/tps/{profile/BaseTokenProfileResolver.java => mapping/BaseMappingResolver.java} (64%)
 rename base/tps/src/org/dogtagpki/server/tps/{profile/TokenProfileParams.java => mapping/FilterMappingParams.java} (72%)
 rename base/tps/src/org/dogtagpki/server/tps/{profile/MappingTokenProfileResolver.java => mapping/FilterMappingResolver.java} (50%)
 rename base/tps/src/org/dogtagpki/server/tps/{profile/TokenProfileResolverManager.java => mapping/MappingResolverManager.java} (51%)

diff --git a/base/common/src/org/dogtagpki/tps/msg/EndOpMsg.java b/base/common/src/org/dogtagpki/tps/msg/EndOpMsg.java
index 2518985914d10d75de78579d86381969d9da2ce3..d9064769bee0761e3790ed3f30b62e5e78124e9d 100644
--- a/base/common/src/org/dogtagpki/tps/msg/EndOpMsg.java
+++ b/base/common/src/org/dogtagpki/tps/msg/EndOpMsg.java
@@ -44,8 +44,8 @@ public class EndOpMsg extends TPSMessage {
         STATUS_ERROR_UPGRADE_APPLET,
         STATUS_ERROR_KEY_CHANGE_OVER,
         STATUS_ERROR_EXTERNAL_AUTH,
-        STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND,
-        STATUS_ERROR_DEFAULT_TOKENTYPE_PARAMS_NOT_FOUND,
+        STATUS_ERROR_MAPPING_RESOLVER_FAILED, // was STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND
+        STATUS_ERROR_MAPPING_RESOLVER_PARAMS_NOT_FOUND, // was STATUS_ERROR_DEFAULT_TOKENTYPE_PARAMS_NOT_FOUND
         STATUS_ERROR_PUBLISH,
         STATUS_ERROR_LDAP_CONN,
         STATUS_ERROR_DISABLED_TOKEN,
@@ -153,10 +153,10 @@ public class EndOpMsg extends TPSMessage {
         case STATUS_ERROR_EXTERNAL_AUTH:
             result = 21;
             break;
-        case STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND:
+        case STATUS_ERROR_MAPPING_RESOLVER_FAILED:
             result = 22;
             break;
-        case STATUS_ERROR_DEFAULT_TOKENTYPE_PARAMS_NOT_FOUND:
+        case STATUS_ERROR_MAPPING_RESOLVER_PARAMS_NOT_FOUND:
             result = 23;
             break;
         case STATUS_ERROR_PUBLISH:
diff --git a/base/tps/shared/conf/CS.cfg.in b/base/tps/shared/conf/CS.cfg.in
index 4fa477dbc731db0da46df29d88563ea26d5aadae..aadcbfcb18f69a43d5d351ea579d28b22abe1804 100644
--- a/base/tps/shared/conf/CS.cfg.in
+++ b/base/tps/shared/conf/CS.cfg.in
@@ -789,7 +789,7 @@ op.enroll._032=# Token ATR:
 op.enroll._033=#   Web Store  - 3B759400006202020201
 op.enroll._034=#########################################
 op.enroll.allowUnknownToken=true
-op.enroll.tokenProfileResolver=enrollMappingResolver
+op.enroll.mappingResolver=enrollMappingResolver
 op.enroll.soKey.cuidMustMatchKDD=false
 op.enroll.soKey.enableBoundedGPKeyVersion=true
 op.enroll.soKey.minimumGPKeyVersion=01
@@ -1395,7 +1395,7 @@ op.enroll.userKey.update.applet.requiredVersion=1.4.4d40a449
 op.enroll.userKey.update.symmetricKeys.enable=false
 op.enroll.userKey.update.symmetricKeys.requiredVersion=1
 op.format.allowUnknownToken=true
-op.format.tokenProfileResolver=formatMappingResolver
+op.format.mappingResolver=formatMappingResolver
 op.format.cleanToken.cuidMustMatchKDD=false
 op.format.cleanToken.enableBoundedGPKeyVersion=true
 op.format.cleanToken.minimumGPKeyVersion=01
@@ -1543,7 +1543,7 @@ op.format.userKey.update.applet.encryption=true
 op.format.userKey.update.applet.requiredVersion=1.4.4d40a449
 op.format.userKey.update.symmetricKeys.enable=false
 op.format.userKey.update.symmetricKeys.requiredVersion=1
-op.pinReset.tokenProfileResolver=pinResetMappingResolver
+op.pinReset.mappingResolver=pinResetMappingResolver
 op.pinReset.userKey.cuidMustMatchKDD=false
 op.pinReset.userKey.enableBoundedGPKeyVersion=true
 op.pinReset.userKey.minimumGPKeyVersion=01
@@ -1655,89 +1655,89 @@ preop.system.name=TPS
 preop.wizard.name=TPS Setup Wizard
 proxy.securePort=[PKI_PROXY_SECURE_PORT]
 proxy.unsecurePort=[PKI_PROXY_UNSECURE_PORT]
-tokenProfileResolver.list=formatMappingResolver,enrollMappingResolver,pinResetMappingResolver
-tokenProfileResolver.enrollMappingResolver.class_id=mappingTokenProfileResolverImpl
-tokenProfileResolver.enrollMappingResolver.mapping.0.filter.appletMajorVersion=1
-tokenProfileResolver.enrollMappingResolver.mapping.0.filter.appletMinorVersion=
-tokenProfileResolver.enrollMappingResolver.mapping.0.filter.tokenATR=
-tokenProfileResolver.enrollMappingResolver.mapping.0.filter.tokenCUID.end=
-tokenProfileResolver.enrollMappingResolver.mapping.0.filter.tokenCUID.start=
-tokenProfileResolver.enrollMappingResolver.mapping.0.filter.tokenType=userKey
-tokenProfileResolver.enrollMappingResolver.mapping.0.target.tokenType=userKey
-tokenProfileResolver.enrollMappingResolver.mapping.1.filter.appletMajorVersion=
-tokenProfileResolver.enrollMappingResolver.mapping.1.filter.appletMinorVersion=
-tokenProfileResolver.enrollMappingResolver.mapping.1.filter.tokenATR=
-tokenProfileResolver.enrollMappingResolver.mapping.1.filter.tokenCUID.end=
-tokenProfileResolver.enrollMappingResolver.mapping.1.filter.tokenCUID.start=
-tokenProfileResolver.enrollMappingResolver.mapping.1.filter.tokenType=soKey
-tokenProfileResolver.enrollMappingResolver.mapping.1.target.tokenType=soKey
-tokenProfileResolver.enrollMappingResolver.mapping.2.filter.appletMajorVersion=
-tokenProfileResolver.enrollMappingResolver.mapping.2.filter.appletMinorVersion=
-tokenProfileResolver.enrollMappingResolver.mapping.2.filter.tokenATR=
-tokenProfileResolver.enrollMappingResolver.mapping.2.filter.tokenCUID.end=
-tokenProfileResolver.enrollMappingResolver.mapping.2.filter.tokenCUID.start=
-tokenProfileResolver.enrollMappingResolver.mapping.2.filter.tokenType=
-tokenProfileResolver.enrollMappingResolver.mapping.2.target.tokenType=userKey
-tokenProfileResolver.enrollMappingResolver.mapping.order=0,1,2
-tokenProfileResolver.formatMappingResolver.class_id=mappingTokenProfileResolverImpl
-tokenProfileResolver.formatMappingResolver.mapping.0.filter.appletMajorVersion=
-tokenProfileResolver.formatMappingResolver.mapping.0.filter.appletMinorVersion=
-tokenProfileResolver.formatMappingResolver.mapping.0.filter.tokenATR=
-tokenProfileResolver.formatMappingResolver.mapping.0.filter.tokenCUID.end=
-tokenProfileResolver.formatMappingResolver.mapping.0.filter.tokenCUID.start=
-tokenProfileResolver.formatMappingResolver.mapping.0.filter.tokenType=soCleanUserToken
-tokenProfileResolver.formatMappingResolver.mapping.0.target.tokenType=soCleanUserToken
-tokenProfileResolver.formatMappingResolver.mapping.1.filter.appletMajorVersion=
-tokenProfileResolver.formatMappingResolver.mapping.1.filter.appletMinorVersion=
-tokenProfileResolver.formatMappingResolver.mapping.1.filter.tokenATR=
-tokenProfileResolver.formatMappingResolver.mapping.1.filter.tokenCUID.end=
-tokenProfileResolver.formatMappingResolver.mapping.1.filter.tokenCUID.start=
-tokenProfileResolver.formatMappingResolver.mapping.1.filter.tokenType=soUserKey
-tokenProfileResolver.formatMappingResolver.mapping.1.target.tokenType=soUserKey
-tokenProfileResolver.formatMappingResolver.mapping.2.filter.appletMajorVersion=
-tokenProfileResolver.formatMappingResolver.mapping.2.filter.appletMinorVersion=
-tokenProfileResolver.formatMappingResolver.mapping.2.filter.tokenATR=
-tokenProfileResolver.formatMappingResolver.mapping.2.filter.tokenCUID.end=
-tokenProfileResolver.formatMappingResolver.mapping.2.filter.tokenCUID.start=
-tokenProfileResolver.formatMappingResolver.mapping.2.filter.tokenType=soKey
-tokenProfileResolver.formatMappingResolver.mapping.2.target.tokenType=soKey
-tokenProfileResolver.formatMappingResolver.mapping.3.filter.appletMajorVersion=
-tokenProfileResolver.formatMappingResolver.mapping.3.filter.appletMinorVersion=
-tokenProfileResolver.formatMappingResolver.mapping.3.filter.tokenATR=
-tokenProfileResolver.formatMappingResolver.mapping.3.filter.tokenCUID.end=
-tokenProfileResolver.formatMappingResolver.mapping.3.filter.tokenCUID.start=
-tokenProfileResolver.formatMappingResolver.mapping.3.filter.tokenType=userKey
-tokenProfileResolver.formatMappingResolver.mapping.3.target.tokenType=userKey
-tokenProfileResolver.formatMappingResolver.mapping.4.filter.appletMajorVersion=
-tokenProfileResolver.formatMappingResolver.mapping.4.filter.appletMinorVersion=
-tokenProfileResolver.formatMappingResolver.mapping.4.filter.tokenATR=
-tokenProfileResolver.formatMappingResolver.mapping.4.filter.tokenCUID.end=
-tokenProfileResolver.formatMappingResolver.mapping.4.filter.tokenCUID.start=
-tokenProfileResolver.formatMappingResolver.mapping.4.filter.tokenType=soCleanSOToken
-tokenProfileResolver.formatMappingResolver.mapping.4.target.tokenType=soCleanSOToken
-tokenProfileResolver.formatMappingResolver.mapping.5.filter.appletMajorVersion=
-tokenProfileResolver.formatMappingResolver.mapping.5.filter.appletMinorVersion=
-tokenProfileResolver.formatMappingResolver.mapping.5.filter.tokenATR=
-tokenProfileResolver.formatMappingResolver.mapping.5.filter.tokenCUID.end=
-tokenProfileResolver.formatMappingResolver.mapping.5.filter.tokenCUID.start=
-tokenProfileResolver.formatMappingResolver.mapping.5.filter.tokenType=cleanToken
-tokenProfileResolver.formatMappingResolver.mapping.5.target.tokenType=cleanToken
-tokenProfileResolver.formatMappingResolver.mapping.6.filter.appletMajorVersion=
-tokenProfileResolver.formatMappingResolver.mapping.6.filter.appletMinorVersion=
-tokenProfileResolver.formatMappingResolver.mapping.6.filter.tokenATR=
-tokenProfileResolver.formatMappingResolver.mapping.6.filter.tokenCUID.end=
-tokenProfileResolver.formatMappingResolver.mapping.6.filter.tokenCUID.start=
-tokenProfileResolver.formatMappingResolver.mapping.6.target.tokenType=tokenKey
-tokenProfileResolver.formatMappingResolver.mapping.order=0,1,2,3,4,5,6
-tokenProfileResolver.pinResetMappingResolver.class_id=mappingTokenProfileResolverImpl
-tokenProfileResolver.pinResetMappingResolver.mapping.0.filter.appletMajorVersion=
-tokenProfileResolver.pinResetMappingResolver.mapping.0.filter.appletMinorVersion=
-tokenProfileResolver.pinResetMappingResolver.mapping.0.filter.tokenATR=
-tokenProfileResolver.pinResetMappingResolver.mapping.0.filter.tokenCUID.end=
-tokenProfileResolver.pinResetMappingResolver.mapping.0.filter.tokenCUID.start=
-tokenProfileResolver.pinResetMappingResolver.mapping.0.filter.tokenType=
-tokenProfileResolver.pinResetMappingResolver.mapping.0.target.tokenType=userKey
-tokenProfileResolver.pinResetMappingResolver.mapping.order=0
+mappingResolver.list=formatMappingResolver,enrollMappingResolver,pinResetMappingResolver
+mappingResolver.enrollMappingResolver.class_id=filterMappingResolverImpl
+mappingResolver.enrollMappingResolver.mapping.0.filter.appletMajorVersion=1
+mappingResolver.enrollMappingResolver.mapping.0.filter.appletMinorVersion=
+mappingResolver.enrollMappingResolver.mapping.0.filter.tokenATR=
+mappingResolver.enrollMappingResolver.mapping.0.filter.tokenCUID.end=
+mappingResolver.enrollMappingResolver.mapping.0.filter.tokenCUID.start=
+mappingResolver.enrollMappingResolver.mapping.0.filter.tokenType=userKey
+mappingResolver.enrollMappingResolver.mapping.0.target.tokenType=userKey
+mappingResolver.enrollMappingResolver.mapping.1.filter.appletMajorVersion=
+mappingResolver.enrollMappingResolver.mapping.1.filter.appletMinorVersion=
+mappingResolver.enrollMappingResolver.mapping.1.filter.tokenATR=
+mappingResolver.enrollMappingResolver.mapping.1.filter.tokenCUID.end=
+mappingResolver.enrollMappingResolver.mapping.1.filter.tokenCUID.start=
+mappingResolver.enrollMappingResolver.mapping.1.filter.tokenType=soKey
+mappingResolver.enrollMappingResolver.mapping.1.target.tokenType=soKey
+mappingResolver.enrollMappingResolver.mapping.2.filter.appletMajorVersion=
+mappingResolver.enrollMappingResolver.mapping.2.filter.appletMinorVersion=
+mappingResolver.enrollMappingResolver.mapping.2.filter.tokenATR=
+mappingResolver.enrollMappingResolver.mapping.2.filter.tokenCUID.end=
+mappingResolver.enrollMappingResolver.mapping.2.filter.tokenCUID.start=
+mappingResolver.enrollMappingResolver.mapping.2.filter.tokenType=
+mappingResolver.enrollMappingResolver.mapping.2.target.tokenType=userKey
+mappingResolver.enrollMappingResolver.mapping.order=0,1,2
+mappingResolver.formatMappingResolver.class_id=filterMappingResolverImpl
+mappingResolver.formatMappingResolver.mapping.0.filter.appletMajorVersion=
+mappingResolver.formatMappingResolver.mapping.0.filter.appletMinorVersion=
+mappingResolver.formatMappingResolver.mapping.0.filter.tokenATR=
+mappingResolver.formatMappingResolver.mapping.0.filter.tokenCUID.end=
+mappingResolver.formatMappingResolver.mapping.0.filter.tokenCUID.start=
+mappingResolver.formatMappingResolver.mapping.0.filter.tokenType=soCleanUserToken
+mappingResolver.formatMappingResolver.mapping.0.target.tokenType=soCleanUserToken
+mappingResolver.formatMappingResolver.mapping.1.filter.appletMajorVersion=
+mappingResolver.formatMappingResolver.mapping.1.filter.appletMinorVersion=
+mappingResolver.formatMappingResolver.mapping.1.filter.tokenATR=
+mappingResolver.formatMappingResolver.mapping.1.filter.tokenCUID.end=
+mappingResolver.formatMappingResolver.mapping.1.filter.tokenCUID.start=
+mappingResolver.formatMappingResolver.mapping.1.filter.tokenType=soUserKey
+mappingResolver.formatMappingResolver.mapping.1.target.tokenType=soUserKey
+mappingResolver.formatMappingResolver.mapping.2.filter.appletMajorVersion=
+mappingResolver.formatMappingResolver.mapping.2.filter.appletMinorVersion=
+mappingResolver.formatMappingResolver.mapping.2.filter.tokenATR=
+mappingResolver.formatMappingResolver.mapping.2.filter.tokenCUID.end=
+mappingResolver.formatMappingResolver.mapping.2.filter.tokenCUID.start=
+mappingResolver.formatMappingResolver.mapping.2.filter.tokenType=soKey
+mappingResolver.formatMappingResolver.mapping.2.target.tokenType=soKey
+mappingResolver.formatMappingResolver.mapping.3.filter.appletMajorVersion=
+mappingResolver.formatMappingResolver.mapping.3.filter.appletMinorVersion=
+mappingResolver.formatMappingResolver.mapping.3.filter.tokenATR=
+mappingResolver.formatMappingResolver.mapping.3.filter.tokenCUID.end=
+mappingResolver.formatMappingResolver.mapping.3.filter.tokenCUID.start=
+mappingResolver.formatMappingResolver.mapping.3.filter.tokenType=userKey
+mappingResolver.formatMappingResolver.mapping.3.target.tokenType=userKey
+mappingResolver.formatMappingResolver.mapping.4.filter.appletMajorVersion=
+mappingResolver.formatMappingResolver.mapping.4.filter.appletMinorVersion=
+mappingResolver.formatMappingResolver.mapping.4.filter.tokenATR=
+mappingResolver.formatMappingResolver.mapping.4.filter.tokenCUID.end=
+mappingResolver.formatMappingResolver.mapping.4.filter.tokenCUID.start=
+mappingResolver.formatMappingResolver.mapping.4.filter.tokenType=soCleanSOToken
+mappingResolver.formatMappingResolver.mapping.4.target.tokenType=soCleanSOToken
+mappingResolver.formatMappingResolver.mapping.5.filter.appletMajorVersion=
+mappingResolver.formatMappingResolver.mapping.5.filter.appletMinorVersion=
+mappingResolver.formatMappingResolver.mapping.5.filter.tokenATR=
+mappingResolver.formatMappingResolver.mapping.5.filter.tokenCUID.end=
+mappingResolver.formatMappingResolver.mapping.5.filter.tokenCUID.start=
+mappingResolver.formatMappingResolver.mapping.5.filter.tokenType=cleanToken
+mappingResolver.formatMappingResolver.mapping.5.target.tokenType=cleanToken
+mappingResolver.formatMappingResolver.mapping.6.filter.appletMajorVersion=
+mappingResolver.formatMappingResolver.mapping.6.filter.appletMinorVersion=
+mappingResolver.formatMappingResolver.mapping.6.filter.tokenATR=
+mappingResolver.formatMappingResolver.mapping.6.filter.tokenCUID.end=
+mappingResolver.formatMappingResolver.mapping.6.filter.tokenCUID.start=
+mappingResolver.formatMappingResolver.mapping.6.target.tokenType=tokenKey
+mappingResolver.formatMappingResolver.mapping.order=0,1,2,3,4,5,6
+mappingResolver.pinResetMappingResolver.class_id=filterMappingResolverImpl
+mappingResolver.pinResetMappingResolver.mapping.0.filter.appletMajorVersion=
+mappingResolver.pinResetMappingResolver.mapping.0.filter.appletMinorVersion=
+mappingResolver.pinResetMappingResolver.mapping.0.filter.tokenATR=
+mappingResolver.pinResetMappingResolver.mapping.0.filter.tokenCUID.end=
+mappingResolver.pinResetMappingResolver.mapping.0.filter.tokenCUID.start=
+mappingResolver.pinResetMappingResolver.mapping.0.filter.tokenType=
+mappingResolver.pinResetMappingResolver.mapping.0.target.tokenType=userKey
+mappingResolver.pinResetMappingResolver.mapping.order=0
 registry.file=[PKI_INSTANCE_PATH]/conf/tps/registry.cfg
 selftests._000=##
 selftests._001=## Self Tests
@@ -1810,7 +1810,7 @@ target.Generals.displayname=General
 target.Generals.pattern=^applet\..*\|^general\..*\|^failover.pod.enable\|^channel\..*
 target.Profile_Mappings.displayname=Token Profile Mapping Resolvers
 target.Profile_Mappings.list=enrollMappingResolver,formatMappingResolver,pinResetMappingResolver
-target.Profile_Mappings.pattern=tokenProfileResolver\.$name\.mapping\..*
+target.Profile_Mappings.pattern=mappingResolver\.$name\.mapping\..*
 target.Profiles.displayname=Token Profile
 target.Profiles.list=userKey,soKey,soCleanUserToken,soUserKey,cleanToken,soCleanSoToken,tokenKey
 target.Profiles.pattern=op\..*\.$name\..*
diff --git a/base/tps/shared/conf/registry.cfg b/base/tps/shared/conf/registry.cfg
index dc26ae8616e8a8406910f7b95c04149c9eac8be1..4315b2f3fe4d69250a9e87287ec7206181062dbf 100644
--- a/base/tps/shared/conf/registry.cfg
+++ b/base/tps/shared/conf/registry.cfg
@@ -1,5 +1,5 @@
-types=tpsTokenProfileResolver
-tpsTokenProfileResolver.ids=mappingTokenProfileResolverImpl
-tpsTokenProfileResolver.mappingTokenProfileResolverImpl.class=org.dogtagpki.server.tps.profile.MappingTokenProfileResolver
-tpsTokenProfileResolver.mappingTokenProfileResolverImpl.desc=Mapping-based Token profile resolver
-tpsTokenProfileResolver.mappingTokenProfileResolverImpl.name=Mapping-based Token profile resolver
+types=tpsMappingResolver
+tpsMappingResolver.ids=filterMappingResolverImpl
+tpsMappingResolver.filterMappingResolverImpl.class=org.dogtagpki.server.tps.mapping.FilterMappingResolver
+tpsMappingResolver.filterMappingResolverImpl.desc=filter-based Token mapping resolver
+tpsMappingResolver.filterMappingResolverImpl.name=filter-based Token mapping resolver
diff --git a/base/tps/src/org/dogtagpki/server/tps/TPSSubsystem.java b/base/tps/src/org/dogtagpki/server/tps/TPSSubsystem.java
index 75cdddadbcd0d02d80ade8a9f61b15ad251f42af..e8734a9b879111319460d3bff3eb47b0672505a0 100644
--- a/base/tps/src/org/dogtagpki/server/tps/TPSSubsystem.java
+++ b/base/tps/src/org/dogtagpki/server/tps/TPSSubsystem.java
@@ -28,7 +28,7 @@ import org.dogtagpki.server.tps.dbs.ActivityDatabase;
 import org.dogtagpki.server.tps.dbs.TPSCertDatabase;
 import org.dogtagpki.server.tps.dbs.TokenDatabase;
 import org.dogtagpki.server.tps.engine.TPSEngine;
-import org.dogtagpki.server.tps.profile.TokenProfileResolverManager;
+import org.dogtagpki.server.tps.mapping.MappingResolverManager;
 import org.mozilla.jss.CryptoManager;
 import org.mozilla.jss.CryptoManager.NotInitializedException;
 import org.mozilla.jss.crypto.ObjectNotFoundException;
@@ -69,7 +69,7 @@ public class TPSSubsystem implements IAuthority, ISubsystem {
     public TokenDatabase tokenDatabase;
     public ConnectionManager connManager;
     public AuthenticationManager authManager;
-    public TokenProfileResolverManager profileResolverManager;
+    public MappingResolverManager mappingResolverManager;
     public TPSEngine engine;
     public TPSTokendb tdb;
 
@@ -119,8 +119,8 @@ public class TPSSubsystem implements IAuthority, ISubsystem {
         connManager.initConnectors();
         authManager = new AuthenticationManager();
         authManager.initAuthInstances();
-        profileResolverManager = new TokenProfileResolverManager();
-        profileResolverManager.initProfileResolverInstances();
+        mappingResolverManager = new MappingResolverManager();
+        mappingResolverManager.initMappingResolverInstances();
         CMS.debug("TPSSubsystem: startup() ends.");
     }
 
@@ -205,8 +205,8 @@ public class TPSSubsystem implements IAuthority, ISubsystem {
         return authManager;
     }
 
-    public TokenProfileResolverManager getProfileResolverManager() {
-        return profileResolverManager;
+    public MappingResolverManager getMappingResolverManager() {
+        return mappingResolverManager;
     }
 
     public TPSTokendb getTokendb() {
diff --git a/base/tps/src/org/dogtagpki/server/tps/engine/TPSEngine.java b/base/tps/src/org/dogtagpki/server/tps/engine/TPSEngine.java
index 7672a9bb7018ea8caadc0868f639d2b4e4e83454..b24f85d60bad7969cd5dde6e7e9323564639379b 100644
--- a/base/tps/src/org/dogtagpki/server/tps/engine/TPSEngine.java
+++ b/base/tps/src/org/dogtagpki/server/tps/engine/TPSEngine.java
@@ -170,7 +170,7 @@ public class TPSEngine {
     public static final String RENEWAL_OP = "renewal";
 
     public static final String OP_FORMAT_PREFIX = "op." + FORMAT_OP;
-    public static final String CFG_PROFILE_RESOLVER = "tokenProfileResolver";
+    public static final String CFG_PROFILE_RESOLVER = "mappingResolver";
     public static final String CFG_DEF_FORMAT_PROFILE_RESOLVER = "formatMappingResolver";
     public static final String CFG_DEF_ENROLL_PROFILE_RESOLVER = "enrollMappingResolver";
     public static final String CFG_DEF_PIN_RESET_PROFILE_RESOLVER = "pinResetMappingResolver";
diff --git a/base/tps/src/org/dogtagpki/server/tps/profile/BaseTokenProfileResolver.java b/base/tps/src/org/dogtagpki/server/tps/mapping/BaseMappingResolver.java
similarity index 64%
rename from base/tps/src/org/dogtagpki/server/tps/profile/BaseTokenProfileResolver.java
rename to base/tps/src/org/dogtagpki/server/tps/mapping/BaseMappingResolver.java
index c62d1ed2b0bb1cc5372ceadde9b49950a940ebae..9b36727be0edc5ce26626173103c1f5dc4ab07f5 100644
--- a/base/tps/src/org/dogtagpki/server/tps/profile/BaseTokenProfileResolver.java
+++ b/base/tps/src/org/dogtagpki/server/tps/mapping/BaseMappingResolver.java
@@ -1,4 +1,4 @@
-package org.dogtagpki.server.tps.profile;
+package org.dogtagpki.server.tps.mapping;
 
 import org.dogtagpki.tps.main.TPSException;
 
@@ -6,21 +6,21 @@ import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.base.IConfigStore;
 
 /**
- * This class implements the base TPS Profile Resolver instance
+ * This class implements the base TPS mapping filter Resolver instance
  *
  * @author cfu
  */
-public abstract class BaseTokenProfileResolver {
+public abstract class BaseMappingResolver {
     protected IConfigStore configStore = null;
     protected String instanceName = "";
     protected String prefix = "";
 
-    public BaseTokenProfileResolver() {
+    public BaseMappingResolver() {
     }
 
     public void init(String instName) {
         instanceName = instName;
-        prefix = TokenProfileResolverManager.TOKEN_PROFILE_RESOLVER_CFG +
+        prefix = MappingResolverManager.MAPPING_RESOLVER_CFG +
                 "." + instanceName;
         configStore = CMS.getConfigStore();
     }
@@ -33,6 +33,6 @@ public abstract class BaseTokenProfileResolver {
         return prefix;
     }
 
-    public abstract String getTokenType(TokenProfileParams pPram)
+    public abstract String getResolvedMapping(FilterMappingParams pPram)
             throws TPSException;
 }
diff --git a/base/tps/src/org/dogtagpki/server/tps/profile/TokenProfileParams.java b/base/tps/src/org/dogtagpki/server/tps/mapping/FilterMappingParams.java
similarity index 72%
rename from base/tps/src/org/dogtagpki/server/tps/profile/TokenProfileParams.java
rename to base/tps/src/org/dogtagpki/server/tps/mapping/FilterMappingParams.java
index d04bc9fb8d3a163a8a52f44bd81f9c3bea66a3d8..ee89826fb35da6ba9773e46a9151c8f084ee9c17 100644
--- a/base/tps/src/org/dogtagpki/server/tps/profile/TokenProfileParams.java
+++ b/base/tps/src/org/dogtagpki/server/tps/mapping/FilterMappingParams.java
@@ -15,7 +15,7 @@
 // (C) 2014 Red Hat, Inc.
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
-package org.dogtagpki.server.tps.profile;
+package org.dogtagpki.server.tps.mapping;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -27,19 +27,19 @@ import org.dogtagpki.tps.msg.EndOpMsg.TPSStatus;
 import com.netscape.certsrv.apps.CMS;
 
 /**
- * A class represents profile params information.
+ * A class represents filter mapping params information.
  * <P>
  *
- * @version $Revision$, $Date$
+ * @author cfu
  */
-public class TokenProfileParams {
+public class FilterMappingParams {
 
-    public static final String PROFILE_PARAM_MAJOR_VERSION = "pp_major_version";
-    public static final String PROFILE_PARAM_MINOR_VERSION = "pp_minor_version";
-    public static final String PROFILE_PARAM_CUID = "pp_cuid";
-    public static final String PROFILE_PARAM_MSN = "pp_msn";
-    public static final String PROFILE_PARAM_EXT_TOKEN_TYPE = "pp_ext_tokenType";
-    public static final String PROFILE_PARAM_EXT_TOKEN_ATR = "pp_ext_tokenATR";
+    public static final String FILTER_PARAM_MAJOR_VERSION = "fp_major_version";
+    public static final String FILTER_PARAM_MINOR_VERSION = "fp_minor_version";
+    public static final String FILTER_PARAM_CUID = "fp_cuid";
+    public static final String FILTER_PARAM_MSN = "fp_msn";
+    public static final String FILTER_PARAM_EXT_TOKEN_TYPE = "fp_ext_tokenType";
+    public static final String FILTER_PARAM_EXT_TOKEN_ATR = "fp_ext_tokenATR";
 
     private HashMap<String, String> content = new HashMap<String, String>();
 
@@ -47,7 +47,7 @@ public class TokenProfileParams {
      * Constructs a meta information.
      * <P>
      */
-    public TokenProfileParams() {
+    public FilterMappingParams() {
     }
 
     /**
@@ -78,10 +78,10 @@ public class TokenProfileParams {
            throws TPSException {
         String val = content.get(name);
         if (val == null) {
-            CMS.debug("TokenProfileParams.getString: param null:"+ name);
+            CMS.debug("FilterMappingParams.getString: param null:"+ name);
             throw new TPSException (
-                    "TokenProfileParams.getString: param null:"+ name,
-                    TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_PARAMS_NOT_FOUND);
+                    "FilterMappingParams.getString: param null:"+ name,
+                    TPSStatus.STATUS_ERROR_MAPPING_RESOLVER_PARAMS_NOT_FOUND);
         }
         return val;
     }
@@ -96,18 +96,18 @@ public class TokenProfileParams {
            throws TPSException {
         String val = content.get(name);
         if (val == null) {
-            CMS.debug("TokenProfileParams.getInt: param null:"+ name);
+            CMS.debug("FilterMappingParams.getInt: param null:"+ name);
             throw new TPSException (
-                    "TokenProfileParams.getInt: param null:"+ name,
-                    TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_PARAMS_NOT_FOUND);
+                    "FilterMappingParams.getInt: param null:"+ name,
+                    TPSStatus.STATUS_ERROR_MAPPING_RESOLVER_PARAMS_NOT_FOUND);
         }
         try {
             int intVal = Integer.parseInt(val);
             return intVal;
         } catch (NumberFormatException e) {
-            CMS.debug("TokenProfileParams.getInt: param "+ name + "=" + val + e);
+            CMS.debug("FilterMappingParams.getInt: param "+ name + "=" + val + e);
             throw new TPSException (
-                    "TokenProfileParams.getInt: param major_version:"+ e,
+                    "FilterMappingParams.getInt: param major_version:"+ e,
                     TPSStatus.STATUS_ERROR_MISCONFIGURATION);
         }
     }
diff --git a/base/tps/src/org/dogtagpki/server/tps/profile/MappingTokenProfileResolver.java b/base/tps/src/org/dogtagpki/server/tps/mapping/FilterMappingResolver.java
similarity index 50%
rename from base/tps/src/org/dogtagpki/server/tps/profile/MappingTokenProfileResolver.java
rename to base/tps/src/org/dogtagpki/server/tps/mapping/FilterMappingResolver.java
index 264fba882805df3b81618f4492998056bd6ede2f..c1fcb974e6bb0d8788778669c050329507d6683c 100644
--- a/base/tps/src/org/dogtagpki/server/tps/profile/MappingTokenProfileResolver.java
+++ b/base/tps/src/org/dogtagpki/server/tps/mapping/FilterMappingResolver.java
@@ -1,4 +1,4 @@
-package org.dogtagpki.server.tps.profile;
+package org.dogtagpki.server.tps.mapping;
 
 import org.dogtagpki.server.tps.engine.TPSEngine;
 import org.dogtagpki.tps.main.TPSException;
@@ -9,95 +9,98 @@ import com.netscape.certsrv.base.EBaseException;
 import com.netscape.certsrv.base.EPropertyNotFound;
 
 /**
- * MappingTokenProfileResolver is a profile resolver plugin that calculates
- * token type by sorting through a list of filters in mapping
+ * FilterMappingResolver is a mapping resolver plugin that calculates
+ * result by sorting through a list of filters in mapping
+ *
+ * @author cfu
  */
-public class MappingTokenProfileResolver extends BaseTokenProfileResolver {
+public class FilterMappingResolver extends BaseMappingResolver {
 
-    public MappingTokenProfileResolver() {
+    public FilterMappingResolver() {
     }
 
-    public String getTokenType(TokenProfileParams pParam)
+    public String getResolvedMapping(FilterMappingParams mappingParams)
             throws TPSException {
-
+        String method = "FilterMappingResolver.getResolvedMapping: ";
         String tokenType = null;
         String mappingOrder = null;
         int major_version = 0;
         int minor_version = 0;
         String cuid = null;
         // String msn = null;
-        String eTokenType = null;
-        String eTokenATR = null;
+        String extTokenType = null;
+        String extTokenATR = null;
 
-        CMS.debug("MappingTokenProfileResolver.getTokenType: starts");
+        CMS.debug(method + " starts");
 
-        major_version = pParam.getInt(TokenProfileParams.PROFILE_PARAM_MAJOR_VERSION);
-        CMS.debug("MappingTokenProfileResolver: param major_version =" + major_version);
+        major_version = mappingParams.getInt(FilterMappingParams.FILTER_PARAM_MAJOR_VERSION);
+        CMS.debug(method + " param major_version =" + major_version);
 
-        minor_version = pParam.getInt(TokenProfileParams.PROFILE_PARAM_MINOR_VERSION);
-        CMS.debug("MappingTokenProfileResolver: param minor_version =" + minor_version);
+        minor_version = mappingParams.getInt(FilterMappingParams.FILTER_PARAM_MINOR_VERSION);
+        CMS.debug(method + " param minor_version =" + minor_version);
+
+        cuid =  mappingParams.getString(FilterMappingParams.FILTER_PARAM_CUID);
+        // msn = (String) mappingParams.get(FilterMappingParams.FILTER_PARAM_MSN);
 
-        cuid =  pParam.getString(TokenProfileParams.PROFILE_PARAM_CUID);
-        // msn = (String) pParam.get(TokenProfileParams.PROFILE_PARAM_MSN);
         // they don't necessarily have extension
         try {
-            eTokenType = pParam.getString(TokenProfileParams.PROFILE_PARAM_EXT_TOKEN_TYPE);
-            eTokenATR =  pParam.getString(TokenProfileParams.PROFILE_PARAM_EXT_TOKEN_ATR);
+            extTokenType = mappingParams.getString(FilterMappingParams.FILTER_PARAM_EXT_TOKEN_TYPE);
+            extTokenATR =  mappingParams.getString(FilterMappingParams.FILTER_PARAM_EXT_TOKEN_ATR);
         } catch (TPSException e) {
-            CMS.debug("MappingTokenProfileResolver: OK to not have extension. Continue.");
+            CMS.debug(method + " OK to not have extension. Continue.");
         }
 
-        CMS.debug("MappingTokenProfileResolver: params retrieved.");
+        CMS.debug(method + " mapping params retrieved.");
 
         String configName = prefix + "." + TPSEngine.CFG_PROFILE_MAPPING_ORDER;
 
         try {
-            CMS.debug("MappingTokenProfileResolver: getting mapping order:" +
+            CMS.debug(method + " getting mapping order:" +
                     configName);
             mappingOrder = configStore.getString(configName);
         } catch (EPropertyNotFound e) {
-            CMS.debug("MappingTokenProfileResolver: exception:" + e);
+            CMS.debug(method + " exception:" + e);
             throw new TPSException(
-                    "MappingTokenProfileResolver.getTokenType: Token Type configuration incorrect! Mising mapping order!",
-                    TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND);
+                    method + " configuration incorrect! Mising mapping order:" + configName,
+                    TPSStatus.STATUS_ERROR_MAPPING_RESOLVER_FAILED);
 
         } catch (EBaseException e1) {
             //The whole feature won't work if this is wrong.
-            CMS.debug("MappingTokenProfileResolver: exception:" + e1);
+            CMS.debug(method + " exception:" + e1);
             throw new TPSException(
-                    "MappingTokenProfileResolver.getTokenType: Internal error obtaining config value.!",
-                    TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND);
+                    method + " Internal error obtaining config value:" + configName,
+                    TPSStatus.STATUS_ERROR_MAPPING_RESOLVER_FAILED);
         }
 
         String targetTokenType = null;
 
         for (String mappingId : mappingOrder.split(",")) {
 
-            CMS.debug("MappingTokenProfileResolver.getTokenType:  mapping: " + mappingId);
+            CMS.debug(method + "  mapping: " + mappingId);
 
             String mappingConfigName = prefix + ".mapping." + mappingId + ".target.tokenType";
 
-            CMS.debug("MappingTokenProfileResolver.getTokenType:  mappingConfigName: " + mappingConfigName);
+            CMS.debug(method + "  mappingConfigName: " + mappingConfigName);
 
             //We need this to exist.
             try {
                 targetTokenType = configStore.getString(mappingConfigName);
             } catch (EPropertyNotFound e) {
                 throw new TPSException(
-                        "MappingTokenProfileResolver.getTokenType: Token Type configuration incorrect! No target token type config value found! Config: "
+                        method + " Token Type configuration incorrect! No target token type config value found! Config: "
                                 + mappingConfigName,
-                        TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND);
+                        TPSStatus.STATUS_ERROR_MAPPING_RESOLVER_FAILED);
 
             } catch (EBaseException e) {
                 throw new TPSException(
-                        "MappingTokenProfileResolver.getTokenType: Internal error obtaining config value. Config: "
+                        method + " Internal error obtaining config value. Config: "
                                 + mappingConfigName,
-                        TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND);
+                        TPSStatus.STATUS_ERROR_MAPPING_RESOLVER_FAILED);
             }
 
             mappingConfigName = prefix + ".mapping." + mappingId + ".filter.tokenType";
 
-            CMS.debug("MappingTokenProfileResolver.getTokenType:  mappingConfigName: " + mappingConfigName);
+            CMS.debug(method + "  mappingConfigName: " + mappingConfigName);
 
             //For this and remaining cases, it is not automatically an error if we don't get anything back
             // from the config.
@@ -105,33 +108,33 @@ public class MappingTokenProfileResolver extends BaseTokenProfileResolver {
                 tokenType = configStore.getString(mappingConfigName, null);
             } catch (EBaseException e) {
                 throw new TPSException(
-                        "MappingTokenProfileResolver.getTokenType: Internal error obtaining config value. Config: "
+                        method + " Internal error obtaining config value. Config: "
                                 + mappingConfigName,
-                        TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND);
+                        TPSStatus.STATUS_ERROR_MAPPING_RESOLVER_FAILED);
 
             }
 
-            CMS.debug("MappingTokenProfileResolver.getTokenType:  targetTokenType: " + targetTokenType);
+            CMS.debug(method + "  targetTokenType: " + targetTokenType);
 
             if (tokenType != null && tokenType.length() > 0) {
 
-                if (eTokenType == null) {
+                if (extTokenType == null) {
                     continue;
                 }
 
-                //String eTokenType = extensions.get("tokenType");
-                //if (eTokenType == null) {
+                //String extTokenType = extensions.get("tokenType");
+                //if (extTokenType == null) {
                 //    continue;
                 //}
 
-                if (!eTokenType.equals(tokenType)) {
+                if (!extTokenType.equals(tokenType)) {
                     continue;
                 }
             }
 
             mappingConfigName = prefix + ".mapping." + mappingId + ".filter.tokenATR";
 
-            CMS.debug("MappingTokenProfileResolver.getTokenType:  mappingConfigName: " + mappingConfigName);
+            CMS.debug(method + " mappingConfigName: " + mappingConfigName);
 
             String tokenATR = null;
 
@@ -139,25 +142,25 @@ public class MappingTokenProfileResolver extends BaseTokenProfileResolver {
                 tokenATR = configStore.getString(mappingConfigName, null);
             } catch (EBaseException e) {
                 throw new TPSException(
-                        "MappingTokenProfileResolver.getTokenType: Internal error obtaining config value. Config: "
+                        method + " Internal error obtaining config value. Config: "
                                 + mappingConfigName,
-                        TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND);
+                        TPSStatus.STATUS_ERROR_MAPPING_RESOLVER_FAILED);
             }
 
-            CMS.debug("MappingTokenProfileResolver.getTokenType:  tokenATR: " + tokenATR);
+            CMS.debug(method + " tokenATR: " + tokenATR);
 
             if (tokenATR != null && tokenATR.length() > 0) {
-                if (eTokenATR == null) {
+                if (extTokenATR == null) {
                     continue;
                 }
 
-                //String eTokenATR = extensions.get("tokenATR");
+                //String extTokenATR = extensions.get("tokenATR");
 
-                //if (eTokenATR == null) {
+                //if (extTokenATR == null) {
                 //    continue;
                 //}
 
-                if (!eTokenATR.equals(tokenATR)) {
+                if (!extTokenATR.equals(tokenATR)) {
                     continue;
                 }
 
@@ -165,7 +168,7 @@ public class MappingTokenProfileResolver extends BaseTokenProfileResolver {
 
             mappingConfigName = prefix + ".mapping." + mappingId + ".filter.tokenCUID.start";
 
-            CMS.debug("MappingTokenProfileResolver.getTokenType:  mappingConfigName: " + mappingConfigName);
+            CMS.debug(method + " mappingConfigName: " + mappingConfigName);
 
             String tokenCUIDStart = null;
 
@@ -174,12 +177,12 @@ public class MappingTokenProfileResolver extends BaseTokenProfileResolver {
 
             } catch (EBaseException e) {
                 throw new TPSException(
-                        "MappingTokenProfileResolver.getTokenType: Internal error obtaining config value. Config: "
+                        method + " Internal error obtaining config value. Config: "
                                 + mappingConfigName,
-                        TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND);
+                        TPSStatus.STATUS_ERROR_MAPPING_RESOLVER_FAILED);
             }
 
-            CMS.debug("MappingTokenProfileResolver.getTokenType:  tokenCUIDStart: " + tokenCUIDStart);
+            CMS.debug(method + "  tokenCUIDStart: " + tokenCUIDStart);
 
             if (tokenCUIDStart != null && tokenCUIDStart.length() > 0) {
                 if (cuid == null) {
@@ -198,19 +201,19 @@ public class MappingTokenProfileResolver extends BaseTokenProfileResolver {
 
             mappingConfigName = prefix + ".mapping." + mappingId + ".filter.tokenCUID.end";
 
-            CMS.debug("MappingTokenProfileResolver.getTokenType:  mappingConfigName: " + mappingConfigName);
+            CMS.debug(method + "  mappingConfigName: " + mappingConfigName);
 
             String tokenCUIDEnd = null;
             try {
                 tokenCUIDEnd = configStore.getString(mappingConfigName, null);
             } catch (EBaseException e) {
                 throw new TPSException(
-                        "MappingTokenProfileResolver.getTokenType: Internal error obtaining config value. Config: "
+                        method + " Internal error obtaining config value. Config: "
                                 + mappingConfigName,
-                        TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND);
+                        TPSStatus.STATUS_ERROR_MAPPING_RESOLVER_FAILED);
             }
 
-            CMS.debug("MappingTokenProfileResolver.getTokenType:  tokenCUIDEnd: " + tokenCUIDEnd);
+            CMS.debug(method + "  tokenCUIDEnd: " + tokenCUIDEnd);
 
             if (tokenCUIDEnd != null && tokenCUIDEnd.length() > 0) {
                 if (cuid == null) {
@@ -229,7 +232,7 @@ public class MappingTokenProfileResolver extends BaseTokenProfileResolver {
 
             mappingConfigName = prefix + ".mapping." + mappingId + ".filter.appletMajorVersion";
 
-            CMS.debug("MappingTokenProfileResolver.getTokenType:  mappingConfigName: " + mappingConfigName);
+            CMS.debug(method + "  mappingConfigName: " + mappingConfigName);
 
             String majorVersion = null;
             String minorVersion = null;
@@ -238,12 +241,12 @@ public class MappingTokenProfileResolver extends BaseTokenProfileResolver {
                 majorVersion = configStore.getString(mappingConfigName, null);
             } catch (EBaseException e) {
                 throw new TPSException(
-                        "MappingTokenProfileResolver.getTokenType: Internal error obtaining config value. Config: "
+                        method + " Internal error obtaining config value. Config: "
                                 + mappingConfigName,
-                        TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND);
+                        TPSStatus.STATUS_ERROR_MAPPING_RESOLVER_FAILED);
             }
 
-            CMS.debug("MappingTokenProfileResolver.getTokenType:  majorVersion: " + majorVersion);
+            CMS.debug(method + "  majorVersion: " + majorVersion);
             if (majorVersion != null && majorVersion.length() > 0) {
 
                 int major = Integer.parseInt(majorVersion);
@@ -255,17 +258,17 @@ public class MappingTokenProfileResolver extends BaseTokenProfileResolver {
 
             mappingConfigName = prefix + ".mapping." + mappingId + ".filter.appletMinorVersion";
 
-            CMS.debug("MappingTokenProfileResolver.getTokenType:  mappingConfigName: " + mappingConfigName);
+            CMS.debug(method + "  mappingConfigName: " + mappingConfigName);
 
             try {
                 minorVersion = configStore.getString(mappingConfigName, null);
             } catch (EBaseException e) {
                 throw new TPSException(
-                        "MappingTokenProfileResolver.getTokenType: Internal error obtaining config value. Config: "
+                        method + " Internal error obtaining config value. Config: "
                                 + mappingConfigName,
-                        TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND);
+                        TPSStatus.STATUS_ERROR_MAPPING_RESOLVER_FAILED);
             }
-            CMS.debug("MappingTokenProfileResolver.getTokenType:  minorVersion " + minorVersion);
+            CMS.debug(method + "  minorVersion " + minorVersion);
 
             if (minorVersion != null && minorVersion.length() > 0) {
 
@@ -277,14 +280,14 @@ public class MappingTokenProfileResolver extends BaseTokenProfileResolver {
             }
 
             //if we make it this far, we have a token type
-            CMS.debug("MappingTokenProfileResolver.getTokenType: Selected Token type: " + targetTokenType);
+            CMS.debug(method + " Selected Token type: " + targetTokenType);
             break;
         }
 
         if (targetTokenType == null) {
-            CMS.debug("MappingTokenProfileResolver.getTokenType: end found: " + targetTokenType);
-            throw new TPSException("MappingTokenProfileResolver.getTokenType: Can't find token type!",
-                    TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND);
+            CMS.debug(method + " end found: " + targetTokenType);
+            throw new TPSException(method + " Can't find token type!",
+                    TPSStatus.STATUS_ERROR_MAPPING_RESOLVER_FAILED);
         }
 
         return targetTokenType;
diff --git a/base/tps/src/org/dogtagpki/server/tps/profile/TokenProfileResolverManager.java b/base/tps/src/org/dogtagpki/server/tps/mapping/MappingResolverManager.java
similarity index 51%
rename from base/tps/src/org/dogtagpki/server/tps/profile/TokenProfileResolverManager.java
rename to base/tps/src/org/dogtagpki/server/tps/mapping/MappingResolverManager.java
index b6325fccaf79525d701a0fb2a44f48767bd1e30e..3c9b196da554614f99a6cc9370664b1c71a6b8b4 100644
--- a/base/tps/src/org/dogtagpki/server/tps/profile/TokenProfileResolverManager.java
+++ b/base/tps/src/org/dogtagpki/server/tps/mapping/MappingResolverManager.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.profile;
+package org.dogtagpki.server.tps.mapping;
 
 import java.util.HashMap;
 
@@ -27,88 +27,88 @@ import com.netscape.certsrv.registry.IPluginInfo;
 import com.netscape.certsrv.registry.IPluginRegistry;
 
 /**
- * TokenProfileResolverManager is a class for profile resolver plugin
+ * mappingResolverManager is a class for mapping resolver plugin
  * management
  *
  * @author cfu
  */
-public class TokenProfileResolverManager
+public class MappingResolverManager
 {
-    private static final String TOKEN_PROFILE_RESOLVER_TYPE = "tpsTokenProfileResolver";
+    private static final String TOKEN_MAPPING_RESOLVER_TYPE = "tpsMappingResolver";
     public static final String PROP_RESOLVER_LIST = "list";
     public static final String PROP_RESOLVER_CLASS_ID = "class_id";
 
-    protected static final String TOKEN_PROFILE_RESOLVER_CFG = "tokenProfileResolver";
+    protected static final String MAPPING_RESOLVER_CFG = "mappingResolver";
     protected IPluginRegistry registry = null;
-    protected HashMap<String, BaseTokenProfileResolver> tokenProfileResolvers = null;
+    protected HashMap<String, BaseMappingResolver> mappingResolvers = null;
 
-    public TokenProfileResolverManager() {
-        tokenProfileResolvers = new HashMap<String, BaseTokenProfileResolver>();
+    public MappingResolverManager() {
+        mappingResolvers = new HashMap<String, BaseMappingResolver>();
     }
 
     /**
-     * initializes all profile resolver plugin instances specified in
+     * initializes all mapping resolver plugin instances specified in
      * <instance-name>/conf/registry.cfg
      *
      * configuration e.g.
      *
      * registry.cfg:
-     * types=tpsTokenProfileResolver
-     * tpsProfileResolver.ids=mappingTokenProfileResolverImpl
-     * tpsProfileResolver.mappingTokenProfileResolverImpl.class=org.dogtagpki.server.tps.profile.MappingTokenProfileResolver
-     * tpsProfileResolver.mappingTokenProfileResolverImpl.desc=Mapping-based Token profile resolver
-     * tpsProfileResolver.mappingTokenProfileResolverImpl.name=Mapping-based Token profile resolver
+     * types=tpsMappingResolver
+     * tpsMappingResolver.ids=mappingTokenProfileResolverImpl
+     * tpsMappingResolver.mappingTokenProfileResolverImpl.class=org.dogtagpki.server.tps.mapping.mappingResolver
+     * tpsMappingResolver.mappingTokenProfileResolverImpl.desc=Mapping-based Token profile resolver
+     * tpsMappingResolver.mappingTokenProfileResolverImpl.name=Mapping-based Token profile resolver
      *
      * CS.cfg :
      * registry.file=/var/lib/pki/pki-tomcat/conf/tps/registry.cfg
-     * tokenProfileResolver.list=formatMappingResolver,enrollMappingResolver,pinResetMappingResolver
-     * tokenProfileResolver.formatMappingResolver.class_id=mappingProfileResolverImpl
-     * tokenProfileResolver.formatMappingResolver.[plugin-specific configuration]
+     * mappingResolver.list=formatMappingResolver,enrollMappingResolver,pinResetMappingResolver
+     * mappingResolver.formatMappingResolver.class_id=mappingProfileResolverImpl
+     * mappingResolver.formatMappingResolver.[plugin-specific configuration]
      *
-     * op.format.tokenProfileResolver=formatMappingResolver
+     * op.format.mappingResolver=formatMappingResolver
      * ...
-     * op.enroll.tokenProfileResolver=enrollMappingResolver
+     * op.enroll.mappingResolver=enrollMappingResolver
      *
      * Note: "none" indicates no resolver plugin applied
-     * op.format.tokenProfileResolver=none
+     * op.format.mappingResolver=none
      */
-    public void initProfileResolverInstances()
+    public void initMappingResolverInstances()
             throws EBaseException {
-
-        CMS.debug("TokenProfileResolverManager: initProfileResolverInstances(): begins");
+        String method = "mappingResolverManager.initMappingResolverInstance:";
+        CMS.debug(method + " begins");
         IConfigStore conf = CMS.getConfigStore();
         registry = (IPluginRegistry) CMS.getSubsystem(CMS.SUBSYSTEM_REGISTRY);
         if (registry == null) {
-            CMS.debug("TokenProfileResolverManager: initProfileResolverInstances(): registry null");
+            CMS.debug(method + " registry null");
             return;
         }
 
-        IConfigStore prConf = conf.getSubStore(TOKEN_PROFILE_RESOLVER_CFG);
+        IConfigStore prConf = conf.getSubStore(MAPPING_RESOLVER_CFG);
         String profileList = prConf.getString(PROP_RESOLVER_LIST, "");
 
         for (String prInst : profileList.split(",")) {
             String classID = prConf.getString(prInst + "." + PROP_RESOLVER_CLASS_ID);
-            CMS.debug("TokenProfileResolverManager: initProfileResolverInstances(): initializing classID=" + classID);
+            CMS.debug(method + " initializing classID=" + classID);
             IPluginInfo resolverInfo =
-                    registry.getPluginInfo(TOKEN_PROFILE_RESOLVER_TYPE, classID);
+                    registry.getPluginInfo(TOKEN_MAPPING_RESOLVER_TYPE, classID);
             String resolverClass = resolverInfo.getClassName();
-            BaseTokenProfileResolver resolver = null;
+            BaseMappingResolver resolver = null;
             try {
-                resolver = (BaseTokenProfileResolver)
+                resolver = (BaseMappingResolver)
                         Class.forName(resolverClass).newInstance();
             } catch (Exception e) {
                 // throw Exception
-                CMS.debug("TokenProfileResolverManager: resolver plugin Class.forName " +
+                CMS.debug(method + " resolver plugin Class.forName " +
                         resolverClass + " " + e.toString());
                 throw new EBaseException(e.toString());
             }
             resolver.init(prInst);
-            tokenProfileResolvers.put(prInst, resolver);
-            CMS.debug("TokenProfileResolverManager: initProfileResolverInstances(): resolver instance added: " + prInst);
+            mappingResolvers.put(prInst, resolver);
+            CMS.debug(method + " resolver instance added: " + prInst);
         }
     }
 
-    public BaseTokenProfileResolver getResolverInstance(String name) {
-        return tokenProfileResolvers.get(name);
+    public BaseMappingResolver getResolverInstance(String name) {
+        return mappingResolvers.get(name);
     }
 }
diff --git a/base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java b/base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java
index 27d88c2f129626e55df1294fdc9836a77dcaa5ee..00303432cdeb96f80f62f9ed228c627947178163 100644
--- a/base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java
+++ b/base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java
@@ -55,8 +55,8 @@ import org.dogtagpki.server.tps.engine.TPSEngine;
 import org.dogtagpki.server.tps.main.ExternalRegAttrs;
 //import org.dogtagpki.server.tps.main.ExternalRegCertToDelete;
 import org.dogtagpki.server.tps.main.ExternalRegCertToRecover;
-import org.dogtagpki.server.tps.profile.BaseTokenProfileResolver;
-import org.dogtagpki.server.tps.profile.TokenProfileParams;
+import org.dogtagpki.server.tps.mapping.BaseMappingResolver;
+import org.dogtagpki.server.tps.mapping.FilterMappingParams;
 import org.dogtagpki.tps.apdu.APDU;
 import org.dogtagpki.tps.apdu.APDUResponse;
 import org.dogtagpki.tps.apdu.GetDataAPDU;
@@ -2068,32 +2068,32 @@ public class TPSProcessor {
         if (!resolverInstName.equals("none") && (selectedTokenType == null)) {
 
             try {
-                TokenProfileParams pParams = new TokenProfileParams();
-                CMS.debug("In TPSProcessor.resolveTokenProfile : after new TokenProfileParams");
-                pParams.set(TokenProfileParams.PROFILE_PARAM_MAJOR_VERSION,
+                FilterMappingParams pParams = new FilterMappingParams();
+                CMS.debug("In TPSProcessor.resolveTokenProfile : after new MappingFilterParams");
+                pParams.set(FilterMappingParams.FILTER_PARAM_MAJOR_VERSION,
                         String.valueOf(major_version));
-                pParams.set(TokenProfileParams.PROFILE_PARAM_MINOR_VERSION,
+                pParams.set(FilterMappingParams.FILTER_PARAM_MINOR_VERSION,
                         String.valueOf(minor_version));
-                pParams.set(TokenProfileParams.PROFILE_PARAM_CUID, cuid);
-                pParams.set(TokenProfileParams.PROFILE_PARAM_MSN, msn);
+                pParams.set(FilterMappingParams.FILTER_PARAM_CUID, cuid);
+                pParams.set(FilterMappingParams.FILTER_PARAM_MSN, msn);
                 if (beginMsg.getExtensions() != null) {
-                    pParams.set(TokenProfileParams.PROFILE_PARAM_EXT_TOKEN_TYPE,
+                    pParams.set(FilterMappingParams.FILTER_PARAM_EXT_TOKEN_TYPE,
                             beginMsg.getExtensions().get("tokenType"));
-                    pParams.set(TokenProfileParams.PROFILE_PARAM_EXT_TOKEN_ATR,
+                    pParams.set(FilterMappingParams.FILTER_PARAM_EXT_TOKEN_ATR,
                             beginMsg.getExtensions().get("tokenATR"));
                 }
-                CMS.debug("In TPSProcessor.resolveTokenProfile : after setting TokenProfileParams");
+                CMS.debug("In TPSProcessor.resolveTokenProfile : after setting MappingFilterParams");
                 TPSSubsystem subsystem =
                         (TPSSubsystem) CMS.getSubsystem(TPSSubsystem.ID);
-                BaseTokenProfileResolver resolverInst =
-                        subsystem.getProfileResolverManager().getResolverInstance(resolverInstName);
-                tokenType = resolverInst.getTokenType(pParams);
+                BaseMappingResolver resolverInst =
+                        subsystem.getMappingResolverManager().getResolverInstance(resolverInstName);
+                tokenType = resolverInst.getResolvedMapping(pParams);
                 CMS.debug("In TPSProcessor.resolveTokenProfile : profile resolver result: " + tokenType);
                 setSelectedTokenType(tokenType);
             } catch (EBaseException et) {
                 CMS.debug("In TPSProcessor.resolveTokenProfile exception:" + et);
                 throw new TPSException("TPSProcessor.resolveTokenProfile failed.",
-                        TPSStatus.STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND);
+                        TPSStatus.STATUS_ERROR_MAPPING_RESOLVER_FAILED);
             }
 
         } else {
-- 
1.8.4.2

