You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2017/11/20 18:51:07 UTC

svn commit: r1815834 - in /tomcat/trunk: conf/jaspic-providers.xml java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java test/org/apache/catalina/authenticator/jaspic/TestAuthConfigFactoryImpl.java webapps/docs/changelog.xml

Author: markt
Date: Mon Nov 20 18:51:07 2017
New Revision: 1815834

URL: http://svn.apache.org/viewvc?rev=1815834&view=rev
Log:
 When calling AuthConfigFactory.removeRegistration() and the registration is persistent, it should be removed from the persistent store.
Patch provided by Lazar.
This closes #91

Modified:
    tomcat/trunk/conf/jaspic-providers.xml
    tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java
    tomcat/trunk/test/org/apache/catalina/authenticator/jaspic/TestAuthConfigFactoryImpl.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/conf/jaspic-providers.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/conf/jaspic-providers.xml?rev=1815834&r1=1815833&r2=1815834&view=diff
==============================================================================
--- tomcat/trunk/conf/jaspic-providers.xml (original)
+++ tomcat/trunk/conf/jaspic-providers.xml Mon Nov 20 18:51:07 2017
@@ -1,23 +1,9 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one or more
-  contributor license agreements.  See the NOTICE file distributed with
-  this work for additional information regarding copyright ownership.
-  The ASF licenses this file to You under the Apache License, Version 2.0
-  (the "License"); you may not use this file except in compliance with
-  the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
--->
-<jaspic-providers xmlns="http://tomcat.apache.org/xml"
-                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-                  xsi:schemaLocation="http://tomcat.apache.org/xml jaspic-providers.xsd"
-                  version="1.0">
-  <!-- No JASPIC providers configured by default -->
+<?xml version='1.0' encoding='utf-8'?>
+<jaspic-providers
+    xmlns="http://tomcat.apache.org/xml"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://tomcat.apache.org/xml jaspic-providers.xsd"
+    version="1.0">
+  <provider className="org.apache.catalina.authenticator.jaspic.SimpleAuthConfigProvider" layer="L_1" appContext="AC_1">
+  </provider>
 </jaspic-providers>

Modified: tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java?rev=1815834&r1=1815833&r2=1815834&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java (original)
+++ tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java Mon Nov 20 18:51:07 2017
@@ -238,6 +238,9 @@ public class AuthConfigFactoryImpl exten
             for (RegistrationListenerWrapper wrapper : registration.listeners) {
                 wrapper.getListener().notify(wrapper.getMessageLayer(), wrapper.getAppContext());
             }
+            if (registration.isPersistent()) {
+                savePersistentRegistrations();
+            }
             return true;
         }
     }

Modified: tomcat/trunk/test/org/apache/catalina/authenticator/jaspic/TestAuthConfigFactoryImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/authenticator/jaspic/TestAuthConfigFactoryImpl.java?rev=1815834&r1=1815833&r2=1815834&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/authenticator/jaspic/TestAuthConfigFactoryImpl.java (original)
+++ tomcat/trunk/test/org/apache/catalina/authenticator/jaspic/TestAuthConfigFactoryImpl.java Mon Nov 20 18:51:07 2017
@@ -16,6 +16,7 @@
  */
 package org.apache.catalina.authenticator.jaspic;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
@@ -29,6 +30,8 @@ import javax.security.auth.message.confi
 import org.junit.Assert;
 import org.junit.Test;
 
+import org.apache.catalina.Globals;
+
 public class TestAuthConfigFactoryImpl {
 
     @Test
@@ -306,6 +309,45 @@ public class TestAuthConfigFactoryImpl {
     }
 
 
+    @Test
+    public void testRemovePersistentRegistration() {
+        // set CATALINA_BASE to test so that the file with persistent providers will be written in test/conf folder
+        String oldCatalinaBase = System.getProperty(Globals.CATALINA_BASE_PROP);
+        System.setProperty(Globals.CATALINA_BASE_PROP, "test");
+
+        File file = new File("test/conf/jaspic-providers.xml");
+        if (file.exists()) {
+            file.delete();
+        }
+
+        try {
+            AuthConfigFactory factory = new AuthConfigFactoryImpl();
+            factory.registerConfigProvider(
+                    SimpleAuthConfigProvider.class.getName(), null, "L_1", "AC_1", null);
+            String registrationId2 = factory.registerConfigProvider(
+                    SimpleAuthConfigProvider.class.getName(), null, "L_2", "AC_2", null);
+
+            factory.removeRegistration(registrationId2);
+            factory.refresh();
+
+            String[] registrationIds = factory.getRegistrationIDs(null);
+            for (String registrationId : registrationIds) {
+                Assert.assertNotEquals(registrationId2, registrationId);
+            }
+        } finally {
+            if (oldCatalinaBase != null ) {
+                System.setProperty(Globals.CATALINA_BASE_PROP, oldCatalinaBase);
+            } else {
+                System.clearProperty(Globals.CATALINA_BASE_PROP);
+            }
+
+            if (file.exists()) {
+                file.delete();
+            }
+        }
+    }
+
+
     private static class SimpleRegistrationListener implements RegistrationListener {
 
         private final String layer;

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1815834&r1=1815833&r2=1815834&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Mon Nov 20 18:51:07 2017
@@ -111,11 +111,17 @@
       </fix>
       <fix>
         <bug>61782</bug>: When calling
-        <code>AuthConfigFactoryImpl.doRegisterConfigProvider()</code> and the
+        <code>AuthConfigFactory.doRegisterConfigProvider()</code> and the
         requested JASPIC config provider class is found by the web application
         class loader, do not attempt to load the class with the class loader
         that loaded the JASPIC API. Patch provided by Lazar. (markt)
       </fix>
+      <fix>
+        <bug>61783</bug>: When calling
+        <code>AuthConfigFactory.removeRegistration()</code> and the registration
+        is persistent, it should be removed from the persistent store. Patch
+        provided by Lazar. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org