package com.kamco.cd.kamcoback.auth;

import org.mindrot.jbcrypt.BCrypt;
import org.springframework.security.crypto.password.PasswordEncoder;

public class JBCryptPasswordEncoder implements PasswordEncoder {

  @Override
  public String encode(CharSequence rawPassword) {
    throw new UnsupportedOperationException("custom salt 사용");
  }

  @Override
  public boolean matches(CharSequence rawPassword, String encodedPassword) {
    if (encodedPassword == null || encodedPassword.isBlank()) {
      return false;
    }

    return BCrypt.checkpw(rawPassword.toString(), encodedPassword);
  }
}
