Skip to content

Commit 6f5c643

Browse files
committed
Merge web-eid-spring-boot-example into web-eid-authtoken-validation-java/example
WE2-932 Signed-off-by: Sven Mitt <[email protected]>
2 parents 88daa08 + f54db1b commit 6f5c643

File tree

75 files changed

+5726
-0
lines changed

Some content is hidden

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

75 files changed

+5726
-0
lines changed

example/.gitattributes

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
* text=auto
2+
*.java text eol=lf
3+
*.xml text eol=lf
4+
*.pl text eol=lf
5+
*.py text eol=lf
6+
*.html text eol=lf
7+
*.scss text eol=lf
8+
*.css text eol=lf
9+
*.js text eol=lf
10+
*.bat text eol=crlf
11+
*.cmd text eol=crlf
12+
MANIFEST.MF text eol=lf
13+
commit-msg text eol=lf
14+
.gitattributes text eol=lf
15+
.gitignore text eol=lf
16+
*.deb filter=lfs diff=lfs merge=lfs -text
17+
*.pkg filter=lfs diff=lfs merge=lfs -text
18+
*.msi filter=lfs diff=lfs merge=lfs -text
19+
*.zip filter=lfs diff=lfs merge=lfs -text
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Maven build
2+
3+
on: [ push, pull_request ]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- uses: actions/setup-java@v4
13+
with:
14+
distribution: zulu
15+
java-version: 17
16+
17+
- name: Cache Maven packages
18+
uses: actions/cache@v4
19+
with:
20+
path: ~/.m2
21+
key: ${{ runner.os }}-m2-v17-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/pom.xml') }}
22+
restore-keys: ${{ runner.os }}-m2-v17-${{ secrets.CACHE_VERSION }}
23+
24+
- name: Build
25+
run: mvn --batch-mode compile
26+
27+
- name: Test and package
28+
run: mvn --batch-mode package

example/.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**
5+
!**/src/test/**
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
30+
### VS Code ###
31+
.vscode/
32+
33+
### Vim ###
34+
*.swp
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/*
2+
* Copyright 2007-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import java.io.*;
17+
import java.net.*;
18+
import java.nio.channels.*;
19+
import java.util.Properties;
20+
21+
public class MavenWrapperDownloader {
22+
private static final String WRAPPER_VERSION = "0.5.6";
23+
/**
24+
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
25+
*/
26+
private static final String DEFAULT_DOWNLOAD_URL =
27+
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" +
28+
WRAPPER_VERSION +
29+
"/maven-wrapper-" +
30+
WRAPPER_VERSION +
31+
".jar";
32+
33+
/**
34+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
35+
* use instead of the default one.
36+
*/
37+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties";
38+
39+
/**
40+
* Path where the maven-wrapper.jar will be saved to.
41+
*/
42+
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";
43+
44+
/**
45+
* Name of the property which should be used to override the default download url for the wrapper.
46+
*/
47+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
48+
49+
public static void main(String args[]) {
50+
System.out.println("- Downloader started");
51+
File baseDirectory = new File(args[0]);
52+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
53+
54+
// If the maven-wrapper.properties exists, read it and check if it contains a custom
55+
// wrapperUrl parameter.
56+
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
57+
String url = DEFAULT_DOWNLOAD_URL;
58+
if (mavenWrapperPropertyFile.exists()) {
59+
FileInputStream mavenWrapperPropertyFileInputStream = null;
60+
try {
61+
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
62+
Properties mavenWrapperProperties = new Properties();
63+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
64+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
65+
} catch (IOException e) {
66+
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
67+
} finally {
68+
try {
69+
if (mavenWrapperPropertyFileInputStream != null) {
70+
mavenWrapperPropertyFileInputStream.close();
71+
}
72+
} catch (IOException e) {
73+
// Ignore ...
74+
}
75+
}
76+
}
77+
System.out.println("- Downloading from: " + url);
78+
79+
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
80+
if (!outputFile.getParentFile().exists()) {
81+
if (!outputFile.getParentFile().mkdirs()) {
82+
System.out.println(
83+
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"
84+
);
85+
}
86+
}
87+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
88+
try {
89+
downloadFileFromURL(url, outputFile);
90+
System.out.println("Done");
91+
System.exit(0);
92+
} catch (Throwable e) {
93+
System.out.println("- Error downloading");
94+
e.printStackTrace();
95+
System.exit(1);
96+
}
97+
}
98+
99+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
100+
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
101+
String username = System.getenv("MVNW_USERNAME");
102+
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
103+
Authenticator.setDefault(
104+
new Authenticator() {
105+
106+
@Override
107+
protected PasswordAuthentication getPasswordAuthentication() {
108+
return new PasswordAuthentication(username, password);
109+
}
110+
}
111+
);
112+
}
113+
URL website = new URL(urlString);
114+
ReadableByteChannel rbc;
115+
rbc = Channels.newChannel(website.openStream());
116+
FileOutputStream fos = new FileOutputStream(destination);
117+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
118+
fos.close();
119+
rbc.close();
120+
}
121+
}
49.5 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

example/.prettierrc.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
trailingComma: "none"
2+
useTabs: false
3+
tabWidth: 4
4+
semi: true
5+
singleQuote: false
6+
printWidth: 120
7+

example/AUTHORS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Contributors
2+
3+
Here is the list of people involved in creating the example application.
4+
5+
Juri Letberg
6+
Mart Sõmermaa
7+
Martin Ott

example/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020-2023 Estonian Information System Authority
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)