package org.ros.chatto.dto;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.Data;

@Data
public class MessageCipherDTO {
	@Pattern(regexp = "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") // regex for base64
	@NotBlank
	private String iv;
	@Max(1)
	@NotBlank
	private int v;
	@Max(1_000_000)
	@Min(1_000)
	@NotBlank
	@JsonProperty("iter")
	private int iterations;
	@Max(256)
	@Min(128)
	@JsonProperty("ks")
	private int keySize;
	@Max(256)
	@Min(128)
	@JsonProperty("ts")
	private int tagSize;
	@Pattern(regexp = "^[A-Za-z0-9]+$") // alphabetic
	@NotBlank
	private String mode;
	@Pattern(regexp = "^[A-Za-z0-9]+$")
	private String adata;
	@Pattern(regexp = "^[A-Za-z0-9]+$")
	@NotBlank
	private String cipher;
	@Pattern(regexp = "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$")
	@NotBlank
	private String salt;
	@JsonProperty("ct")
	@Pattern(regexp = "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$")
	@NotBlank
	@Size(max = 2000, min = 1)
	private String cipherText;
}
