Authorize share access

This commit is contained in:
eikek
2021-10-03 23:56:59 +02:00
parent 97922340d9
commit f4596db63d
13 changed files with 457 additions and 11 deletions

View File

@ -6,18 +6,29 @@
package docspell.common
import java.nio.charset.StandardCharsets
import cats.effect.Sync
import cats.implicits._
import io.circe.{Decoder, Encoder}
import scodec.bits.ByteVector
final class Password(val pass: String) extends AnyVal {
def isEmpty: Boolean = pass.isEmpty
def nonEmpty: Boolean = pass.nonEmpty
def length: Int = pass.length
def asByteVector: ByteVector =
ByteVector.view(pass.getBytes(StandardCharsets.UTF_8))
override def toString: String =
if (pass.isEmpty) "<empty>" else "***"
def compare(other: Password): Boolean =
this.pass.zip(other.pass).forall { case (a, b) => a == b } &&
this.nonEmpty && this.length == other.length
}
object Password {

View File

@ -70,6 +70,9 @@ object Timestamp {
def atUtc(ldt: LocalDateTime): Timestamp =
from(ldt.atZone(UTC))
def ofMillis(ms: Long): Timestamp =
Timestamp(Instant.ofEpochMilli(ms))
def daysBetween(ts0: Timestamp, ts1: Timestamp): Long =
ChronoUnit.DAYS.between(ts0.toUtcDate, ts1.toUtcDate)