[java-identity-provider] 36/51: IDP-1121 stop supplying the workContext to the Scripted Resolver plugins
Rod Widdowson
rdw at steadingsoftware.com
Wed Feb 6 08:43:07 EST 2019
This is an automated email from the git hooks/post-receive script.
rdw 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=0c41ffa700a186b70c2838f7399dc2fb6d711408
commit 0c41ffa700a186b70c2838f7399dc2fb6d711408
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sun Jan 27 14:23:39 2019 +0000
IDP-1121 stop supplying the workContext to the Scripted Resolver plugins
https://issues.shibboleth.net/jira/browse/IDP-1121
And therefore kill off the DelegatedWorkContext
---
.../resolver/ad/impl/DelegatedWorkContext.java | 225 ---------------------
.../ad/impl/ScriptedAttributeDefinition.java | 3 -
.../resolver/dc/impl/ScriptedDataConnector.java | 17 +-
.../resolver/ad/impl/ScriptedAttributeTest.java | 32 ---
.../idp/attribute/resolver/impl/ad/work.script | 6 -
5 files changed, 6 insertions(+), 277 deletions(-)
diff --git a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/DelegatedWorkContext.java b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/DelegatedWorkContext.java
deleted file mode 100644
index 34b5ad3..0000000
--- a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/DelegatedWorkContext.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements. See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID 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 net.shibboleth.idp.attribute.resolver.ad.impl;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.resolver.AttributeDefinition;
-import net.shibboleth.idp.attribute.resolver.DataConnector;
-import net.shibboleth.idp.attribute.resolver.ResolutionException;
-import net.shibboleth.idp.attribute.resolver.ResolvedAttributeDefinition;
-import net.shibboleth.idp.attribute.resolver.ResolvedDataConnector;
-import net.shibboleth.idp.attribute.resolver.context.AttributeResolverWorkContext;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
-import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
-import net.shibboleth.utilities.java.support.primitive.DeprecationSupport;
-import net.shibboleth.utilities.java.support.primitive.DeprecationSupport.ObjectType;
-
-import org.opensaml.messaging.context.BaseContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A delegate for {@link AttributeResolverWorkContext}.
- *
- * <p>
- * This is only here because in a moment of madness we pushed the work context into the scripted definitions. This
- * preserves the function while making it obvious that we don't want people to use it.
- * </p>
- *
- * @deprecated
- */
- at Deprecated
-public class DelegatedWorkContext extends BaseContext {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(DelegatedWorkContext.class);
-
- /** The delegate. */
- @Nonnull private final AttributeResolverWorkContext delegate;
-
- /** The log prefix. */
- @Nullable private final String logPrefix;
-
- /**
- * Constructor.
- *
- * @param parent the value to be delegated.
- * @param prefix the log prefix of the calling scripted definition.
- */
- public DelegatedWorkContext(@Nonnull final AttributeResolverWorkContext parent, @Nullable final String prefix) {
- delegate = parent;
- setParent(delegate.getParent());
- logPrefix = prefix;
- }
-
- /* BaseContext Overrides */
-
- @Override @Nullable public BaseContext getParent() {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- return delegate.getParent();
- }
-
- @Override @Nullable public <T extends BaseContext> T getSubcontext(@Nonnull final Class<T> clazz) {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- return delegate.getSubcontext(clazz);
- }
-
- @Override @Nullable public <T extends BaseContext> T getSubcontext(@Nonnull final Class<T> clazz,
- final boolean autocreate) {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- return delegate.getSubcontext(clazz, autocreate);
- }
-
- @Override @Nullable public BaseContext getSubcontext(@Nonnull @NotEmpty final String className)
- throws ClassNotFoundException {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- return delegate.getSubcontext(className);
- }
-
- @Override @Nullable public BaseContext getSubcontext(@Nonnull @NotEmpty final String className,
- final boolean autocreate) throws ClassNotFoundException {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- return delegate.getSubcontext(className, autocreate);
- }
-
- @Override @Nonnull public BaseContext addSubcontext(@Nonnull final BaseContext subContext) {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- return delegate.addSubcontext(subContext);
- }
-
- @Override @Nonnull public BaseContext addSubcontext(@Nonnull final BaseContext subcontext, final boolean replace) {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- return delegate.addSubcontext(subcontext, replace);
- }
-
- @Override public void removeSubcontext(@Nonnull final BaseContext subcontext) {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- delegate.removeSubcontext(subcontext);
- }
-
- @Override public <T extends BaseContext> void removeSubcontext(@Nonnull final Class<T> clazz) {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- delegate.removeSubcontext(clazz);
- }
-
- @Override public <T extends BaseContext> boolean containsSubcontext(@Nonnull final Class<T> clazz) {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- return delegate.containsSubcontext(clazz);
- }
-
- @Override public void clearSubcontexts() {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- delegate.clearSubcontexts();
- }
-
- @Override @Deprecated public boolean isAutoCreateSubcontexts() {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- return delegate.isAutoCreateSubcontexts();
- }
-
- @Override @Deprecated public void setAutoCreateSubcontexts(final boolean autoCreate) {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- delegate.setAutoCreateSubcontexts(autoCreate);
- }
-
- /** {@inheritDoc} */
- @Override @Nonnull public Iterator<BaseContext> iterator() {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- return delegate.iterator();
- }
-
- /* Attribute Resolver implementations */
-
- /**
- * see {@link AttributeResolverWorkContext#getResolvedIdPAttributeDefinitions()}.
- *
- * @return what the delegate does.
- */
- @Nonnull @NonnullElements @Unmodifiable public Map<String, ResolvedAttributeDefinition>
- getResolvedIdPAttributeDefinitions() {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- log.error("'{}' Use of workContext.getResolvedIdPAttributeDefinitions()"
- + " is deprecated and will cause instability", logPrefix);
- return delegate.getResolvedIdPAttributeDefinitions();
- }
-
- /**
- * see {@link AttributeResolverWorkContext#recordAttributeDefinitionResolution(AttributeDefinition,IdPAttribute)}.
- *
- * @param definition as the delegate does
- * @param attribute as the delegate does
- * @throws ResolutionException as the delegate does
- */
- public void recordAttributeDefinitionResolution(@Nonnull final AttributeDefinition definition,
- @Nullable final IdPAttribute attribute) throws ResolutionException {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- log.error("'{}' Use of workContext.getResolvedIdPAttributeDefinitions()"
- + " is deprecated and will cause instability", logPrefix);
- delegate.recordAttributeDefinitionResolution(definition, attribute);
- }
-
- /**
- * see {@link AttributeResolverWorkContext#getResolvedDataConnectors()}.
- *
- * @return what the delegate does.
- */
- @Nonnull @NonnullElements @Unmodifiable public Map<String, ResolvedDataConnector> getResolvedDataConnectors() {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- log.error("'{}' Use of workContext.getResolvedDataConnectors() is deprecated and will cause instability",
- logPrefix);
- return delegate.getResolvedDataConnectors();
- }
-
- /**
- * see {@link AttributeResolverWorkContext#recordDataConnectorResolution(DataConnector,Map)}.
- *
- * @param connector as the delegate does
- * @param attributes as the delegate does
- * @throws ResolutionException as the delegate does
- */
- public void recordDataConnectorResolution(@Nonnull final DataConnector connector,
- @Nullable final Map<String, IdPAttribute> attributes) throws ResolutionException {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- log.error("'{}' Use of workContext.recordDataConnectorResolution() is deprecated and will cause instability",
- logPrefix);
- delegate.recordDataConnectorResolution(connector, attributes);
- }
-
- /**
- * see {@link AttributeResolverWorkContext#recordFailoverResolution}.
- *
- * @param failedConnector as the delegate does
- * @param failoverConnector as the delegate does
- * @throws ResolutionException as the delegate does
- */
- public void recordFailoverResolution(@Nonnull final DataConnector failedConnector,
- @Nonnull final DataConnector failoverConnector) throws ResolutionException {
- DeprecationSupport.warnOnce(ObjectType.CLASS, AttributeResolverWorkContext.class.getName(), null, null);
- log.error("'{}' Use of workContext.recordFailoverResolution() is deprecated and will cause instability",
- logPrefix);
- delegate.recordFailoverResolution(failedConnector, failoverConnector);
-
- }
-}
diff --git a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/ScriptedAttributeDefinition.java b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/ScriptedAttributeDefinition.java
index 43e3a38..2ec10cc 100644
--- a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/ScriptedAttributeDefinition.java
+++ b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/ad/impl/ScriptedAttributeDefinition.java
@@ -249,9 +249,6 @@ public class ScriptedAttributeDefinition extends AbstractAttributeDefinition {
log.debug("{} Adding contexts to script context", getLogPrefix());
scriptContext.setAttribute("resolutionContext", input[0], ScriptContext.ENGINE_SCOPE);
- scriptContext.setAttribute("workContext",
- new DelegatedWorkContext((AttributeResolverWorkContext) input[1], getLogPrefix()),
- ScriptContext.ENGINE_SCOPE);
final ProfileRequestContext prc = prcLookupStrategy.apply((AttributeResolutionContext) input[0]);
if (null == prc) {
diff --git a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/impl/ScriptedDataConnector.java b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/impl/ScriptedDataConnector.java
index 4aea98e..ed79843 100644
--- a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/impl/ScriptedDataConnector.java
+++ b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/impl/ScriptedDataConnector.java
@@ -33,12 +33,17 @@ import javax.script.ScriptContext;
import javax.script.ScriptException;
import javax.security.auth.Subject;
+import org.opensaml.messaging.context.navigate.ChildContextLookup;
+import org.opensaml.messaging.context.navigate.ParentContextLookup;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import net.shibboleth.idp.attribute.IdPAttribute;
import net.shibboleth.idp.attribute.IdPAttributeValue;
import net.shibboleth.idp.attribute.resolver.AbstractDataConnector;
import net.shibboleth.idp.attribute.resolver.PluginDependencySupport;
import net.shibboleth.idp.attribute.resolver.ResolutionException;
-import net.shibboleth.idp.attribute.resolver.ad.impl.DelegatedWorkContext;
import net.shibboleth.idp.attribute.resolver.ad.impl.ScriptedIdPAttributeImpl;
import net.shibboleth.idp.attribute.resolver.context.AttributeResolutionContext;
import net.shibboleth.idp.attribute.resolver.context.AttributeResolverWorkContext;
@@ -50,16 +55,9 @@ import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.scripting.AbstractScriptEvaluator;
import net.shibboleth.utilities.java.support.scripting.EvaluableScript;
-import org.opensaml.messaging.context.navigate.ChildContextLookup;
-import org.opensaml.messaging.context.navigate.ParentContextLookup;
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* A Data Connector which populates a series of attributes from a provided {@link ProfileRequestContext}.
*/
- at SuppressWarnings("deprecation")
public class ScriptedDataConnector extends AbstractDataConnector {
/** The id of the object where the results go. */
@@ -226,9 +224,6 @@ public class ScriptedDataConnector extends AbstractDataConnector {
log.debug("{} Adding current attribute resolution contexts to script context", getLogPrefix());
scriptContext.setAttribute("resolutionContext", input[0], ScriptContext.ENGINE_SCOPE);
- scriptContext.setAttribute("workContext",
- new DelegatedWorkContext((AttributeResolverWorkContext) input[1], getLogPrefix()),
- ScriptContext.ENGINE_SCOPE);
final ProfileRequestContext prc = prcLookupStrategy.apply((AttributeResolutionContext) input[0]);
if (null == prc) {
diff --git a/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/impl/ScriptedAttributeTest.java b/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/impl/ScriptedAttributeTest.java
index 58a1aec..7ac00dc 100644
--- a/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/impl/ScriptedAttributeTest.java
+++ b/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/ad/impl/ScriptedAttributeTest.java
@@ -380,38 +380,6 @@ public class ScriptedAttributeTest extends XMLObjectBaseTestCase {
Assert.assertTrue(values.contains(TestSources.ATTRIBUTE_ATTRIBUTE_VALUE_RESULT));
}
- @Test public void workContext() throws ResolutionException, ComponentInitializationException, ScriptException,
- IOException {
-
- // Set the dependency on the data connector
- final Set<ResolverAttributeDefinitionDependency> ds = new LazySet<>();
- ds.add(TestSources.makeAttributeDefinitionDependency(TestSources.DEPENDS_ON_ATTRIBUTE_NAME_ATTR));
- final ScriptedAttributeDefinition scripted = new ScriptedAttributeDefinition();
- scripted.setId(TEST_ATTRIBUTE_NAME);
- scripted.setScript(new EvaluableScript(SCRIPT_LANGUAGE, getScript("work.script")));
- scripted.setAttributeDependencies(ds);
- scripted.initialize();
-
- // And resolve
- final Set<AttributeDefinition> attrDefinitions = new LazySet<>();
- attrDefinitions.add(scripted);
- attrDefinitions.add(TestSources.populatedStaticAttribute());
-
- final Set<DataConnector> dataDefinitions = new LazySet<>();
- dataDefinitions.add(TestSources.populatedStaticConnector());
-
- final AttributeResolverImpl resolver = AttributeResolverImplTest.newAttributeResolverImpl("foo", attrDefinitions, dataDefinitions);
- resolver.initialize();
-
- final AttributeResolutionContext context = generateContext();
- resolver.resolveAttributes(context);
- final IdPAttribute attribute = context.getResolvedIdPAttributes().get(TEST_ATTRIBUTE_NAME);
- final List<IdPAttributeValue<?>> values = attribute.getValues();
-
- Assert.assertEquals(values.size(), 3);
- Assert.assertTrue(values.contains(TestSources.COMMON_ATTRIBUTE_VALUE_RESULT));
- }
-
/**
* Test resolution of an script which looks at the provided attributes.
*
diff --git a/idp-attribute-resolver-impl/src/test/resources/net/shibboleth/idp/attribute/resolver/impl/ad/work.script b/idp-attribute-resolver-impl/src/test/resources/net/shibboleth/idp/attribute/resolver/impl/ad/work.script
deleted file mode 100644
index 96084fa..0000000
--- a/idp-attribute-resolver-impl/src/test/resources/net/shibboleth/idp/attribute/resolver/impl/ad/work.script
+++ /dev/null
@@ -1,6 +0,0 @@
-values = at1.getNativeAttribute().getValues().iterator();
- val = values.next();
- Scripted.addValue(val);
- Scripted.addValue(workContext.getResolvedIdPAttributeDefinitions().toString());
- Scripted.addValue(workContext.getResolvedDataConnectors().toString());
-
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list