-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ticket jdbc repo
- Loading branch information
Showing
32 changed files
with
316 additions
and
156 deletions.
There are no files selected for viewing
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
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
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
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
8 changes: 4 additions & 4 deletions
8
src/main/kotlin/com/vauthenticator/server/config/TicketConfig.kt
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
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
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
8 changes: 4 additions & 4 deletions
8
src/main/kotlin/com/vauthenticator/server/mfa/domain/MfaMethodsEnrollmentAssociation.kt
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
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
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
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
6 changes: 5 additions & 1 deletion
6
...server/ticket/DynamoDbTicketRepository.kt → ...pter/dynamodb/DynamoDbTicketRepository.kt
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
61 changes: 61 additions & 0 deletions
61
src/main/kotlin/com/vauthenticator/server/ticket/adapter/jdbc/JdbcTicketRepository.kt
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,61 @@ | ||
package com.vauthenticator.server.ticket.adapter.jdbc | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.vauthenticator.server.role.domain.Role | ||
import com.vauthenticator.server.ticket.domain.Ticket | ||
import com.vauthenticator.server.ticket.domain.TicketContext | ||
import com.vauthenticator.server.ticket.domain.TicketId | ||
import com.vauthenticator.server.ticket.domain.TicketRepository | ||
import org.springframework.jdbc.core.JdbcTemplate | ||
import java.util.* | ||
|
||
class JdbcTicketRepository( | ||
private val jdbcTemplate: JdbcTemplate, | ||
private val objectMapper: ObjectMapper | ||
) : TicketRepository { | ||
|
||
override fun store(ticket: Ticket) { | ||
jdbcTemplate.update( | ||
"INSERT INTO TICKET (ticket, ttl, user_name, client_application_id, context) VALUES (?,?,?,?,?)", | ||
ticket.ticketId.content, | ||
ticket.ttl, | ||
ticket.userName, | ||
ticket.clientAppId, | ||
objectMapper.writeValueAsString(ticket.context.content) | ||
) | ||
} | ||
|
||
|
||
override fun loadFor(ticketId: TicketId): Optional<Ticket> { | ||
val queryResult = jdbcTemplate.query( | ||
"SELECT * FROM TICKET WHERE ticket = ?", | ||
{ rs, _ -> | ||
Ticket( | ||
ticketId = TicketId(rs.getString("ticket")), | ||
ttl = rs.getLong("ttl"), | ||
userName = rs.getString("user_name"), | ||
clientAppId = rs.getString("client_application_id"), | ||
context = TicketContext( | ||
objectMapper.readValue( | ||
rs.getString("context"), | ||
Map::class.java | ||
) as Map<String, String> | ||
) | ||
|
||
) | ||
}, | ||
ticketId.content | ||
) | ||
|
||
return if (queryResult.isEmpty()) { | ||
Optional.empty() | ||
} else { | ||
Optional.of(queryResult.first()) | ||
} | ||
} | ||
|
||
override fun delete(ticketId: TicketId) { | ||
jdbcTemplate.update("DELETE FROM TICKET WHERE ticket=?", ticketId.content) | ||
} | ||
|
||
} |
14 changes: 7 additions & 7 deletions
14
...om/vauthenticator/server/ticket/Ticket.kt → ...henticator/server/ticket/domain/Ticket.kt
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
2 changes: 1 addition & 1 deletion
2
...henticator/server/ticket/TicketCreator.kt → ...tor/server/ticket/domain/TicketCreator.kt
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
2 changes: 1 addition & 1 deletion
2
...ticator/server/ticket/TicketRepository.kt → .../server/ticket/domain/TicketRepository.kt
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.vauthenticator.server.ticket | ||
package com.vauthenticator.server.ticket.domain | ||
|
||
import java.util.* | ||
|
||
|
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
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
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
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
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
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
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
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
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
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
6 changes: 3 additions & 3 deletions
6
src/test/kotlin/com/vauthenticator/server/support/TicketFixture.kt
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
Oops, something went wrong.