当前位置: 首页>>代码示例>>Java>>正文


Java Registration类代码示例

本文整理汇总了Java中org.jivesoftware.smack.packet.Registration的典型用法代码示例。如果您正苦于以下问题:Java Registration类的具体用法?Java Registration怎么用?Java Registration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Registration类属于org.jivesoftware.smack.packet包,在下文中一共展示了Registration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: changePassword

import org.jivesoftware.smack.packet.Registration; //导入依赖的package包/类
/**
 * Changes the password of the currently logged-in account. This operation can only
 * be performed after a successful login operation has been completed. Not all servers
 * support changing passwords; an XMPPException will be thrown when that is the case.
 *
 * @throws IllegalStateException if not currently logged-in to the server.
 * @throws XMPPException if an error occurs when changing the password.
 */
public void changePassword(String newPassword) throws XMPPException {
    Registration reg = new Registration();
    reg.setType(IQ.Type.SET);
    reg.setTo(connection.getServiceName());
    Map<String, String> map = new HashMap<String, String>();
    map.put("username",StringUtils.parseName(connection.getUser()));
    map.put("password",newPassword);
    reg.setAttributes(map);
    PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
            new PacketTypeFilter(IQ.class));
    PacketCollector collector = connection.createPacketCollector(filter);
    connection.sendPacket(reg);
    IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from server.");
    }
    else if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:31,代码来源:AccountManager.java

示例2: deleteAccount

import org.jivesoftware.smack.packet.Registration; //导入依赖的package包/类
/**
 * Deletes the currently logged-in account from the server. This operation can only
 * be performed after a successful login operation has been completed. Not all servers
 * support deleting accounts; an XMPPException will be thrown when that is the case.
 *
 * @throws IllegalStateException if not currently logged-in to the server.
 * @throws XMPPException if an error occurs when deleting the account.
 */
public void deleteAccount() throws XMPPException {
    if (!connection.isAuthenticated()) {
        throw new IllegalStateException("Must be logged in to delete a account.");
    }
    Registration reg = new Registration();
    reg.setType(IQ.Type.SET);
    reg.setTo(connection.getServiceName());
    Map<String, String> attributes = new HashMap<String, String>();
    // To delete an account, we add a single attribute, "remove", that is blank.
    attributes.put("remove", "");
    reg.setAttributes(attributes);
    PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
            new PacketTypeFilter(IQ.class));
    PacketCollector collector = connection.createPacketCollector(filter);
    connection.sendPacket(reg);
    IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from server.");
    }
    else if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:34,代码来源:AccountManager.java

示例3: getRegistrationInfo

import org.jivesoftware.smack.packet.Registration; //导入依赖的package包/类
/**
 * Gets the account registration info from the server.
 *
 * @throws XMPPException if an error occurs.
 */
private synchronized void getRegistrationInfo() throws XMPPException {
    Registration reg = new Registration();
    reg.setTo(connection.getServiceName());
    PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
            new PacketTypeFilter(IQ.class));
    PacketCollector collector = connection.createPacketCollector(filter);
    connection.sendPacket(reg);
    IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from server.");
    }
    else if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
    else {
        info = (Registration)result;
    }
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:26,代码来源:AccountManager.java

示例4: getRegistrationForm

import org.jivesoftware.smack.packet.Registration; //导入依赖的package包/类
/**
 * Returns the room's registration form that an unaffiliated user, can use to become a member
 * of the room or <tt>null</tt> if no registration is possible. Some rooms may restrict the
 * privilege to register members and allow only room admins to add new members.<p>
 *
 * If the user requesting registration requirements is not allowed to register with the room
 * (e.g. because that privilege has been restricted), the room will return a "Not Allowed"
 * error to the user (error code 405).
 *
 * @return the registration Form that contains the fields to complete together with the
 * instrucions or <tt>null</tt> if no registration is possible.
 * @throws XMPPException if an error occurs asking the registration form for the room or a
 * 405 error if the user is not allowed to register with the room.
 */
public Form getRegistrationForm() throws XMPPException {
    Registration reg = new Registration();
    reg.setType(IQ.Type.GET);
    reg.setTo(room);

    PacketFilter filter =
        new AndFilter(new PacketIDFilter(reg.getPacketID()), new PacketTypeFilter(IQ.class));
    PacketCollector collector = connection.createPacketCollector(filter);
    connection.sendPacket(reg);
    IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from server.");
    }
    else if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
    return Form.getFormFrom(result);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:34,代码来源:MultiUserChat.java

示例5: sendRegistrationForm

import org.jivesoftware.smack.packet.Registration; //导入依赖的package包/类
/**
 * Sends the completed registration form to the server. After the user successfully submits
 * the form, the room may queue the request for review by the room admins or may immediately
 * add the user to the member list by changing the user's affiliation from "none" to "member.<p>
 *
 * If the desired room nickname is already reserved for that room, the room will return a
 * "Conflict" error to the user (error code 409). If the room does not support registration,
 * it will return a "Service Unavailable" error to the user (error code 503).
 *
 * @param form the completed registration form.
 * @throws XMPPException if an error occurs submitting the registration form. In particular, a
 *      409 error can occur if the desired room nickname is already reserved for that room;
 *      or a 503 error can occur if the room does not support registration.
 */
public void sendRegistrationForm(Form form) throws XMPPException {
    Registration reg = new Registration();
    reg.setType(IQ.Type.SET);
    reg.setTo(room);
    reg.addExtension(form.getDataFormToSend());

    PacketFilter filter =
        new AndFilter(new PacketIDFilter(reg.getPacketID()), new PacketTypeFilter(IQ.class));
    PacketCollector collector = connection.createPacketCollector(filter);
    connection.sendPacket(reg);
    IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from server.");
    }
    else if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:34,代码来源:MultiUserChat.java

示例6: changePassword

import org.jivesoftware.smack.packet.Registration; //导入依赖的package包/类
/**
 * Changes the password of the currently logged-in account. This operation can only
 * be performed after a successful login operation has been completed. Not all servers
 * support changing passwords; an XMPPException will be thrown when that is the case.
 *
 * @throws IllegalStateException if not currently logged-in to the server.
 * @throws XMPPException if an error occurs when changing the password.
 */
public void changePassword(String newPassword) throws XMPPException {
    Registration reg = new Registration();
    reg.setType(IQ.Type.SET);
    reg.setTo(connection.getServiceName());
    reg.setUsername(StringUtils.parseName(connection.getUser()));
    reg.setPassword(newPassword);
    PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
            new PacketTypeFilter(IQ.class));
    PacketCollector collector = connection.createPacketCollector(filter);
    connection.sendPacket(reg);
    IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from server.");
    }
    else if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
}
 
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:29,代码来源:AccountManager.java

示例7: deleteAccount

import org.jivesoftware.smack.packet.Registration; //导入依赖的package包/类
/**
 * Deletes the currently logged-in account from the server. This operation can only
 * be performed after a successful login operation has been completed. Not all servers
 * support deleting accounts; an XMPPException will be thrown when that is the case.
 *
 * @throws IllegalStateException if not currently logged-in to the server.
 * @throws XMPPException if an error occurs when deleting the account.
 */
public void deleteAccount() throws XMPPException {
    if (!connection.isAuthenticated()) {
        throw new IllegalStateException("Must be logged in to delete a account.");
    }
    Registration reg = new Registration();
    reg.setType(IQ.Type.SET);
    reg.setTo(connection.getServiceName());
    // To delete an account, we set remove to true
    reg.setRemove(true);
    PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
            new PacketTypeFilter(IQ.class));
    PacketCollector collector = connection.createPacketCollector(filter);
    connection.sendPacket(reg);
    IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from server.");
    }
    else if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
}
 
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:32,代码来源:AccountManager.java

示例8: createAccount

import org.jivesoftware.smack.packet.Registration; //导入依赖的package包/类
/**
 * 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 XMPPException
 *             if an error occurs creating the account.
 * @see #getAccountAttributes()
 */
public void createAccount(String username, String password,
		Map<String, String> attributes) throws XMPPException {
	if (!supportsAccountCreation()) {
		throw new XMPPException("Server does not support account creation.");
	}
	Registration reg = new Registration();
	reg.setType(IQ.Type.SET);
	reg.setTo(connection.getServiceName());
	attributes.put("username", username);
	attributes.put("password", password);
	reg.setAttributes(attributes);
	PacketFilter filter = new AndFilter(new PacketIDFilter(
			reg.getPacketID()), new PacketTypeFilter(IQ.class));
	PacketCollector collector = connection.createPacketCollector(filter);
	connection.sendPacket(reg);
	IQ result = (IQ) collector.nextResult(SmackConfiguration
			.getPacketReplyTimeout());
	// Stop queuing results
	collector.cancel();
	if (result == null) {
		throw new XMPPException("No response from server.");
	} else if (result.getType() == IQ.Type.ERROR) {
		throw new XMPPException(result.getError());
	}
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:41,代码来源:AccountManager.java

示例9: changePassword

import org.jivesoftware.smack.packet.Registration; //导入依赖的package包/类
/**
 * Changes the password of the currently logged-in account. This operation
 * can only be performed after a successful login operation has been
 * completed. Not all servers support changing passwords; an XMPPException
 * will be thrown when that is the case.
 * 
 * @throws IllegalStateException
 *             if not currently logged-in to the server.
 * @throws XMPPException
 *             if an error occurs when changing the password.
 */
public void changePassword(String newPassword) throws XMPPException {
	Registration reg = new Registration();
	reg.setType(IQ.Type.SET);
	reg.setTo(connection.getServiceName());
	Map<String, String> map = new HashMap<String, String>();
	map.put("username", StringUtils.parseName(connection.getUser()));
	map.put("password", newPassword);
	reg.setAttributes(map);
	PacketFilter filter = new AndFilter(new PacketIDFilter(
			reg.getPacketID()), new PacketTypeFilter(IQ.class));
	PacketCollector collector = connection.createPacketCollector(filter);
	connection.sendPacket(reg);
	IQ result = (IQ) collector.nextResult(SmackConfiguration
			.getPacketReplyTimeout());
	// Stop queuing results
	collector.cancel();
	if (result == null) {
		throw new XMPPException("No response from server.");
	} else if (result.getType() == IQ.Type.ERROR) {
		throw new XMPPException(result.getError());
	}
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:34,代码来源:AccountManager.java

示例10: getRegistrationInfo

import org.jivesoftware.smack.packet.Registration; //导入依赖的package包/类
/**
 * Gets the account registration info from the server.
 * 
 * @throws XMPPException
 *             if an error occurs.
 */
private synchronized void getRegistrationInfo() throws XMPPException {
	Registration reg = new Registration();
	reg.setTo(connection.getServiceName());
	PacketFilter filter = new AndFilter(new PacketIDFilter(
			reg.getPacketID()), new PacketTypeFilter(IQ.class));
	PacketCollector collector = connection.createPacketCollector(filter);
	connection.sendPacket(reg);
	IQ result = (IQ) collector.nextResult(SmackConfiguration
			.getPacketReplyTimeout());
	// Stop queuing results
	collector.cancel();
	if (result == null) {
		throw new XMPPException("No response from server.");
	} else if (result.getType() == IQ.Type.ERROR) {
		throw new XMPPException(result.getError());
	} else {
		info = (Registration) result;
	}
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:26,代码来源:AccountManager.java

示例11: refreshRegisterInfo

import org.jivesoftware.smack.packet.Registration; //导入依赖的package包/类
private void refreshRegisterInfo() {
	Registration packet = new Registration();
	packet.setFrom(connection.getUser());
	packet.setType(IQ.Type.GET);
	packet.setTo(entityJID);
	PacketCollector collector = connection
			.createPacketCollector(new PacketIDFilter(packet.getPacketID()));
	connection.sendPacket(packet);
	Packet result = collector.nextResult(SmackConfiguration
			.getPacketReplyTimeout());
	collector.cancel();
	if (result instanceof Registration && result.getError() == null) {
		Registration register = (Registration) result;
		this.registerInfo = register;
	}
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:17,代码来源:Gateway.java

示例12: getRegistrationForm

import org.jivesoftware.smack.packet.Registration; //导入依赖的package包/类
/**
 * Returns the room's registration form that an unaffiliated user, can use
 * to become a member of the room or <tt>null</tt> if no registration is
 * possible. Some rooms may restrict the privilege to register members and
 * allow only room admins to add new members.
 * <p>
 * 
 * If the user requesting registration requirements is not allowed to
 * register with the room (e.g. because that privilege has been restricted),
 * the room will return a "Not Allowed" error to the user (error code 405).
 * 
 * @return the registration Form that contains the fields to complete
 *         together with the instrucions or <tt>null</tt> if no registration
 *         is possible.
 * @throws XMPPException
 *             if an error occurs asking the registration form for the room
 *             or a 405 error if the user is not allowed to register with
 *             the room.
 */
public Form getRegistrationForm() throws XMPPException {
	Registration reg = new Registration();
	reg.setType(IQ.Type.GET);
	reg.setTo(room);

	PacketFilter filter = new AndFilter(new PacketIDFilter(
			reg.getPacketID()), new PacketTypeFilter(IQ.class));
	PacketCollector collector = connection.createPacketCollector(filter);
	connection.sendPacket(reg);
	IQ result = (IQ) collector.nextResult(SmackConfiguration
			.getPacketReplyTimeout());
	collector.cancel();
	if (result == null) {
		throw new XMPPException("No response from server.");
	} else if (result.getType() == IQ.Type.ERROR) {
		throw new XMPPException(result.getError());
	}
	return Form.getFormFrom(result);
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:39,代码来源:MultiUserChat.java

示例13: changePassword

import org.jivesoftware.smack.packet.Registration; //导入依赖的package包/类
/**
 * Changes the password of the currently logged-in account. This operation can only
 * be performed after a successful login operation has been completed. Not all servers
 * support changing passwords; an XMPPException will be thrown when that is the case.
 *
 * @throws IllegalStateException if not currently logged-in to the server.
 * @throws org.jivesoftware.smack.XMPPException if an error occurs when changing the password.
 */
public void changePassword(String newPassword) throws XMPPException {
    Registration reg = new Registration();
    reg.setType(IQ.Type.SET);
    reg.setTo(connection.getServiceName());
    reg.setUsername(StringUtils.parseName(connection.getUser()));
    reg.setPassword(newPassword);
    PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
            new PacketTypeFilter(IQ.class));
    PacketCollector collector = connection.createPacketCollector(filter);
    connection.sendPacket(reg);
    IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from server.");
    }
    else if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
}
 
开发者ID:msdx,项目名称:AndroidPNClient,代码行数:29,代码来源:AccountManager.java

示例14: deleteAccount

import org.jivesoftware.smack.packet.Registration; //导入依赖的package包/类
/**
 * Deletes the currently logged-in account from the server. This operation can only
 * be performed after a successful login operation has been completed. Not all servers
 * support deleting accounts; an XMPPException will be thrown when that is the case.
 *
 * @throws IllegalStateException if not currently logged-in to the server.
 * @throws org.jivesoftware.smack.XMPPException if an error occurs when deleting the account.
 */
public void deleteAccount() throws XMPPException {
    if (!connection.isAuthenticated()) {
        throw new IllegalStateException("Must be logged in to delete a account.");
    }
    Registration reg = new Registration();
    reg.setType(IQ.Type.SET);
    reg.setTo(connection.getServiceName());
    // To delete an account, we set remove to true
    reg.setRemove(true);
    PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
            new PacketTypeFilter(IQ.class));
    PacketCollector collector = connection.createPacketCollector(filter);
    connection.sendPacket(reg);
    IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from server.");
    }
    else if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
}
 
开发者ID:msdx,项目名称:AndroidPNClient,代码行数:32,代码来源:AccountManager.java

示例15: getRegistrationInfo

import org.jivesoftware.smack.packet.Registration; //导入依赖的package包/类
/**
 * Gets the account registration info from the server.
 *
 * @throws org.jivesoftware.smack.XMPPException if an error occurs.
 */
private synchronized void getRegistrationInfo() throws XMPPException {
    Registration reg = new Registration();
    reg.setTo(connection.getServiceName());
    PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
            new PacketTypeFilter(IQ.class));
    PacketCollector collector = connection.createPacketCollector(filter);
    connection.sendPacket(reg);
    IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from server.");
    }
    else if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
    else {
        info = (Registration)result;
    }
}
 
开发者ID:msdx,项目名称:AndroidPNClient,代码行数:26,代码来源:AccountManager.java


注:本文中的org.jivesoftware.smack.packet.Registration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。