-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementerte felles sikkerhetsmodul i bekreftelse-api
- Loading branch information
1 parent
428d622
commit 0de4459
Showing
39 changed files
with
904 additions
and
1,059 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
39 changes: 0 additions & 39 deletions
39
apps/bekreftelse-api/src/main/kotlin/no/nav/paw/bekreftelse/api/context/RequestContext.kt
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
apps/bekreftelse-api/src/main/kotlin/no/nav/paw/bekreftelse/api/context/SecurityContext.kt
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
...e-api/src/main/kotlin/no/nav/paw/bekreftelse/api/exception/BearerTokenManglerException.kt
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
...api/src/main/kotlin/no/nav/paw/bekreftelse/api/exception/BrukerHarIkkeTilgangException.kt
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
...kreftelse-api/src/main/kotlin/no/nav/paw/bekreftelse/api/exception/SystemfeilException.kt
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
...e-api/src/main/kotlin/no/nav/paw/bekreftelse/api/exception/UgyldigBearerTokenException.kt
This file was deleted.
Oops, something went wrong.
61 changes: 0 additions & 61 deletions
61
apps/bekreftelse-api/src/main/kotlin/no/nav/paw/bekreftelse/api/model/AccessToken.kt
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
apps/bekreftelse-api/src/main/kotlin/no/nav/paw/bekreftelse/api/model/Bruker.kt
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
apps/bekreftelse-api/src/main/kotlin/no/nav/paw/bekreftelse/api/model/Converters.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,79 @@ | ||
package no.nav.paw.bekreftelse.api.model | ||
|
||
import no.nav.paw.bekreftelse.internehendelser.BekreftelseTilgjengelig | ||
import no.nav.paw.bekreftelse.melding.v1.Bekreftelse | ||
import no.nav.paw.bekreftelse.melding.v1.vo.Bekreftelsesloesning | ||
import no.nav.paw.bekreftelse.melding.v1.vo.BrukerType | ||
import no.nav.paw.bekreftelse.melding.v1.vo.Metadata | ||
import no.nav.paw.bekreftelse.melding.v1.vo.Svar | ||
import no.nav.paw.security.authentication.model.Bruker | ||
import no.nav.paw.security.authentication.model.M2MToken | ||
import no.nav.paw.security.authentication.model.NavAnsatt | ||
import no.nav.paw.security.authentication.model.Sluttbruker | ||
import no.nav.paw.security.authorization.exception.IngenTilgangException | ||
import java.time.Instant | ||
|
||
fun Bruker<*>.asBekreftelseBruker(): no.nav.paw.bekreftelse.melding.v1.vo.Bruker { | ||
return when (this) { | ||
is Sluttbruker -> no.nav.paw.bekreftelse.melding.v1.vo.Bruker(BrukerType.SLUTTBRUKER, ident.verdi) | ||
is NavAnsatt -> no.nav.paw.bekreftelse.melding.v1.vo.Bruker(BrukerType.VEILEDER, ident) | ||
is M2MToken -> no.nav.paw.bekreftelse.melding.v1.vo.Bruker(BrukerType.SYSTEM, ident) | ||
else -> throw IngenTilgangException("Ukjent brukergruppe") | ||
} | ||
} | ||
|
||
fun BekreftelseTilgjengelig.asBekreftelse( | ||
harJobbetIDennePerioden: Boolean, | ||
vilFortsetteSomArbeidssoeker: Boolean, | ||
bruker: no.nav.paw.bekreftelse.melding.v1.vo.Bruker, | ||
kilde: String, | ||
aarsak: String, | ||
bekreftelsesloesning: Bekreftelsesloesning | ||
): Bekreftelse { | ||
return Bekreftelse.newBuilder() | ||
.setBekreftelsesloesning(bekreftelsesloesning) | ||
.setId(bekreftelseId) | ||
.setPeriodeId(periodeId) | ||
.setSvar( | ||
asSvar( | ||
harJobbetIDennePerioden, | ||
vilFortsetteSomArbeidssoeker, | ||
bruker, | ||
kilde, | ||
aarsak | ||
) | ||
) | ||
.build() | ||
} | ||
|
||
private fun BekreftelseTilgjengelig.asSvar( | ||
harJobbetIDennePerioden: Boolean, | ||
vilFortsetteSomArbeidssoeker: Boolean, | ||
bruker: no.nav.paw.bekreftelse.melding.v1.vo.Bruker, | ||
kilde: String, | ||
aarsak: String | ||
): Svar { | ||
return Svar.newBuilder() | ||
.setSendtInnAv( | ||
Metadata.newBuilder() | ||
.setUtfoertAv(bruker) | ||
.setKilde(kilde) | ||
.setAarsak(aarsak) | ||
.setTidspunkt(Instant.now()) | ||
.build() | ||
) | ||
.setGjelderFra(gjelderFra) | ||
.setGjelderTil(gjelderTil) | ||
.setHarJobbetIDennePerioden(harJobbetIDennePerioden) | ||
.setVilFortsetteSomArbeidssoeker(vilFortsetteSomArbeidssoeker) | ||
.build() | ||
} | ||
|
||
fun BekreftelseRow.asTilgjengeligBekreftelse() = this.data.asTilgjengeligBekreftelse() | ||
|
||
private fun BekreftelseTilgjengelig.asTilgjengeligBekreftelse() = TilgjengeligBekreftelse( | ||
periodeId = this.periodeId, | ||
bekreftelseId = this.bekreftelseId, | ||
gjelderFra = this.gjelderFra, | ||
gjelderTil = this.gjelderTil | ||
) |
10 changes: 0 additions & 10 deletions
10
apps/bekreftelse-api/src/main/kotlin/no/nav/paw/bekreftelse/api/model/Identitetsnummer.kt
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.