org.jxmpp.jid.FullJid Java Examples

The following examples show how to use org.jxmpp.jid.FullJid. 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: JingleUtil.java    From Smack with Apache License 2.0 6 votes vote down vote up
public Jingle createTransportReject(FullJid recipient, FullJid initiator, String sessionId,
                                    JingleContent.Creator contentCreator, String contentName,
                                    JingleContentTransport transport) {
    Jingle.Builder jb = Jingle.getBuilder();
    jb.setAction(JingleAction.transport_reject)
            .setInitiator(initiator)
            .setSessionId(sessionId);

    JingleContent.Builder cb = JingleContent.getBuilder();
    cb.setCreator(contentCreator).setName(contentName).setTransport(transport);

    Jingle jingle = jb.addJingleContent(cb.build()).build();
    jingle.setTo(recipient);
    jingle.setFrom(connection.getUser());

    return jingle;
}
 
Example #2
Source File: JingleS5BTransportManager.java    From Smack with Apache License 2.0 6 votes vote down vote up
public Jingle createCandidateActivated(FullJid remote, FullJid initiator, String sessionId,
                                       JingleContent.Senders senders, JingleContent.Creator creator,
                                       String name, String streamId, String candidateId) {
    Jingle.Builder jb = Jingle.getBuilder();
    jb.setInitiator(initiator).setSessionId(sessionId).setAction(JingleAction.transport_info);

    JingleContent.Builder cb = JingleContent.getBuilder();
    cb.setName(name).setCreator(creator).setSenders(senders);

    JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
    tb.setStreamId(streamId).setCandidateActivated(candidateId);

    Jingle jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
    jingle.setFrom(getConnection().getUser().asFullJidOrThrow());
    jingle.setTo(remote);
    return jingle;
}
 
Example #3
Source File: JingleS5BTransportManager.java    From Smack with Apache License 2.0 6 votes vote down vote up
public Jingle createProxyError(FullJid remote, FullJid initiator, String sessionId,
                               JingleContent.Senders senders, JingleContent.Creator creator,
                               String name, String streamId) {
    Jingle.Builder jb = Jingle.getBuilder();
    jb.setSessionId(sessionId).setAction(JingleAction.transport_info).setInitiator(initiator);

    JingleContent.Builder cb = JingleContent.getBuilder();
    cb.setSenders(senders).setCreator(creator).setName(name);

    JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
    tb.setStreamId(sessionId).setProxyError().setStreamId(streamId);

    Jingle jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
    jingle.setTo(remote);
    jingle.setFrom(getConnection().getUser().asFullJidOrThrow());
    return jingle;
}
 
Example #4
Source File: JingleS5BTransportManager.java    From Smack with Apache License 2.0 6 votes vote down vote up
public Jingle createCandidateError(FullJid remote, FullJid initiator, String sessionId, JingleContent.Senders senders, JingleContent.Creator creator, String name, String streamId) {
    Jingle.Builder jb = Jingle.getBuilder();
    jb.setSessionId(sessionId).setInitiator(initiator).setAction(JingleAction.transport_info);

    JingleContent.Builder cb = JingleContent.getBuilder();
    cb.setName(name).setCreator(creator).setSenders(senders);

    JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
    tb.setCandidateError().setStreamId(streamId);

    Jingle jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
    jingle.setFrom(getConnection().getUser().asFullJidOrThrow());
    jingle.setTo(remote);

    return jingle;
}
 
Example #5
Source File: JingleS5BTransportManager.java    From Smack with Apache License 2.0 6 votes vote down vote up
public Jingle createCandidateUsed(FullJid recipient, FullJid initiator, String sessionId, JingleContent.Senders contentSenders,
                                  JingleContent.Creator contentCreator, String contentName, String streamId,
                                  String candidateId) {
    Jingle.Builder jb = Jingle.getBuilder();
    jb.setSessionId(sessionId).setInitiator(initiator).setAction(JingleAction.transport_info);

    JingleContent.Builder cb = JingleContent.getBuilder();
    cb.setName(contentName).setCreator(contentCreator).setSenders(contentSenders);

    JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
    tb.setCandidateUsed(candidateId).setStreamId(streamId);

    Jingle jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
    jingle.setFrom(getConnection().getUser().asFullJidOrThrow());
    jingle.setTo(recipient);

    return jingle;
}
 
Example #6
Source File: JidCreate.java    From jxmpp with Apache License 2.0 6 votes vote down vote up
/**
 * Get a {@link FullJid} representing the given String.
 *
 * @param jid the JID's String.
 * @return a full JID representing the input String.
 * @throws XmppStringprepException if an error occurs.
 */
public static FullJid fullFrom(String jid) throws XmppStringprepException {
	FullJid fullJid = FULLJID_CACHE.lookup(jid);
	if (fullJid != null) {
		return fullJid;
	}

	String localpart = XmppStringUtils.parseLocalpart(jid);
	String domainpart = XmppStringUtils.parseDomain(jid);
	String resource = XmppStringUtils.parseResource(jid);
	try {
		fullJid = fullFrom(localpart, domainpart, resource);
	} catch (XmppStringprepException e) {
		throw new XmppStringprepException(jid, e);
	}
	FULLJID_CACHE.put(jid, fullJid);
	return fullJid;
}
 
Example #7
Source File: JingleUtil.java    From Smack with Apache License 2.0 6 votes vote down vote up
public Jingle createSessionInitiate(FullJid recipient,
                                    String sessionId,
                                    JingleContent.Creator contentCreator,
                                    String contentName,
                                    JingleContent.Senders contentSenders,
                                    JingleContentDescription description,
                                    JingleContentTransport transport) {

    Jingle.Builder jb = Jingle.getBuilder();
    jb.setAction(JingleAction.session_initiate)
            .setSessionId(sessionId)
            .setInitiator(connection.getUser());

    JingleContent.Builder cb = JingleContent.getBuilder();
    cb.setCreator(contentCreator)
            .setName(contentName)
            .setSenders(contentSenders)
            .setDescription(description)
            .setTransport(transport);

    Jingle jingle = jb.addJingleContent(cb.build()).build();
    jingle.setFrom(connection.getUser());
    jingle.setTo(recipient);

    return jingle;
}
 
Example #8
Source File: JingleS5BTransportTest.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Test
public void candidateFromStreamHostTest() throws XmppStringprepException, UnknownHostException {
    FullJid jid = JidCreate.fullFrom("[email protected]/test");
    String host = "localhost";
    int port = 1234;
    Bytestream.StreamHost streamHost = new Bytestream.StreamHost(jid, host, port);

    JingleS5BTransportCandidate candidate = new JingleS5BTransportCandidate(streamHost, 2000, JingleS5BTransportCandidate.Type.direct);

    assertEquals(2000, candidate.getPriority());
    assertEquals(jid, candidate.getJid());
    assertEquals(host, candidate.getHost().toString());
    assertEquals(port, candidate.getPort());

    assertEquals(streamHost.toXML().toString(), candidate.getStreamHost().toXML().toString());
}
 
Example #9
Source File: Jingle.java    From Smack with Apache License 2.0 6 votes vote down vote up
private Jingle(String sessionId, JingleAction action, FullJid initiator, FullJid responder, JingleReason reason,
                List<JingleContent> contents) {
    super(ELEMENT, NAMESPACE);
    this.sessionId = StringUtils.requireNotNullNorEmpty(sessionId, "Jingle session ID must not be null");
    this.action = Objects.requireNonNull(action, "Jingle action must not be null");
    this.initiator = initiator;
    this.responder = responder;
    this.reason = reason;
    if (contents != null) {
        this.contents = Collections.unmodifiableList(contents);
    }
    else {
        this.contents = Collections.emptyList();
    }
    setType(Type.set);
}
 
Example #10
Source File: JingleUtil.java    From Smack with Apache License 2.0 6 votes vote down vote up
public Jingle createTransportAccept(FullJid recipient, FullJid initiator, String sessionId,
                                    JingleContent.Creator contentCreator, String contentName,
                                    JingleContentTransport transport) {
    Jingle.Builder jb = Jingle.getBuilder();
    jb.setAction(JingleAction.transport_accept)
            .setInitiator(initiator)
            .setSessionId(sessionId);

    JingleContent.Builder cb = JingleContent.getBuilder();
    cb.setCreator(contentCreator).setName(contentName).setTransport(transport);

    Jingle jingle = jb.addJingleContent(cb.build()).build();
    jingle.setTo(recipient);
    jingle.setFrom(connection.getUser());

    return jingle;
}
 
Example #11
Source File: JingleUtil.java    From Smack with Apache License 2.0 6 votes vote down vote up
public Jingle createTransportReplace(FullJid recipient, FullJid initiator, String sessionId,
                                     JingleContent.Creator contentCreator, String contentName,
                                     JingleContentTransport transport) {
    Jingle.Builder jb = Jingle.getBuilder();
    jb.setInitiator(initiator)
            .setSessionId(sessionId)
            .setAction(JingleAction.transport_replace);

    JingleContent.Builder cb = JingleContent.getBuilder();
    cb.setName(contentName).setCreator(contentCreator).setTransport(transport);
    Jingle jingle = jb.addJingleContent(cb.build()).build();

    jingle.setTo(recipient);
    jingle.setFrom(connection.getUser());

    return jingle;
}
 
Example #12
Source File: JingleUtil.java    From Smack with Apache License 2.0 6 votes vote down vote up
public Jingle createSessionAccept(FullJid recipient,
                                  String sessionId,
                                  JingleContent.Creator contentCreator,
                                  String contentName,
                                  JingleContent.Senders contentSenders,
                                  JingleContentDescription description,
                                  JingleContentTransport transport) {

    Jingle.Builder jb = Jingle.getBuilder();
    jb.setResponder(connection.getUser())
            .setAction(JingleAction.session_accept)
            .setSessionId(sessionId);

    JingleContent.Builder cb = JingleContent.getBuilder();
    cb.setCreator(contentCreator)
            .setName(contentName)
            .setSenders(contentSenders)
            .setDescription(description)
            .setTransport(transport);

    Jingle jingle = jb.addJingleContent(cb.build()).build();
    jingle.setTo(recipient);
    jingle.setFrom(connection.getUser());

    return jingle;
}
 
Example #13
Source File: JidCreate.java    From jxmpp with Apache License 2.0 5 votes vote down vote up
/**
 * Get a {@link FullJid} from a given {@link CharSequence} or {@code null} if the input does not represent a JID.
 *
 * @param cs the input {@link CharSequence}
 * @return a JID or {@code null}
 */
public static FullJid fullFromOrNull(CharSequence cs) {
	try {
		return fullFrom(cs);
	} catch (XmppStringprepException e) {
		return null;
	}
}
 
Example #14
Source File: JingleUtil.java    From Smack with Apache License 2.0 5 votes vote down vote up
public IQ sendSessionTerminateAlternativeSession(FullJid recipient, String sessionId, String altSessionId)
        throws InterruptedException, XMPPException.XMPPErrorException,
        SmackException.NotConnectedException, SmackException.NoResponseException {

    Jingle jingle = createSessionTerminateAlternativeSession(recipient, sessionId, altSessionId);
    return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
 
Example #15
Source File: JidCreate.java    From jxmpp with Apache License 2.0 5 votes vote down vote up
/**
 * Get a {@link FullJid} constructed from a {@link BareJid} and a {@link Resourcepart}.
 *
 * @param bareJid a entity bare JID.
 * @param resource a resourcepart.
 * @return a full JID.
 */
public static FullJid fullFrom(BareJid bareJid, Resourcepart resource) {
	if (bareJid.isEntityBareJid()) {
		EntityBareJid entityBareJid = (EntityBareJid) bareJid;
		return new LocalDomainAndResourcepartJid(entityBareJid, resource);
	} else {
		DomainBareJid domainBareJid = (DomainBareJid) bareJid;
		return new DomainAndResourcepartJid(domainBareJid, resource);
	}
}
 
Example #16
Source File: JingleUtil.java    From Smack with Apache License 2.0 5 votes vote down vote up
public Jingle createSessionTerminateContentCancel(FullJid recipient, String sessionId,
                                                  JingleContent.Creator contentCreator, String contentName) {
    Jingle.Builder jb = Jingle.getBuilder();
    jb.setAction(JingleAction.session_terminate)
            .setSessionId(sessionId);

    JingleContent.Builder cb = JingleContent.getBuilder();
    cb.setCreator(contentCreator).setName(contentName);

    Jingle jingle = jb.addJingleContent(cb.build()).build();
    jingle.setFrom(connection.getUser());
    jingle.setTo(recipient);

    return jingle;
}
 
Example #17
Source File: JingleUtil.java    From Smack with Apache License 2.0 5 votes vote down vote up
public IQ sendSessionInitiateFileOffer(FullJid recipient,
                                       String sessionId,
                                       JingleContent.Creator contentCreator,
                                       String contentName,
                                       JingleContentDescription description,
                                       JingleContentTransport transport)
        throws SmackException.NotConnectedException, InterruptedException,
        XMPPException.XMPPErrorException, SmackException.NoResponseException {

    Jingle jingle = createSessionInitiateFileOffer(recipient, sessionId, contentCreator, contentName, description, transport);
    return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
 
Example #18
Source File: JingleSession.java    From Smack with Apache License 2.0 5 votes vote down vote up
public JingleSession(FullJid initiator, FullJid responder, Role role, String sid, List<JingleContent> contents) {
    if (role == Role.initiator) {
        this.local = initiator;
        this.remote = responder;
    } else {
        this.local = responder;
        this.remote = initiator;
    }
    this.sid = sid;
    this.role = role;

    if (contents != null) {
        this.contents.addAll(contents);
    }
}
 
Example #19
Source File: JingleUtil.java    From Smack with Apache License 2.0 5 votes vote down vote up
public IQ sendSessionTerminateContentCancel(FullJid recipient, String sessionId,
                              JingleContent.Creator contentCreator, String contentName)
        throws SmackException.NotConnectedException, InterruptedException,
        XMPPException.XMPPErrorException, SmackException.NoResponseException {
    Jingle jingle = createSessionTerminateContentCancel(recipient, sessionId, contentCreator, contentName);
    return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
 
Example #20
Source File: JidCreate.java    From jxmpp with Apache License 2.0 5 votes vote down vote up
/**
 * Get a {@link FullJid} constructed from the given parts.
 *
 * @param localpart a optional localpart.
 * @param domainpart a domainpart.
 * @param resource a resourcepart.
 * @param context the JXMPP context.
 * @return a full JID.
 * @throws XmppStringprepException if an error occurs.
 */
public static FullJid fullFrom(String localpart, String domainpart, String resource, JxmppContext context) throws XmppStringprepException {
	FullJid fullJid;
	try {
		if (localpart == null || localpart.length() == 0) {
			fullJid = new DomainAndResourcepartJid(domainpart, resource, context);
		} else {
			fullJid = new LocalDomainAndResourcepartJid(localpart, domainpart, resource, context);
		}
	} catch (XmppStringprepException e) {
		throw new XmppStringprepException(localpart + '@' + domainpart + '/' + resource, e);
	}
	return fullJid;
}
 
Example #21
Source File: JingleUtil.java    From Smack with Apache License 2.0 5 votes vote down vote up
public Jingle createSessionPing(FullJid recipient, String sessionId) {
    Jingle.Builder jb = Jingle.getBuilder();
    jb.setSessionId(sessionId)
            .setAction(JingleAction.session_info);

    Jingle jingle = jb.build();
    jingle.setFrom(connection.getUser());
    jingle.setTo(recipient);

    return jingle;
}
 
Example #22
Source File: JingleUtil.java    From Smack with Apache License 2.0 5 votes vote down vote up
public Jingle createSessionInitiateFileOffer(FullJid recipient,
                                             String sessionId,
                                             JingleContent.Creator contentCreator,
                                             String contentName,
                                             JingleContentDescription description,
                                             JingleContentTransport transport) {
    return createSessionInitiate(recipient, sessionId, contentCreator, contentName,
            JingleContent.Senders.initiator, description, transport);
}
 
Example #23
Source File: JingleUtil.java    From Smack with Apache License 2.0 5 votes vote down vote up
public IQ sendTransportAccept(FullJid recipient, FullJid initiator, String sessionId,
                              JingleContent.Creator contentCreator, String contentName,
                              JingleContentTransport transport)
        throws SmackException.NotConnectedException, InterruptedException,
        XMPPException.XMPPErrorException, SmackException.NoResponseException {
    Jingle jingle = createTransportAccept(recipient, initiator, sessionId, contentCreator, contentName, transport);
    return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
 
Example #24
Source File: JingleUtil.java    From Smack with Apache License 2.0 5 votes vote down vote up
public IQ sendSessionInitiate(FullJid recipient,
                              String sessionId,
                              JingleContent.Creator contentCreator,
                              String contentName,
                              JingleContent.Senders contentSenders,
                              JingleContentDescription description,
                              JingleContentTransport transport)
        throws SmackException.NotConnectedException, InterruptedException {

    Jingle jingle = createSessionInitiate(recipient, sessionId, contentCreator, contentName, contentSenders,
            description, transport);

    return connection.createStanzaCollectorAndSend(jingle).nextResult();
}
 
Example #25
Source File: JingleUtil.java    From Smack with Apache License 2.0 5 votes vote down vote up
public IQ sendSessionAccept(FullJid recipient,
                            String sessionId,
                            JingleContent.Creator contentCreator,
                            String contentName,
                            JingleContent.Senders contentSenders,
                            JingleContentDescription description,
                            JingleContentTransport transport)
        throws SmackException.NotConnectedException, InterruptedException {

    Jingle jingle = createSessionAccept(recipient, sessionId, contentCreator, contentName, contentSenders,
            description, transport);

    return connection.createStanzaCollectorAndSend(jingle).nextResult();
}
 
Example #26
Source File: JingleUtil.java    From Smack with Apache License 2.0 5 votes vote down vote up
public Jingle createSessionTerminate(FullJid recipient, String sessionId, JingleReason reason) {
    Jingle.Builder jb = Jingle.getBuilder();
    jb.setAction(JingleAction.session_terminate)
            .setSessionId(sessionId)
            .setReason(reason);

    Jingle jingle = jb.build();
    jingle.setFrom(connection.getUser());
    jingle.setTo(recipient);

    return jingle;
}
 
Example #27
Source File: JingleS5BTransportTest.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Test
public void transportCandidateIllegalPortTest() throws XmppStringprepException, UnknownHostException {
    FullJid jid = JidCreate.fullFrom("[email protected]/test");
    assertThrows(IllegalArgumentException.class, () -> {
        new JingleS5BTransportCandidate(
                "cid", "host", jid, -5555, 30, JingleS5BTransportCandidate.Type.proxy);
    });
}
 
Example #28
Source File: JingleS5BTransportTest.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Test
public void transportCandidateIllegalPriorityTest() throws XmppStringprepException, UnknownHostException {
    FullJid jid = JidCreate.fullFrom("[email protected]/test");
    assertThrows(IllegalArgumentException.class, () -> {
        new JingleS5BTransportCandidate(
                "cid", "localhost", jid, 5555, -30, JingleS5BTransportCandidate.Type.proxy);
    });
}
 
Example #29
Source File: JingleUtil.java    From Smack with Apache License 2.0 5 votes vote down vote up
public IQ sendSessionTerminateSuccess(FullJid recipient, String sessionId)
        throws InterruptedException, XMPPException.XMPPErrorException,
        SmackException.NotConnectedException, SmackException.NoResponseException {

    Jingle jingle = createSessionTerminateSuccess(recipient, sessionId);
    return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
 
Example #30
Source File: JingleUtil.java    From Smack with Apache License 2.0 5 votes vote down vote up
public IQ sendSessionTerminateBusy(FullJid recipient, String sessionId)
        throws InterruptedException, XMPPException.XMPPErrorException,
        SmackException.NotConnectedException, SmackException.NoResponseException {

    Jingle jingle = createSessionTerminateBusy(recipient, sessionId);
    return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}