正在查看: bbinstant v6.24.0 应用的 DataPacketExtension.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: bbinstant v6.24.0 应用的 DataPacketExtension.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.jivesoftware.smackx.bytestreams.ibb.packet;
import okhttp3.internal.ws.e;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smack.util.stringencoder.Base64;
public class DataPacketExtension implements ExtensionElement {
public static final String ELEMENT = "data";
public static final String NAMESPACE = "http://jabber.org/protocol/ibb";
private final String data;
private byte[] decodedData;
private final long seq;
private final String sessionID;
public DataPacketExtension(String str, long j, String str2) {
if (str == null || "".equals(str)) {
throw new IllegalArgumentException("Session ID must not be null or empty");
}
if (j < 0 || j > e.PAYLOAD_SHORT_MAX) {
throw new IllegalArgumentException("Sequence must not be between 0 and 65535");
}
if (str2 == null) {
throw new IllegalArgumentException("Data must not be null");
}
this.sessionID = str;
this.seq = j;
this.data = str2;
}
public String getData() {
return this.data;
}
public byte[] getDecodedData() {
byte[] bArr = this.decodedData;
if (bArr != null) {
return bArr;
}
if (this.data.matches(".*={1,2}+.+")) {
return null;
}
byte[] decode = Base64.decode(this.data);
this.decodedData = decode;
return decode;
}
@Override
public String getElementName() {
return "data";
}
protected IQ.IQChildElementXmlStringBuilder getIQChildElementBuilder(IQ.IQChildElementXmlStringBuilder iQChildElementXmlStringBuilder) {
iQChildElementXmlStringBuilder.attribute("seq", Long.toString(this.seq));
iQChildElementXmlStringBuilder.attribute("sid", this.sessionID);
iQChildElementXmlStringBuilder.rightAngleBracket();
iQChildElementXmlStringBuilder.append((CharSequence) this.data);
return iQChildElementXmlStringBuilder;
}
@Override
public String getNamespace() {
return "http://jabber.org/protocol/ibb";
}
public long getSeq() {
return this.seq;
}
public String getSessionID() {
return this.sessionID;
}
@Override
public XmlStringBuilder toXML() {
IQ.IQChildElementXmlStringBuilder iQChildElementBuilder = getIQChildElementBuilder(new IQ.IQChildElementXmlStringBuilder(this));
iQChildElementBuilder.closeElement(this);
return iQChildElementBuilder;
}
}