Skip to content

Eksempel app for oppsett og bruk av Fiks-Io-klient#798

Open
ErlendStokkeMonstadKS wants to merge 15 commits intomainfrom
FO-434-eksempel-app
Open

Eksempel app for oppsett og bruk av Fiks-Io-klient#798
ErlendStokkeMonstadKS wants to merge 15 commits intomainfrom
FO-434-eksempel-app

Conversation

@ErlendStokkeMonstadKS
Copy link
Contributor

Siden EksempelApp er avhengig av at man faktisk kan stenge ned klienten riktig så legger jeg på fiks for å kunne stenge ned klienten.

@OrjanSkotnes OrjanSkotnes self-requested a review March 6, 2026 11:19
Copy link
Contributor

@OrjanSkotnes OrjanSkotnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dette ser veldig bra ut! Jeg har lagt inn noen kommentarer. Det må også utarbeides en readme til denne eksempel applikasjonen.

}

private static PrivateKey setOppPrivateKey(FiksIOKlientProperties klientProperties) throws InvalidKeySpecException, NoSuchAlgorithmException, IOException {
return KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(((PrivateKeyInfo) new PEMParser(new FileReader(fileFromResource(klientProperties.privatekeyFile()))).readObject()).getEncoded()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Burde ikke ressursene her bli lukket? fileReader og PEMParser? burde vel vært i en try-resources block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vet ikke, fikser det uansett.

}
}

public static void send(FiksIOKlient klient, KontoId kontoId, String meldingType, String innhold) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrappe denne i en try-catch med logging? .NET versjonen gjør dette. Den genererer klientMeldingId og klientKorrelasjonsId. Logger forsøk på sending og resultet. Returnerer til slutt en meldings-id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Litt usikker på hva du mener, la oss se på det sammen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vi har nok loggingen vi trenger her

System.out.println(" P - Send PING melding");
System.out.println(" G - Send PONG melding");
System.out.println(" K - Hent konto informasjon");
System.out.println(" Q - Avslutter applikasjonen");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Få på plass en helesjekk...isOpen, getKonto, getKontoStatus, validerPublicKeyMotPrivateKey?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hent konto informasjon er egentlig getKontoStatus da status er med i konto informasjon.

System.out.println(" K - Hent konto informasjon");
System.out.println(" Q - Avslutter applikasjonen");

try (Scanner scanner = new Scanner(System.in)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ingen demonstrasjon av payload-dekryptering / ASiC-E-lesing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La oss ta det direkte, ting er litt annerledes mellom Java og Dotnet.


private static void runInteractiveConsole(FiksIOKlient javaKlient, KontoId kontoId) {
System.out.println("Starter interaktiv konsoll:");
System.out.println(" P - Send PING melding");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bør følge samme spor som .net example med reelle protokollnavn.

FiksIOPing = "ping";
FiksIOPong = "pong";
FiksArkivPing = "no.ks.fiks.arkiv.v1.ping";
FiksArkivPong = "no.ks.fiks.arkiv.v1.pong";
FiksPlanPing = "no.ks.fiks.plan.v2.ping";
FiksPlanPong = "no.ks.fiks.plan.v2.pong";
FiksMatrikkelfoeringPing = "no.ks.fiks.matrikkelfoering.v2.ping";
FiksMatrikkelfoeringPong = "no.ks.fiks.matrikkelfoering.v2.pong";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La oss snakke om det direkte, jeg unngikk dette bevist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brukt reelle protokollnavn, men tar ikke å inkluderer alle variantene her

}

public static void send(FiksIOKlient klient, KontoId kontoId, String meldingType, String innhold) {
klient.send(MeldingRequest.builder().mottakerKontoId(kontoId).meldingType(meldingType).build(), innhold, "melding.txt");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hva mener du? Avsender er jo satt opp i klienten.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Legger det på loggingen.


konto.id=

integasjon.id=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skrivefeil på integrasjon, begge felt.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fikser

}

public static void send(FiksIOKlient klient, KontoId kontoId, String meldingType, String innhold) {
klient.send(MeldingRequest.builder().mottakerKontoId(kontoId).meldingType(meldingType).build(), innhold, "melding.txt");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hva mener du? Avsender er jo satt opp i klienten.

Benytter try-resource block for å sette opp privateKey
@ks-no ks-no deleted a comment from OrjanSkotnes Mar 6, 2026
@ErlendStokkeMonstadKS
Copy link
Contributor Author

README tar vi når vi er enig om resten.

Copy link
Contributor

@jarleborsheim jarleborsheim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM den README'en 🌮
Bra levert! Du får en fredagstaco!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants