[java-shib-attribute] branch main updated: JSATTR-53 - Scripted data connector caching is broken
Codeberg
noreply at shibboleth.net
Thu Aug 27 21:02:45 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-shib-attribute.
View the commit online:
https://codeberg.org/Shibboleth/java-shib-attribute/commit/111adbcd2cf9d7fde00791135d236df4218578de
The following commit(s) were added to refs/heads/main by this push:
new 111adbcd2 JSATTR-53 - Scripted data connector caching is broken
111adbcd2 is described below
commit 111adbcd2cf9d7fde00791135d236df4218578de
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Thu Aug 27 17:02:31 2026 -0400
JSATTR-53 - Scripted data connector caching is broken
https://shibboleth.atlassian.net/browse/JSATTR-53
Added missing check and init method install.
Broke tests initially, fixes applied.
---
.../resolver/dc/scripted/impl/ScriptedSearchBuilder.java | 13 +++++++------
.../dc/scripted/impl/ScriptedDataConnectorTest.java | 10 ++++++++--
.../spring/dc/impl/ScriptedDataConnectorParser.java | 1 +
.../resolver/spring/dc/resolver/scriptedAttributeBoth.xml | 4 ++++
4 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/shib-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/scripted/impl/ScriptedSearchBuilder.java b/shib-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/scripted/impl/ScriptedSearchBuilder.java
index 18bba9ba0..38e8f08e1 100644
--- a/shib-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/scripted/impl/ScriptedSearchBuilder.java
+++ b/shib-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/scripted/impl/ScriptedSearchBuilder.java
@@ -60,12 +60,12 @@ public class ScriptedSearchBuilder extends AbstractInitializableComponent
@Override protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
- final VelocityEngine localEngine = engine;
- if (null == localEngine) {
- throw new ComponentInitializationException("Velocity engine cannot be null");
- }
-
if (null != cacheKeyTemplateText) {
+ final VelocityEngine localEngine = engine;
+ if (null == localEngine) {
+ throw new ComponentInitializationException("Velocity engine cannot be null if cache key template exists");
+ }
+
cacheKeyTemplate = Template.fromTemplate(localEngine, cacheKeyTemplateText);
}
}
@@ -114,7 +114,8 @@ public class ScriptedSearchBuilder extends AbstractInitializableComponent
@Override
@Nonnull public ScriptedSearch build(@Nonnull final AttributeResolutionContext resolutionContext,
@Nonnull final Map<String, List<IdPAttributeValue>> dependencyAttributes) throws ResolutionException {
-
+ checkComponentActive();
+
return new ScriptedSearch() {
@Nonnull public AttributeResolutionContext getResolutionContext() {
diff --git a/shib-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/dc/scripted/impl/ScriptedDataConnectorTest.java b/shib-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/dc/scripted/impl/ScriptedDataConnectorTest.java
index b031f00c0..c1623750d 100644
--- a/shib-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/dc/scripted/impl/ScriptedDataConnectorTest.java
+++ b/shib-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/dc/scripted/impl/ScriptedDataConnectorTest.java
@@ -60,10 +60,13 @@ public class ScriptedDataConnectorTest {
@Test(expectedExceptions=ResolutionException.class)
public void error() throws ComponentInitializationException, ScriptException, IOException, ResolutionException {
+ final ScriptedSearchBuilder builder = new ScriptedSearchBuilder();
+ builder.initialize();
+
final ScriptedDataConnector connector = new ScriptedDataConnector();
connector.setId("Scripted");
connector.setScript(getScript("error.js"));
- connector.setExecutableSearchBuilder(new ScriptedSearchBuilder());
+ connector.setExecutableSearchBuilder(builder);
connector.initialize();
final AttributeResolutionContext context = new ProfileRequestContext().ensureSubcontext(AttributeResolutionContext.class);
@@ -73,6 +76,8 @@ public class ScriptedDataConnectorTest {
}
@Test public void custom() throws ComponentInitializationException, ResolutionException, ScriptException, IOException {
+ final ScriptedSearchBuilder builder = new ScriptedSearchBuilder();
+ builder.initialize();
final ScriptedDataConnector connector = new ScriptedDataConnector();
connector.setId("Scripted");
@@ -82,7 +87,7 @@ public class ScriptedDataConnectorTest {
connector.setCustomObject(attribute);
connector.setScript(getScript("custom.js"));
- connector.setExecutableSearchBuilder(new ScriptedSearchBuilder());
+ connector.setExecutableSearchBuilder(builder);
connector.initialize();
final AttributeResolutionContext context = new ProfileRequestContext().ensureSubcontext(AttributeResolutionContext.class);
@@ -117,6 +122,7 @@ public class ScriptedDataConnectorTest {
final TestCache cache = new TestCache();
connector.setResultsCache(cache);
connector.setScript(getScript("cache.js"));
+
final ScriptedSearchBuilder builder = new ScriptedSearchBuilder();
builder.setVelocityEngine(VelocityEngine.newVelocityEngine());
diff --git a/shib-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/ScriptedDataConnectorParser.java b/shib-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/ScriptedDataConnectorParser.java
index de11920af..2e74ec3c5 100644
--- a/shib-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/ScriptedDataConnectorParser.java
+++ b/shib-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/ScriptedDataConnectorParser.java
@@ -117,6 +117,7 @@ public class ScriptedDataConnectorParser extends AbstractDataConnectorParser {
//
final BeanDefinitionBuilder searchBuilder =
BeanDefinitionBuilder.genericBeanDefinition(ScriptedSearchBuilder.class);
+ searchBuilder.setInitMethodName("initialize");
String velocityEngineRef = StringSupport.trimOrNull(config.getAttributeNS(null, "templateEngine"));
if (null == velocityEngineRef) {
velocityEngineRef = getCustomProperty(VELOCIY_ENGINE_BEAN_IDENTIFIER, null);
diff --git a/shib-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/scriptedAttributeBoth.xml b/shib-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/scriptedAttributeBoth.xml
index 258cb63c4..1536d4f91 100644
--- a/shib-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/scriptedAttributeBoth.xml
+++ b/shib-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/resolver/scriptedAttributeBoth.xml
@@ -31,5 +31,9 @@
]]></Script>
<ScriptFile>classpath:/net/shibboleth/idp/attribute/resolver/spring/dc/scriptedConnector.8.js</ScriptFile>
<FailoverDataConnector ref="w"/>
+
+ <ResultCache/>
+
+ <CacheKeyTemplate>foo</CacheKeyTemplate>
</DataConnector>
</beans>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list