org.signal.libsignal.metadata.ProtocolException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of signal-client-java Show documentation
Show all versions of signal-client-java Show documentation
Signal Protocol cryptography library for Java
package org.signal.libsignal.metadata;
import org.signal.libsignal.metadata.protocol.UnidentifiedSenderMessageContent;
import org.whispersystems.libsignal.util.guava.Optional;
public abstract class ProtocolException extends Exception {
private final Optional content;
private final String sender;
private final int senderDevice;
public ProtocolException(Exception e, String sender, int senderDevice) {
this.content = Optional.absent();
this.sender = sender;
this.senderDevice = senderDevice;
}
ProtocolException(Exception e, UnidentifiedSenderMessageContent content) {
this.content = Optional.of(content);
this.sender = content.getSenderCertificate().getSender();
this.senderDevice = content.getSenderCertificate().getSenderDeviceId();
}
public Optional getUnidentifiedSenderMessageContent() {
return content;
}
public String getSender() {
return sender;
}
public int getSenderDevice() {
return senderDevice;
}
public int getContentHint() {
if (content.isPresent()) {
return content.get().getContentHint();
}
return UnidentifiedSenderMessageContent.CONTENT_HINT_DEFAULT;
}
public Optional getGroupId() {
if (content.isPresent()) {
return content.get().getGroupId();
}
return Optional.absent();
}
}