}
NDC.pushAppend(connectorName);
try {
AuthenticationIdentity identity =
new SimpleAuthenticationIdentity(username, password, domain);
AuthenticationResponse response =
manager.authenticate(connectorName, identity);
if (response.isValid()) {
ServletUtil.writeXMLTagWithAttrs(
out, 2, ServletUtil.XMLTAG_SUCCESS,
ServletUtil.XMLTAG_CONNECTOR_NAME + "=\"" + connectorName + "\"",
false);
// TODO: Either fix ServletUtil XML code to XML escape attr values and
// element text bodies, or add the ability to append attributes to
// XmlUtils.appendStartTag().
out.append(ServletUtil.indentStr(3));
XmlUtils.xmlAppendStartTag(ServletUtil.XMLTAG_IDENTITY, out);
XmlUtils.xmlAppendAttrValue(username, out);
XmlUtils.xmlAppendEndTag(ServletUtil.XMLTAG_IDENTITY, out);
// Add any returned groups that the user may belong to.
if (response.getGroups() != null) {
for (Object item : response.getGroups()) {
Principal group = (item instanceof String) ?
new Principal((String) item) : (Principal) item;
out.append(ServletUtil.indentStr(3));
out.append('<').append(ServletUtil.XMLTAG_GROUP);
if (group.getPrincipalType() ==