Example usage for org.dom4j Element elementTextTrim

List of usage examples for org.dom4j Element elementTextTrim

Introduction

In this page you can find the example usage for org.dom4j Element elementTextTrim.

Prototype

String elementTextTrim(QName qname);

Source Link

Usage

From source file:org.jivesoftware.openfire.muc.spi.LocalMUCUser.java

License:Open Source License

/**
 * This method does all packet routing in the chat server. Packet routing is actually very
 * simple:/*from  w  ww .jav a2  s.c  om*/
 * 
 * <ul>
 * <li>Discover the room the user is talking to (server packets are dropped)</li>
 * <li>If the room is not registered and this is a presence "available" packet, try to join the
 * room</li>
 * <li>If the room is registered, and presence "unavailable" leave the room</li>
 * <li>Otherwise, rewrite the sender address and send to the room.</li>
 * </ul>
 * 
 * @param packet The packet to route.
 */
public void process(Message packet) {
    // Ignore messages of type ERROR sent to a room 
    if (Message.Type.error == packet.getType()) {
        return;
    }
    lastPacketTime = System.currentTimeMillis();
    JID recipient = packet.getTo();
    String group = recipient.getNode();
    if (group == null) {
        // Ignore packets to the groupchat server
        // In the future, we'll need to support TYPE_IQ queries to the server for MUC
        Log.info(LocaleUtils.getLocalizedString("muc.error.not-supported") + " " + packet.toString());
    } else {
        MUCRole role = roles.get(group);
        if (role == null) {
            if (server.hasChatRoom(group)) {
                boolean declinedInvitation = false;
                Element userInfo = null;
                if (Message.Type.normal == packet.getType()) {
                    // An user that is not an occupant could be declining an invitation
                    userInfo = packet.getChildElement("x", "http://jabber.org/protocol/muc#user");
                    if (userInfo != null && userInfo.element("decline") != null) {
                        // A user has declined an invitation to a room
                        // WARNING: Potential fraud if someone fakes the "from" of the
                        // message with the JID of a member and sends a "decline"
                        declinedInvitation = true;
                    }
                }
                if (declinedInvitation) {
                    Element info = userInfo.element("decline");
                    server.getChatRoom(group).sendInvitationRejection(new JID(info.attributeValue("to")),
                            info.elementTextTrim("reason"), packet.getFrom());
                } else {
                    // The sender is not an occupant of the room
                    sendErrorPacket(packet, PacketError.Condition.not_acceptable);
                }
            } else {
                // The sender is not an occupant of a NON-EXISTENT room!!!
                sendErrorPacket(packet, PacketError.Condition.recipient_unavailable);
            }
        } else {
            // Check and reject conflicting packets with conflicting roles
            // In other words, another user already has this nickname
            if (!role.getUserAddress().equals(packet.getFrom())) {
                sendErrorPacket(packet, PacketError.Condition.conflict);
            } else {
                try {
                    if (packet.getSubject() != null && packet.getSubject().trim().length() > 0
                            && Message.Type.groupchat == packet.getType()
                            && (packet.getBody() == null || packet.getBody().trim().length() == 0)) {
                        // An occupant is trying to change the room's subject
                        role.getChatRoom().changeSubject(packet, role);

                    } else {
                        // An occupant is trying to send a private, send public message,
                        // invite someone to the room or reject an invitation
                        Message.Type type = packet.getType();
                        String resource = packet.getTo().getResource();
                        if (resource == null || resource.trim().length() == 0) {
                            resource = null;
                        }
                        if (resource == null && Message.Type.groupchat == type) {
                            // An occupant is trying to send a public message
                            role.getChatRoom().sendPublicMessage(packet, role);
                        } else if (resource != null
                                && (Message.Type.chat == type || Message.Type.normal == type)) {
                            // An occupant is trying to send a private message
                            role.getChatRoom().sendPrivatePacket(packet, role);
                        } else if (resource == null && Message.Type.normal == type) {
                            // An occupant could be sending an invitation or declining an
                            // invitation
                            Element userInfo = packet.getChildElement("x",
                                    "http://jabber.org/protocol/muc#user");
                            // Real real real UGLY TRICK!!! Will and MUST be solved when
                            // persistence will be added. Replace locking with transactions!
                            LocalMUCRoom room = (LocalMUCRoom) role.getChatRoom();
                            if (userInfo != null && userInfo.element("invite") != null) {
                                // An occupant is sending invitations

                                // Try to keep the list of extensions sent together with the
                                // message invitation. These extensions will be sent to the
                                // invitees.
                                @SuppressWarnings("unchecked")
                                List<Element> extensions = new ArrayList<Element>(
                                        packet.getElement().elements());
                                extensions.remove(userInfo);

                                // Send invitations to invitees
                                @SuppressWarnings("unchecked")
                                Iterator<Element> it = userInfo.elementIterator("invite");
                                while (it.hasNext()) {
                                    Element info = it.next();
                                    JID jid = new JID(info.attributeValue("to"));

                                    // Add the user as a member of the room if the room is
                                    // members only
                                    if (room.isMembersOnly()) {
                                        room.addMember(jid, null, role);
                                    }

                                    // Send the invitation to the invitee
                                    room.sendInvitation(jid, info.elementTextTrim("reason"), role, extensions);
                                }
                            } else if (userInfo != null && userInfo.element("decline") != null) {
                                // An occupant has declined an invitation
                                Element info = userInfo.element("decline");
                                room.sendInvitationRejection(new JID(info.attributeValue("to")),
                                        info.elementTextTrim("reason"), packet.getFrom());
                            } else {
                                sendErrorPacket(packet, PacketError.Condition.bad_request);
                            }
                        } else {
                            sendErrorPacket(packet, PacketError.Condition.bad_request);
                        }
                    }
                } catch (ForbiddenException e) {
                    sendErrorPacket(packet, PacketError.Condition.forbidden);
                } catch (NotFoundException e) {
                    sendErrorPacket(packet, PacketError.Condition.recipient_unavailable);
                } catch (ConflictException e) {
                    sendErrorPacket(packet, PacketError.Condition.conflict);
                } catch (CannotBeInvitedException e) {
                    sendErrorPacket(packet, PacketError.Condition.not_acceptable);
                } catch (IllegalArgumentException e) {
                    sendErrorPacket(packet, PacketError.Condition.jid_malformed);
                }
            }
        }
    }
}

From source file:org.jivesoftware.openfire.muc.spi.LocalMUCUser.java

License:Open Source License

public void process(Presence packet) {
    // Ignore presences of type ERROR sent to a room
    if (Presence.Type.error == packet.getType()) {
        return;//  w  w  w.  ja v  a  2  s .co  m
    }
    lastPacketTime = System.currentTimeMillis();
    JID recipient = packet.getTo();
    String group = recipient.getNode();
    if (group != null) {
        MUCRole role = roles.get(group);
        if (role == null) {
            // If we're not already in a room, we either are joining it or it's not
            // properly addressed and we drop it silently
            if (recipient.getResource() != null && recipient.getResource().trim().length() > 0) {
                if (packet.isAvailable()) {
                    try {
                        // Get or create the room
                        MUCRoom room = server.getChatRoom(group, packet.getFrom());
                        // User must support MUC in order to create a room
                        Element mucInfo = packet.getChildElement("x", "http://jabber.org/protocol/muc");
                        HistoryRequest historyRequest = null;
                        String password = null;
                        // Check for password & requested history if client supports MUC
                        if (mucInfo != null) {
                            password = mucInfo.elementTextTrim("password");
                            if (mucInfo.element("history") != null) {
                                historyRequest = new HistoryRequest(mucInfo);
                            }
                        }
                        // The user joins the room
                        role = room.joinRoom(recipient.getResource().trim(), password, historyRequest, this,
                                packet.createCopy());
                        // If the client that created the room is non-MUC compliant then
                        // unlock the room thus creating an "instant" room
                        if (mucInfo == null && room.isLocked() && !room.isManuallyLocked()) {
                            room.unlock(role);
                        }
                    } catch (UnauthorizedException e) {
                        sendErrorPacket(packet, PacketError.Condition.not_authorized);
                    } catch (ServiceUnavailableException e) {
                        sendErrorPacket(packet, PacketError.Condition.service_unavailable);
                    } catch (UserAlreadyExistsException e) {
                        sendErrorPacket(packet, PacketError.Condition.conflict);
                    } catch (RoomLockedException e) {
                        // If a user attempts to enter a room while it is "locked" (i.e., before the room creator provides an initial configuration and therefore before the room officially exists), the service MUST refuse entry and return an <item-not-found/> error to the user
                        sendErrorPacket(packet, PacketError.Condition.item_not_found);
                    } catch (ForbiddenException e) {
                        sendErrorPacket(packet, PacketError.Condition.forbidden);
                    } catch (RegistrationRequiredException e) {
                        sendErrorPacket(packet, PacketError.Condition.registration_required);
                    } catch (ConflictException e) {
                        sendErrorPacket(packet, PacketError.Condition.conflict);
                    } catch (NotAcceptableException e) {
                        sendErrorPacket(packet, PacketError.Condition.not_acceptable);
                    } catch (NotAllowedException e) {
                        sendErrorPacket(packet, PacketError.Condition.not_allowed);
                    }
                } else {
                    // TODO: send error message to user (can't send presence to group you
                    // haven't joined)
                }
            } else {
                if (packet.isAvailable()) {
                    // A resource is required in order to join a room
                    // http://xmpp.org/extensions/xep-0045.html#enter
                    // If the user does not specify a room nickname (note the bare JID on the 'from' address in the following example), the service MUST return a <jid-malformed/> error
                    sendErrorPacket(packet, PacketError.Condition.jid_malformed);
                }
                // TODO: send error message to user (can't send packets to group you haven't
                // joined)
            }
        } else {
            // Check and reject conflicting packets with conflicting roles
            // In other words, another user already has this nickname
            if (!role.getUserAddress().equals(packet.getFrom())) {
                sendErrorPacket(packet, PacketError.Condition.conflict);
            } else {
                if (Presence.Type.unavailable == packet.getType()) {
                    try {
                        // TODO Consider that different nodes can be creating and processing this presence at the same time (when remote node went down)
                        removeRole(group);
                        role.getChatRoom().leaveRoom(role);
                    } catch (Exception e) {
                        Log.error(e.getMessage(), e);
                    }
                } else {
                    try {
                        String resource = (recipient.getResource() == null
                                || recipient.getResource().trim().length() == 0 ? null
                                        : recipient.getResource().trim());
                        if (resource == null || role.getNickname().equalsIgnoreCase(resource)) {
                            // Occupant has changed his availability status
                            role.getChatRoom().presenceUpdated(role, packet);
                        } else {
                            // Occupant has changed his nickname. Send two presences
                            // to each room occupant

                            // Check if occupants are allowed to change their nicknames
                            if (!role.getChatRoom().canChangeNickname()) {
                                sendErrorPacket(packet, PacketError.Condition.not_acceptable);
                            }
                            // Answer a conflic error if the new nickname is taken
                            else if (role.getChatRoom().hasOccupant(resource)) {
                                sendErrorPacket(packet, PacketError.Condition.conflict);
                            } else {
                                // Send "unavailable" presence for the old nickname
                                Presence presence = role.getPresence().createCopy();
                                // Switch the presence to OFFLINE
                                presence.setType(Presence.Type.unavailable);
                                presence.setStatus(null);
                                // Add the new nickname and status 303 as properties
                                Element frag = presence.getChildElement("x",
                                        "http://jabber.org/protocol/muc#user");
                                frag.element("item").addAttribute("nick", resource);
                                frag.addElement("status").addAttribute("code", "303");
                                role.getChatRoom().send(presence);

                                // Send availability presence for the new nickname
                                String oldNick = role.getNickname();
                                role.getChatRoom().nicknameChanged(role, packet, oldNick, resource);
                            }
                        }
                    } catch (Exception e) {
                        Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
                    }
                }
            }
        }
    }
}

From source file:org.jivesoftware.openfire.plugin.spark.SparkManager.java

License:Open Source License

/**
 * Handles the IQ version reply. If only a given list of clients are allowed to connect
 * then the reply will be analyzed. If the client is not present in the list, no name
 * was responsed or an IQ error was returned (e.g. IQ version not supported) then
 * the client session will be terminated.
 *
 * @param iq the IQ version reply sent by the client.
 *///from w  ww  . j  a v  a2 s. c  om
private void handleClientVersion(IQ iq) {
    final String clientsAllowed = JiveGlobals.getProperty("clients.allowed", "all");
    final boolean disconnectIfNoMatch = !"all".equals(clientsAllowed);
    if ("all".equals(clientsAllowed) || !disconnectIfNoMatch) {
        // There is nothing to do here. Just return.
        return;
    }

    // Get the client session of the user that sent the IQ version response
    ClientSession session = sessionManager.getSession(iq.getFrom());
    if (session == null) {
        // Do nothing if the session no longer exists
        return;
    }

    if (IQ.Type.result == iq.getType()) {
        // Get list of allowed clients to connect
        final List<String> clients = new ArrayList<String>();

        StringTokenizer clientTokens = new StringTokenizer(clientsAllowed, ",");
        while (clientTokens.hasMoreTokens()) {
            clients.add(clientTokens.nextToken().toLowerCase());
        }

        final String otherClientsAllowed = JiveGlobals.getProperty("other.clients.allowed", "");
        clientTokens = new StringTokenizer(otherClientsAllowed, ",");
        while (clientTokens.hasMoreTokens()) {
            clients.add(clientTokens.nextToken().toLowerCase().trim());
        }

        Element child = iq.getChildElement();
        String clientName = child.elementTextTrim("name");
        boolean disconnect = true;
        if (clientName != null) {
            // Check if the client should be disconnected
            for (String c : clients) {
                if (clientName.toLowerCase().contains(c)) {
                    disconnect = false;
                    break;
                }
            }
        } else {
            // Always disconnect clients that didn't provide their name
            disconnect = true;
        }
        if (disconnect) {
            closeSession(session, clientName != null ? clientName : "Unknown");
        }
    } else {
        // If the session is invalid. Close the connection.
        closeSession(session, "Unknown");
    }
}

From source file:org.jivesoftware.xmpp.workgroup.request.InvitationRequest.java

License:Open Source License

public InvitationRequest(IQ packet, Workgroup workgroup) {
    super();//w ww .  j a v  a2 s  .  c  o m
    Element iq = packet.getChildElement();
    this.type = Type.valueOf(iq.attributeValue("type"));
    Element sessionElement = iq.element("session");
    sessionID = sessionElement.attributeValue("id");
    inviter = packet.getFrom();
    invitee = new JID(iq.elementTextTrim("invitee"));
    reason = iq.elementTextTrim("reason");
    this.workgroup = workgroup;
    String jid = sessionElement.attributeValue("workgroup");
    try {
        if (jid == null) {
            // Keep backwards compatibility. This "trick" will only work while the workgroup
            // that received the user request and that is sending the invitation is the
            // same workgroup.
            userRequest = workgroup.getUserRequest(sessionID);
        } else {
            JID workgroupJID = new JID(jid);
            userRequest = WorkgroupManager.getInstance().getWorkgroup(workgroupJID).getUserRequest(sessionID);
        }
        // Notify the user request that is now related to this new request
        userRequest.addRelatedRequest(this);
        // Add metadata of original user request to this offer
        if (userRequest.getMetaData() != null) {
            metaData.putAll(userRequest.getMetaData());
        }
    } catch (Exception e) {
        Log.error("Workgroup not found for invitation: " + jid, e);
    }
}

From source file:org.jivesoftware.xmpp.workgroup.request.TransferRequest.java

License:Open Source License

public TransferRequest(IQ packet, Workgroup workgroup) {
    super();// w w  w.  j  a  va 2  s . c  o  m
    Element iq = packet.getChildElement();
    this.type = Type.valueOf(iq.attributeValue("type"));
    Element sessionElement = iq.element("session");
    sessionID = sessionElement.attributeValue("id");
    inviter = packet.getFrom();
    invitee = new JID(iq.elementTextTrim("invitee"));
    reason = iq.elementTextTrim("reason");
    this.workgroup = workgroup;
    String jid = sessionElement.attributeValue("workgroup");
    try {
        if (jid == null) {
            // Keep backwards compatibility. This "trick" will only work while the workgroup
            // that received the user request and that is making the transfer is the
            // same workgroup.
            userRequest = workgroup.getUserRequest(sessionID);
        } else {
            JID workgroupJID = new JID(jid);
            // Replace the workgroup if the original offer originated from a different
            // workgroup
            this.workgroup = WorkgroupManager.getInstance().getWorkgroup(workgroupJID);
            userRequest = this.workgroup.getUserRequest(sessionID);
        }
        // Notify the user request that is now related to this new request
        userRequest.addRelatedRequest(this);
        // Add metadata of original user request to this offer
        if (userRequest.getMetaData() != null) {
            metaData.putAll(userRequest.getMetaData());
        }
    } catch (Exception e) {
        Log.error("Workgroup not found for transfer: " + jid, e);
    }
}

From source file:org.jivesoftware.xmpp.workgroup.search.ChatSearchManager.java

License:Open Source License

private void addTranscriptToIndex(ChatInformation chat, IndexWriter writer) throws IOException {
    // Flag that indicates if the transcript includes one or more messages. If no message was
    // found then nothing will be added to the index
    boolean hasMessages = false;
    Document document = new Document();

    for (Iterator<Element> elements = chat.getTranscript().elementIterator(); elements.hasNext();) {
        Element element = elements.next();
        // Only add Messages to the index (Presences are discarded)
        if ("message".equals(element.getName())) {
            // TODO Index XHTML bodies?
            String body = element.elementTextTrim("body");
            String from = element.attributeValue("from");
            String to = element.attributeValue("to");

            String fromNickname = new JID(from).getResource();
            String toNickname = new JID(to).getResource();

            final StringBuilder builder = new StringBuilder();
            builder.append(body);/*from  w w w. ja va 2  s. c  om*/
            builder.append(" ");
            builder.append(fromNickname);
            builder.append(" ");
            builder.append(toNickname);

            if (body != null) {
                if (chat.getNotes() != null) {
                    builder.append(" ");
                    builder.append(chat.getNotes());
                }

                if (chat.getAgentJIDs() != null) {
                    for (String jid : chat.getAgentJIDs()) {
                        builder.append(" ");
                        builder.append(jid);
                    }
                }
                document.add(new Field("body", builder.toString(), Field.Store.NO, Field.Index.TOKENIZED));
                // Indicate that a message was found
                hasMessages = true;
            }
        }
    }
    if (hasMessages) {
        // Add the sessionID that indentifies the chat session to the document
        document.add(new Field("sessionID", String.valueOf(chat.getSessionID()), Field.Store.YES,
                Field.Index.UN_TOKENIZED));
        // Add the JID of the agents involved in the chat to the document
        for (String agentJID : chat.getAgentJIDs()) {
            document.add(new Field("agentJID", agentJID, Field.Store.YES, Field.Index.UN_TOKENIZED));
        }
        // Add the date when the chat started to the document
        long date = chat.getCreationDate().getTime();
        document.add(new Field("creationDate", DateTools.timeToString(date, DateTools.Resolution.DAY),
                Field.Store.YES, Field.Index.UN_TOKENIZED));

        writer.addDocument(document);
    }
}

From source file:org.nuxeo.ecm.core.io.impl.AbstractDocumentModelWriter.java

License:Apache License

@SuppressWarnings("unchecked")
private static Object getElementData(ExportedDocument xdoc, Element element, Type type) {
    // empty xml tag must be null value (not empty string)
    if (!element.hasContent()) {
        return null;
    }/*from  www. ja  v a  2s.  c  o  m*/
    if (type.isSimpleType()) {
        return type.decode(element.getText());
    } else if (type.isListType()) {
        ListType ltype = (ListType) type;
        List<Object> list = new ArrayList<>();
        Iterator<Element> it = element.elementIterator();
        while (it.hasNext()) {
            Element el = it.next();
            list.add(getElementData(xdoc, el, ltype.getFieldType()));
        }
        Type ftype = ltype.getFieldType();
        if (ftype.isSimpleType()) { // these are stored as arrays
            Class klass = getFieldClass(ftype);
            if (klass.isPrimitive()) {
                return PrimitiveArrays.toPrimitiveArray(list, klass);
            } else {
                return list.toArray((Object[]) Array.newInstance(klass, list.size()));
            }
        }
        return list;
    } else {
        ComplexType ctype = (ComplexType) type;
        if (TypeConstants.isContentType(ctype)) {
            String mimeType = element.elementText(ExportConstants.BLOB_MIME_TYPE);
            String encoding = element.elementText(ExportConstants.BLOB_ENCODING);
            String content = element.elementTextTrim(ExportConstants.BLOB_DATA);
            String filename = element.elementTextTrim(ExportConstants.BLOB_FILENAME);
            if ((content == null || content.length() == 0) && (mimeType == null || mimeType.length() == 0)) {
                return null; // remove blob
            }
            Blob blob = null;
            if (xdoc.hasExternalBlobs()) {
                blob = xdoc.getBlob(content);
            }
            if (blob == null) { // maybe the blob is embedded in Base64
                // encoded data
                byte[] bytes = Base64.decodeBase64(content);
                blob = Blobs.createBlob(bytes);
            }
            blob.setMimeType(mimeType);
            blob.setEncoding(encoding);
            blob.setFilename(filename);
            return blob;
        } else { // a complex type
            Map<String, Object> map = new HashMap<>();
            Iterator<Element> it = element.elementIterator();
            while (it.hasNext()) {
                Element el = it.next();
                String name = el.getName();
                Object value = getElementData(xdoc, el, ctype.getField(el.getName()).getType());
                map.put(name, value);
            }
            return map;
        }
    }
}

From source file:org.richie.codeGen.database.pdm.PdmParser.java

License:Apache License

/**
 * @param vo//from  ww w  .j  a  va 2  s .com
 * @param tableElement
 */
private static Table parseTableElement(Element tableElement) {
    Table table = new Table();
    table.setId(tableElement.attributeValue("Id"));
    table.setName(tableElement.elementTextTrim("Name"));
    table.setCode(tableElement.elementTextTrim("Code"));
    table.setUpdateTime(tableElement.elementTextTrim("ModificationDate"));
    return table;
}

From source file:org.richie.codeGen.database.pdm.PdmParser.java

License:Apache License

/**
 * ?//from  w w  w  .j  a  v  a2  s .co m
 * 
 * @param col
 * @param primaryKeyId
 * @param colElement
 */
private static Column parseColumn(String primaryKeyId, Element colElement) {
    Column col = new Column();
    String columnId = colElement.attributeValue("Id");
    col.setId(columnId);
    col.setDefaultValue(colElement.elementTextTrim("DefaultValue"));
    col.setName(colElement.elementTextTrim("Name"));
    col.setIsForeignKey(false);
    col.setIsPrimaryKey(false);
    col.setIsHiden(false);
    if (colElement.elementTextTrim("DataType") == null) {
        col.setDataType(null);
    } else if (colElement.elementTextTrim("DataType").indexOf("(") > 0) {
        col.setDataType(colElement.elementTextTrim("DataType").substring(0,
                colElement.elementTextTrim("DataType").indexOf("(")));
    } else {
        col.setDataType(colElement.elementTextTrim("DataType"));
    }
    col.setCode(colElement.elementTextTrim("Code"));
    if (colElement.elementTextTrim("Length") != null) {
        col.setLength(Integer.parseInt(colElement.elementTextTrim("Length")));
    }
    if (colElement.elementTextTrim("Precision") != null) {
        col.setPrecision(Integer.parseInt(colElement.elementTextTrim("Precision")));
    }
    if (colElement.elementTextTrim("Mandatory") != null
            && "1".equals(colElement.elementTextTrim("Mandatory"))) {
        col.setIsNotNull(true);
    } else {
        col.setIsNotNull(false);
    }
    if (columnId.equals(primaryKeyId)) {
        col.setIsPrimaryKey(true);
        col.setIsNotNull(true);
        col.setIsHiden(true);
    }
    return col;
}

From source file:org.springframework.extensions.config.RemoteConfigElement.java

License:Apache License

/**
 * New instance./*from   w  w w  . ja va  2  s  .  c  o  m*/
 * 
 * @param elem the elem
 * 
 * @return the remote config element
 */
protected static RemoteConfigElement newInstance(Element elem) {
    RemoteConfigElement configElement = new RemoteConfigElement();

    // connectors
    List connectors = elem.elements(REMOTE_CONNECTOR);
    for (int i = 0; i < connectors.size(); i++) {
        Element el = (Element) connectors.get(i);
        ConnectorDescriptor descriptor = new ConnectorDescriptor(el);
        configElement.connectors.put(descriptor.getId(), descriptor);
    }

    // authenticators
    List authenticators = elem.elements(REMOTE_AUTHENTICATOR);
    for (int i = 0; i < authenticators.size(); i++) {
        Element el = (Element) authenticators.get(i);
        AuthenticatorDescriptor descriptor = new AuthenticatorDescriptor(el);
        configElement.authenticators.put(descriptor.getId(), descriptor);
    }

    // endpoints
    List endpoints = elem.elements(REMOTE_ENDPOINT);
    for (int i = 0; i < endpoints.size(); i++) {
        Element el = (Element) endpoints.get(i);
        EndpointDescriptor descriptor = new EndpointDescriptor(el);
        configElement.endpoints.put(descriptor.getId(), descriptor);
    }

    String _defaultEndpointId = elem.elementTextTrim("default-endpoint-id");
    if (_defaultEndpointId != null && _defaultEndpointId.length() > 0) {
        configElement.defaultEndpointId = _defaultEndpointId;
    }

    String _defaultCredentialVaultProviderId = elem.elementTextTrim("default-credential-vault-provider-id");
    if (_defaultCredentialVaultProviderId != null && _defaultCredentialVaultProviderId.length() > 0) {
        configElement.defaultCredentialVaultProviderId = _defaultCredentialVaultProviderId;
    }

    Element remoteSSLConfig = elem.element(REMOTE_SSL_CONFIG);
    if (remoteSSLConfig != null) {
        configElement.sslConfigDescriptor = new SSLConfigDescriptor(remoteSSLConfig);
    }

    return configElement;
}