diff options
author | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2021-09-02 14:08:28 +0200 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2021-09-02 14:08:28 +0200 |
commit | 77b735d531aa880671c35a1ed3d2d56312742644 (patch) | |
tree | 6d1ddfad12be5cc94224d2073e242af2905fe8eb | |
parent | 2053da3c7247ff4f23a7adacd55af1566038a8d3 (diff) | |
parent | 8390095d1f7d25cf0a78709d3de6b77b72ea41bc (diff) | |
download | egovutils-77b735d531aa880671c35a1ed3d2d56312742644.tar.gz egovutils-77b735d531aa880671c35a1ed3d2d56312742644.tar.bz2 egovutils-77b735d531aa880671c35a1ed3d2d56312742644.zip |
Merge branch 'nightlyBuild' of gitlab.iaik.tugraz.at:egiz/egovutils into nightlyBuild
-rw-r--r-- | .classpath | 5 | ||||
-rw-r--r-- | pom.xml | 596 | ||||
-rw-r--r-- | src/main/java/at/gv/util/ValidationUtils.java | 19 | ||||
-rw-r--r-- | src/main/java/at/gv/util/client/ur_V7/URClient.java | 590 | ||||
-rw-r--r-- | src/main/java/at/gv/util/client/ur_V7/URClientException.java | 33 | ||||
-rw-r--r-- | src/main/resources/wsdl/szr/szr_pvp.xsd | 7 | ||||
-rw-r--r-- | src/main/resources/wsdl/szr_v4/pvp19.xsd | 7 | ||||
-rw-r--r-- | src/main/resources/wsdl/szr_v4/szr_v4.0.xsd | 1 | ||||
-rw-r--r-- | src/test/java/at/gv/util/test/ValitationUtilsTest.java | 36 |
9 files changed, 1030 insertions, 264 deletions
@@ -15,6 +15,7 @@ <attributes> <attribute name="optional" value="true"/> <attribute name="maven.pomderived" value="true"/> + <attribute name="test" value="true"/> </attributes> </classpathentry> <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"> @@ -28,9 +29,9 @@ <attribute name="org.eclipse.jst.component.nondependency" value=""/> </attributes> </classpathentry> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <attributes> - <attribute name="owner.project.facets" value="java"/> + <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> <classpathentry kind="output" path="target/classes"/> @@ -1,287 +1,359 @@ <?xml version="1.0"?> <project - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" - xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <modelVersion>4.0.0</modelVersion> - <groupId>at.gv.util</groupId> - <artifactId>egovutils</artifactId> - <version>2.0.11-SNAPSHOT</version> - <name>zuseutil</name> - <url>http://maven.apache.org</url> - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <java.version>1.8</java.version> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <groupId>at.gv.util</groupId> + <artifactId>egovutils</artifactId> + <version>2.0.12-SNAPSHOT</version> + <name>zuseutil</name> + <url>http://maven.apache.org</url> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <java.version>1.8</java.version> - <cxf.version>3.4.1</cxf.version> - <org.slf4j.version>1.7.30</org.slf4j.version> + <cxf.version>3.4.1</cxf.version> + <org.slf4j.version>1.7.30</org.slf4j.version> + <org.apache.httpcomponents.httpclient.version>4.5.13</org.apache.httpcomponents.httpclient.version> + <commons-collections.version>3.2.2</commons-collections.version> + <commons-lang.version>2.6</commons-lang.version> + <commons-codec.version>1.15</commons-codec.version> + <commons-beanutils.version>1.9.4</commons-beanutils.version> + <commons-validator.version>1.7</commons-validator.version> - <org.apache.httpcomponents.httpclient.version>4.5.13</org.apache.httpcomponents.httpclient.version> - <commons-collections.version>3.2.2</commons-collections.version> - <commons-lang.version>2.6</commons-lang.version> - <commons-codec.version>1.15</commons-codec.version> - <commons-beanutils.version>1.9.4</commons-beanutils.version> - <commons-validator.version>1.7</commons-validator.version> + <javax.xml.bind.jaxb-api.version>2.3.0</javax.xml.bind.jaxb-api.version> + <xalan.version>2.7.1</xalan.version> + <xerces.xercesImpl.version>2.12.0</xerces.xercesImpl.version> - <javax.xml.bind.jaxb-api.version>2.3.0</javax.xml.bind.jaxb-api.version> - <xalan.version>2.7.1</xalan.version> - <xerces.xercesImpl.version>2.12.0</xerces.xercesImpl.version> + <javax.servlet-api.version>2.5</javax.servlet-api.version> - <javax.servlet-api.version>2.5</javax.servlet-api.version> + <surefire.version>2.22.0</surefire.version> + <iaik_ecc.version>2.19</iaik_ecc.version> - <surefire.version>2.22.0</surefire.version> - <iaik_ecc.version>2.19</iaik_ecc.version> + <!-- Compile and deploy plugins --> + <versions-maven-plugin.version>2.8.1</versions-maven-plugin.version> + <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version> + <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version> + <maven-source-plugin.version>3.2.1</maven-source-plugin.version> + <maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version> + <wagon-ssh.version>3.4.3</wagon-ssh.version> - </properties> + </properties> - <repositories> - <repository> - <id>egiz-commons</id> - <url>https://apps.egiz.gv.at/maven/</url> - <releases> - <enabled>true</enabled> - </releases> - <snapshots> - <enabled>false</enabled> - </snapshots> - </repository> - <repository> - <id>egiz-commons-snapshot</id> - <url>https://apps.egiz.gv.at/maven-snapshot/</url> - <releases> - <enabled>false</enabled> - </releases> - <snapshots> - <enabled>true</enabled> - </snapshots> - </repository> - <repository> - <id>MOA_web</id> - <name>MOA Dependencies weblocation</name> - <releases> - <enabled>true</enabled> - <checksumPolicy>ignore</checksumPolicy> - </releases> - <layout>default</layout> - <url>https://git.egiz.gv.at/EAAF-Components/plain/eaaf_modules/eaaf_module_moa-sig/repository</url> - </repository> - </repositories> + <repositories> + <repository> + <id>egiz-commons</id> + <url>https://apps.egiz.gv.at/maven/</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + <repository> + <id>egiz-commons-snapshot</id> + <url>https://apps.egiz.gv.at/maven-snapshot/</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + <repository> + <id>MOA_web</id> + <name>MOA Dependencies weblocation</name> + <releases> + <enabled>true</enabled> + <checksumPolicy>ignore</checksumPolicy> + </releases> + <layout>default</layout> + <url>https://git.egiz.gv.at/EAAF-Components/plain/eaaf_modules/eaaf_module_moa-sig/repository</url> + </repository> + </repositories> - <profiles> - <profile> - <id>default</id> - <activation> - <activeByDefault>true</activeByDefault> - <property> - <name>default</name> - </property> - </activation> - </profile> - <profile> - <id>jenkinsDeploy</id> - <distributionManagement> - <repository> - <id>egizMaven</id> - <url>sftp://apps.egiz.gv.at/maven</url> - </repository> - <snapshotRepository> - <id>egizMaven</id> - <url>sftp://apps.egiz.gv.at/maven-snapshot</url> - </snapshotRepository> - </distributionManagement> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-deploy-plugin</artifactId> - <version>2.8.2</version> - <configuration> - <deployAtEnd>true</deployAtEnd> - </configuration> - <executions> - <execution> - <id>default-deploy</id> - <phase>deploy</phase> - <goals> - <goal>deploy</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> + <profiles> + <profile> + <id>default</id> + <activation> + <activeByDefault>true</activeByDefault> + <property> + <name>default</name> + </property> + </activation> + </profile> + <profile> + <id>jenkinsDeploy</id> + <distributionManagement> + <repository> + <id>egizMaven</id> + <url>sftp://apps.egiz.gv.at/maven</url> + </repository> + <snapshotRepository> + <id>egizMaven</id> + <url>sftp://apps.egiz.gv.at/maven-snapshot</url> + </snapshotRepository> + </distributionManagement> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <version>${maven-deploy-plugin.version}</version> + <configuration> + <deployAtEnd>true</deployAtEnd> + </configuration> + <executions> + <execution> + <id>default-deploy</id> + <phase>deploy</phase> + <goals> + <goal>deploy</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.7.0</version> - <configuration> - <source>1.8</source> - <target>1.8</target> - </configuration> - <executions> - <execution> - <goals> - <goal>compile</goal> - <goal>testCompile</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <version>3.1.0</version> - <executions> - <execution> - <goals> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>${maven-compiler-plugin.version}</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + <executions> + <execution> + <goals> + <goal>compile</goal> + <goal>testCompile</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>${maven-jar-plugin.version}</version> + <executions> + <execution> + <goals> + <goal>test-jar</goal> + </goals> + </execution> + </executions> + </plugin> - <!-- enable co-existence of testng and junit --> - <plugin> - <artifactId>maven-surefire-plugin</artifactId> - <version>${surefire.version}</version> - <configuration> - <threadCount>1</threadCount> - </configuration> - <dependencies> - <dependency> - <groupId>org.apache.maven.surefire</groupId> - <artifactId>surefire-junit47</artifactId> - <version>${surefire.version}</version> - </dependency> - </dependencies> - </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>${maven-source-plugin.version}</version> + <executions> + <execution> + <id>attach-sources</id> + <goals> + <goal>jar-no-fork</goal> + </goals> + </execution> + </executions> + </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>versions-maven-plugin</artifactId> - <version>2.7</version> - </plugin> + <!-- enable co-existence of testng and junit --> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + <configuration> + <threadCount>1</threadCount> + </configuration> + <dependencies> + <dependency> + <groupId>org.apache.maven.surefire</groupId> + <artifactId>surefire-junit47</artifactId> + <version>${surefire.version}</version> + </dependency> + </dependencies> + </plugin> - </plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>versions-maven-plugin</artifactId> + <version>${versions-maven-plugin.version}</version> + </plugin> - <extensions> - <extension> - <groupId>org.apache.maven.wagon</groupId> - <artifactId>wagon-ssh</artifactId> - <version>3.3.3</version> - </extension> - </extensions> - </build> + </plugins> + <extensions> + <extension> + <groupId>org.apache.maven.wagon</groupId> + <artifactId>wagon-ssh</artifactId> + <version>${wagon-ssh.version}</version> + </extension> + </extensions> + </build> - <dependencies> - <dependency> - <groupId>xerces</groupId> - <artifactId>xercesImpl</artifactId> - <version>${xerces.xercesImpl.version}</version> - </dependency> - <dependency> - <groupId>xalan</groupId> - <artifactId>xalan</artifactId> - <version>${xalan.version}</version> - </dependency> - <dependency> - <groupId>javax.xml.bind</groupId> - <artifactId>jaxb-api</artifactId> - <version>${javax.xml.bind.jaxb-api.version}</version> - </dependency> - <!-- Apache CXF libs --> - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-frontend-jaxws</artifactId> - <version>${cxf.version}</version> - </dependency> - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-transports-http</artifactId> - <version>${cxf.version}</version> - </dependency> - <!-- Jetty is needed if you're are not using the CXFServlet --> - <!-- <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http-jetty</artifactId> - <version>${cxf.version}</version> </dependency> --> + <dependencies> + <dependency> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + <version>${xerces.xercesImpl.version}</version> + </dependency> + <dependency> + <groupId>xalan</groupId> + <artifactId>xalan</artifactId> + <version>${xalan.version}</version> + </dependency> + <dependency> + <groupId>javax.xml.bind</groupId> + <artifactId>jaxb-api</artifactId> + <version>${javax.xml.bind.jaxb-api.version}</version> + </dependency> - <dependency> - <groupId>commons-validator</groupId> - <artifactId>commons-validator</artifactId> - <version>${commons-validator.version}</version> - </dependency> - <dependency> - <groupId>commons-beanutils</groupId> - <artifactId>commons-beanutils</artifactId> - <version>${commons-beanutils.version}</version> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>${org.slf4j.version}</version> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - <version>${javax.servlet-api.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - <version>${commons-codec.version}</version> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>${commons-lang.version}</version> - <type>jar</type> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpclient</artifactId> - <version>${org.apache.httpcomponents.httpclient.version}</version> - </dependency> + <!-- Apache CXF libs --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxws</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http</artifactId> + <version>${cxf.version}</version> + </dependency> + <!-- Jetty is needed if you're are not using the CXFServlet --> + <!-- <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http-jetty</artifactId> + <version>${cxf.version}</version> </dependency> --> + + <!-- Apache CXF libs--> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxws</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-features-clustering</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-features-logging</artifactId> + <version>${cxf.version}</version> + </dependency> + + + <!-- Jetty is needed if you're are not using the CXFServlet --> +<!-- <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http-jetty</artifactId> + <version>${cxf.version}</version> + </dependency> --> + + + <dependency> + <groupId>commons-validator</groupId> + <artifactId>commons-validator</artifactId> + <version>${commons-validator.version}</version> + </dependency> + <dependency> + <groupId>commons-beanutils</groupId> + <artifactId>commons-beanutils</artifactId> + <version>${commons-beanutils.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>${org.slf4j.version}</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>${javax.servlet-api.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + <version>${commons-codec.version}</version> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>${commons-lang.version}</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>${org.apache.httpcomponents.httpclient.version}</version> + </dependency> - <dependency> - <groupId>commons-collections</groupId> - <artifactId>commons-collections</artifactId> - <version>${commons-collections.version}</version> - </dependency> + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + <version>${commons-collections.version}</version> + </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.13.1</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>iaik</groupId> - <artifactId>iaik_ecc_signed</artifactId> - <version>${iaik_ecc.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <version>${org.slf4j.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>iaik.prod</groupId> - <artifactId>iaik_jce_full</artifactId> - <version>5.61_moa</version> - <scope>test</scope> - </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.13.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>iaik</groupId> + <artifactId>iaik_ecc_signed</artifactId> + <version>${iaik_ecc.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>${org.slf4j.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>iaik.prod</groupId> + <artifactId>iaik_jce_full</artifactId> + <version>5.61_moa</version> + <scope>test</scope> + </dependency> - </dependencies> + <!-- for testing --> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <version>5.7.1 </version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> + <version>5.7.1 </version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-migrationsupport</artifactId> + <version>5.7.1 </version> + <scope>test</scope> + </dependency> + + </dependencies> </project> diff --git a/src/main/java/at/gv/util/ValidationUtils.java b/src/main/java/at/gv/util/ValidationUtils.java index cbc7207..108fe27 100644 --- a/src/main/java/at/gv/util/ValidationUtils.java +++ b/src/main/java/at/gv/util/ValidationUtils.java @@ -2,11 +2,16 @@ package at.gv.util; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.Period; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.util.regex.Pattern; public class ValidationUtils { private static final String DATEFORMAT = "dd.MM.yyyy"; + private static final int REPRESENTATION_MIN_AGE = 14; public static boolean isDateFormat(String dateString) { @@ -57,5 +62,19 @@ public class ValidationUtils { return Pattern.compile("[0-9]{4}").matcher(postcode).matches(); } + + public static boolean isOverThirteen(String representativeDateOfBirth) { + try { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATEFORMAT); + LocalDate birthdate= LocalDate.parse(representativeDateOfBirth, formatter); + Period p = Period.between(birthdate, LocalDate.now()); + return p.getYears() >= REPRESENTATION_MIN_AGE; + + } catch (DateTimeParseException e) { + return false; + + } + + } } diff --git a/src/main/java/at/gv/util/client/ur_V7/URClient.java b/src/main/java/at/gv/util/client/ur_V7/URClient.java new file mode 100644 index 0000000..530951e --- /dev/null +++ b/src/main/java/at/gv/util/client/ur_V7/URClient.java @@ -0,0 +1,590 @@ +package at.gv.util.client.ur_V7; + +import java.math.BigInteger; +import java.net.URL; +import java.util.ArrayList; +import java.util.GregorianCalendar; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.annotation.Resource; +import javax.net.ssl.SSLContext; +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeConstants; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; +import javax.xml.ws.BindingProvider; +import javax.xml.ws.WebServiceContext; +import javax.xml.ws.WebServiceException; +import javax.xml.ws.handler.Handler; + +import org.apache.commons.lang.RandomStringUtils; +import org.apache.cxf.configuration.jsse.TLSClientParameters; +import org.apache.cxf.endpoint.Client; +import org.apache.cxf.frontend.ClientProxy; +import org.apache.cxf.transport.http.HTTPConduit; +import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.util.LaxHostNameVerifier; +import at.gv.util.LoggingHandler; +import at.gv.util.MiscUtil; +import at.gv.util.client.pvp.rprofile.Pvp18pSoapHandler; +import at.gv.util.config.EgovUtilConfiguration; +import at.gv.util.ex.EgovUtilException; +import at.gv.util.wsdl.ur_V7.URSuche; +import at.gv.util.wsdl.ur_V7.URSucheService; +import at.gv.util.wsdl.ur_V7.XmlSwFault; +import at.gv.util.xsd.szr.pvp.PvpTokenType; +import at.gv.util.xsd.ur_V7.pd.IdentificationType; +import at.gv.util.xsd.ur_V7.pd.NichtNatuerlichePersonTyp; +import at.gv.util.xsd.ur_V7.pd.PersonenDatenTyp; +import at.gv.util.xsd.ur_V7.pd.PersonenDatenTyp.Zusatzdaten; +import at.gv.util.xsd.ur_V7.pd.PersonenDatenZusatzdatenTyp; +import at.gv.util.xsd.ur_V7.pd.ZusatzdatenPersonenTyp; +import at.gv.util.xsd.ur_V7.search.BestandszeitraumVollzug; +import at.gv.util.xsd.ur_V7.search.FktRegelTypVollzug; +import at.gv.util.xsd.ur_V7.search.FunktionVollzug; +import at.gv.util.xsd.ur_V7.search.SucheUnternehmenNachBpkRequest; +import at.gv.util.xsd.ur_V7.search.SucheUnternehmenNachIdRequest; +import at.gv.util.xsd.ur_V7.search.SucheUnternehmenRequest; +import at.gv.util.xsd.ur_V7.search.SucheUnternehmensdaten; +import at.gv.util.xsd.ur_V7.simpletypes.EvbStatusTyp; +import at.gv.util.xsd.ur_V7.xmlsw.ExtraResultCriteria; +import at.gv.util.xsd.ur_V7.xmlsw.ResultCriteriaType; +import at.gv.util.xsd.ur_V7.xmlsw.ResultRecord; +import at.gv.util.xsd.ur_V7.xmlsw.SearchByExampleType; +import at.gv.util.xsd.ur_V7.xmlsw.SearchCriteriaType; +import at.gv.util.xsd.ur_V7.xmlsw.SearchResponseType; + +public class URClient { + + @Resource + WebServiceContext wsContext; + + private EgovUtilConfiguration config = null; + private Logger log = LoggerFactory.getLogger(URClient.class); + private boolean logEnabled = true; + private boolean evbCheck = true; + private URSuche urSuche = null; + + private final static String version = "V5.0"; + private List<String> allowedKeys = null; + private HashSet<String> allowedERsBKeys = null; + + public URClient(EgovUtilConfiguration config, List<String> allowedKeys, HashSet<String> ersbkeys, boolean evbCheck, boolean logEnabled) throws EgovUtilException { + MiscUtil.assertNotNull(config, "config"); + this.config = config; + this.allowedKeys = allowedKeys; + this.logEnabled = logEnabled; + this.evbCheck = evbCheck; + this.allowedERsBKeys = ersbkeys; + + initialize(); + } + + public List<URSearchResult> searchByRegisterNumberFullInfo(String number, String type, int maxResults) throws Exception { + + SucheUnternehmenNachIdRequest request = new SucheUnternehmenNachIdRequest(); + + if (type.equals("ERJ")) + request.setErj(number); + else if (type.equals("FBN")) + request.setFbn(number); + else if (type.equals("KUR")) + request.setKur(number); + else if (type.equals("SEK")) + request.setSek(number); + else if (type.equals("ZVR")) + request.setZvr(number); + else + throw new Exception("Wrong RegisterNumber Type"); + + request.setMitHistorie(true); + + SearchCriteriaType sct = new SearchCriteriaType(); + sct.setSucheUnternehmenNachIdRequest(request); + List<ResultRecord> results = searchByExample(sct, -1); + + return getURSearchResult(results); + } + + public List<URSearchResult> searchByBpk(String vzbpk) throws URClientException { + SucheUnternehmenNachBpkRequest request = new SucheUnternehmenNachBpkRequest(); + request.setVersion(version); + request.setBpkWTUREncoded(vzbpk); + + request.setNurAktive(true); + + SearchCriteriaType sct = new SearchCriteriaType(); + sct.setSucheUnternehmenNachBpkRequest(request); + + List<ResultRecord> results = searchByExample(sct, -1); + return getURSearchResult(results); + } + + public List<NichtNatuerlichePersonTyp> searchByRegisterNumber(String number, String type, int maxResults) throws URClientException { + SucheUnternehmenRequest request = new SucheUnternehmenRequest(); + request.setVersion(version); + SucheUnternehmensdaten sud = new SucheUnternehmensdaten(); + sud.setId(number); + sud.setIdArt(type); + request.setUnternehmensdaten(sud); + + + SearchCriteriaType sct = new SearchCriteriaType(); + sct.setSucheUnternehmenRequest(request); + + List<ResultRecord> results = searchByExample(sct, maxResults); + return getNichtNatuerlichePersonen(results); + } + + public List<NichtNatuerlichePersonTyp> searchByName(String name, String plz, int maxResults) throws URClientException { + SucheUnternehmenRequest request = new SucheUnternehmenRequest(); + request.setVersion(version); + SucheUnternehmensdaten sud = new SucheUnternehmensdaten(); + sud.setUntName(name); + if (MiscUtil.isNotEmpty(plz)) { + sud.setPlz(plz); + } + request.setUnternehmensdaten(sud); + + SearchCriteriaType sct = new SearchCriteriaType(); + sct.setSucheUnternehmenRequest(request); + + List<ResultRecord> results = searchByExample(sct, maxResults); + return getNichtNatuerlichePersonen(results); + } + + private List<URSearchResult> getURSearchResult(List<ResultRecord> records) throws URClientException { + + if (records == null || records.size() == 0) { + return new ArrayList<URSearchResult>(); + } + + List<URSearchResult> result = new ArrayList<URSearchResult>(); + + log.debug("UR SOAP response with " + records.size() + "records"); + + for (ResultRecord rr : records) { + PersonenDatenTyp pdt = rr.getPersonenDaten(); + NichtNatuerlichePersonTyp nnpt = pdt.getNichtNatuerlichePerson(); + Zusatzdaten zsd = pdt.getZusatzdaten(); + + //check validity era + boolean check_valera = isInValidityEra(zsd); + + //check allowed keys + boolean check_allowedkeys = hasAllowedKeys(nnpt.getIdentification()); + + //ERsB function codes + List<String> ersbcode = hasAllowedEVBCode(zsd); + + //check EVB + boolean check_EVB = isEVB(zsd); + + if (check_valera && check_allowedkeys && (check_EVB || !ersbcode.isEmpty())) { + result.add(new URSearchResult(nnpt, ersbcode, check_EVB)); + } + else { + log.debug("No validity for " + nnpt.getRest().get(0).getValue() + + "(Validity era=" + String.valueOf(check_valera) + + " Allowed Keys="+ String.valueOf(check_allowedkeys) + + " EVB check=" + String.valueOf(check_EVB) +")"); + } + } + + return result; + } + + private List<NichtNatuerlichePersonTyp> getNichtNatuerlichePersonen(List<ResultRecord> records) throws URClientException { + + if (records == null || records.size() == 0) { + return new ArrayList<NichtNatuerlichePersonTyp>(); + } + + List<NichtNatuerlichePersonTyp> result = new ArrayList<NichtNatuerlichePersonTyp>(); + + log.debug("UR SOAP response with " + records.size() + "records"); + + for (ResultRecord rr : records) { + PersonenDatenTyp pdt = rr.getPersonenDaten(); + NichtNatuerlichePersonTyp nnpt = pdt.getNichtNatuerlichePerson(); + Zusatzdaten zsd = pdt.getZusatzdaten(); + + //check validity era + boolean check_valera = isInValidityEra(zsd); + + //check allowed keys + boolean check_allowedkeys = hasAllowedKeys(nnpt.getIdentification()); + + //check EVB + boolean check_EVB = isEVB(zsd); + + if (check_valera && check_allowedkeys && check_EVB) { + result.add(nnpt); + } + else { + log.debug("No validity for " + nnpt.getRest().get(0).getValue() + + "(Validity era=" + String.valueOf(check_valera) + + " Allowed Keys="+ String.valueOf(check_allowedkeys) + + " EVB check=" + String.valueOf(check_EVB) +")"); + } + } + + return result; + } + + private List<String> hasAllowedEVBCode(Zusatzdaten zsd) { + + Set<String> set = new HashSet<String>(); + + if ((this.allowedERsBKeys == null || this.allowedERsBKeys.size() == 0)) { + return new ArrayList<String>(); + + } else { + + GregorianCalendar now = new GregorianCalendar(); + XMLGregorianCalendar xmldate; + try { + xmldate = DatatypeFactory.newInstance().newXMLGregorianCalendar(now); + if(zsd != null) { + List<PersonenDatenZusatzdatenTyp> pd = zsd.getPersonenDaten(); + for (PersonenDatenZusatzdatenTyp pdzd : pd) { + + ZusatzdatenPersonenTyp zusatzdaten = pdzd.getZusatzdaten(); + if (zusatzdaten != null) { + + List<FunktionVollzug> function = zusatzdaten.getFunktion(); + for (FunktionVollzug funct : function) { + + if (this.allowedERsBKeys.contains(String.valueOf(funct.getFktName()))) { + List<FktRegelTypVollzug> functRegel = funct.getFktRegel(); + for (FktRegelTypVollzug el : functRegel) { + if ( el.getFktRegelVon() == null && el.getFktRegelBis() == null) + set.add(String.valueOf(funct.getFktName())); + + else if ( el.getFktRegelVon() != null && el.getFktRegelBis() == null + && el.getFktRegelVon().compare(xmldate) == DatatypeConstants.LESSER ) + set.add(String.valueOf(funct.getFktName())); + + else if ( el.getFktRegelVon() == null && el.getFktRegelBis() != null + && el.getFktRegelBis().compare(xmldate) == DatatypeConstants.GREATER ) + set.add(String.valueOf(funct.getFktName())); + + + else if ( el.getFktRegelVon() != null && el.getFktRegelBis() != null + && (el.getFktRegelVon().compare(xmldate) == DatatypeConstants.LESSER + && el.getFktRegelBis().compare(xmldate) == DatatypeConstants.GREATER) ) + set.add(String.valueOf(funct.getFktName())); + + } + } + } + } + } + } + + } catch (DatatypeConfigurationException e) { + log.warn("Internal error during date conversion", e); + + } + + return new ArrayList<String>(set); + } + } + + //check if corporation is in validity era + //TODO: check correctness of TRUE if no validity era is defined!!! + private boolean isInValidityEra(Zusatzdaten zsd) throws URClientException { + if(zsd != null) { + List<BestandszeitraumVollzug> validityera = zsd.getBestandszeitraum(); + for ( BestandszeitraumVollzug valera_el : validityera) { + try { + GregorianCalendar now = new GregorianCalendar(); + XMLGregorianCalendar xmldate = DatatypeFactory.newInstance().newXMLGregorianCalendar(now); + + if ( !(valera_el.getBestandVon().compare(xmldate) == DatatypeConstants.LESSER + && valera_el.getBestandBis().compare(xmldate) == DatatypeConstants.GREATER) ) { + + log.debug("Corporation is not within the validity period"); + return false; + } + + } catch (DatatypeConfigurationException e) { + log.warn("Internal error during date conversion", e); + } + } + } + return true; + } + + // check if person is einzelvertretungsbefugt + private boolean isEVB(Zusatzdaten zsd) { + if (!this.evbCheck) { + return true; + } + else { + if(zsd != null) { + List<PersonenDatenZusatzdatenTyp> pd = zsd.getPersonenDaten(); + for (PersonenDatenZusatzdatenTyp pdzd : pd) { + + if (pdzd.getZusatzdaten() != null) { + EvbStatusTyp evbstatus = pdzd.getZusatzdaten().getEvbStatus(); + if (evbstatus!=null && evbstatus.equals(EvbStatusTyp.J)) { + return true; + } + } + } + } + } + return false; + } + + //check allowedKeys + private boolean hasAllowedKeys(List<IdentificationType> list) throws URClientException { + + if ((this.allowedKeys == null || this.allowedKeys.size() == 0)) { + return true; + + } else { + for (IdentificationType idt : list) { + if (this.allowedKeys.contains(idt.getType())) { + return true; + } + } + } + return false; + } + + + + // search by example + public List<ResultRecord> searchByExample(SearchCriteriaType sct, int maxResults) throws URClientException { + + + SearchByExampleType body = new SearchByExampleType(); + + body.setSearchRequestId(createURSearchId()); + ResultCriteriaType rc = new ResultCriteriaType(); + + log.debug("UR SOAP request with Id " + body.getSearchRequestId()); + + // set only value of max results if > 0 + if (maxResults > 0) { + rc.setMaxRecords(BigInteger.valueOf(maxResults)); + } + + // set ExtraResultCriterias + ExtraResultCriteria ec = new ExtraResultCriteria(); + ec.setErsbAttribute(true); + rc.setExtraResultCriteria(ec); + body.setResultCriteria(rc); + + body.setSearchCriteria(sct); + + + //request UR service + SearchResponseType srt = null; + try { + srt = this.urSuche.searchByExample(body); + + } catch (javax.xml.ws.soap.SOAPFaultException e) { + //request secondary service + switchTOSecondarySystem(e); + try { + srt = this.urSuche.searchByExample(body); + + } catch (XmlSwFault e1) { + + if (e1.getFaultInfo() != null) { + throw new URClientException(e1.getFaultInfo().getHelp(), e1.getFaultInfo().getCode().intValue()); + + } else { + throw new URClientException(e1.getMessage(), -1, e1); + } + } + + } catch (WebServiceException e) { + //request secondary service + switchTOSecondarySystem(e); + + try { + srt = this.urSuche.searchByExample(body); + + } catch (XmlSwFault e1) { + + if (e1.getFaultInfo() != null) { + throw new URClientException(e1.getFaultInfo().getHelp(), e1.getFaultInfo().getCode().intValue()); + + } else { + throw new URClientException(e1.getMessage(), -1, e1); + } + } + + } catch (XmlSwFault e) { + + if (e.getFaultInfo() != null) { + throw new URClientException(e.getFaultInfo().getHelp(), e.getFaultInfo().getCode().intValue()); + + } else { + throw new URClientException(e.getMessage(), -1, e); + } + + } + + // check number of records found +// int numFound = 0; +// if (srt.getResultInfo() != null) { +// numFound = srt.getResultInfo().getReturnedRecords().intValue(); +// } + // check whether we have an error message + if (srt.getMessage() != null) { + if (srt.getMessage().getCode().intValue() != 2040) { // 2040 = no records found + throw new URClientException(srt.getMessage().getReason().get(0), srt.getMessage().getCode().intValue()); + } + } + + if (srt.getResultRecords() == null || srt.getResultRecords().getResultRecord() == null) { + return new ArrayList<ResultRecord>(); + } + return srt.getResultRecords().getResultRecord(); + } + + private void switchTOSecondarySystem(Exception e) throws URClientException { + log.warn("Request primary UR service failed with error \"" + e.getMessage() +"\". " + + "Switch to secondary UR service."); + + String urURL = config.getURSecondaryProductionEnvironmentURL(); + try { + setURServiceURL(urURL); + + } catch (EgovUtilException e1) { + log.error("Switch to secodary UR service FAILED!", e1); + throw new URClientException(e1.getMessage(), 0); + } + } + + private void setURServiceURL(String urURL) throws EgovUtilException { + // set UR Service URL + + log.trace("UR connection URL: " + urURL); + BindingProvider bindingProvider = (BindingProvider) urSuche; + Map<String, Object> requestContext = bindingProvider.getRequestContext(); + requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, urURL); + + //set HTTP Client Timeout (Default Timeout 60sec) + Client client = ClientProxy.getClient(urSuche); + HTTPConduit http = (HTTPConduit) client.getConduit(); + HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); + + //set HTTP Client Timeout (Default Timeout 60sec) + httpClientPolicy.setConnectionTimeout(15000); + httpClientPolicy.setAllowChunking(false); + httpClientPolicy.setReceiveTimeout(32000); + http.setClient(httpClientPolicy); + + //check for ssl + if (urURL.toLowerCase().startsWith("https")) { + log.trace("Using ssl for SZR client request."); + SSLContext sslContext = this.config.getURsslConfiguration().getSSLContext(false); + if (sslContext == null) { + throw new EgovUtilException("SSL context from configuration is empty. Please configure an SSL context in the configuration first."); + } + TLSClientParameters tlsParams = new TLSClientParameters(); + tlsParams.setSSLSocketFactory(sslContext.getSocketFactory()); + + // check for lax hostname + if (this.config.getURsslConfiguration().useLaxHostNameVerifier()) { + log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); + tlsParams.setHostnameVerifier(new LaxHostNameVerifier()); + } + http.setTlsClientParameters(tlsParams ); + } + + } + + + @SuppressWarnings({ "rawtypes", "unchecked" }) + private void initialize() throws EgovUtilException { + URL url = URClient.class.getResource("/wsdl/ur_V5/URSucheService.wsdl"); + URSucheService urService = null; + urService = new URSucheService(url, new QName("urn:at:statistik:ur:ws", "URSucheService")); + urSuche = urService.getURSucheService(); + + BindingProvider bindingProvider = (BindingProvider) urSuche; + + //set service URLs + String urURL = null; + if (config.isURTestEnvironment()) { + log.trace("Initializing UR test configuration."); + urURL = config.getURTestEnvironmentURL(); + } else { + log.trace("Initializing UR productive configuration."); + urURL = config.getURProductionEnvironmentURL(); + } + + setURServiceURL(urURL); + + log.trace("Adding JAX-WS request/response trace handler."); + List<Handler> handlerList = bindingProvider.getBinding().getHandlerChain(); + if (handlerList == null) { + handlerList = new ArrayList(); + } + + LoggingHandler loggingHandler = new LoggingHandler(); + if (this.logEnabled) { + handlerList.add(loggingHandler); + } + + log.trace("Adding WS-Security Header handler."); + PvpTokenType pvpToken = config.getURPVPToken(); + Pvp18pSoapHandler szrSOAPHandler = new Pvp18pSoapHandler(); + szrSOAPHandler.configure(pvpToken); + handlerList.add(szrSOAPHandler); + bindingProvider.getBinding().setHandlerChain(handlerList); + } + + private String createURSearchId() { + return RandomStringUtils.randomAlphanumeric(8) + "-" + + RandomStringUtils.randomAlphanumeric(4) + "-" + RandomStringUtils.randomAlphanumeric(4) + "-" + + RandomStringUtils.randomAlphanumeric(12); + } + + public class URSearchResult { + private NichtNatuerlichePersonTyp result; + private List<String> ersbcode; + private boolean evb; + + public URSearchResult() { + this.result = null; + this.ersbcode = null; + this.evb = false; + } + + public URSearchResult(NichtNatuerlichePersonTyp result, List<String> ersb_code, boolean isevb) { + this.result = result; + this.ersbcode = ersb_code; + this.evb = isevb; + } + + public NichtNatuerlichePersonTyp getResult() { + return result; + } + + public List<String> getErsbcode() { + return ersbcode; + } + + public boolean isEVB() { + return evb; + } + } + + +} + diff --git a/src/main/java/at/gv/util/client/ur_V7/URClientException.java b/src/main/java/at/gv/util/client/ur_V7/URClientException.java new file mode 100644 index 0000000..fa922b9 --- /dev/null +++ b/src/main/java/at/gv/util/client/ur_V7/URClientException.java @@ -0,0 +1,33 @@ +package at.gv.util.client.ur_V7; + +public class URClientException extends Exception { + + private static final long serialVersionUID = 5173056345209288701L; + + private int code = -1; + + public URClientException(int code) { + super(); + this.code = code; + } + + public URClientException(String message, int code, Throwable cause) { + super(message, cause); + this.code = code; + } + + public URClientException(String message, int code) { + super(message); + this.code = code; + } + + public URClientException(int code, Throwable cause) { + super(cause); + this.code = code; + } + + public int getCode() { + return this.code; + } + +} diff --git a/src/main/resources/wsdl/szr/szr_pvp.xsd b/src/main/resources/wsdl/szr/szr_pvp.xsd index a536c47..373c45e 100644 --- a/src/main/resources/wsdl/szr/szr_pvp.xsd +++ b/src/main/resources/wsdl/szr/szr_pvp.xsd @@ -1,6 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns="http://egov.gv.at/pvp1.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://egov.gv.at/pvp1.xsd" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="pvpToken" type="pvpTokenType"/> + <xs:element name="debug-ticket"> + <xs:complexType> + <xs:sequence> + <xs:element name="txid" type="xs:string" minOccurs="1" maxOccurs="1" /> + </xs:sequence> + </xs:complexType> + </xs:element> <xs:complexType name="pvpTokenType"> <xs:sequence> <xs:element name="authenticate"> diff --git a/src/main/resources/wsdl/szr_v4/pvp19.xsd b/src/main/resources/wsdl/szr_v4/pvp19.xsd index 596a2b9..aad728a 100644 --- a/src/main/resources/wsdl/szr_v4/pvp19.xsd +++ b/src/main/resources/wsdl/szr_v4/pvp19.xsd @@ -12,6 +12,13 @@ </xs:complexContent> </xs:complexType> </xs:element> + <xs:element name="debug-ticket"> + <xs:complexType> + <xs:sequence> + <xs:element name="txid" type="xs:string" minOccurs="1" maxOccurs="1" /> + </xs:sequence> + </xs:complexType> + </xs:element> <xs:complexType name="pvpTokenType"> <xs:sequence> <xs:element name="authenticate"> diff --git a/src/main/resources/wsdl/szr_v4/szr_v4.0.xsd b/src/main/resources/wsdl/szr_v4/szr_v4.0.xsd index fd255b1..1e2a06c 100644 --- a/src/main/resources/wsdl/szr_v4/szr_v4.0.xsd +++ b/src/main/resources/wsdl/szr_v4/szr_v4.0.xsd @@ -154,6 +154,7 @@ <xs:complexType name="SignContentResponseType"> <xs:sequence> <xs:element name="JwsAlg" type="xs:string" minOccurs="0"/> + <xs:element name="Cert" minOccurs="0" type="xs:base64Binary"/> <xs:element name="Out" type="szr:SignContentEntry" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> diff --git a/src/test/java/at/gv/util/test/ValitationUtilsTest.java b/src/test/java/at/gv/util/test/ValitationUtilsTest.java new file mode 100644 index 0000000..e4e5b3f --- /dev/null +++ b/src/test/java/at/gv/util/test/ValitationUtilsTest.java @@ -0,0 +1,36 @@ +package at.gv.util.test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.apache.commons.lang.RandomStringUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.BlockJUnit4ClassRunner; + +import at.gv.util.ValidationUtils; + +@RunWith(BlockJUnit4ClassRunner.class) +public class ValitationUtilsTest { + + @Test + public void dateOfBirthFormat() { + assertFalse("wrong format not detected", ValidationUtils.isDateFormat("19-06-2002")); + assertFalse("wrong format not detected", ValidationUtils.isOverThirteen(RandomStringUtils.randomAlphanumeric(10))); + + assertTrue("detected", ValidationUtils.isDateFormat("19.06.2002")); + + } + + @Test + public void ageVerification() { + assertTrue("not over 14", ValidationUtils.isOverThirteen("01.01.1985")); + assertTrue("not over 14", ValidationUtils.isOverThirteen("17.06.2007")); + assertTrue("not over 14", ValidationUtils.isOverThirteen("18.06.2007")); + assertFalse("not over 14", ValidationUtils.isOverThirteen("19.06.2015")); + + assertFalse("not over 14", ValidationUtils.isOverThirteen("19-06-2002")); + assertFalse("not over 14", ValidationUtils.isOverThirteen(RandomStringUtils.randomAlphanumeric(10))); + + } +} |