package com.bocloud.nms.model.hillstone;

import java.util.Objects;
import java.util.Optional;

public class SNMPV3UserModel extends HillStoneGenericModel {
    private Long vendorId; // 所属平台
    private String username; // 名称
    private Integer remoteIpType; // 远程IP类型
    private String groupName; // V3用户组
    private Long remoteIp; // 远程IP
    private Long remoteIpMask;//远程IP掩码
    private Integer authType; // 认证类型 1->MD5; 2->SHA-1;
    private String authPass; // 认证密码
    private Integer privType; // 加密算法 1->AES-128; 2->DES;
    private String privPass; // 加密密码
    private String safeMode = "V3";//安全模式

    public String getSafeMode() {
        return safeMode;
    }

    public Long getRemoteIpMask() {
        return remoteIpMask;
    }

    public void setRemoteIpMask(Long remoteIpMask) {
        this.remoteIpMask = remoteIpMask;
    }

    public Long getVendorId() {
        return vendorId;
    }

    public void setVendorId(Long vendorId) {
        this.vendorId = vendorId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Integer getRemoteIpType() {
        return remoteIpType;
    }

    public void setRemoteIpType(Integer remoteIpType) {
        this.remoteIpType = remoteIpType;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public Long getRemoteIp() {
        return remoteIp;
    }

    public void setRemoteIp(Long remoteIp) {
        this.remoteIp = remoteIp;
    }

    public Integer getAuthType() {
        return authType;
    }

    public void setAuthType(Integer authType) {
        this.authType = authType;
    }

    public String getAuthPass() {
        return authPass;
    }

    public void setAuthPass(String authPass) {
        this.authPass = authPass;
    }

    public Integer getPrivType() {
        return privType;
    }

    public void setPrivType(Integer privType) {
        this.privType = privType;
    }

    public String getPrivPass() {
        return privPass;
    }

    public String getRemoteIpString() {
        return Optional.ofNullable(this.getRemoteIp()).map(Ipv4::convertIp).orElse(null);
    }

    public void setPrivPass(String privPass) {
        this.privPass = privPass;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        SNMPV3UserModel that = (SNMPV3UserModel) o;
        return Objects.equals(vendorId, that.vendorId) &&
            Objects.equals(username, that.username);
    }

    @Override
    public int hashCode() {
        return Objects.hash(vendorId, username);
    }
}
