diff options
author | vlad <vlad@driver.xyz> | 2017-07-13 02:27:55 -0700 |
---|---|---|
committer | Jakob Odersky <jakob@driver.xyz> | 2017-07-19 17:28:54 -0700 |
commit | 7f7bd651122754a3df47894b64ddb0456561bbe7 (patch) | |
tree | a7f7a6acfccb1daa90f5a8afdd26ea3819600d69 /src/main/scala/xyz/driver/pdsuicommon/domain/PasswordHash.scala | |
parent | 99ebbb98068324c2c26dd59484acbe9a8b62ae59 (diff) | |
download | rest-query-7f7bd651122754a3df47894b64ddb0456561bbe7.tar.gz rest-query-7f7bd651122754a3df47894b64ddb0456561bbe7.tar.bz2 rest-query-7f7bd651122754a3df47894b64ddb0456561bbe7.zip |
Updates for authenticationv0.2.2
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuicommon/domain/PasswordHash.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuicommon/domain/PasswordHash.scala | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/src/main/scala/xyz/driver/pdsuicommon/domain/PasswordHash.scala b/src/main/scala/xyz/driver/pdsuicommon/domain/PasswordHash.scala deleted file mode 100644 index 337d925..0000000 --- a/src/main/scala/xyz/driver/pdsuicommon/domain/PasswordHash.scala +++ /dev/null @@ -1,36 +0,0 @@ -package xyz.driver.pdsuicommon.domain - -import java.nio.charset.Charset - -import org.mindrot.jbcrypt.BCrypt - -final case class PasswordHash(value: Array[Byte]) { - - lazy val hashString: String = new String(value, Charset.forName("UTF-8")) - - override def toString: String = { - s"${this.getClass.getSimpleName}($hashString)" - } - - override def equals(that: Any): Boolean = { - that match { - case thatHash: PasswordHash => java.util.Arrays.equals(this.value, thatHash.value) - case _ => false - } - } - - override def hashCode(): Int = - 42 + java.util.Arrays.hashCode(this.value) - - def is(password: String): Boolean = - BCrypt.checkpw(password, hashString) -} - -object PasswordHash { - - def apply(password: String): PasswordHash = - new PasswordHash(getHash(password)) - - private def getHash(str: String): Array[Byte] = - BCrypt.hashpw(str, BCrypt.gensalt()).getBytes(Charset.forName("UTF-8")) -} |