From 93d68fbf9f5d8e122199657b15f888a58f7f2664 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Thu, 14 Nov 2013 15:32:11 -0500
Subject: [PATCH] Replaced auth.properties with acl.properties.

The ACLInterceptor has been modified to use acl.properties instead of
auth.properties to match the interceptor name.

The UpdateAuthzProperties upgrade script has been renamed and modified
to replace the auth.properties in existing instances with acl.properties.
---
 .../ca/WEB-INF/{auth.properties => acl.properties} |  0
 base/common/upgrade/10.0.5/.gitignore              |  4 ++
 base/common/upgrade/10.0.6/.gitignore              |  4 ++
 .../WEB-INF/{auth.properties => acl.properties}    |  0
 .../WEB-INF/{auth.properties => acl.properties}    |  0
 .../netscape/cms/authorization/ACLInterceptor.java | 16 ++++----
 .../cms/authorization/AuthMethodInterceptor.java   | 48 +++++++++++-----------
 base/server/python/pki/server/__init__.py          |  2 +-
 base/server/upgrade/10.0.6/.gitignore              |  4 ++
 ...ateAuthzProperties => 02-ReplaceAuthProperties} | 23 ++++++++---
 .../WEB-INF/{auth.properties => acl.properties}    |  0
 .../WEB-INF/{auth.properties => acl.properties}    |  0
 12 files changed, 62 insertions(+), 39 deletions(-)
 rename base/ca/shared/webapps/ca/WEB-INF/{auth.properties => acl.properties} (100%)
 create mode 100644 base/common/upgrade/10.0.5/.gitignore
 create mode 100644 base/common/upgrade/10.0.6/.gitignore
 rename base/kra/shared/webapps/kra/WEB-INF/{auth.properties => acl.properties} (100%)
 rename base/ocsp/shared/webapps/ocsp/WEB-INF/{auth.properties => acl.properties} (100%)
 create mode 100644 base/server/upgrade/10.0.6/.gitignore
 rename base/server/upgrade/10.0.99/{02-UpdateAuthzProperties => 02-ReplaceAuthProperties} (68%)
 rename base/tks/shared/webapps/tks/WEB-INF/{auth.properties => acl.properties} (100%)
 rename base/tps-tomcat/shared/webapps/tps/WEB-INF/{auth.properties => acl.properties} (100%)

diff --git a/base/ca/shared/webapps/ca/WEB-INF/auth.properties b/base/ca/shared/webapps/ca/WEB-INF/acl.properties
similarity index 100%
rename from base/ca/shared/webapps/ca/WEB-INF/auth.properties
rename to base/ca/shared/webapps/ca/WEB-INF/acl.properties
diff --git a/base/common/upgrade/10.0.5/.gitignore b/base/common/upgrade/10.0.5/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..5e7d2734cfc60289debf74293817c0a8f572ff32
--- /dev/null
+++ b/base/common/upgrade/10.0.5/.gitignore
@@ -0,0 +1,4 @@
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/base/common/upgrade/10.0.6/.gitignore b/base/common/upgrade/10.0.6/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..5e7d2734cfc60289debf74293817c0a8f572ff32
--- /dev/null
+++ b/base/common/upgrade/10.0.6/.gitignore
@@ -0,0 +1,4 @@
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/base/kra/shared/webapps/kra/WEB-INF/auth.properties b/base/kra/shared/webapps/kra/WEB-INF/acl.properties
similarity index 100%
rename from base/kra/shared/webapps/kra/WEB-INF/auth.properties
rename to base/kra/shared/webapps/kra/WEB-INF/acl.properties
diff --git a/base/ocsp/shared/webapps/ocsp/WEB-INF/auth.properties b/base/ocsp/shared/webapps/ocsp/WEB-INF/acl.properties
similarity index 100%
rename from base/ocsp/shared/webapps/ocsp/WEB-INF/auth.properties
rename to base/ocsp/shared/webapps/ocsp/WEB-INF/acl.properties
diff --git a/base/server/cms/src/com/netscape/cms/authorization/ACLInterceptor.java b/base/server/cms/src/com/netscape/cms/authorization/ACLInterceptor.java
index b43eb3cbeabe77842fd501a2dc7b79d45890688b..e831cf9708ace541107bb4a7d187b015f7c06987 100644
--- a/base/server/cms/src/com/netscape/cms/authorization/ACLInterceptor.java
+++ b/base/server/cms/src/com/netscape/cms/authorization/ACLInterceptor.java
@@ -49,7 +49,7 @@ import com.netscape.cms.realm.PKIPrincipal;
 @Provider
 public class ACLInterceptor implements ContainerRequestFilter {
 
-    Properties authProperties;
+    Properties properties;
 
     @Context
     ServletContext servletContext;
@@ -57,14 +57,14 @@ public class ACLInterceptor implements ContainerRequestFilter {
     @Context
     SecurityContext securityContext;
 
-    public synchronized void loadAuthProperties() throws IOException {
+    public synchronized void loadProperties() throws IOException {
 
-        if (authProperties != null)
+        if (properties != null)
             return;
 
-        URL url = servletContext.getResource("/WEB-INF/auth.properties");
-        authProperties = new Properties();
-        authProperties.load(url.openStream());
+        URL url = servletContext.getResource("/WEB-INF/acl.properties");
+        properties = new Properties();
+        properties.load(url.openStream());
     }
 
     @Override
@@ -118,9 +118,9 @@ public class ACLInterceptor implements ContainerRequestFilter {
         }
 
         try {
-            loadAuthProperties();
+            loadProperties();
 
-            String value = authProperties.getProperty(name);
+            String value = properties.getProperty(name);
 
             // If no property defined, allow request.
             if (value == null) {
diff --git a/base/server/cms/src/com/netscape/cms/authorization/AuthMethodInterceptor.java b/base/server/cms/src/com/netscape/cms/authorization/AuthMethodInterceptor.java
index 75159f375e285c5966c6db02b0aeed38142c8580..279de20c1d473f18ed7c75b5a9fd43f0a847be72 100644
--- a/base/server/cms/src/com/netscape/cms/authorization/AuthMethodInterceptor.java
+++ b/base/server/cms/src/com/netscape/cms/authorization/AuthMethodInterceptor.java
@@ -48,7 +48,7 @@ import com.netscape.cms.realm.PKIPrincipal;
 @Provider
 public class AuthMethodInterceptor implements ContainerRequestFilter {
 
-    Properties authMethodProperties;
+    Properties properties;
 
     @Context
     ServletContext servletContext;
@@ -56,36 +56,36 @@ public class AuthMethodInterceptor implements ContainerRequestFilter {
     @Context
     SecurityContext securityContext;
 
-    public synchronized void loadAuthProperties() throws IOException {
+    public synchronized void loadProperties() throws IOException {
 
-        if (authMethodProperties != null)
+        if (properties != null)
             return;
 
-        authMethodProperties = new Properties();
+        properties = new Properties();
 
         URL url = servletContext.getResource("/WEB-INF/auth-method.properties");
 
         if (url == null) {
-            authMethodProperties.put("default", "*");
-            authMethodProperties.put("account", "certUserDBAuthMgr,passwdUserDBAuthMgr");
-            authMethodProperties.put("authenticators", "certUserDBAuthMgr");
-            authMethodProperties.put("certs", "certUserDBAuthMgr");
-            authMethodProperties.put("certrequests", "certUserDBAuthMgr");
-            authMethodProperties.put("config", "certUserDBAuthMgr");
-            authMethodProperties.put("connections", "certUserDBAuthMgr");
-            authMethodProperties.put("groups", "certUserDBAuthMgr");
-            authMethodProperties.put("keys", "certUserDBAuthMgr");
-            authMethodProperties.put("keyrequests", "certUserDBAuthMgr");
-            authMethodProperties.put("kraconnectors", "certUserDBAuthMgr");
-            authMethodProperties.put("profiles", "certUserDBAuthMgr");
-            authMethodProperties.put("securityDomain.installToken", "passwdUserDBAuthMgr");
-            authMethodProperties.put("selftests", "certUserDBAuthMgr");
-            authMethodProperties.put("tokens", "certUserDBAuthMgr");
-            authMethodProperties.put("tpsconnectors", "certUserDBAuthMgr");
-            authMethodProperties.put("users", "certUserDBAuthMgr");
+            properties.put("default", "*");
+            properties.put("account", "certUserDBAuthMgr,passwdUserDBAuthMgr");
+            properties.put("authenticators", "certUserDBAuthMgr");
+            properties.put("certs", "certUserDBAuthMgr");
+            properties.put("certrequests", "certUserDBAuthMgr");
+            properties.put("config", "certUserDBAuthMgr");
+            properties.put("connections", "certUserDBAuthMgr");
+            properties.put("groups", "certUserDBAuthMgr");
+            properties.put("keys", "certUserDBAuthMgr");
+            properties.put("keyrequests", "certUserDBAuthMgr");
+            properties.put("kraconnectors", "certUserDBAuthMgr");
+            properties.put("profiles", "certUserDBAuthMgr");
+            properties.put("securityDomain.installToken", "passwdUserDBAuthMgr");
+            properties.put("selftests", "certUserDBAuthMgr");
+            properties.put("tokens", "certUserDBAuthMgr");
+            properties.put("tpsconnectors", "certUserDBAuthMgr");
+            properties.put("users", "certUserDBAuthMgr");
 
         } else {
-            authMethodProperties.load(url.openStream());
+            properties.load(url.openStream());
         }
     }
 
@@ -118,9 +118,9 @@ public class AuthMethodInterceptor implements ContainerRequestFilter {
         CMS.debug("AuthMethodInterceptor: mapping: " + name);
 
         try {
-            loadAuthProperties();
+            loadProperties();
 
-            String value = authMethodProperties.getProperty(name);
+            String value = properties.getProperty(name);
             Collection<String> authMethods = new HashSet<String>();
             if (value != null) {
                 for (String v : value.split(",")) {
diff --git a/base/server/python/pki/server/__init__.py b/base/server/python/pki/server/__init__.py
index eb1e4b81a0b799948a5c1c93bbfc653014209d85..e41f1a980584ecb234784cd0a0c947164c17cbe5 100644
--- a/base/server/python/pki/server/__init__.py
+++ b/base/server/python/pki/server/__init__.py
@@ -26,7 +26,7 @@ import pki
 
 INSTANCE_BASE_DIR = '/var/lib/pki'
 REGISTRY_DIR = '/etc/sysconfig/pki'
-SUBSYSTEM_TYPES = ['ca', 'kra', 'ocsp', 'tks']
+SUBSYSTEM_TYPES = ['ca', 'kra', 'ocsp', 'tks', 'tps']
 
 
 class PKISubsystem(object):
diff --git a/base/server/upgrade/10.0.6/.gitignore b/base/server/upgrade/10.0.6/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..5e7d2734cfc60289debf74293817c0a8f572ff32
--- /dev/null
+++ b/base/server/upgrade/10.0.6/.gitignore
@@ -0,0 +1,4 @@
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/base/server/upgrade/10.0.99/02-UpdateAuthzProperties b/base/server/upgrade/10.0.99/02-ReplaceAuthProperties
similarity index 68%
rename from base/server/upgrade/10.0.99/02-UpdateAuthzProperties
rename to base/server/upgrade/10.0.99/02-ReplaceAuthProperties
index 992b2d518336d1c25d8d1b6edc468fd11e44f1f1..62076da5fac23015b5fb80432511cb78f7b65e79 100755
--- a/base/server/upgrade/10.0.99/02-UpdateAuthzProperties
+++ b/base/server/upgrade/10.0.99/02-ReplaceAuthProperties
@@ -25,21 +25,32 @@ import shutil
 import pki.server.upgrade
 
 
-class UpdateAuthzProperties(pki.server.upgrade.PKIServerUpgradeScriptlet):
+class ReplaceAuthProperties(pki.server.upgrade.PKIServerUpgradeScriptlet):
 
     def __init__(self):
-        self.message = 'Update auth.properties'
+        self.message = 'Replace auth.properties with acl.properties'
 
     def upgrade_subsystem(self, instance, subsystem):
+
         auth_properties = os.path.join(
             instance.base_dir,
             'webapps', subsystem.name,
             'WEB-INF', 'auth.properties')
 
-        self.backup(auth_properties)
-        default_auth_properties = os.path.join(
+        acl_properties = os.path.join(
+            instance.base_dir,
+            'webapps', subsystem.name,
+            'WEB-INF', 'acl.properties')
+
+        default_acl_properties = os.path.join(
             pki.SHARE_DIR, subsystem.name,
             'webapps', subsystem.name,
-            'WEB-INF', 'auth.properties')
+            'WEB-INF', 'acl.properties')
 
-        shutil.copyfile(default_auth_properties, auth_properties)
+        self.backup(auth_properties)
+        self.backup(acl_properties)
+
+        if os.path.exists(auth_properties):
+            os.remove(auth_properties)
+
+        shutil.copyfile(default_acl_properties, acl_properties)
diff --git a/base/tks/shared/webapps/tks/WEB-INF/auth.properties b/base/tks/shared/webapps/tks/WEB-INF/acl.properties
similarity index 100%
rename from base/tks/shared/webapps/tks/WEB-INF/auth.properties
rename to base/tks/shared/webapps/tks/WEB-INF/acl.properties
diff --git a/base/tps-tomcat/shared/webapps/tps/WEB-INF/auth.properties b/base/tps-tomcat/shared/webapps/tps/WEB-INF/acl.properties
similarity index 100%
rename from base/tps-tomcat/shared/webapps/tps/WEB-INF/auth.properties
rename to base/tps-tomcat/shared/webapps/tps/WEB-INF/acl.properties
-- 
1.8.1.4

