mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-29 23:42:06 +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:
parent
8a48d3d11e
commit
2271ca730e
2 changed files with 6 additions and 48 deletions
|
@ -187,8 +187,8 @@ public class AccountManager {
|
|||
Registration reg = new Registration();
|
||||
reg.setType(IQ.Type.SET);
|
||||
reg.setTo(connection.getHost());
|
||||
reg.setUsername(username);
|
||||
reg.setPassword(password);
|
||||
attributes.put("username",username);
|
||||
attributes.put("password",password);
|
||||
reg.setAttributes(attributes);
|
||||
PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
|
||||
new PacketTypeFilter(IQ.class));
|
||||
|
@ -217,8 +217,10 @@ public class AccountManager {
|
|||
Registration reg = new Registration();
|
||||
reg.setType(IQ.Type.SET);
|
||||
reg.setTo(connection.getHost());
|
||||
reg.setUsername(StringUtils.parseName(connection.getUser()));
|
||||
reg.setPassword(newPassword);
|
||||
HashMap map = new HashMap();
|
||||
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);
|
||||
|
|
|
@ -48,47 +48,9 @@ import java.util.Iterator;
|
|||
*/
|
||||
public class Registration extends IQ {
|
||||
|
||||
private String username = null;
|
||||
private String password = null;
|
||||
private String instructions = 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
|
||||
* 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() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
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) {
|
||||
buf.append("<instructions>").append(instructions).append("</instructions>");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue