Removed server. Moved libraryBasic to library and libraryExtended to validator to prevent confusion with profiles.
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
done
|
||||
- 2.1 now default
|
||||
- pushprovider
|
||||
- integrates ZUV
|
||||
- integrates validator
|
||||
- validator now additionally supports xrechnung
|
||||
- integrates mustangserver
|
||||
- modular project setup
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# See https://docs.docker.com/engine/userguide/eng-image/multistage-build/
|
||||
# to build please run
|
||||
# sudo docker build --tag mustang:2.0 .
|
||||
# to start please run
|
||||
# sudo docker run --publish 8080:8080 --detach --name mustang mustang:2.0
|
||||
# takes around 15s to start up, afterwards access http://127.0.0.1:8080
|
||||
# to remove please run
|
||||
# sudo docker rm --force mustang
|
||||
|
||||
FROM openjdk:8-jdk-alpine as builder
|
||||
WORKDIR /build
|
||||
RUN apk --no-cache add openjdk11 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
|
||||
RUN apk --update add git maven
|
||||
RUN git clone https://github.com/ZUGFeRD/mustangproject.git
|
||||
RUN cd mustangproject && mvn clean package
|
||||
|
||||
|
||||
FROM openjdk:8-jre-alpine as runner
|
||||
|
||||
ENV MUSTANG_VERSION=2.0.0-SNAPSHOT
|
||||
|
||||
# Since this is a running network service we'll create an unprivileged account
|
||||
# which will be used to perform the rest of the work and run the actual service:
|
||||
|
||||
# Debian:
|
||||
# RUN useradd --system --user-group --home-dir=/opt/mustang mustang
|
||||
# Alpine / Busybox:
|
||||
RUN install -d -o root -g root -m 755 /opt && adduser -h /opt/mustang -S mustang
|
||||
USER mustang
|
||||
WORKDIR /opt/mustang
|
||||
|
||||
COPY --from=builder /build/mustangproject/Mustang-Server/target/Mustang-Server-${MUSTANG_VERSION}.jar /opt/mustang/
|
||||
COPY --from=builder /build/mustangproject/Mustang-Server/config.yml /opt/mustang/
|
||||
COPY --from=builder /build/mustangproject/Mustang-Server/dwstart.keystore /opt/mustang/
|
||||
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT java -jar /opt/mustang/Mustang-Server-${MUSTANG_VERSION}.jar server config.yml
|
||||
@@ -1,14 +0,0 @@
|
||||
0.0.2
|
||||
=====
|
||||
2019-09-15
|
||||
|
||||
- Https support,
|
||||
- User authentication (for combine method, username good-guy password secret)
|
||||
- completed mandatory swagger attributes.
|
||||
|
||||
|
||||
0.0.1
|
||||
=====
|
||||
2019-08-18
|
||||
|
||||
Possibility to extract/combine files, swagger support
|
||||
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed 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.
|
||||
@@ -1,45 +0,0 @@
|
||||
# mustangAPI
|
||||
A rest API for [Mustangproject](https://www.mustangproject.org), i.e. for ZUGFeRD/Factur-X
|
||||
|
||||

|
||||
|
||||
## Architecture
|
||||
|
||||
Using a
|
||||
* [Dropwizard](https://dropwizard.io) and a
|
||||
* Swagger integration
|
||||
|
||||
Recommended: German 45min Dropwizard/Swagger introduction [video](https://media.ccc.de/v/froscon2017-1985-einfache_rest-apis_mit_dropwizard_und_swagger) and [slides](https://programm.froscon.de/2017/system/event_attachments/attachments/000/000/469/original/20170818_LeanIX_Presentation_Froscon.pdf) from Froscon 2017
|
||||
|
||||
## Features
|
||||
|
||||
|
||||
* Integrates its own (jersey) webserver
|
||||
* get the API documentation online (Human readable and as OpenAPI)
|
||||
* try the API in a swagger generated demo web client
|
||||
* Extract the XML from a ZUGFeRD/Factur-X invoice
|
||||
* Combine custom XML and a PDF/A-1 file to a ZUGFeRD/Factur-X invoice
|
||||
|
||||
Feel free to send pull requests for more functionality.
|
||||
|
||||
## Compile
|
||||
|
||||
`mvn clean package`
|
||||
|
||||
## Start
|
||||
|
||||
`java -jar target/server-0.0.2-SNAPSHOT.jar server config.yml`
|
||||
|
||||
## Use
|
||||
|
||||
use http://127.0.0.1:8080/swagger to try the methods (https://localhost:8443/swagger would work but is self-signed).
|
||||
Access http://localhost:8080/swagger.yaml to build your clients.
|
||||
For demo purposes, extract does not require authentication but combine requires http authentication with user name "good-guy" and password "secret".
|
||||
|
||||
## Support
|
||||
|
||||
Community support is available via the [ZUGFeRD Google Group](https://groups.google.com/forum/?hl=de#!forum/zugferd)
|
||||
|
||||
## Contact
|
||||
|
||||
For commercial and/or legal inquiries contact Jochen Stärk jochen@zugferd.org
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 116 KiB |
@@ -1,13 +0,0 @@
|
||||
swagger:
|
||||
resourcePackage: mustang
|
||||
server:
|
||||
applicationConnectors:
|
||||
- type: http
|
||||
port: 8080
|
||||
- type: https
|
||||
port: 8443
|
||||
# keytool -genkeypair -keyalg RSA -dname "CN=localhost" -keystore dwstart.keystore -keypass crimson -storepass crimson
|
||||
keyStorePath: ./dwstart.keystore
|
||||
keyStorePassword: "crimson"
|
||||
validateCerts: false
|
||||
validatePeers: false
|
||||
Binary file not shown.
@@ -1,147 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.mustangproject</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.mustangproject</groupId>
|
||||
<artifactId>Mustang-Server</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<name>Mustang Server</name>
|
||||
<description>A rest API for ZUGFeRD, Factur-X and XRechnung</description>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<dropwizard.version>1.3.12</dropwizard.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mustangproject</groupId>
|
||||
<artifactId>libraryExtended</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<!-- prototypes of new mustangproject versions can be installed by referring to them and installed to the local repo from a jar file with
|
||||
mvn install:install-file -Dfile=mustang-1.5.4-SNAPSHOT.jar -DgroupId=org.mustangproject.ZUGFeRD -DartifactId=mustang -Dversion=1.5.4 -Dpackaging=jar -DgeneratePom=true
|
||||
-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.dropwizard</groupId>
|
||||
<artifactId>dropwizard-core</artifactId>
|
||||
<version>${dropwizard.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.smoketurner</groupId>
|
||||
<artifactId>dropwizard-swagger</artifactId>
|
||||
<version>1.3.12-1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.dropwizard</groupId>
|
||||
<artifactId>dropwizard-forms</artifactId>
|
||||
<version>${dropwizard.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.dropwizard</groupId>
|
||||
<artifactId>dropwizard-auth</artifactId>
|
||||
<version>${dropwizard.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!--
|
||||
junit
|
||||
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.junit</groupId>
|
||||
<artifactId>junit5-api</artifactId>
|
||||
<version>5.0.0-ALPHA</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit</groupId>
|
||||
<artifactId>junit5-engine</artifactId>
|
||||
<version>5.0.0-ALPHA</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- the rest -->
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox-tools</artifactId>
|
||||
<version>2.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.cssbox</groupId>
|
||||
<artifactId>pdf2dom</artifactId>
|
||||
<version>1.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itextpdf</artifactId>
|
||||
<version>5.5.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itextpdf.tool</groupId>
|
||||
<artifactId>xmlworker</artifactId>
|
||||
<version>5.5.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>3.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>3.15</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>true</createDependencyReducedPom>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
<!-- includes <include>assets/**</include> </includes ! -->
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
|
||||
|
||||
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>api.ApiApplication</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,51 +0,0 @@
|
||||
package api;
|
||||
|
||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||
import org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature;
|
||||
|
||||
import io.dropwizard.Application;
|
||||
import io.dropwizard.auth.AuthDynamicFeature;
|
||||
import io.dropwizard.auth.AuthValueFactoryProvider;
|
||||
import io.dropwizard.auth.basic.BasicCredentialAuthFilter;
|
||||
import io.dropwizard.setup.Bootstrap;
|
||||
import io.dropwizard.setup.Environment;
|
||||
import io.federecio.dropwizard.swagger.SwaggerBundle;
|
||||
import io.federecio.dropwizard.swagger.SwaggerBundleConfiguration;
|
||||
import mustang.MustangResource;
|
||||
|
||||
public class ApiApplication extends Application<ApiConfiguration> {
|
||||
public static void main(String[] args) throws Exception {
|
||||
new ApiApplication().run(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Mustang Server";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(Bootstrap<ApiConfiguration> bootstrap) {
|
||||
|
||||
bootstrap.addBundle(new SwaggerBundle<ApiConfiguration>() {
|
||||
@Override
|
||||
protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(ApiConfiguration configuration) {
|
||||
return configuration.swaggerBundleConfiguration;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApiConfiguration configuration, Environment environment) {
|
||||
final MustangResource resource = new MustangResource();
|
||||
|
||||
environment.jersey()
|
||||
.register(new AuthDynamicFeature(new BasicCredentialAuthFilter.Builder<User>()
|
||||
.setAuthenticator(new BasicAuthenticator()).setAuthorizer(new BasicAuthorizer())
|
||||
.setRealm("Rest API access").buildAuthFilter()));
|
||||
environment.jersey().register(RolesAllowedDynamicFeature.class);
|
||||
environment.jersey().register(new AuthValueFactoryProvider.Binder<>(User.class));
|
||||
environment.jersey().register(MultiPartFeature.class);
|
||||
environment.jersey().register(resource);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package api;
|
||||
import io.dropwizard.Configuration;
|
||||
import io.federecio.dropwizard.swagger.SwaggerBundleConfiguration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ApiConfiguration extends Configuration {
|
||||
|
||||
@JsonProperty("swagger")
|
||||
public SwaggerBundleConfiguration swaggerBundleConfiguration;
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package api;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import io.dropwizard.auth.AuthenticationException;
|
||||
import io.dropwizard.auth.Authenticator;
|
||||
import io.dropwizard.auth.basic.BasicCredentials;
|
||||
|
||||
public class BasicAuthenticator implements Authenticator<BasicCredentials, User> {
|
||||
@Override
|
||||
public Optional<User> authenticate(BasicCredentials credentials) throws AuthenticationException {
|
||||
if ("secret".equals(credentials.getPassword())) {
|
||||
return Optional.of(new User(credentials.getUsername()));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package api;
|
||||
|
||||
|
||||
import io.dropwizard.auth.Authorizer;
|
||||
|
||||
public class BasicAuthorizer implements Authorizer<User> {
|
||||
@Override
|
||||
public boolean authorize(User user, String role) {
|
||||
return user.getName().equals("good-guy") && role.equals("ADMIN");
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package api;
|
||||
|
||||
import io.dropwizard.auth.PrincipalImpl;
|
||||
|
||||
public class User extends PrincipalImpl {
|
||||
String username;
|
||||
|
||||
public User(String name) {
|
||||
super(name);
|
||||
username=name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
package mustang;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.File;
|
||||
import java.nio.file.*;
|
||||
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
import org.mustangproject.ZUGFeRD.ZUGFeRDConformanceLevel;
|
||||
import org.mustangproject.ZUGFeRD.ZUGFeRDExporter;
|
||||
import org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA1Factory;
|
||||
import org.mustangproject.ZUGFeRD.ZUGFeRDImporter;
|
||||
|
||||
import org.mustangproject.library.extended.ZUGFeRDValidator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.itextpdf.text.Document;
|
||||
import com.itextpdf.text.DocumentException;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
import com.itextpdf.tool.xml.XMLWorkerHelper;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.License;
|
||||
import io.swagger.annotations.Info;
|
||||
import io.swagger.annotations.SwaggerDefinition;
|
||||
|
||||
@Path("/mustang")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Api(value = "Mustang")
|
||||
@SwaggerDefinition(info = @Info(description = "Rest API to read/write hybrid (ZUGFeRD/Factur-X) e-invoices with a Mustang Server", version = "V0.0.2", title = "Mustangproject API", license = @License(name = "Apache 2.0", url = "http://www.apache.org")
|
||||
|
||||
), schemes = { SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS })
|
||||
public class MustangResource {
|
||||
|
||||
Logger logger = LoggerFactory.getLogger(MustangResource.class.getName());
|
||||
|
||||
public MustangResource() {
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/extract")
|
||||
// @RolesAllowed("ADMIN")
|
||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||
@Produces(MediaType.APPLICATION_XML)
|
||||
@ApiOperation(value = "Extracts XML from a zf/fx PDF", notes = "Input PDF must be ZUGFeRD or Factur-X")
|
||||
public String extractFile(
|
||||
@ApiParam(required = true, value = "Input ZUGFeRD/Factur-X file") @FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition contentDispositionHeader) {
|
||||
|
||||
ZUGFeRDImporter zi;
|
||||
logger.debug("Reading...");
|
||||
zi = new ZUGFeRDImporter(fileInputStream);
|
||||
return "<response>" + zi.getUTF8() + "</response>";
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/validateFX")
|
||||
// @RolesAllowed("ADMIN")
|
||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||
@Produces(MediaType.APPLICATION_XML)
|
||||
@ApiOperation(value = "Validates a ZUGFeRD PDF file", notes = "Input PDF must be ZUGFeRD or Factur-X")
|
||||
public String validateFX(
|
||||
@ApiParam(required = true, value = "Input ZUGFeRD/Factur-X file") @FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition contentDispositionHeader) {
|
||||
ZUGFeRDValidator zfv = new ZUGFeRDValidator();
|
||||
String validationResult = "";
|
||||
try {
|
||||
|
||||
final File tempFile = File.createTempFile("tovalidate", ".pdf");
|
||||
tempFile.deleteOnExit();
|
||||
|
||||
Files.copy(fileInputStream, tempFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
validationResult = zfv.validate(tempFile.getAbsolutePath());
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(),ex);
|
||||
}
|
||||
|
||||
logger.debug("Validating...");
|
||||
return validationResult;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/combine")
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
@ApiOperation(value = "Combine PDF file and custom XML to zf/fx PDF", notes = "Input PDF must be PDF/A-1, output PDF will be a ZUGFeRD/Factur-X PDF/A-3 file called invoice.pdf. Demo authentication good-guy:secret")
|
||||
public Response combineFile(
|
||||
@ApiParam(required = true, value = "Input PDF/A-1 file") @FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition contentDispositionHeader,
|
||||
@ApiParam(required = true, value = "The zf/fx XML to add to the file") @FormDataParam("xml") String XML,
|
||||
@ApiParam(required = true, defaultValue = "zf", value = "zf|fx:zf for ZUGFeRD, fx for Factur-X") @FormDataParam("format") String format,
|
||||
@ApiParam(required = true, defaultValue = "2", value = "version, i.e. fx 1 or zf 1 or 2") @FormDataParam("version") int version,
|
||||
@ApiParam(required = true, defaultValue = "EN16931", value = "Profile: BASIC|COMFORT|EXTENDED for zf1, MINIMUM|BASICWL|BASIC|CIUS|EN16931|EXTENDED for zf2/fx1") @FormDataParam("profile") String profile) {
|
||||
|
||||
ZUGFeRDExporter ze;
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
|
||||
try {
|
||||
logger.debug("Converting to PDF/A-3u");
|
||||
|
||||
if ((version < 1) || (version > 2)) {
|
||||
// this should be checked with annotations but I did not get it to work
|
||||
throw new IllegalArgumentException("invalid version");
|
||||
}
|
||||
|
||||
// this should be restricted to the enum with annotations but I did not get it
|
||||
// to work
|
||||
ZUGFeRDConformanceLevel prof = ZUGFeRDConformanceLevel.valueOf(profile);
|
||||
/*
|
||||
* Add .setZUGFeRDVersion and .setZUGFeRDConformanceLevel in the next lines to
|
||||
* set the ZUGFeRD version respective profile of the XML you are inserting.
|
||||
*/
|
||||
ze = new ZUGFeRDExporterFromA1Factory().setProducer("Mustang API")
|
||||
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(version)
|
||||
.setZUGFeRDConformanceLevel(prof).load(fileInputStream);
|
||||
logger.debug("Attaching ZUGFeRD-Data");
|
||||
if (format.equalsIgnoreCase("fx")) {
|
||||
ze.setFacturX();
|
||||
}
|
||||
ze.setZUGFeRDXMLData(XML.getBytes("UTF-8"));
|
||||
logger.debug("Writing ZUGFeRD-PDF");
|
||||
|
||||
ze.export(output);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
byte[] bytes = output.toByteArray();
|
||||
InputStream inputStream = new ByteArrayInputStream(bytes);
|
||||
|
||||
return Response.ok(inputStream).header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"invoice.pdf\"")
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/test")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@ApiOperation(value = "Returns a hello world", notes = "Just a test")
|
||||
public Response test() {
|
||||
|
||||
return Response.status(Response.Status.OK).entity("{\"payload\":\"test\"}").build();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package mustangAPI;
|
||||
|
||||
import javax.ws.rs.client.Client;
|
||||
import javax.ws.rs.client.ClientBuilder;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
|
||||
import api.ApiApplication;
|
||||
|
||||
public class IntegrationTest {
|
||||
/*@ClassRule
|
||||
public static final DropwizardAppRule<ApiConfiguration> RULE
|
||||
= new DropwizardAppRule<>(ApiApplication.class,
|
||||
"config.yml");
|
||||
@Test
|
||||
public void testGetGreeting() {
|
||||
//test w/ssl
|
||||
* //Create SSL Configurator
|
||||
SslConfigurator sslConfigurator = SslConfigurator.newInstance();
|
||||
//Register a keystore
|
||||
sslConfigurator.trustStoreFile("dwstart.keystore")
|
||||
.trustStorePassword("crimson");
|
||||
//Create SSL Context
|
||||
SSLContext sSLContext = sslConfigurator.createSSLContext();
|
||||
//Obtain client
|
||||
Client client = ClientBuilder
|
||||
.newBuilder()
|
||||
.sslContext(sSLContext)
|
||||
.build();
|
||||
|
||||
|
||||
|
||||
|
||||
String expected = "Hello world!";
|
||||
//Obtain client
|
||||
Client client = ClientBuilder.newClient();
|
||||
//Build a feature in basic authentication mode
|
||||
HttpAuthenticationFeature feature
|
||||
= HttpAuthenticationFeature.basic("javaeeeee", "crimson");
|
||||
//Register the feature
|
||||
client.register(feature);
|
||||
//Get actual resul string
|
||||
String actual = client
|
||||
.target("http://localhost:8080/secured_hello")
|
||||
.request(MediaType.TEXT_PLAIN)
|
||||
.get(String.class);
|
||||
//Do an assertion
|
||||
assertEquals(expected, actual);
|
||||
}*/
|
||||
}
|
||||
6
NOTICE
6
NOTICE
@@ -22,4 +22,8 @@ Copyright (c) 2002-2007, www.pdfbox.org
|
||||
Copyright (c) 2006-2007, www.jempbox.org
|
||||
|
||||
Apache PDFBox was based on source code originally developed in the PaDaF project.
|
||||
Copyright (c) 2010 Atos Worldline SAS
|
||||
Copyright (c) 2010 Atos Worldline SAS
|
||||
|
||||
Based on VeraPDF-library https://github.com/veraPDF/veraPDF-library licensed under the MPL 2.0
|
||||
Based on PH-Schematron https://github.com/phax/ph-schematron licensed under the APL2.0
|
||||
Based on https://github.com/itplr-kosit/xrechnung-schematron licensed under the APL2.0
|
||||
|
||||
14
NOTICE.txt
14
NOTICE.txt
@@ -1,14 +0,0 @@
|
||||
Apache PDFBox
|
||||
Copyright 2014 The Apache Software Foundation
|
||||
|
||||
This product includes software developed at
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
|
||||
Based on source code originally developed in the PDFBox, JempBox and
|
||||
FontBox projects.
|
||||
Copyright (c) 2002-2007, www.pdfbox.org
|
||||
Copyright (c) 2006-2007, www.jempbox.org
|
||||
|
||||
Based on source code originally developed in the PaDaF project.
|
||||
Copyright (c) 2010 Atos Worldline SAS
|
||||
|
||||
|
Before Width: | Height: | Size: 154 KiB After Width: | Height: | Size: 154 KiB |
@@ -8,10 +8,10 @@
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.mustangproject</groupId>
|
||||
<artifactId>libraryBasic</artifactId>
|
||||
<artifactId>library</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>libraryBasic</name>
|
||||
<name>Library for to write and read FacturX 1.0 and ZUGFeRD 1.0 and 2.1 e-invoices. A PDF/A file is required, the XML can be generated or provided. </name>
|
||||
<description>The Mustang project is a java library to read and write ZUGFeRD meta data inside your invoice PDFs
|
||||
</description>
|
||||
<url>http://www.mustangproject.org/</url>
|
||||
@@ -19,7 +19,7 @@
|
||||
<connection>scm:git:https://github.com/ZUGFeRD/mustangproject.git</connection>
|
||||
<developerConnection>scm:git:https://github.com/ZUGFeRD/mustangproject.git</developerConnection>
|
||||
<url>https://github.com/ZUGFeRD/mustangproject</url>
|
||||
<tag>mustang-1.7.3</tag>
|
||||
<tag>mustang-2.0.0-SNAPSHOT</tag>
|
||||
</scm>
|
||||
<repositories>
|
||||
<repository><!-- for jargs -->
|
||||
@@ -35,7 +35,6 @@ import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
import org.mustangproject.XMLTools;
|
||||
import org.mustangproject.toecount.Toecount;
|
||||
|
||||
public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
||||
|
||||
@@ -574,7 +573,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
|
||||
zugferdData = zugferdRaw;
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
Logger.getLogger(Toecount.class.getName()).log(Level.SEVERE, null, e);
|
||||
Logger.getLogger(ZUGFeRD2PullProvider.class.getName()).log(Level.SEVERE, null, e);
|
||||
} // $NON-NLS-1$
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user