-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Ticket APIs to jmap-extensions-api
- Loading branch information
1 parent
4c4e644
commit 5b1d651
Showing
5 changed files
with
40 additions
and
26 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...tensions-api/src/main/scala/com/linagora/tmail/james/jmap/ticket/ForbiddenException.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.linagora.tmail.james.jmap.ticket | ||
|
||
case class ForbiddenException() extends RuntimeException |
12 changes: 12 additions & 0 deletions
12
...kend/jmap/extensions-api/src/main/scala/com/linagora/tmail/james/jmap/ticket/Ticket.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.linagora.tmail.james.jmap.ticket | ||
|
||
import org.apache.james.core.Username | ||
import org.apache.james.jmap.core.UTCDate | ||
|
||
import java.net.InetAddress | ||
|
||
case class Ticket(clientAddress: InetAddress, | ||
value: TicketValue, | ||
generatedOn: UTCDate, | ||
validUntil: UTCDate, | ||
username: Username) |
11 changes: 11 additions & 0 deletions
11
...jmap/extensions-api/src/main/scala/com/linagora/tmail/james/jmap/ticket/TicketStore.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.linagora.tmail.james.jmap.ticket | ||
|
||
import reactor.core.scala.publisher.SMono | ||
|
||
trait TicketStore { | ||
def persist(ticket: Ticket): SMono[Unit] | ||
|
||
def retrieve(value: TicketValue): SMono[Ticket] | ||
|
||
def delete(ticketValue: TicketValue): SMono[Unit] | ||
} |
14 changes: 14 additions & 0 deletions
14
...jmap/extensions-api/src/main/scala/com/linagora/tmail/james/jmap/ticket/TicketValue.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.linagora.tmail.james.jmap.ticket | ||
|
||
import java.util.UUID | ||
import scala.util.Try | ||
|
||
object TicketValue { | ||
def parse(string: String): Either[IllegalArgumentException, TicketValue] = Try(UUID.fromString(string)) | ||
.map(TicketValue(_)) | ||
.fold(e => Left(new IllegalArgumentException("TicketValue must be backed by a UUID", e)), Right(_)) | ||
|
||
def generate: TicketValue = TicketValue(UUID.randomUUID()) | ||
} | ||
|
||
case class TicketValue(value: UUID) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters