org.jivesoftware.smack.util.StringUtils Java Examples

The following examples show how to use org.jivesoftware.smack.util.StringUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AccountManager.java    From Smack with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new account using the specified username, password and account attributes.
 * The attributes Map must contain only String name/value pairs and must also have values
 * for all required attributes.
 *
 * @param username the username.
 * @param password the password.
 * @param attributes the account attributes.
 * @throws XMPPErrorException if an error occurs creating the account.
 * @throws NoResponseException if there was no response from the server.
 * @throws NotConnectedException if the XMPP connection is not connected.
 * @throws InterruptedException if the calling thread was interrupted.
 * @see #getAccountAttributes()
 */
public void createAccount(Localpart username, String password, Map<String, String> attributes)
                throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    if (!connection().isSecureConnection() && !allowSensitiveOperationOverInsecureConnection) {
        throw new IllegalStateException("Creating account over insecure connection");
    }
    if (username == null) {
        throw new IllegalArgumentException("Username must not be null");
    }
    if (StringUtils.isNullOrEmpty(password)) {
        throw new IllegalArgumentException("Password must not be null");
    }

    attributes.put("username", username.toString());
    attributes.put("password", password);
    Registration reg = new Registration(attributes);
    reg.setType(IQ.Type.set);
    reg.setTo(connection().getXMPPServiceDomain());
    createStanzaCollectorAndSend(reg).nextResultOrThrow();
}
 
Example #2
Source File: InvitationManager.java    From Spark with Apache License 2.0 6 votes vote down vote up
/**
 * Invite or transfer a queue.
 *
 * @param chatRoom    the <code>ChatRoom</code> to invite or transfer.
 * @param sessionID   the sessionID of this Fastpath session.
 * @param jid         the jid of the room.
 * @param messageText the message to send to the user.
 * @param transfer    true if this is a transfer.
 */
public static void transferOrInviteToWorkgroup(ChatRoom chatRoom, String workgroup, String sessionID, final Jid jid, String messageText, final boolean transfer) {
    String msg = messageText != null ? StringUtils.escapeForXml(messageText).toString() : FpRes.getString("message.please.join.me.in.conference");
    try {
        if (!transfer) {
        	// TODO : CHECK FASHPATH
            FastpathPlugin.getAgentSession().sendRoomInvitation(RoomInvitation.Type.workgroup, jid, sessionID, msg);
        }
        else {
            FastpathPlugin.getAgentSession().sendRoomTransfer(RoomTransfer.Type.workgroup, jid.toString(), sessionID, msg);
        }
    }
    catch (XMPPException | SmackException | InterruptedException e) {
        Log.error(e);
    }


    String username = SparkManager.getUserManager().getUserNicknameFromJID(jid.asBareJid());

    String notification = FpRes.getString("message.user.has.been.invited", username);
    if (transfer) {
        notification = FpRes.getString("message.waiting.for.user", username);
    }
    chatRoom.getTranscriptWindow().insertNotificationMessage(notification, ChatManager.NOTIFICATION_COLOR);
}
 
Example #3
Source File: MetaDataUtils.java    From Smack with Apache License 2.0 6 votes vote down vote up
/**
 * Serializes a Map of String name/value pairs into the meta-data XML format.
 *
 * @param metaData the Map of meta-data as Map&lt;String, List&lt;String&gt;&gt;
 * @return the meta-data values in XML form.
 */
public static String serializeMetaData(Map<String, List<String>> metaData) {
    StringBuilder buf = new StringBuilder();
    if (metaData != null && metaData.size() > 0) {
        buf.append("<metadata xmlns=\"http://jivesoftware.com/protocol/workgroup\">");
        for (String key : metaData.keySet()) {
            List<String> value = metaData.get(key);
            for (String v : value) {
                buf.append("<value name=\"").append(key).append("\">");
                buf.append(StringUtils.escapeForXmlText(v));
                buf.append("</value>");
            }
        }
        buf.append("</metadata>");
    }
    return buf.toString();
}
 
Example #4
Source File: LoginIntegrationTest.java    From Smack with Apache License 2.0 6 votes vote down vote up
/**
 * Check that the server is returning the correct error when trying to login using an invalid
 * (i.e. non-existent) user.
 *
 * @throws InterruptedException if the calling thread was interrupted.
 * @throws XMPPException if an XMPP protocol error was received.
 * @throws IOException if an I/O error occurred.
 * @throws SmackException if Smack detected an exceptional situation.
 * @throws NoSuchAlgorithmException if no such algorithm is available.
 * @throws KeyManagementException if there was a key mangement error.
 */
@SmackIntegrationTest
public void testInvalidLogin() throws SmackException, IOException, XMPPException,
                InterruptedException, KeyManagementException, NoSuchAlgorithmException {
    final String nonExistentUserString = StringUtils.insecureRandomString(24);
    final String invalidPassword = "invalidPassword";

    AbstractXMPPConnection connection = getUnconnectedConnection();
    connection.connect();

    try {
        SASLErrorException saslErrorException = assertThrows(SASLErrorException.class,
                        () -> connection.login(nonExistentUserString, invalidPassword));

        SaslNonza.SASLFailure saslFailure = saslErrorException.getSASLFailure();
        assertEquals(SASLError.not_authorized, saslFailure.getSASLError());
    } finally {
        connection.disconnect();
    }
}
 
Example #5
Source File: NodeInfo.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Override
public boolean equals(Object other) {
    if (this == other) {
        return true;
    }
    if (other == null) {
        return false;
    }
    if (!(other instanceof NodeInfo)) {
        return false;
    }
    NodeInfo otherNodeInfo = (NodeInfo) other;
    if (!nodeId.equals(otherNodeInfo.nodeId)) {
        return false;
    }
    if (StringUtils.nullSafeCharSequenceEquals(sourceId, otherNodeInfo.sourceId)
                    && StringUtils.nullSafeCharSequenceEquals(cacheType, otherNodeInfo.cacheType)) {
        return true;
    }
    return false;
}
 
Example #6
Source File: HashTest.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Test
public void hashTest() {
    assertEquals(md5sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.MD5, array())));
    assertEquals(sha1sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA_1, array())));
    assertEquals(sha224sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA_224, array())));
    assertEquals(sha256sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA_256, array())));
    assertEquals(sha384sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA_384, array())));
    assertEquals(sha512sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA_512, array())));
    assertEquals(sha3_224sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA3_224, array())));
    assertEquals(sha3_256sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA3_256, array())));
    assertEquals(sha3_384sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA3_384, array())));
    assertEquals(sha3_512sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA3_512, array())));
    assertEquals(b2_160sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.BLAKE2B160, array())));
    assertEquals(b2_256sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.BLAKE2B256, array())));
    assertEquals(b2_384sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.BLAKE2B384, array())));
    assertEquals(b2_512sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.BLAKE2B512, array())));
}
 
Example #7
Source File: EntityCapsManagerTest.java    From Smack with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("UnusedVariable")
private static void testSimpleDirectoryCache(StringEncoder<String> stringEncoder) throws IOException {

    EntityCapsPersistentCache cache = new SimpleDirectoryPersistentCache(createTempDirectory());
    EntityCapsManager.setPersistentCache(cache);

    DiscoverInfo di = createComplexSamplePacket();
    CapsVersionAndHash versionAndHash = EntityCapsManager.generateVerificationString(di, StringUtils.SHA1);
    String nodeVer = di.getNode() + "#" + versionAndHash.version;

    // Save the data in EntityCapsManager
    EntityCapsManager.addDiscoverInfoByNode(nodeVer, di);

    // Lose all the data
    EntityCapsManager.clearMemoryCache();

    DiscoverInfo restored_di = EntityCapsManager.getDiscoveryInfoByNodeVer(nodeVer);
    assertNotNull(restored_di);
    assertEquals(di.toXML().toString(), restored_di.toXML().toString());
}
 
Example #8
Source File: HashElementTest.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Test
public void stanzaTest() throws Exception {
    String message = "Hello World!";
    HashElement element = HashManager.calculateHashElement(SHA_256, StringUtils.toUtf8Bytes(message));
    String expected = "<hash xmlns='urn:xmpp:hashes:2' algo='sha-256'>f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk=</hash>";
    assertEquals(expected, element.toXML().toString());

    HashElement parsed = new HashElementProvider().parse(TestUtils.getParser(expected));
    assertEquals(expected, parsed.toXML().toString());
    assertEquals(SHA_256, parsed.getAlgorithm());
    assertEquals("f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk=", parsed.getHashB64());
    assertArrayEquals(HashManager.sha_256(message), parsed.getHash());

    assertEquals(element, parsed);
    assertTrue(element.equals(parsed));

    HashElement other = new HashElement(HashManager.ALGORITHM.SHA_512,
            "861844d6704e8573fec34d967e20bcfef3d424cf48be04e6dc08f2bd58c729743371015ead891cc3cf1c9d34b49264b510751b1ff9e537937bc46b5d6ff4ecc8".getBytes(StandardCharsets.UTF_8));
    assertFalse(element.equals(other));
}
 
Example #9
Source File: AbstractListFilter.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public final String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append(getClass().getSimpleName());
    sb.append(": (");
    sb.append(StringUtils.toStringBuilder(filters, ", "));
    sb.append(')');
    return sb.toString();
}
 
Example #10
Source File: RandomStringStanzaIdSource.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public StanzaIdSource constructStanzaIdSource() {
    StanzaIdSource stanzaIdSource;
    if (verySecure) {
        stanzaIdSource = () -> StringUtils.randomString(length);
    } else {
        stanzaIdSource = () -> StringUtils.insecureRandomString(length);
    }
    return stanzaIdSource;
}
 
Example #11
Source File: OnceForThisStanza.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public boolean accept(Stanza packet) {
    String otherId = packet.getStanzaId();
    if (StringUtils.isNullOrEmpty(otherId)) {
        return false;
    }
    if (id.equals(otherId)) {
        connection.removeRequestAckPredicate(this);
        return true;
    }
    return false;
}
 
Example #12
Source File: XmlEnvironment.java    From Smack with Apache License 2.0 5 votes vote down vote up
public String getEffectiveNamespaceOrUse(String namespace) {
    String effectiveNamespace = getEffectiveLanguage();
    if (StringUtils.isNullOrEmpty(effectiveNamespace)) {
        return namespace;
    }
    return effectiveNamespace;
}
 
Example #13
Source File: RiotApi.java    From League-of-Legends-XMPP-Chat-Library with MIT License 5 votes vote down vote up
public String getName(String userId) throws IOException {
	final String summonerId = StringUtils.parseName(userId).replace("sum",
			"");
	final String response = request("https://" + server.api + "/api/lol/"
			+ server.getApiRegion() + "/v1.4/summoner/" + summonerId + "/name?api_key="
			+ riotApiKey.getKey());
	final Map<String, String> summoner = new GsonBuilder().create()
			.fromJson(response, new TypeToken<Map<String, String>>() {
			}.getType());
	return summoner.get(summonerId);
}
 
Example #14
Source File: TaxiChatManagerListener.java    From weixin with Apache License 2.0 5 votes vote down vote up
@Override
public void chatCreated(Chat chat, boolean arg1) {
	chat.addMessageListener(new MessageListener() {

		@Override
		public void processMessage(Chat arg0, Message msg) {//登录用户
			StringUtils.parseName(XmppManager.getInstance().getConnection().getUser());
			//发送消息用户
			msg.getFrom();
			//消息内容
			String body = msg.getBody();
			System.out.println("body--->" + body);
			boolean left = body.substring(0, 1).equals("{");
			boolean right = body.substring(body.length() - 1, body.length()).equals("}");
			if (left && right) {
				try {
					JSONObject obj = new JSONObject(body);
					String type = obj.getString("messageType");
					String chanId = obj.getString("chanId");
					String chanName = obj.getString("chanName");

					System.out.println("---body--->" + body);
				} catch (JSONException e) {
					e.printStackTrace();
				}
			}
			
			
			Intent intent = new Intent("net.cgt.weixin.chat");
			intent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);// 包含从未启动过的应用
			intent.putExtra("from", msg.getFrom());
			intent.putExtra("body", body);
			GlobalParams.activity.sendBroadcast(intent);
		}
	});
}
 
Example #15
Source File: IOCipherOmemoStore.java    From Zom-Android-XMPP with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean isTrustedOmemoIdentity(OmemoManager omemoManager, OmemoDevice device, OmemoFingerprint fingerprint) {
    File trustPath = hierarchy.getContactsTrustPath(omemoManager, device);
    try {
        String depositedFingerprint = new String(readBytes(trustPath), StringUtils.UTF8);

        return  depositedFingerprint.length() > 2
                && depositedFingerprint.charAt(0) == '1'
                && new OmemoFingerprint(depositedFingerprint.substring(2)).equals(fingerprint);
    } catch (IOException e) {
        return false;
    }
}
 
Example #16
Source File: IQ.java    From AndroidPNClient with Apache License 2.0 5 votes vote down vote up
public String toXML() {
    StringBuilder buf = new StringBuilder();
    buf.append("<iq ");
    if (getPacketID() != null) {
        buf.append("id=\"" + getPacketID() + "\" ");
    }
    if (getTo() != null) {
        buf.append("to=\"").append(StringUtils.escapeForXML(getTo())).append("\" ");
    }
    if (getFrom() != null) {
        buf.append("from=\"").append(StringUtils.escapeForXML(getFrom())).append("\" ");
    }
    if (type == null) {
        buf.append("type=\"get\">");
    }
    else {
        buf.append("type=\"").append(getType()).append("\">");
    }
    // Add the query section if there is one.
    String queryXML = getChildElementXML();
    if (queryXML != null) {
        buf.append(queryXML);
    }
    // Add the error sub-packet, if there is one.
    XMPPError error = getError();
    if (error != null) {
        buf.append(error.toXML());
    }
    buf.append("</iq>");
    return buf.toString();
}
 
Example #17
Source File: IOCipherOmemoStore.java    From Zom-Android-XMPP with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean isDecidedOmemoIdentity(OmemoManager omemoManager, OmemoDevice device, OmemoFingerprint fingerprint) {
    File trustPath = hierarchy.getContactsTrustPath(omemoManager, device);
    try {
        String depositedFingerprint = new String(readBytes(trustPath), StringUtils.UTF8);

        return  depositedFingerprint.length() > 2
                && (depositedFingerprint.charAt(0) == '1' || depositedFingerprint.charAt(0) == '2')
                && new OmemoFingerprint(depositedFingerprint.substring(2)).equals(fingerprint);
    } catch (IOException e) {
        return false;
    }
}
 
Example #18
Source File: Version.java    From Smack with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new Version object with given details.
 *
 * @param name The natural-language name of the software. This element is REQUIRED.
 * @param version The specific version of the software. This element is REQUIRED.
 * @param os The operating system of the queried entity. This element is OPTIONAL.
 */
public Version(String name, String version, String os) {
    super(ELEMENT, NAMESPACE);
    this.setType(IQ.Type.result);
    this.name = StringUtils.requireNotNullNorEmpty(name, "name must not be null");
    this.version = StringUtils.requireNotNullNorEmpty(version, "version must not be null");
    this.os = os;
}
 
Example #19
Source File: XmlEnvironment.java    From Smack with Apache License 2.0 5 votes vote down vote up
public String getEffectiveLanguage() {
    if (effectiveLanguageDetermined) {
        return effectiveLanguage;
    }

    if (StringUtils.isNotEmpty(language)) {
        effectiveLanguage = language;
    } else if (next != null) {
        effectiveLanguage = next.getEffectiveLanguage();
    }

    effectiveLanguageDetermined = true;
    return effectiveLanguage;
}
 
Example #20
Source File: MamElements.java    From Smack with Apache License 2.0 5 votes vote down vote up
/**
 * MAM result extension constructor.
 *
 * @param queryId TODO javadoc me please
 * @param id TODO javadoc me please
 * @param forwarded TODO javadoc me please
 */
public MamResultExtension(String queryId, String id, Forwarded forwarded) {
    if (StringUtils.isEmpty(id)) {
        throw new IllegalArgumentException("id must not be null or empty");
    }
    if (forwarded == null) {
        throw new IllegalArgumentException("forwarded must no be null");
    }
    this.id = id;
    this.forwarded = forwarded;
    this.queryId = queryId;
}
 
Example #21
Source File: PrivacyListManager.java    From Smack with Apache License 2.0 5 votes vote down vote up
/**
 * Answer the default privacy list. Returns <code>null</code> if there is no default list.
 *
 * @return the privacy list of the default list.
 * @throws XMPPErrorException if there was an XMPP error returned.
 * @throws NoResponseException if there was no response from the remote entity.
 * @throws NotConnectedException if the XMPP connection is not connected.
 * @throws InterruptedException if the calling thread was interrupted.
 */
public PrivacyList getDefaultList() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    Privacy privacyAnswer = this.getPrivacyWithListNames();
    String listName = privacyAnswer.getDefaultName();
    if (StringUtils.isNullOrEmpty(listName)) {
        return null;
    }
    boolean isDefaultAndActive = listName.equals(privacyAnswer.getActiveName());
    return new PrivacyList(isDefaultAndActive, true, listName, getPrivacyListItems(listName));
}
 
Example #22
Source File: SASLExternalMechanism.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
protected byte[] getAuthenticationText() {
    if (authorizationId != null) {
      return toBytes(authorizationId.toString());
    }

    if (StringUtils.isNullOrEmpty(authenticationId)) {
        return null;
    }

    return toBytes(XmppStringUtils.completeJidFrom(authenticationId, serviceName));
}
 
Example #23
Source File: SpoilerElement.java    From Smack with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new SpoilerElement with a hint about a content and a language attribute.
 *
 * @param language language of the hint.
 * @param hint hint about the content.
 */
public SpoilerElement(String language, String hint) {
    if (StringUtils.isNotEmpty(language) && StringUtils.isNullOrEmpty(hint)) {
        throw new IllegalArgumentException("Hint cannot be null or empty if language is not empty.");
    }
    this.language = language;
    this.hint = hint;
}
 
Example #24
Source File: StandardExtensionElement.java    From Smack with Apache License 2.0 5 votes vote down vote up
public Builder addAttribute(String name, String value) {
    StringUtils.requireNotNullNorEmpty(name, "Attribute name must be set");
    Objects.requireNonNull(value, "Attribute value must be not null");
    if (attributes == null) {
        attributes = new LinkedHashMap<>();
    }
    attributes.put(name, value);
    return this;
}
 
Example #25
Source File: Socks5BytestreamManager.java    From Smack with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new unique session ID.
 *
 * @return a new unique session ID
 */
private static String getNextSessionID() {
    StringBuilder buffer = new StringBuilder();
    buffer.append(SESSION_ID_PREFIX);
    buffer.append(StringUtils.secureOnlineAttackSafeRandomString());
    return buffer.toString();
}
 
Example #26
Source File: Macros.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) {
    buf.rightAngleBracket();

    if (isPersonal()) {
        buf.append("<personal>true</personal>");
    }
    if (getPersonalMacroGroup() != null) {
        buf.append("<personalMacro>");
        buf.append(StringUtils.escapeForXmlText(getPersonalMacroGroup().toXML()));
        buf.append("</personalMacro>");
    }

    return buf;
}
 
Example #27
Source File: SASLMechanism.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
protected void authenticate() throws IOException, XMPPException {
  String authenticationText = null;
  try {
    if (sc.hasInitialResponse()) {
      byte[] response = sc.evaluateChallenge(new byte[0]);
      authenticationText = StringUtils.encodeBase64(response, false);
    }
  } catch (SaslException e) {
    throw new XMPPException("SASL authentication failed", e);
  }

  // Send the authentication to the server
  getSASLAuthentication().send(new AuthMechanism(getName(), authenticationText));
}
 
Example #28
Source File: JingleIBBTransportTest.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Test
public void parserTest() throws Exception {
    String sid = StringUtils.randomString(24);
    short size = 8192;

    String xml = "<transport xmlns='urn:xmpp:jingle:transports:ibb:1' block-size='8192' sid='" + sid + "'/>";

    JingleIBBTransport transport = new JingleIBBTransport(size, sid);
    assertEquals(xml, transport.toXML().toString());
    assertEquals(size, transport.getBlockSize());
    assertEquals(sid, transport.getSessionId());

    JingleIBBTransport parsed = new JingleIBBTransportProvider()
            .parse(TestUtils.getParser(xml));
    assertEquals(transport, parsed);
    assertTrue(transport.equals(parsed));
    assertEquals(xml, parsed.toXML().toString());

    JingleIBBTransport transport1 = new JingleIBBTransport((short) 1024);
    assertEquals((short) 1024, transport1.getBlockSize());
    assertNotSame(transport, transport1);
    assertNotSame(transport.getSessionId(), transport1.getSessionId());

    assertFalse(transport.equals(null));

    JingleIBBTransport transport2 = new JingleIBBTransport();
    assertEquals(JingleIBBTransport.DEFAULT_BLOCK_SIZE, transport2.getBlockSize());
    assertFalse(transport1.equals(transport2));

    JingleIBBTransport transport3 = new JingleIBBTransport((short) -1024);
    assertEquals(JingleIBBTransport.DEFAULT_BLOCK_SIZE, transport3.getBlockSize());

    assertEquals(transport3.getNamespace(), JingleIBBTransport.NAMESPACE_V1);
    assertEquals(transport3.getElementName(), "transport");

    JingleIBBTransport transport4 = new JingleIBBTransport("session-id");
    assertEquals(JingleIBBTransport.DEFAULT_BLOCK_SIZE, transport4.getBlockSize());
}
 
Example #29
Source File: FilledForm.java    From Smack with Apache License 2.0 5 votes vote down vote up
public FilledForm(DataForm dataForm) {
    this.dataForm = Objects.requireNonNull(dataForm);
    String formType = dataForm.getFormType();
    if (StringUtils.isNullOrEmpty(formType)) {
        throw new IllegalArgumentException("The provided data form has no hidden FROM_TYPE field.");
    }
    if (dataForm.getType() == Type.cancel) {
        throw new IllegalArgumentException("Forms of type 'cancel' are not filled nor fillable");
    }
    formTypeFormField = dataForm.getHiddenFormTypeField();
}
 
Example #30
Source File: SmackException.java    From Smack with Apache License 2.0 5 votes vote down vote up
public static NoEndpointsDiscoveredException from(List<LookupConnectionEndpointsFailed> lookupFailures) {
    StringBuilder sb = new StringBuilder();

    if (lookupFailures.isEmpty()) {
        sb.append("No endpoint lookup finished within the timeout");
    } else {
        sb.append("Not endpoints could be discovered due the following lookup failures: ");
        StringUtils.appendTo(lookupFailures, sb);
    }

    return new NoEndpointsDiscoveredException(sb.toString(), lookupFailures);
}