Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bankid-bot committed Jun 21, 2023
1 parent d855855 commit 87afb62
Show file tree
Hide file tree
Showing 182 changed files with 44,615 additions and 1 deletion.
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
18 changes: 18 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.1-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
BSD 3-Clause License

Copyright (c) 2023, BankID
Copyright (c) 2022, Finansiell ID-Teknik BID AB
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# BankID sample code

BankID is the largest eID in Sweden, with more than 8,4 million users and over 6000 connected businesses and authorities. Our solution has revolutionized everyday life in Sweden and lays the foundation for a modern and accessible society.


## Demo site

To help you integrate BankID in a correct, secure and user-friendly way, we have created a demo site, where you can test the digital identification flow and the digital signature flow.

<img src="https://www.bankid.com/assets/bankid/img/github_demo.png" />

[Visit the demo site](https://www.bankid.com/demo)

## Sample code
Here we provide the code used to create the demo site. The code languages used are:
* Frontend: React
* Backend: Java


## Help for a full integration

To integrate the BankID infrastructure, it is necessary to set up frontend and backend as well as to have a SSL-certificate. For help with your full integration, check out our [developer section](https://www.bankid.com/en/utvecklare/guider) on our website.

## Disclaimer and terms of use

We, Finansiell ID-teknik BID AB are not responsible for the correctness, nor the usage, of the code provided. You must always test your integration thoroughly and you are responsible for ensuring it works in your environment.

You may not use the name of our company or brand without written consent.

---

## More info

[Readme for the backend](/server/README.md)

[Readme for the frontend](/client/README.md)
11 changes: 11 additions & 0 deletions build/buildDocker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
dockerTempTag=codefront-server
echo ${dockerTempTag}

mkdir -p docker/target/bin/
cp ../server/target/codefront-develop-SNAPSHOT.war docker/target/bin/codefront-server.war

docker buildx build docker/. \
--no-cache \
-t ${dockerTempTag} \
--progress=plain
20 changes: 20 additions & 0 deletions build/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: "3"

services:
codefront:
image: codefront-server
restart: always
user: "2000"
read_only: true
cap_drop:
- ALL
environment:
- SPRING_PROFILES_ACTIVE=dev
tmpfs:
# These directories need to be writable at runtime.
- /tmp:uid=2000,gid=2000
volumes:
- ../server/certificates/:/opt/codefront/certificates/:r
- ./docker/src/logback-spring.xml:/opt/codefront/src/main/resources/logback-spring.xml:r
ports:
- "8443:8443"
30 changes: 30 additions & 0 deletions build/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ARG BASE_IMAGE=${BASE_IMAGE:-registry.access.redhat.com/ubi8/openjdk-11-runtime:1.15-1.1678874813}
FROM ${BASE_IMAGE}

LABEL base-image=${BASE_IMAGE}
LABEL name="codefront-server"
LABEL description="CodeFront-server is the java-based server, currently the main GUI server"
LABEL distribution-scope="opensource"
LABEL summary="codefront-server"

# Expose ports and volumes.
EXPOSE 8443
VOLUME ["/opt/codefront/config/", "/opt/codefront/logs"]

# Copy files.
COPY src/runCodeFront.sh target/bin/codefront-server.war /opt/codefront/
COPY src/logback-spring.xml /opt/codefront/default-config/

USER root

# Run required commands.
RUN chmod 755 /opt && \
chmod 755 /opt/codefront/runCodeFront.sh && \
chmod 644 /opt/codefront/codefront-server.war

# Set working directory and user.
WORKDIR /opt/codefront/
USER 2000

# Set entry point.
ENTRYPOINT ["/opt/codefront/runCodeFront.sh"]
29 changes: 29 additions & 0 deletions build/docker/src/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<configuration>
<springProfile name="!dev-log">
<appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<customFields>{"HOSTNAME":"${HOSTNAME}"}</customFields>
</encoder>
</appender>
<logger name="jsonLogger" additivity="false" level="DEBUG">
<appender-ref ref="consoleAppender"/>
</logger>
<root level="INFO">
<appender-ref ref="consoleAppender"/>
</root>
</springProfile>
<springProfile name="dev-log">
<appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d [%thread] %level{8} %logger{50} [%X{userIp}] [%X{userId}] %msg%n</pattern>
</encoder>
</appender>

<logger name="consoleLogger" additivity="false" level="DEBUG">
<appender-ref ref="consoleAppender"/>
</logger>
<root level="INFO">
<appender-ref ref="consoleAppender"/>
</root>
</springProfile>
</configuration>
13 changes: 13 additions & 0 deletions build/docker/src/runCodeFront.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
exec java \
$JAVA_OPTS \
-XX:-ParallelRefProcEnabled \
-XX:MaxGCPauseMillis=500 \
-XX:+ExitOnOutOfMemoryError \
\
-Djava.net.preferIPv4Stack=true \
-Djava.awt.headless=true \
\
-jar \
/opt/codefront/codefront-server.war \
"$@"
213 changes: 213 additions & 0 deletions checkstyle-conf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<!--
Checkstyle configuration that checks the sun coding conventions from:
- the Java Language Specification at
http://java.sun.com/docs/books/jls/second_edition/html/index.html
- the Sun Code Conventions at http://java.sun.com/docs/codeconv/
- the Javadoc guidelines at
http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
- the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
- some best practices
Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sf.net (or in your downloaded distribution).
Most Checks are configurable, be sure to consult the documentation.
To completely disable a check, just comment it out or delete it from the file.
Finally, it is worth reading the documentation.
-->

<module name="Checker">
<!--
If you set the basedir property below, then all reported file
names will be relative to the specified directory. See
http://checkstyle.sourceforge.net/5.x/config.html#Checker
<property name="basedir" value="${basedir}"/>
-->

<!-- Checks that a package-info.java file exists for each package. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
<!-- <module name="JavadocPackage"/> -->

<!-- Checks whether files end with a new line. -->
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
<!-- <module name="NewlineAtEndOfFile"/> -->

<!-- Checks that property files contain the same keys. -->
<!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
<!-- <module name="Translation"/> -->

<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="FileLength"/>

<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<!-- <module name="FileTabCharacter"/> -->

<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<!-- <module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="minimum" value="0"/>
<property name="maximum" value="0"/>
<property name="message" value="Line has trailing spaces."/>
</module> -->

<!-- Checks for Headers -->
<!-- See http://checkstyle.sf.net/config_header.html -->
<module name="Header">
<property name="headerFile" value="checkstyle.header"/>
<property name="fileExtensions" value="java"/>
</module>

<module name="LineLength">
<property name="max" value="120"/>
<property name="fileExtensions" value="java"/>
</module>

<!-- Filter to be able to use suppress annotations -->
<module name="SuppressWarningsFilter" />

<module name="TreeWalker">

<module name="RequireThis">
<property name="checkMethods" value="false"/>
<property name="validateOnlyOverlapping" value="false" />
</module>

<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<module name="JavadocMethod">
</module>
<module name="JavadocType">
<property name="scope" value="package"/>
</module>
<module name="JavadocVariable">
<property name="scope" value="package"/>
</module>
<module name="JavadocStyle">
<property name="checkEmptyJavadoc" value="true" />
</module>
<module name="MissingJavadocMethod">
<property name="scope" value="package" />
</module>
<module name="MissingJavadocType">
<property name="scope" value="package" />
</module>
<module name="InvalidJavadocPosition"/>
<module name="JavadocBlockTagLocation"/>
<module name="JavadocContentLocationCheck"/>
<module name="JavadocParagraph"/>

<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>


<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="UnusedImports"/>


<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="MethodLength"/>
<module name="ParameterNumber">
<property name="max" value="10"/>
<property name="ignoreOverriddenMethods" value="true"/>
</module>


<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="EmptyForIteratorPad"/>
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>


<!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>


<!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sf.net/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>


<!-- Checks for common coding problems -->
<!-- See http://checkstyle.sf.net/config_coding.html -->
<!-- <module name="AvoidInlineConditionals"/> -->
<!-- <module name="DoubleCheckedLocking"/> -->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<!-- <module name="HiddenField"/> -->
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber">
<property name="ignoreAnnotation" value="true"/>
</module>
<module name="MissingSwitchDefault"/>
<!-- <module name="RedundantThrows"/> -->
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>

<!-- Checks for class design -->
<!-- See http://checkstyle.sf.net/config_design.html -->
<!-- <module name="DesignForExtension"/> -->
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier"/>


<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="ArrayTypeStyle"/>
<!-- <module name="FinalParameters"/> -->
<!-- <module name="TodoComment"/> -->
<module name="UpperEll"/>

<!-- Suppress warnings for annotations -->
<module name="SuppressWarningsHolder" />
</module>

</module>
9 changes: 9 additions & 0 deletions checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">

<suppressions>
<suppress files="[\\/]generated-sources[\\/]" checks="[a-zA-Z0-9]*"/>
</suppressions>
Loading

0 comments on commit 87afb62

Please sign in to comment.