Skip to content

Commit 73acfb1

Browse files
Initial commit
0 parents  commit 73acfb1

50 files changed

Lines changed: 2050 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
name: Java CI
7+
8+
on: [push]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Set up JDK 16
17+
uses: actions/setup-java@v2
18+
with:
19+
java-version: '16'
20+
distribution: 'adopt'
21+
22+
- name: Validate Gradle wrapper
23+
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
24+
25+
- name: Check
26+
run: ./gradlew check
27+
28+
- name: Build with Gradle
29+
run: ./gradlew build

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.gradle
2+
.idea
3+
build
4+
lib

README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
[![Continuous Integration](https://github.com/nicklaswallgren/bankid-java-sdk/workflows/ci/badge.svg)](https://github.com/nicklaswallgren/bankid-java-sdk/actions)
2+
[![License](https://img.shields.io/github/license/nicklaswallgren/bankid-java-sdk)](https://github.com/nicklaswallgren/bankid-java-sdk/blob/master/LICENSE)
3+
[![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/NicklasWallgren/bankid-java-sdk.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/NicklasWallgren/bankid-java-sdk/context:java)
4+
5+
# BankID SDK
6+
7+
SDK to interact with BankID API. It includes support for all the v5.1 features.
8+
There are some [examples that may be useful](./examples).
9+
10+
## Installation
11+
The artifact is available through Maven Central via Sonatype.
12+
13+
### Maven
14+
```xml
15+
<dependency>
16+
<groupId>dev.nicklasw</groupId>
17+
<artifactId>bankid-sdk</artifactId>
18+
<version>0.10.0</version>
19+
</dependency>
20+
```
21+
22+
### Gradle
23+
```
24+
compile 'dev.nicklasw:bankid-sdk:0.10.0'
25+
```
26+
27+
## Changelog
28+
29+
Please see the [changelog](./CHANGELOG.md) for a release history and indications on how to upgrade from one version to another.
30+
31+
## Contributing
32+
33+
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.
34+
35+
## Code Guide
36+
37+
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.
38+
39+
## General Usage
40+
```java
41+
42+
import static dev.nicklasw.bankid.configuration.Configuration.URL_TEST;
43+
44+
import java.net.URI;
45+
import java.nio.file.Path;
46+
47+
import dev.nicklasw.bankid.BankId;
48+
import dev.nicklasw.bankid.client.request.AuthenticationRequest;
49+
import dev.nicklasw.bankid.client.response.AuthenticateResponse;
50+
import dev.nicklasw.bankid.client.utils.ResourceUtils;
51+
import dev.nicklasw.bankid.configuration.Configuration;
52+
import dev.nicklasw.bankid.configuration.Pkcs12;
53+
import dev.nicklasw.bankid.exceptions.BankIdApiErrorException;
54+
55+
final URI pkcs12ResourceUri = ResourceUtils.optionalUriFrom("test.p12")
56+
.orElseThrow();
57+
final URI caResourceUri = ResourceUtils.optionalUriFrom("ca.test.crt")
58+
.orElseThrow();
59+
60+
final Pkcs12 pkcs12 = Pkcs12.of(Path.of(pkcs12ResourceUri), "qwerty123");
61+
62+
final Configuration configuration = Configuration.builder()
63+
.baseURL(URL_TEST)
64+
.pkcs12(pkcs12)
65+
.certificate(Path.of(caResourceUri))
66+
.build();
67+
68+
final BankId bankId = BankId.of(configuration);
69+
70+
final AuthenticateResponse authenticateResponse = bankId.authenticate(
71+
AuthenticationRequest.builder()
72+
.personalNumber("PERSONAL_NUMBER")
73+
.endUserIp("IP_ADDRESS")
74+
.build());
75+
```
76+
77+
## License
78+
79+
[MIT](./LICENSE)

build.gradle

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
plugins {
2+
id 'java'
3+
id "io.freefair.lombok" version "6.0.0-m2"
4+
id 'com.github.johnrengelman.shadow' version '7.0.0'
5+
id "com.github.spotbugs" version "4.7.2"
6+
id "net.ltgt.errorprone" version "2.0.2"
7+
id 'checkstyle'
8+
id 'maven-publish'
9+
}
10+
11+
group 'dev.nicklasw'
12+
version '0.10.0-SNAPSHOT'
13+
14+
sourceCompatibility=16
15+
targetCompatibility=16
16+
17+
repositories {
18+
mavenCentral()
19+
}
20+
21+
dependencies {
22+
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.12.3'
23+
24+
compileOnly 'com.github.spotbugs:spotbugs-annotations'
25+
26+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
27+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
28+
29+
errorprone("com.google.errorprone:error_prone_core:2.8.0")
30+
}
31+
32+
shadowJar {
33+
classifier = ''
34+
relocate 'com.fasterxml.jackson', 'shadow.com.fasterxml.jackson'
35+
}
36+
37+
test {
38+
useJUnitPlatform()
39+
}
40+
41+
spotbugs {
42+
toolVersion = '4.3.0'
43+
}
44+
45+
spotbugsMain {
46+
reports {
47+
html {
48+
enabled = true
49+
destination = file("$buildDir/reports/spotbugs/main/spotbugs.html")
50+
stylesheet = 'fancy-hist.xsl'
51+
}
52+
}
53+
}
54+
55+
tasks.withType(JavaCompile) {
56+
options.compilerArgs << "-Werror"
57+
options.errorprone.enabled = true
58+
options.errorprone {
59+
disableWarningsInGeneratedCode = true
60+
ignoreUnknownCheckNames = false
61+
allErrorsAsWarnings = false
62+
// workaround for: https://github.com/google/error-prone/issues/780
63+
errorproneArgs = [
64+
'-Xep:UnusedVariable:OFF', // https://github.com/google/error-prone/issues/1266
65+
'-Xep:UnusedMethod:OFF', // https://github.com/google/error-prone/issues/1266
66+
'-Xep:MissingOverride:OFF',
67+
'-Xep:JavaTimeDefaultTimeZone:OFF',
68+
'-Xep:SameNameButDifferent:OFF',
69+
'-Xep:MissingSummary:OFF', // Until https://github.com/projectlombok/lombok/issues/2730
70+
'-Xlint:deprecation',
71+
]
72+
}
73+
}
74+
75+
publishing {
76+
77+
repositories {
78+
maven {
79+
name = "GitHubPackages"
80+
url = "https://maven.pkg.github.com/NicklasWallgren/bankid-sdk"
81+
credentials {
82+
username = "NicklasWallgren"
83+
password = "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"
84+
}
85+
}
86+
}
87+
88+
publications {
89+
mavenJava(MavenPublication) {
90+
from components.java
91+
}
92+
}
93+
94+
}

0 commit comments

Comments
 (0)