[java-identity-provider COMMIT] in /trunk/idp-profile-api/src: main/java/net/shibboleth/idp/profile/ScriptedAction.ja...
noreply at shibboleth.net
noreply at shibboleth.net
Mon Sep 14 12:58:41 EDT 2015
Author: rdw
Date: Mon Sep 14 12:58:41 2015
New Revision: 7748
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7748&view=rev
Log:
IDP-774 Custom object injection for scripting contexts: Attributes
https://issues.shibboleth.net/jira/browse/IDP-774
custom Object for ScriptedAction, ScriptedContextLookupFunction and ScriptedPredicate.
Modified:
trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/ScriptedAction.java
trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/context/navigate/ScriptedContextLookupFunction.java
trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/logic/ScriptedPredicate.java
trunk/idp-profile-api/src/test/java/net/shibboleth/idp/profile/context/navigate/ScriptedFunctionTest.java
trunk/idp-profile-api/src/test/java/net/shibboleth/idp/profile/logic/ScriptedPredicateTest.java
Modified: trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/ScriptedAction.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/ScriptedAction.java?rev=7748&r1=7747&r2=7748&view=diff
==============================================================================
--- trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/ScriptedAction.java (original)
+++ trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/ScriptedAction.java Mon Sep 14 12:58:41 2015
@@ -59,6 +59,9 @@
/** Debugging info. */
@Nullable private final String logPrefix;
+ /** The custom object we can inject. */
+ @Nullable private Object customObject;
+
/**
* Constructor.
*
@@ -79,11 +82,28 @@
script = Constraint.isNotNull(theScript, "Supplied script should not be null");
logPrefix = "Anonymous Scripted Action :";
}
+
+ /**
+ * Return the custom (externally provided) object.
+ * @return the custom object
+ */
+ @Nullable public Object getCustomObject() {
+ return customObject;
+ }
+
+ /**
+ * Set the custom (externally provided) object.
+ * @param object the custom object
+ */
+ @Nullable public void setCustomObject(Object object) {
+ customObject = object;
+ }
/** {@inheritDoc} */
@Override public void doExecute(@Nullable final ProfileRequestContext profileContext) {
final SimpleScriptContext scriptContext = new SimpleScriptContext();
scriptContext.setAttribute("profileContext", profileContext, ScriptContext.ENGINE_SCOPE);
+ scriptContext.setAttribute("custom", getCustomObject(), ScriptContext.ENGINE_SCOPE);
try {
final Object result = script.eval(scriptContext);
Modified: trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/context/navigate/ScriptedContextLookupFunction.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/context/navigate/ScriptedContextLookupFunction.java?rev=7748&r1=7747&r2=7748&view=diff
==============================================================================
--- trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/context/navigate/ScriptedContextLookupFunction.java (original)
+++ trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/context/navigate/ScriptedContextLookupFunction.java Mon Sep 14 12:58:41 2015
@@ -63,6 +63,9 @@
/** What class we want the output to test against. */
@Nonnull private final Class<T> inputClass;
+ /** The custom object we can be injected into the script. */
+ @Nullable private Object customObject;
+
/**
* Constructor.
*
@@ -103,6 +106,22 @@
outputClass = outputType;
}
+ /**
+ * Return the custom (externally provided) object.
+ * @return the custom object
+ */
+ @Nullable public Object getCustomObject() {
+ return customObject;
+ }
+
+ /**
+ * Set the custom (externally provided) object.
+ * @param object the custom object
+ */
+ @Nullable public void setCustomObject(Object object) {
+ customObject = object;
+ }
+
/** {@inheritDoc} */
@Override public Object apply(@Nullable T context) {
@@ -113,6 +132,7 @@
final SimpleScriptContext scriptContext = new SimpleScriptContext();
scriptContext.setAttribute("profileContext", context, ScriptContext.ENGINE_SCOPE);
+ scriptContext.setAttribute("custom", getCustomObject(), ScriptContext.ENGINE_SCOPE);
try {
Object output = script.eval(scriptContext);
Modified: trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/logic/ScriptedPredicate.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/logic/ScriptedPredicate.java?rev=7748&r1=7747&r2=7748&view=diff
==============================================================================
--- trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/logic/ScriptedPredicate.java (original)
[... 88 lines stripped ...]
More information about the commits
mailing list