[java-identity-provider] branch master updated: IDP-1532 - Potentially spurious warning from the transcoding registry
Scott Cantor
cantor.2 at osu.edu
Thu Feb 27 11:41:26 EST 2020
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=0875419aa2972683a3a0479bf749d49976e81129
The following commit(s) were added to refs/heads/master by this push:
new 0875419 IDP-1532 - Potentially spurious warning from the transcoding registry
0875419 is described below
commit 0875419aa2972683a3a0479bf749d49976e81129
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Feb 27 11:41:20 2020 -0500
IDP-1532 - Potentially spurious warning from the transcoding registry
https://issues.shibboleth.net/jira/browse/IDP-1532
Enhanced with a suffix list, and renamed the README file.
---
.../transcoding/impl/TranscodingRuleLoader.java | 33 +++++++++++++++++++---
.../src/main/resources/conf/attribute-registry.xml | 9 ++++--
.../conf/attributes/custom/{README.txt => README} | 0
3 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/idp-attribute-impl/src/main/java/net/shibboleth/idp/attribute/transcoding/impl/TranscodingRuleLoader.java b/idp-attribute-impl/src/main/java/net/shibboleth/idp/attribute/transcoding/impl/TranscodingRuleLoader.java
index ad3451c..e0b171f 100644
--- a/idp-attribute-impl/src/main/java/net/shibboleth/idp/attribute/transcoding/impl/TranscodingRuleLoader.java
+++ b/idp-attribute-impl/src/main/java/net/shibboleth/idp/attribute/transcoding/impl/TranscodingRuleLoader.java
@@ -28,6 +28,7 @@ import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,6 +38,7 @@ import net.shibboleth.idp.attribute.transcoding.TranscodingRule;
import net.shibboleth.utilities.java.support.annotation.ParameterName;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.logic.PredicateSupport;
/**
* A mechanism for loading a set of {@link TranscodingRule} objects from sources such as maps
@@ -57,12 +59,17 @@ public class TranscodingRuleLoader {
*
* <p>Individual rules that fail to load will be skipped.</p>
*
+ * <p>The file extensions must include the period, and only apply to
+ * files, while all directories will be examined.</p>
+ *
* @param dir root to search
+ * @param extensions file extensions to include
*
* @throws IOException if an error occurs
*/
- public TranscodingRuleLoader(@Nonnull @ParameterName(name="dir") final Path dir) throws IOException {
-
+ public TranscodingRuleLoader(@Nonnull @ParameterName(name="dir") final Path dir,
+ @Nullable @NonnullElements @ParameterName(name="extensions") final Collection<String> extensions)
+ throws IOException {
log.debug("Loading rules from directory ({})", dir);
rules = new ArrayList<>();
@@ -71,11 +78,12 @@ public class TranscodingRuleLoader {
final File file = child.toFile();
if (file.isDirectory()) {
try {
- rules.addAll(new TranscodingRuleLoader(child).getRules());
+ rules.addAll(new TranscodingRuleLoader(child, extensions).getRules());
} catch (final IOException e) {
log.error("Failed to load rules from directory ({})", file, e);
}
- } else {
+ } else if (!extensions.isEmpty() &&
+ PredicateSupport.anyMatch((String ext) -> file.getName().endsWith(ext)).test(extensions)) {
log.debug("Loading rule from property set in file ({})", file);
try {
final TranscodingRule rule = TranscodingRule.fromResource(new FileSystemResource(file));
@@ -87,10 +95,27 @@ public class TranscodingRuleLoader {
} catch (final IOException e) {
log.error("Failed to load rule from file ({})", file, e);
}
+ } else {
+ log.debug("Ignoring file ({}) with non-matching extension", file);
}
}
}
}
+
+ /**
+ * Load rules from all files found below a directory root.
+ *
+ * <p>Files are assumed to be Java property files in text format.</p>
+ *
+ * <p>Individual rules that fail to load will be skipped.</p>
+ *
+ * @param dir root to search
+ *
+ * @throws IOException if an error occurs
+ */
+ public TranscodingRuleLoader(@Nonnull @ParameterName(name="dir") final Path dir) throws IOException {
+ this(dir, null);
+ }
/**
* Constructor.
diff --git a/idp-conf/src/main/resources/conf/attribute-registry.xml b/idp-conf/src/main/resources/conf/attribute-registry.xml
index 8890f4b..ff26571 100644
--- a/idp-conf/src/main/resources/conf/attribute-registry.xml
+++ b/idp-conf/src/main/resources/conf/attribute-registry.xml
@@ -16,11 +16,14 @@
The system comes preconfigured to load rules directly from resource files
configured in services.xml so they're monitored for changes.
- You can add mappings here, add more XML resource files,
- or drop property files into the directory noted below.
+ You can add mappings here, add more XML resource files, or drop property
+ files into the directory noted below, but they won't be monitored for changes
+ themselves.
-->
<!-- Default directory for custom mappings. -->
- <bean parent="shibboleth.TranscodingRuleLoader" c:_0="%{idp.home}/conf/attributes/custom" />
+ <bean parent="shibboleth.TranscodingRuleLoader"
+ c:dir="%{idp.home}/conf/attributes/custom"
+ c:extensions="#{{'.txt', '.props', '.rule'}}" />
</beans>
diff --git a/idp-conf/src/main/resources/conf/attributes/custom/README.txt b/idp-conf/src/main/resources/conf/attributes/custom/README
similarity index 100%
rename from idp-conf/src/main/resources/conf/attributes/custom/README.txt
rename to idp-conf/src/main/resources/conf/attributes/custom/README
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list