1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 22:12:05 +01:00

Username and password are optional in Registration. SMACK-62

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2503 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2005-06-17 22:28:12 +00:00 committed by gaston
parent 8a48d3d11e
commit 2271ca730e
2 changed files with 6 additions and 48 deletions

View file

@ -187,8 +187,8 @@ public class AccountManager {
Registration reg = new Registration(); Registration reg = new Registration();
reg.setType(IQ.Type.SET); reg.setType(IQ.Type.SET);
reg.setTo(connection.getHost()); reg.setTo(connection.getHost());
reg.setUsername(username); attributes.put("username",username);
reg.setPassword(password); attributes.put("password",password);
reg.setAttributes(attributes); reg.setAttributes(attributes);
PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()), PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
new PacketTypeFilter(IQ.class)); new PacketTypeFilter(IQ.class));
@ -217,8 +217,10 @@ public class AccountManager {
Registration reg = new Registration(); Registration reg = new Registration();
reg.setType(IQ.Type.SET); reg.setType(IQ.Type.SET);
reg.setTo(connection.getHost()); reg.setTo(connection.getHost());
reg.setUsername(StringUtils.parseName(connection.getUser())); HashMap map = new HashMap();
reg.setPassword(newPassword); map.put("username",StringUtils.parseName(connection.getUser()));
map.put("password",newPassword);
reg.setAttributes(map);
PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()), PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
new PacketTypeFilter(IQ.class)); new PacketTypeFilter(IQ.class));
PacketCollector collector = connection.createPacketCollector(filter); PacketCollector collector = connection.createPacketCollector(filter);

View file

@ -48,47 +48,9 @@ import java.util.Iterator;
*/ */
public class Registration extends IQ { public class Registration extends IQ {
private String username = null;
private String password = null;
private String instructions = null; private String instructions = null;
private Map attributes = null; private Map attributes = null;
/**
* Returns the username, or <tt>null</tt> if no username has ben set.
*
* @return the username.
*/
public String getUsername() {
return username;
}
/**
* Sets the username.
*
* @param username the username.
*/
public void setUsername(String username) {
this.username = username;
}
/**
* Returns the password, or <tt>null</tt> if no password has been set.
*
* @return the password.
*/
public String getPassword() {
return password;
}
/**
* Sets the password.
*
* @param password the password.
*/
public void setPassword(String password) {
this.password = password;
}
/** /**
* Returns the registration instructions, or <tt>null</tt> if no instructions * Returns the registration instructions, or <tt>null</tt> if no instructions
* have been set. If present, instructions should be displayed to the end-user * have been set. If present, instructions should be displayed to the end-user
@ -130,12 +92,6 @@ public class Registration extends IQ {
public String getChildElementXML() { public String getChildElementXML() {
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
buf.append("<query xmlns=\"jabber:iq:register\">"); buf.append("<query xmlns=\"jabber:iq:register\">");
if (username != null) {
buf.append("<username>").append(username).append("</username>");
}
if (password != null) {
buf.append("<password>").append(password).append("</password>");
}
if (instructions != null) { if (instructions != null) {
buf.append("<instructions>").append(instructions).append("</instructions>"); buf.append("<instructions>").append(instructions).append("</instructions>");
} }