io.agora.rtm.RtmEncryptionConfig Maven / Gradle / Ivy
package io.agora.rtm;
import io.agora.common.internal.CalledByNative;
import io.agora.rtm.RtmConstants.RtmEncryptionMode;
import java.util.Arrays;
/**
* encryption configuration
*/
public class RtmEncryptionConfig {
/**
* The encryption mode.
*/
private RtmEncryptionMode encryptionMode;
/**
* The encryption key in the string format.
*/
private String encryptionKey = "";
/**
* The encryption salt.
*/
private byte[] encryptionSalt;
/**
* Creates a new instance of {@code RtmEncryptionConfig} with default parameters.
*/
public RtmEncryptionConfig() {
this.encryptionMode = RtmEncryptionMode.NONE;
this.encryptionSalt = new byte[32];
}
/**
* Creates a new instance of {@code RtmEncryptionConfig} with specifies
* parameters.
*
* @param mode The encryption mode
* @param key The encryption key
* @param salt The encryption salt
*/
public RtmEncryptionConfig(RtmEncryptionMode mode, String key, byte[] salt) {
this.encryptionMode = mode;
this.encryptionKey = key;
this.encryptionSalt = salt;
}
public void setEncryptionMode(RtmEncryptionMode mode) {
this.encryptionMode = mode;
}
public void setEncryptionKey(String key) {
this.encryptionKey = key;
}
public void setEncryptionSalt(byte[] salt) {
this.encryptionSalt = Arrays.copyOf(salt, salt.length);
}
@CalledByNative
public int getEncryptionMode() {
return RtmEncryptionMode.getValue(this.encryptionMode);
}
@CalledByNative
public String getEncryptionKey() {
return this.encryptionKey;
}
@CalledByNative
public byte[] getEncryptionSalt() {
return this.encryptionSalt;
}
@Override
public String toString() {
return "RtmEncryptionConfig {encryptionMode: " + encryptionMode
+ ", encryptionKey: " + encryptionKey + ", encryptionSalt: " + encryptionSalt + "}";
}
}