Code Monkey home page Code Monkey logo

bankid-java's Introduction

Continuous Integration License Language grade: Java

BankID SDK

SDK to interact with BankID API. It includes support for all the v6.0 features. There are some examples that may be useful.

Documentation

See the project's Javadoc.

Installation

The artifact is available through Maven Central via Sonatype.

Maven

<dependency>
    <groupId>dev.eidentification</groupId>
    <artifactId>bankid-sdk</artifactId>
    <version>0.15.0</version>
</dependency>

Gradle

implementation 'dev.eidentification:bankid-sdk:0.15.0'

Changelog

Please see the changelog for a release history and indications on how to upgrade from one version to another.

Contributing

If you find any problems or have suggestions about this library, please submit an issue. Moreover, any pull request, code review and feedback are welcome.

Code Guide

We use GitHub Actions to make sure the codebase is consistent and continuously tested (gradle check). We try to keep comments at a maximum of 120 characters of length and code at 120.

General Usage

import static dev.eidentification.configuration.bankid.Configuration.URL_TEST;

import dev.eidentification.bankid.BankId;
import dev.eidentification.request.client.bankid.AuthenticationRequest;
import dev.eidentification.response.client.bankid.AuthenticateResponse;
import dev.eidentification.utils.client.bankid.ResourceUtils;
import dev.eidentification.configuration.bankid.Configuration;
import dev.eidentification.configuration.bankid.Pkcs12;
import dev.eidentification.exceptions.bankid.BankIdApiErrorException;

final InputStream pkcs12Resource = ResourceUtils.tryInputStreamFrom("test.p12");
final InputStream caResource = ResourceUtils.tryInputStreamFrom("ca.test.crt");

final Configuration configuration = Configuration.builder()
    .baseURL(URL_TEST)
    .pkcs12(Pkcs12.of(pkcs12Resource, "qwerty123"))
    .certificate(caResource)
    .build();

final BankId bankId = BankId.of(configuration);

final AuthenticateResponse authenticateResponse = bankId.authenticate(
    AuthenticationRequest.builder()
        .personalNumber("PERSONAL_NUMBER")
        .endUserIp("IP_ADDRESS")
        .build());

License

MIT

bankid-java's People

Contributors

nicklaswallgren avatar dependabot[bot] avatar github-actions[bot] avatar

Stargazers

Daniel L avatar Rickard Åberg avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

xtrex84

bankid-java's Issues

Review

Hej @AnnaKarlsson,
Hoppas allt är bra med dig, och att du haft en förträfflig sommar :)
Det vore kul om du skulle kunna slänga ett öga på det här libbet, och eventuellt komma med några förslag på förbättringar.

java.nio.file.FileSystemNotFoundException: Provider "jar" not installed

Hej och tack för ditt arbete!

Använder Android Studio. Har fastnat i problem med vad jag tror beror på getResource() i tryUriFrom().

final URI caResourceUri = ResourceUtils.tryUriFrom("certificate.pem")
Så här ser min URI ut: caResourceUri : jar:file:/data/app/com.example.bluetoothfunctions-_gxA3PsSi10D4dBRV0j7PQ==/base.apk!/certificate.pem

När jag använder Paths.get(caResourceUri) får jag felmeddelande där felet verkar börja här: Caused by: java.nio.file.FileSystemNotFoundException: Provider "jar" not installed at java.nio.file.Paths.get(Paths.java:147)

Förstår jag rätt kan problemet ha att göra med konklusionen nedan som gör att detta kan fungera i test men inte "at runtime eftersom "there's no resource file at runtime" : "To conclude - URL returned by ClassLoader.getResource cannot be converted to java.io.File as a resource cannot be expressed as java.io.File. "

https://msitko.pl/blog/2019/10/19/when-your-code-fails-after-being-packaged-as-jar.html

Det verkar föreslås att man använder getResourceAsStream istället men då faller många funktioner eftersom de kräver en Path. Eller har jag missförstått något?

BankID v6

Would be lovely with support for the new major version!

"PKCS12 key store mac invalid - wrong password or corrupted file" i Android Studio med senaste TLS certifikat för test: FPTestcert4_20230629.p12

Felet uppkommer med Android Studio i SslUtils
tryCreateKeyManager()
clientStore.load(keystore, password.toCharArray());

Det fungerar dock med tidigare certifikat, tex FPTestcert4_20220818.p12

Sannolikt beroende på detta:

Senaste .p12 versionen fungerar inte med Android Studio Trust Manager:
https://stackoverflow.com/questions/71872900/installing-pcks12-certificate-in-android-wrong-password-bug

”Apparently Android cannot import newer pkcs12 files. I tried this on Android 12 and Android 13. This is what man openssl-pkcs12 says for -legacy:
In the legacy mode, the default algorithm for certificate encryption is RC2_CBC or 3DES_CBC depending on whether the RC2 cipher is enabled in the build. The default algorithm for private key encryption is 3DES_CBC. If the legacy option is not specified, then the legacy provider is not loaded and the default encryption algorithm for both certificates and private keys is AES_256_CBC with PBKDF2 for key derivation.”

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.