public Task StartAsync(CancellationToken cancellationToken)
        {
            Console.WriteLine("Arkivering Service is starting.");

            Console.WriteLine("Setter opp FIKS integrasjon for fagsystem...");
            Guid   accountId           = Guid.Parse(config["accountId"]);     /* Fiks IO accountId as Guid Banke kommune eByggesak konto*/
            string privateKey          = File.ReadAllText("privkey.pem");;    /* Private key for offentlig nøkkel supplied to Fiks IO account */
            Guid   integrationId       = Guid.Parse(config["integrationId"]); /* Integration id as Guid eByggesak system X */
            string integrationPassword = config["integrationPassword"];       /* Integration password */

            // Fiks IO account configuration
            var account = new KontoConfiguration(
                accountId,
                privateKey);

            // Id and password for integration associated to the Fiks IO account.
            var integration = new IntegrasjonConfiguration(
                integrationId,
                integrationPassword, "ks:fiks");

            // ID-porten machine to machine configuration
            var maskinporten = new MaskinportenClientConfiguration(
                audience: @"https://oidc-ver2.difi.no/idporten-oidc-provider/",           // ID-porten audience path
                tokenEndpoint: @"https://oidc-ver2.difi.no/idporten-oidc-provider/token", // ID-porten token path
                issuer: @"arkitektum_test",                                               // issuer name
                numberOfSecondsLeftBeforeExpire: 10,                                      // The token will be refreshed 10 seconds before it expires
                certificate: GetCertificate(config["ThumbprintIdPortenVirksomhetssertifikat"]));

            // Optional: Use custom api host (i.e. for connecting to test api)
            var api = new ApiConfiguration(
                scheme: "https",
                host: "api.fiks.test.ks.no",
                port: 443);

            // Optional: Use custom amqp host (i.e. for connection to test queue)
            var amqp = new AmqpConfiguration(
                host: "io.fiks.test.ks.no",
                port: 5671);

            // Combine all configurations
            var configuration = new FiksIOConfiguration(account, integration, maskinporten, api, amqp);

            client = new FiksIOClient(configuration); // See setup of configuration below



            client.NewSubscription(OnReceivedMelding);

            Console.WriteLine("Abonnerer på meldinger på konto " + accountId.ToString() + " ...");


            SendInngående();

            SendUtgående();



            return(Task.CompletedTask);
        }
Ejemplo n.º 2
0
        public FiksRequestMessageService(AppSettings appAppSettings)
        {
            _appSettings = appAppSettings;
            var config = FiksIOConfigurationBuilder.CreateFiksIOConfiguration(_appSettings);

            _client = new FiksIOClient(config);

            _senderId = config.KontoConfiguration.KontoId;
        }
Ejemplo n.º 3
0
 public ArkivService(AppSettings appSettings)
 {
     this.appSettings = appSettings;
     client           = FiksIOClientBuilder.CreateFiksIoClient(appSettings); //CreateFiksIoClient();
 }
        public Task StartAsync(CancellationToken cancellationToken)
        {
            Console.WriteLine("ePlansak Service is starting.");
            Console.WriteLine("Setter opp FIKS integrasjon for ePlansak...");
            Guid   accountId           = Guid.Parse(config["accountId"]);     /* Fiks IO accountId as Guid Banke kommune digitalt planregister konto*/
            string privateKey          = File.ReadAllText("privkey.pem");;    /* Private key for offentlig nøkkel supplied to Fiks IO account */
            Guid   integrationId       = Guid.Parse(config["integrationId"]); /* Integration id as Guid ePlansak system X */
            string integrationPassword = config["integrationPassword"];       /* Integration password */
            Guid   sendToaccountId     = Guid.Parse(config["sendToAccountId"]);

            // Fiks IO account configuration
            var account = new KontoConfiguration(
                accountId,
                privateKey);

            // Id and password for integration associated to the Fiks IO account.
            var integration = new IntegrasjonConfiguration(
                integrationId,
                integrationPassword, "ks:fiks");

            // ID-porten machine to machine configuration
            var maskinporten = new MaskinportenClientConfiguration(
                audience: @"https://oidc-ver2.difi.no/idporten-oidc-provider/",           // ID-porten audience path
                tokenEndpoint: @"https://oidc-ver2.difi.no/idporten-oidc-provider/token", // ID-porten token path
                issuer: @"arkitektum_test",                                               // issuer name
                numberOfSecondsLeftBeforeExpire: 10,                                      // The token will be refreshed 10 seconds before it expires
                certificate: GetCertificate(config["ThumbprintIdPortenVirksomhetssertifikat"]));

            // Optional: Use custom api host (i.e. for connecting to test api)
            var api = new ApiConfiguration(
                scheme: "https",
                host: "api.fiks.test.ks.no",
                port: 443);

            // Optional: Use custom amqp host (i.e. for connection to test queue)
            var amqp = new AmqpConfiguration(
                host: "io.fiks.test.ks.no",
                port: 5671);

            // Combine all configurations
            var configuration = new FiksIOConfiguration(account, integration, maskinporten, api, amqp);

            client = new FiksIOClient(configuration); // See setup of configuration below

            Guid receiverId = sendToaccountId;        // Receiver id as Guid
            Guid senderId   = accountId;              // Sender id as Guid

            client.NewSubscription(OnReceivedMelding);

            Console.WriteLine("Abonnerer på meldinger på konto " + accountId.ToString() + " ...");

            var messageRequestOpprettePlan = new MeldingRequest(
                mottakerKontoId: receiverId,
                avsenderKontoId: senderId,
                meldingType: "no.geointegrasjon.plan.oppdatering.oppretteplan.v1");                        // Message type as string https://fiks.ks.no/plan.oppretteplanidentinput.v1.schema.json
                                                                                                           //Se oversikt over meldingstyper på https://github.com/ks-no/fiks-io-meldingstype-katalog/tree/test/schema


            string payload = File.ReadAllText("sampleOpprettePlan.json");


            var msg = client.Send(messageRequestOpprettePlan, payload, "meldingOmNyPlan.json").Result;

            Console.WriteLine("Melding " + msg.MeldingId.ToString() + " sendt..." + msg.MeldingType);
            Console.WriteLine(payload);

            //Pause til neste
            Console.WriteLine("Trykke en tast for neste melding");
            Console.ReadKey();
            SendPlanleggingIgangsatt();

            //Pause til neste
            Console.WriteLine("Trykke en tast for neste melding");
            Console.ReadKey();
            SendPlanvedtak();


            return(Task.CompletedTask);
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            // Relative or absolute path to the *.p12-file containing the test certificate used to sign tokens for Maskinporten
            var p12Filename = Environment.GetEnvironmentVariable("P12FILENAME");

            // Password required to use the certificate
            var p12Password = Environment.GetEnvironmentVariable("P12PWD");

            // The issuer as defined in Maskinporten
            var issuer = Environment.GetEnvironmentVariable("MASKINPORTEN_ISSUER");

            // ID-porten machine to machine configuration
            var maskinportenConfig = new MaskinportenClientConfiguration(
                audience: @"https://ver2.maskinporten.no/",           // ID-porten audience path
                tokenEndpoint: @"https://ver2.maskinporten.no/token", // ID-porten token path
                issuer: issuer,                                       // KS issuer name
                numberOfSecondsLeftBeforeExpire: 10,                  // The token will be refreshed 10 seconds before it expires
                certificate: new X509Certificate2(p12Filename, p12Password));

            // accountId as defined in the Fiks Forvaltning Interface
            var fiksIoAccountId = Environment.GetEnvironmentVariable("FIKS_IO_ACCOUNT_ID");
            // private key corresponding to the public key uploaded in the Fiks Forvaltning Interface
            var fiksIoPrivateKeyPath = Environment.GetEnvironmentVariable("FIKS_IO_PRIVATE_KEY_PATH");

            // Fiks IO account configuration
            var kontoConfig = new KontoConfiguration(
                kontoId: Guid.Parse(fiksIoAccountId) /* Fiks IO accountId as Guid */,
                privatNokkel: ReadFromFile(fiksIoPrivateKeyPath) /* Private key in PEM format, paired with the public key supplied to Fiks IO account */);

            // Values generated in Fiks Forvaltning when creating the "Integrasjon"
            var integrasjonId       = Environment.GetEnvironmentVariable("INTEGRASJON_ID");
            var integrasjonPassword = Environment.GetEnvironmentVariable("INTEGRASJON_PWD");

            // Id and password for integration associated to the Fiks IO account.
            var integrasjonConfig = new IntegrasjonConfiguration(
                Guid.Parse(integrasjonId) /* Integration id as Guid */,
                integrasjonPassword /* Integration password */);


            // Optional: Use custom api host (i.e. for connecting to test api)
            var apiConfig = new ApiConfiguration(
                scheme: "https",
                host: "api.fiks.test.ks.no",
                port: 443);

            // Optional: Use custom amqp host (i.e. for connection to test queue)
            var amqpConfig = new AmqpConfiguration(
                host: "io.fiks.test.ks.no",
                port: 5671);

            // Combine all configurations
            var configuration = new FiksIOConfiguration(kontoConfig, integrasjonConfig, maskinportenConfig, apiConfig,
                                                        amqpConfig);

            using (var client = new FiksIOClient(configuration))
            {
                var lookupTask = client.Lookup(new LookupRequest("999999999", "no.ks.fiks.melding", 2));
                lookupTask.Wait(TimeSpan.FromSeconds(30));

                var konto = lookupTask.Result;
            }
        }
Ejemplo n.º 6
0
 public UtvalgService(AppSettings appSettings)
 {
     this.appSettings = appSettings;
     client           = CreateFiksIoClient();
 }