mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 18:59:41 +02:00
SMACK-280: The SASL mechanisms work transparent with packet listeners
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@11615 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
ad65a76e77
commit
e3efee2e8f
3 changed files with 121 additions and 12 deletions
|
@ -216,6 +216,28 @@ public abstract class SASLMechanism implements CallbackHandler {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A SASL challenge stanza.
|
||||
*/
|
||||
public static class Challenge extends Packet {
|
||||
final private String data;
|
||||
|
||||
public Challenge(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder stanza = new StringBuilder();
|
||||
stanza.append("<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">");
|
||||
if (data != null &&
|
||||
data.trim().length() > 0) {
|
||||
stanza.append(data);
|
||||
}
|
||||
stanza.append("</challenge>");
|
||||
return stanza.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A SASL response stanza.
|
||||
*/
|
||||
|
@ -248,4 +270,57 @@ public abstract class SASLMechanism implements CallbackHandler {
|
|||
return stanza.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A SASL success stanza.
|
||||
*/
|
||||
public static class Success extends Packet {
|
||||
final private String data;
|
||||
|
||||
public Success(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder stanza = new StringBuilder();
|
||||
stanza.append("<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">");
|
||||
if (data != null &&
|
||||
data.trim().length() > 0) {
|
||||
stanza.append(data);
|
||||
}
|
||||
stanza.append("</success>");
|
||||
return stanza.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A SASL failure stanza.
|
||||
*/
|
||||
public static class Failure extends Packet {
|
||||
final private String condition;
|
||||
|
||||
public Failure(String condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the SASL related error condition.
|
||||
*
|
||||
* @return the SASL related error condition.
|
||||
*/
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder stanza = new StringBuilder();
|
||||
stanza.append("<failure xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">");
|
||||
if (condition != null &&
|
||||
condition.trim().length() > 0) {
|
||||
stanza.append("<").append(condition).append("/>");
|
||||
}
|
||||
stanza.append("</failure>");
|
||||
return stanza.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue