이창훈/spring/demo/src/main/java/kr/eddi/demo/entity/jpa/member/BasicAuthentication.java
<filename>이창훈/spring/demo/src/main/java/kr/eddi/demo/entity/jpa/member/BasicAuthentication.javapackage kr.eddi.demo.entity.jpa.member;

import kr.eddi.demo.utility.encrypt.EncryptionUtil;
import kr.eddi.demo.utility.password.PasswordHashConverter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.*;

@Entity
@ToString(callSuper = true)
@NoArgsConstructor
@DiscriminatorValue(Authentication.BASIC_AUTH)
public class BasicAuthentication extends Authentication {
    @Setter
    @Column(nullable = false)
    @Convert(converter = PasswordHashConverter.class)
    private String password;

    public BasicAuthentication(JpaMember member, String authenticationType, String password) {
        super(member, authenticationType);
        this.password = password;
    }

    public boolean isRightPassword(String plainToCheck) {
        return EncryptionUtil.checkValidation(plainToCheck, password);
    }
}
