[IdentityIQ 8.3p3]
We are working on a form which generates the fields dynamically based on the username selected. In this case trying to display the authentication question and answer in the form.
The form is able to display the question but the the answer. We can see the answers in the logs.
Below is the form code
<Section label="User Information">
<Field displayName="Select User" name="userName" postBack="true" type="identity">
<Attributes>
<Map>
<entry key="valueProperty" value="name"/>
</Map>
</Attributes>
</Field>
<Field dependencies="userName" dynamic="true" name="identity">
<Attributes>
<Map>
<entry key="hidden">
<value>
<Script>
<Source>
import sailpoint.object.Identity;
import sailpoint.object.AuthenticationAnswer;
import sailpoint.object.AuthenticationQuestion;
import sailpoint.object.Field;
import sailpoint.object.Form;
import java.util.List;
import sailpoint.object.Link;
import sailpoint.object.Filter;
import sailpoint.object.QueryOptions;
import sailpoint.object.Application;
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
Logger log = Logger.getLogger("form");
log.setLevel(Level.DEBUG);
log.debug("*******The authmap is**********: ");
Map getAuthenticationMap(List authentications)
{
Map authMap = null;
if(authentications != null && !authentications.isEmpty())
{
authMap = new HashMap();
for(AuthenticationAnswer answer : authentications)
{
authMap.put(answer.getQuestion().getQuestion(),context.decrypt(answer.getAnswer()));
}
}
log.debug("*******The authmap is**********: "+authMap);
return authMap;
}
if(userName != null)
{
Identity identity = context.getObjectByName(Identity.class,userName);
if(identity != null)
{
log.debug("*******The identity is**********: "+identity.getName());
form.getField("firstname").setValue(identity.getFirstname()==null);
log.debug("*******Test2**********: ");
form.getField("lastname").setValue(identity.getLastname());
log.debug("*******Test3**********: ");
}
Filter filter = Filter.eq("identity.id",identity.getId());
QueryOptions opts = new QueryOptions();
opts.add(filter);
List links = identity.getLinks();
List authAnswers = identity.getAuthenticationAnswers();
Map authMap = getAuthenticationMap(authAnswers);
context.decache(identity);
Form.Section authInfo = form.getSection("authenticationInformation");
if(authInfo == null)
{
authInfo = new Form.Section("authenticationInformation");
}
authInfo.setType("data");
authInfo.setLabel("Authentication Information");
authInfo.setName("authenticationInformation");
List authfields = new ArrayList();
Field field = null;
if(authMap == null)
{
field = new Field();
field.setAttribute("xtype","label");
field.setAttribute("text","Authentication Questions Not configured for " + identity.getDisplayName());
authfields.add(field);
}
else
{
for(String question : authMap.keySet())
{
log.debug("*******The question is**********: "+question);
field = new Field();
field.setDisplayName(question);
field.setValue(authMap.get(question));
log.debug("*******The answer is**********: "+authMap.get(question));
log.debug("Is Field Hidden :::::::: "+field.isHidden());
authfields.add(field);
}
}
authInfo.setItems(authfields);
//log.debug("Is authfields Hidden :::::::: "+authfields.isHidden());
log.debug("Is Section Hidden :::::::: "+authInfo.isHidden());
form.add(authInfo);
}
return true;
</Source>
</Script>
</value>
</entry>
</Map>
</Attributes>
</Field>