use of com.unboundid.ldap.sdk.unboundidds.extensions.PasswordPolicyStateAccountUsabilityWarning in project ldapsdk by pingidentity.
the class ManageAccountProcessor method createResultEntry.
/**
* Creates an entry that encapsulates the content of the provided result.
*
* @param request The request that was processed.
* @param result The result of the processing.
*
* @return The entry that was created.
*/
@NotNull()
private Entry createResultEntry(@NotNull final PasswordPolicyStateExtendedRequest request, @NotNull final LDAPResult result) {
final Entry e = new Entry(request.getUserDN());
e.addAttribute("base-command-line", commandLine + " --targetDN " + StaticUtils.cleanExampleCommandLineArgument(e.getDN()));
e.addAttribute("result-code", String.valueOf(result.getResultCode().intValue()));
final String resultCodeName = result.getResultCode().getName();
if (resultCodeName != null) {
e.addAttribute("result-code-name", resultCodeName);
}
final String diagnosticMessage = result.getDiagnosticMessage();
if (diagnosticMessage != null) {
e.addAttribute("diagnostic-message", diagnosticMessage);
}
final String matchedDN = result.getMatchedDN();
if (matchedDN != null) {
e.addAttribute("matched-dn", matchedDN);
}
final String[] referralURLs = result.getReferralURLs();
if ((referralURLs != null) && (referralURLs.length > 0)) {
e.addAttribute("referral-url", referralURLs);
}
if (!(result instanceof PasswordPolicyStateExtendedResult)) {
return e;
}
final PasswordPolicyStateExtendedResult r = (PasswordPolicyStateExtendedResult) result;
for (final PasswordPolicyStateOperation o : r.getOperations()) {
final String[] values = o.getStringValues();
if (values.length == 0) {
if (suppressEmptyResultOperations) {
continue;
}
}
final String attrName;
final ManageAccountSubCommandType subcommandType = ManageAccountSubCommandType.forOperationType(o.getOperationType());
if (subcommandType == null) {
if (o.getOperationType() == 39) {
// This is a deprecated response that the client doesn't support, but
// older servers may return it.
attrName = "get-password-history";
} else {
// This result may come from a newer version of the server that has
// additional password policy state operation types.
attrName = "unrecognized-operation-type-" + o.getOperationType();
}
} else {
attrName = subcommandType.getPrimaryName();
}
if (values.length == 0) {
e.addAttribute(attrName, "");
} else if (subcommandType == null) {
e.addAttribute(attrName, values);
} else {
// those specially. Otherwise, just go with the string representations.
switch(subcommandType) {
case GET_ACCOUNT_USABILITY_NOTICES:
final String[] notices = new String[values.length];
for (int i = 0; i < values.length; i++) {
try {
notices[i] = new PasswordPolicyStateAccountUsabilityNotice(values[i]).getMessage();
} catch (final Exception ex) {
Debug.debugException(ex);
notices[i] = values[i];
}
}
e.addAttribute(attrName, notices);
break;
case GET_ACCOUNT_USABILITY_WARNINGS:
final String[] warnings = new String[values.length];
for (int i = 0; i < values.length; i++) {
try {
warnings[i] = new PasswordPolicyStateAccountUsabilityWarning(values[i]).getMessage();
} catch (final Exception ex) {
Debug.debugException(ex);
warnings[i] = values[i];
}
}
e.addAttribute(attrName, warnings);
break;
case GET_ACCOUNT_USABILITY_ERRORS:
final String[] errors = new String[values.length];
for (int i = 0; i < values.length; i++) {
try {
errors[i] = new PasswordPolicyStateAccountUsabilityError(values[i]).getMessage();
} catch (final Exception ex) {
Debug.debugException(ex);
errors[i] = values[i];
}
}
e.addAttribute(attrName, errors);
break;
default:
e.addAttribute(attrName, values);
break;
}
}
}
return e;
}
Aggregations