diff options
author | Fraser Tweedale <ftweedal@redhat.com> | 2015-12-01 14:21:08 +1100 |
---|---|---|
committer | Fraser Tweedale <ftweedal@redhat.com> | 2016-01-21 11:05:43 +1100 |
commit | 41717cb774f53e30caf7a57c2e07526445bf0988 (patch) | |
tree | 466caab3e73799b7e074009173ec0a5aa3c3e35a /base | |
parent | 0af4a9393ce38216689e9afe17514b9441784133 (diff) | |
download | pki-41717cb774f53e30caf7a57c2e07526445bf0988.tar.gz pki-41717cb774f53e30caf7a57c2e07526445bf0988.tar.xz pki-41717cb774f53e30caf7a57c2e07526445bf0988.zip |
Ensure config store commits refresh file-based profile data
The file-based LDAP profile subsystem does not update profiles
correctly. Ensure that each commit of the underlying config store
refreshes the profile inputs, outputs and policy objects.
Part of: https://fedorahosted.org/pki/ticket/1700
Diffstat (limited to 'base')
-rw-r--r-- | base/server/cmscore/src/com/netscape/cmscore/profile/AbstractProfileSubsystem.java | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/base/server/cmscore/src/com/netscape/cmscore/profile/AbstractProfileSubsystem.java b/base/server/cmscore/src/com/netscape/cmscore/profile/AbstractProfileSubsystem.java index e93e090de..116b8e202 100644 --- a/base/server/cmscore/src/com/netscape/cmscore/profile/AbstractProfileSubsystem.java +++ b/base/server/cmscore/src/com/netscape/cmscore/profile/AbstractProfileSubsystem.java @@ -22,12 +22,15 @@ import java.util.Enumeration; import java.util.Hashtable; import java.util.LinkedHashMap; +import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.base.IConfigStore; import com.netscape.certsrv.base.ISubsystem; import com.netscape.certsrv.profile.EProfileException; import com.netscape.certsrv.profile.IProfile; import com.netscape.certsrv.profile.IProfileSubsystem; +import com.netscape.certsrv.registry.IPluginInfo; +import com.netscape.certsrv.registry.IPluginRegistry; public abstract class AbstractProfileSubsystem implements IProfileSubsystem { protected static final String PROP_CHECK_OWNER = "checkOwner"; @@ -120,8 +123,42 @@ public abstract class AbstractProfileSubsystem implements IProfileSubsystem { */ public void commitProfile(String id) throws EProfileException { + IConfigStore cs = mProfiles.get(id).getConfigStore(); + + // first create a *new* profile object from the configStore + // and initialise it with the updated configStore + // + IPluginRegistry registry = (IPluginRegistry) + CMS.getSubsystem(CMS.SUBSYSTEM_REGISTRY); + String classId = mProfileClassIds.get(id); + IPluginInfo info = registry.getPluginInfo("profile", classId); + String className = info.getClassName(); + IProfile newProfile = null; try { - mProfiles.get(id).getConfigStore().commit(false); + newProfile = (IProfile) Class.forName(className).newInstance(); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + throw new EProfileException("Could not instantiate class '" + + classId + "' for profile '" + id + "': " + e); + } + newProfile.setId(id); + try { + newProfile.init(this, cs); + } catch (EBaseException e) { + throw new EProfileException( + "Failed to initialise profile '" + id + "': " + e); + } + + // next replace the existing profile with the new profile; + // this is to avoid any intermediate state where the profile + // is not fully initialised with its inputs, outputs and + // policy objects. + // + mProfiles.put(id, newProfile); + + // finally commit the configStore + // + try { + cs.commit(false); } catch (EBaseException e) { throw new EProfileException( "Failed to commit config store of profile '" + id + ": " + e, |