<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Rule language="beanshell" name="Mighty - App FieldValue Rule" type="FieldValue">
<Description>This rule can generate a field value (eg - an account name) using data from the given Identity. If this rule is run in the context of a workflow step then the arguments passed into the step will also be available. Also, any field values that have been processed so far from the policy related to the Application/Role will be available.</Description>
<Signature returnType="String">
<Inputs>
<Argument name="log">
<Description>
The log object is associated with the SailPointContext.
</Description>
</Argument>
<Argument name="context">
<Description>
A sailpoint.api.SailPointContext object that can be used to query the database if necessary.
</Description>
</Argument>
<Argument name="identity" type="Identity">
<Description>
The Identity object represents the user needing the field value.
</Description>
</Argument>
<Argument name="link" type="Link">
<Description>
The sailpoint.object.Link that is being acted upon. If the link is not applicable,
this value will be null.
</Description>
</Argument>
<Argument name="group" type="ManagedAttribute">
<Description>
The sailpoint.object.ManagedAttribute that is being acted upon. If the managed attribute
is not applicable, the value will be null.
</Description>
</Argument>
<Argument name="project" type="ProvisioningProject">
<Description>
The provisioning project is being acted upon. If a provisioning project is not applicable,
the value will be null.
</Description>
</Argument>
<Argument name="accountRequest" type="ProvisioningPlan.AccountRequest">
<Description>
The account request. If an account request is not applicable, the value will be null.
</Description>
</Argument>
<Argument name="objectRequest" type="ProvisioningPlan.ObjectRequest">
<Description>
The object request. If an object request is not applicable, the value will be null.
</Description>
</Argument>
<Argument name="role" type="Bundle">
<Description>
The role with the template we are compiling. If the role is
not applicable, the value will be null.
</Description>
</Argument>
<Argument name="application" type="Application">
<Description>
The sailpont.object.Application with the template we are compiling. If the application
is not applicable, the value will be null.
</Description>
</Argument>
<Argument name="template" type="Template">
<Description>
The Template that contains this field.
</Description>
</Argument>
<Argument name="field" type="Field">
<Description>
The current field is being computed.
</Description>
</Argument>
<Argument name="current" type="Object">
<Description>
The current value corresponds to the identity or account attribute that the field represents.
If no current value is set, this value will be null.
</Description>
</Argument>
<Argument name="operation" type="ProvisioningPlan.Operation">
<Description>
The operation being performed.
</Description>
</Argument>
</Inputs>
<Returns>
<Argument name="value">
<Description>
The string value is created.
</Description>
</Argument>
</Returns>
</Signature>
<Source>
import org.apache.commons.logging.Log;
import org.apache.log4j.Logger;
import sailpoint.api.SailPointContext;
import sailpoint.object.Field;
import sailpoint.object.Identity;
import sailpoint.tools.GeneralException;
Logger logger = Logger.getLogger("Mighty.rule.FeildValueRule");
boolean isDebugEnabled = logger.isDebugEnabled();
Object returnValue = null;
if (identity != null) {
if (isDebugEnabled) {
try {
logger.debug("Identity to XML =======" + identity.toXml());
} catch (GeneralException e) {
logger.error("GeneralException: " + e.getMessage());
}
}
String fieldName = field.getName();
switch (fieldName) {
case "userId":
if (identity.getStringAttribute("userId") != null) {
returnValue = identity.getStringAttribute("userId");
} else {
returnValue = "";
}
break;
case "phoneNo":
if (identity.getStringAttribute("phoneNo") != null) {
returnValue = identity.getStringAttribute("phoneNo");
} else {
returnValue = "";
}
break;
case "email":
if (identity.getEmail() != null) {
returnValue = identity.getEmail();
} else {
returnValue = "";
}
break;
case "firstName":
if (identity.getFirstname() != null) {
returnValue = identity.getFirstname();
} else {
returnValue = "";
}
break;
case "lastName":
if (identity.getLastname() != null) {
returnValue = identity.getLastname();
} else {
returnValue = "";
}
break;
case "dept":
if (identity.getStringAttribute("dept") != null) {
returnValue = identity.getStringAttribute("dept");
} else {
returnValue = "";
}
break;
case "company":
if (identity.getStringAttribute("company") != null) {
returnValue = identity.getStringAttribute("company");
} else {
returnValue = "";
}
break;
case "status":
if (identity.getStringAttribute("status") != null) {
returnValue = identity.getStringAttribute("status");
} else {
returnValue = "";
}
break;
default:
logger.debug("Field is not matched...");
break;
}
if (isDebugEnabled) {
logger.debug("Returning field value = " + returnValue + "for field name " + fieldName);
}
} else {
logger.debug("Identity is null");
returnValue = "";
}
return returnValue;
</Source>
</Rule>
No comments:
Post a Comment