Working around CAS bug
diff --git a/wa/bootstrap/pom.xml b/wa/bootstrap/pom.xml
index 5fe2a70..4837838 100644
--- a/wa/bootstrap/pom.xml
+++ b/wa/bootstrap/pom.xml
@@ -57,6 +57,17 @@
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-core-util-api</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/AuthModulePropertySourceMapper.java b/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/AuthModulePropertySourceMapper.java
index b14c7fe..bb3179c 100644
--- a/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/AuthModulePropertySourceMapper.java
+++ b/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/AuthModulePropertySourceMapper.java
@@ -18,6 +18,8 @@
*/
package org.apache.syncope.wa.bootstrap;
+import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
+import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
@@ -266,6 +268,10 @@
}
}
- return prefix("cas.authn.mfa.simple.", CasCoreConfigurationUtils.asMap(props));
+ // workaround to remove with CAS >= 6.6.1
+ return prefix("cas.authn.mfa.simple.", CasCoreConfigurationUtils.asMap(
+ props,
+ new SimpleFilterProvider().setDefaultFilter(
+ SimpleBeanPropertyFilter.filterOutAllExcept("defined", "undefined"))));
}
}
diff --git a/wa/bootstrap/src/test/java/org/apache/syncope/wa/bootstrap/AuthModulePropertySourceMapperTest.java b/wa/bootstrap/src/test/java/org/apache/syncope/wa/bootstrap/AuthModulePropertySourceMapperTest.java
new file mode 100644
index 0000000..a5175eb
--- /dev/null
+++ b/wa/bootstrap/src/test/java/org/apache/syncope/wa/bootstrap/AuthModulePropertySourceMapperTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+package org.apache.syncope.wa.bootstrap;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+
+import java.util.Map;
+import org.apache.syncope.common.lib.auth.SimpleMfaAuthModuleConf;
+import org.apache.syncope.common.lib.to.AuthModuleTO;
+import org.junit.jupiter.api.Test;
+
+public class AuthModulePropertySourceMapperTest {
+
+ @Test
+ public void mapSimpleMfaAuthModuleConf() {
+ AuthModuleTO authModuleTO = new AuthModuleTO();
+ authModuleTO.setKey("key");
+ authModuleTO.setOrder(0);
+
+ SimpleMfaAuthModuleConf conf = new SimpleMfaAuthModuleConf();
+
+ conf.setEmailAttribute("email");
+ conf.setEmailFrom("syncope@apache.org");
+ conf.setEmailSubject("Subject");
+ conf.setEmailText("Text body");
+
+ conf.setTokenLength(256);
+ conf.setTimeToKillInSeconds(600);
+
+ Map<String, Object> map = new AuthModulePropertySourceMapper(null).map(authModuleTO, conf);
+ assertFalse(map.keySet().stream().anyMatch(k -> k.endsWith("defined")));
+ }
+}