Update Collecting Data authored by Janne Lauros's avatar Janne Lauros
......@@ -26,3 +26,28 @@ Data storage options are in `userprofile.properties` - file.
| `userProfile.recordexExpiration` |P180D| Expiration duration for dormant user record |
The default in-memory storage service can be used only for initial testing. A more permanent server-side [storage implementation](https://shibboleth.atlassian.net/wiki/spaces/IDP4/pages/1265631707/StorageConfiguration#Storage-Implementations) should be used in the long run.
# Collecting custom data
By defining a bean `userProfile.setEventsFunction` deployer may read and store custom events to store.
```
<!-- Deployer defined function for setting user profile events. -->
<bean id="userProfile.setEventsFunction" parent="shibboleth.ContextFunctions.Scripted" factory-method="inlineScript"
p:customObject-ref="userProfile.Cache">
<constructor-arg>
<value>
<![CDATA[
result = "proceed";
logger = Java.type("org.slf4j.LoggerFactory").getLogger("userProfile.setEventsFunction");
var UsernamePrincipal = Java.type("net.shibboleth.idp.authn.principal.UsernamePrincipal");
subjectContext = input.getSubcontext("net.shibboleth.idp.authn.context.SubjectContext");
var usernamePrincipal = new UsernamePrincipal(subjectContext.getPrincipalName());
//1. Setting nonsense event
custom.setSingleEvent(usernamePrincipal, "MY_NONSENSE_TAG", "Nonsense");
logger.info("Oh my what nonsense");
result;
]]>
</value>
</constructor-arg>
</bean>
```