From a3f4198aa1ac2f9b380ac325319b3ce848b3ee47 Mon Sep 17 00:00:00 2001
From: "deepin-community-bot[bot]"
<156989552+deepin-community-bot[bot]@users.noreply.github.com>
Date: Thu, 7 May 2026 12:37:07 +0000
Subject: [PATCH] feat: update libstringprep-java to 2.1-1
---
.gitignore | 107 +-
.gitlab-ci.yml | 112 +-
.mvn/maven.config | 1 +
.mvn/wrapper/MavenWrapperDownloader.java | 173 +-
.mvn/wrapper/maven-wrapper.properties | 20 +-
.settings/.gitignore | 1 -
CHANGELOG.md | 37 +
LICENSE | 2 +-
NOTICE | 9 -
README.md | 123 +-
checks/checkstyle-header.txt | 4 +
checks/checkstyle-suppressions.xml | 8 +
checks/checkstyle.xml | 310 +
checks/pmd-ruleset.xml | 42 +
checks/spotbugs-exclude.xml | 20 +
codegen/pom.xml | 28 +
.../stringprep/codegen/GeneratorCode.java | 62 +
.../stringprep/codegen/parsers/Parser.java | 83 +
.../parsers/ParserBidirectionalTables.java | 23 +
.../codegen/parsers/ParserMappingTables.java | 32 +
.../parsers/ParserProhibitionTables.java | 63 +
.../parsers/ParserUnicodeRepertoires.java | 19 +
.../codegen/parsers/ParserUtil.java | 145 +
.../src/main/resources/rfcs/a1.txt | 0
.../src/main/resources/rfcs/b1.txt | 0
.../src/main/resources/rfcs/b2.txt | 0
.../src/main/resources/rfcs/b3.txt | 0
.../src/main/resources/rfcs/c1.1.txt | 0
.../src/main/resources/rfcs/c1.2.txt | 0
.../src/main/resources/rfcs/c2.1.txt | 0
.../src/main/resources/rfcs/c2.2.txt | 0
.../src/main/resources/rfcs/c3.txt | 0
.../src/main/resources/rfcs/c4.txt | 0
.../src/main/resources/rfcs/c5.txt | 0
.../src/main/resources/rfcs/c6.txt | 0
.../src/main/resources/rfcs/c7.txt | 0
.../src/main/resources/rfcs/c8.txt | 0
.../src/main/resources/rfcs/c9.txt | 0
.../src/main/resources/rfcs/d1.txt | 0
.../src/main/resources/rfcs/d2.txt | 0
.../resources/templates/StringPrepTables.vm | 323 +
{thirdparty => codegen}/velocity-LICENSE | 0
codegenerator/.gitignore | 1 -
codegenerator/pom.xml | 32 -
.../codegenerator/GeneratorCode.java | 72 -
.../stringprep/codegenerator/Parser.java | 145 -
.../parsers/ParserBidirectionalTables.java | 40 -
.../parsers/ParserMappingTables.java | 49 -
.../parsers/ParserProhibitionTables.java | 79 -
.../parsers/ParserUnicodeRepertoires.java | 36 -
.../codegenerator/parsers/ParserUtil.java | 148 -
.../main/resources/templates/StringPrep.vm | 229 -
coverage-report/pom.xml | 63 +
debian/changelog | 20 +
debian/control | 9 +-
debian/copyright | 3 +-
debian/libstringprep-java.poms | 6 +-
debian/maven.ignoreRules | 2 +
debian/maven.properties | 3 +-
debian/maven.rules | 1 -
debian/rules | 4 -
debian/watch | 4 +-
mvnw | 224 +-
mvnw.cmd | 59 +-
nameprep/pom.xml | 56 +
.../src/it/jpms-nameprep/invoker.properties | 3 +
nameprep/src/it/jpms-nameprep/pom.xml | 60 +
.../src/test/java/module-info.java | 12 +
.../test/java/test/nameprep/NameprepTest.java | 59 +
nameprep/src/it/settings.xml | 35 +
.../java/com/ongres/nameprep/Nameprep.java | 53 +
.../com/ongres/nameprep/package-info.java | 10 +
nameprep/src/main/java9/module-info.java | 10 +
.../services/com.ongres.stringprep.Profile | 1 +
.../test/java/test/nameprep/NameprepTest.java | 146 +
parent/pom.xml | 713 +++
pom.xml | 233 +-
saslprep/pom.xml | 52 +-
.../src/it/jpms-saslprep/invoker.properties | 3 +
saslprep/src/it/jpms-saslprep/pom.xml | 60 +
.../src/test/java/module-info.java | 12 +
.../test/java/test/saslprep/SaslPrepTest.java | 68 +
saslprep/src/it/settings.xml | 35 +
.../java/com/ongres/saslprep/SASLprep.java | 68 +
.../java/com/ongres/saslprep/SaslPrep.java | 118 -
.../com/ongres/saslprep/package-info.java | 10 +
saslprep/src/main/java9/module-info.java | 10 +
.../services/com.ongres.stringprep.Profile | 1 +
.../com/ongres/saslprep/SaslPrepTest.java | 63 -
.../test/java/test/saslprep/SaslPrepTest.java | 162 +
stringprep/pom.xml | 150 +-
.../src/it/jpms-stringprep/invoker.properties | 3 +
stringprep/src/it/jpms-stringprep/pom.xml | 60 +
.../src/test/java/module-info.java | 12 +
.../java/test/stringprep/StringprepTest.java | 37 +
stringprep/src/it/settings.xml | 35 +
.../java/com/ongres/stringprep/Option.java | 88 +
.../java/com/ongres/stringprep/Profile.java | 132 +
.../com/ongres/stringprep/ProfileName.java | 32 +
.../com/ongres/stringprep/Stringprep.java | 275 +
.../ongres/stringprep/StringprepLocator.java | 26 +
.../java/com/ongres/stringprep/Tables.java | 5549 +++++++++++++++++
.../com/ongres/stringprep/package-info.java | 10 +
stringprep/src/main/java9/module-info.java | 9 +
.../com/ongres/stringprep/StringPrepTest.java | 196 -
.../java/test/stringprep/ProfileTest.java | 239 +
.../test/java/test/stringprep/TablesTest.java | 167 +
.../profile/CaseFoldAnnotation.java | 56 +
.../profile/CaseFoldNoAnnotation.java | 54 +
.../stringprep/profile/DemoProfileTest.java | 56 +
.../services/com.ongres.stringprep.Profile | 2 +
111 files changed, 10427 insertions(+), 1790 deletions(-)
create mode 100644 .mvn/maven.config
delete mode 100644 .settings/.gitignore
create mode 100644 CHANGELOG.md
delete mode 100644 NOTICE
create mode 100644 checks/checkstyle-header.txt
create mode 100644 checks/checkstyle-suppressions.xml
create mode 100644 checks/checkstyle.xml
create mode 100644 checks/pmd-ruleset.xml
create mode 100644 checks/spotbugs-exclude.xml
create mode 100644 codegen/pom.xml
create mode 100644 codegen/src/main/java/com/ongres/stringprep/codegen/GeneratorCode.java
create mode 100644 codegen/src/main/java/com/ongres/stringprep/codegen/parsers/Parser.java
create mode 100644 codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserBidirectionalTables.java
create mode 100644 codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserMappingTables.java
create mode 100644 codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserProhibitionTables.java
create mode 100644 codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserUnicodeRepertoires.java
create mode 100644 codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserUtil.java
rename codegenerator/src/main/resources/rfcs/a1 => codegen/src/main/resources/rfcs/a1.txt (100%)
rename codegenerator/src/main/resources/rfcs/b1 => codegen/src/main/resources/rfcs/b1.txt (100%)
rename codegenerator/src/main/resources/rfcs/b2 => codegen/src/main/resources/rfcs/b2.txt (100%)
rename codegenerator/src/main/resources/rfcs/b3 => codegen/src/main/resources/rfcs/b3.txt (100%)
rename codegenerator/src/main/resources/rfcs/c1.1 => codegen/src/main/resources/rfcs/c1.1.txt (100%)
rename codegenerator/src/main/resources/rfcs/c1.2 => codegen/src/main/resources/rfcs/c1.2.txt (100%)
rename codegenerator/src/main/resources/rfcs/c2.1 => codegen/src/main/resources/rfcs/c2.1.txt (100%)
rename codegenerator/src/main/resources/rfcs/c2.2 => codegen/src/main/resources/rfcs/c2.2.txt (100%)
rename codegenerator/src/main/resources/rfcs/c3 => codegen/src/main/resources/rfcs/c3.txt (100%)
rename codegenerator/src/main/resources/rfcs/c4 => codegen/src/main/resources/rfcs/c4.txt (100%)
rename codegenerator/src/main/resources/rfcs/c5 => codegen/src/main/resources/rfcs/c5.txt (100%)
rename codegenerator/src/main/resources/rfcs/c6 => codegen/src/main/resources/rfcs/c6.txt (100%)
rename codegenerator/src/main/resources/rfcs/c7 => codegen/src/main/resources/rfcs/c7.txt (100%)
rename codegenerator/src/main/resources/rfcs/c8 => codegen/src/main/resources/rfcs/c8.txt (100%)
rename codegenerator/src/main/resources/rfcs/c9 => codegen/src/main/resources/rfcs/c9.txt (100%)
rename codegenerator/src/main/resources/rfcs/d1 => codegen/src/main/resources/rfcs/d1.txt (100%)
rename codegenerator/src/main/resources/rfcs/d2 => codegen/src/main/resources/rfcs/d2.txt (100%)
create mode 100644 codegen/src/main/resources/templates/StringPrepTables.vm
rename {thirdparty => codegen}/velocity-LICENSE (100%)
delete mode 100644 codegenerator/.gitignore
delete mode 100644 codegenerator/pom.xml
delete mode 100644 codegenerator/src/main/java/com/ongres/stringprep/codegenerator/GeneratorCode.java
delete mode 100644 codegenerator/src/main/java/com/ongres/stringprep/codegenerator/Parser.java
delete mode 100644 codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserBidirectionalTables.java
delete mode 100644 codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserMappingTables.java
delete mode 100644 codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserProhibitionTables.java
delete mode 100644 codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserUnicodeRepertoires.java
delete mode 100644 codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserUtil.java
delete mode 100644 codegenerator/src/main/resources/templates/StringPrep.vm
create mode 100644 coverage-report/pom.xml
create mode 100644 nameprep/pom.xml
create mode 100644 nameprep/src/it/jpms-nameprep/invoker.properties
create mode 100644 nameprep/src/it/jpms-nameprep/pom.xml
create mode 100644 nameprep/src/it/jpms-nameprep/src/test/java/module-info.java
create mode 100644 nameprep/src/it/jpms-nameprep/src/test/java/test/nameprep/NameprepTest.java
create mode 100644 nameprep/src/it/settings.xml
create mode 100644 nameprep/src/main/java/com/ongres/nameprep/Nameprep.java
create mode 100644 nameprep/src/main/java/com/ongres/nameprep/package-info.java
create mode 100644 nameprep/src/main/java9/module-info.java
create mode 100644 nameprep/src/main/resources/META-INF/services/com.ongres.stringprep.Profile
create mode 100644 nameprep/src/test/java/test/nameprep/NameprepTest.java
create mode 100644 parent/pom.xml
create mode 100644 saslprep/src/it/jpms-saslprep/invoker.properties
create mode 100644 saslprep/src/it/jpms-saslprep/pom.xml
create mode 100644 saslprep/src/it/jpms-saslprep/src/test/java/module-info.java
create mode 100644 saslprep/src/it/jpms-saslprep/src/test/java/test/saslprep/SaslPrepTest.java
create mode 100644 saslprep/src/it/settings.xml
create mode 100644 saslprep/src/main/java/com/ongres/saslprep/SASLprep.java
delete mode 100644 saslprep/src/main/java/com/ongres/saslprep/SaslPrep.java
create mode 100644 saslprep/src/main/java/com/ongres/saslprep/package-info.java
create mode 100644 saslprep/src/main/java9/module-info.java
create mode 100644 saslprep/src/main/resources/META-INF/services/com.ongres.stringprep.Profile
delete mode 100644 saslprep/src/test/java/com/ongres/saslprep/SaslPrepTest.java
create mode 100644 saslprep/src/test/java/test/saslprep/SaslPrepTest.java
create mode 100644 stringprep/src/it/jpms-stringprep/invoker.properties
create mode 100644 stringprep/src/it/jpms-stringprep/pom.xml
create mode 100644 stringprep/src/it/jpms-stringprep/src/test/java/module-info.java
create mode 100644 stringprep/src/it/jpms-stringprep/src/test/java/test/stringprep/StringprepTest.java
create mode 100644 stringprep/src/it/settings.xml
create mode 100644 stringprep/src/main/java/com/ongres/stringprep/Option.java
create mode 100644 stringprep/src/main/java/com/ongres/stringprep/Profile.java
create mode 100644 stringprep/src/main/java/com/ongres/stringprep/ProfileName.java
create mode 100644 stringprep/src/main/java/com/ongres/stringprep/Stringprep.java
create mode 100644 stringprep/src/main/java/com/ongres/stringprep/StringprepLocator.java
create mode 100644 stringprep/src/main/java/com/ongres/stringprep/Tables.java
create mode 100644 stringprep/src/main/java/com/ongres/stringprep/package-info.java
create mode 100644 stringprep/src/main/java9/module-info.java
delete mode 100644 stringprep/src/test/java/com/ongres/stringprep/StringPrepTest.java
create mode 100644 stringprep/src/test/java/test/stringprep/ProfileTest.java
create mode 100644 stringprep/src/test/java/test/stringprep/TablesTest.java
create mode 100644 stringprep/src/test/java/test/stringprep/profile/CaseFoldAnnotation.java
create mode 100644 stringprep/src/test/java/test/stringprep/profile/CaseFoldNoAnnotation.java
create mode 100644 stringprep/src/test/java/test/stringprep/profile/DemoProfileTest.java
create mode 100644 stringprep/src/test/resources/META-INF/services/com.ongres.stringprep.Profile
diff --git a/.gitignore b/.gitignore
index 224e7f0..0b35c6e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,106 @@
-.pc/
+# Created by https://www.gitignore.io/api/java,eclipse
+# Edit at https://www.gitignore.io/?templates=java,eclipse
+
+### Eclipse ###
+.metadata
+bin/
+tmp/
+*.tmp
+*.bak
+*.swp
+*~.nib
+local.properties
+.settings/
+.loadpath
+.recommenders
+.pmd
+
+# External tool builders
+.externalToolBuilders/
+
+# Locally stored "Eclipse launch configurations"
+*.launch
+
+# PyDev specific (Python IDE for Eclipse)
+*.pydevproject
+
+# CDT-specific (C/C++ Development Tooling)
+.cproject
+
+# CDT- autotools
+.autotools
+
+# Java annotation processor (APT)
+.factorypath
+
+# PDT-specific (PHP Development Tools)
+.buildpath
+
+# sbteclipse plugin
+.target
+
+# Tern plugin
+.tern-project
+
+# TeXlipse plugin
+.texlipse
+
+# STS (Spring Tool Suite)
+.springBeans
+
+# Code Recommenders
+.recommenders/
+
+# Annotation Processing
+.apt_generated/
+
+# Scala IDE specific (Scala & Java development for Eclipse)
+.cache-main
+.scala_dependencies
+.worksheet
+
+### Eclipse Patch ###
+# Eclipse Core
+.project
+
+# JDT-specific (Eclipse Java Development Tools)
+.classpath
+
+# Annotation Processing
+.apt_generated
+
+.sts4-cache/
+
+### Java ###
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.nar
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+# End of https://www.gitignore.io/api/java,eclipse
+
+/target
+/*/target
+
+.flattened-pom.xml
+
+*pom.xml.versionsBackup
\ No newline at end of file
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ee0373e..a415163 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,19 +1,111 @@
-image: openjdk:11-stretch
+image: eclipse-temurin:21
-stages:
- - build
+variables:
+ # This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
+ # `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
+ MAVEN_OPTS: |
+ -Dhttps.protocols=TLSv1.3,TLSv1.2
+ -Djdk.tls.client.protocols=TLSv1.3,TLSv1.2
+ -Dorg.slf4j.simpleLogger.showDateTime=true
+ -Djava.awt.headless=true
+ -Xss4m
+ MAVEN_CLI_OPTS: |
+ --batch-mode
+ --strict-checksums
+ --errors
+ --show-version
+ --no-transfer-progress
+ -DinstallAtEnd=true
+ -DdeployAtEnd=true
+ -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository
+ -Dmaven.user.home=$CI_PROJECT_DIR/.m2
-cache:
+# Cache downloaded dependencies and plugins between builds.
+# To keep cache across branches add 'key: "$CI_JOB_NAME"'
+cache: &global_cache
+ key:
+ files:
+ - pom.xml
paths:
- - .m2/
+ - .m2
+ - .mvn
-variables:
- M2_HOME: ".m2/maven"
- MAVEN_OPTS: "-Dmaven.repo.local=.m2"
- GITLAB_BASE_URL: "https://gitlab.com"
+workflow:
+ rules:
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
+ - if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
+ when: never
+ - if: '$CI_COMMIT_BRANCH'
+
+stages:
+ - build
+ - test
+ - check
build:
stage: build
script:
- - bash mvnw clean verify -P safer
+ - ./mvnw $MAVEN_CLI_OPTS package -P codegen -DskipTests
+ artifacts:
+ paths:
+ - "*/target/"
+
+tests:
+ stage: test
+ needs:
+ - job: build
+ artifacts: true
+ parallel:
+ matrix:
+ - JDK_IMAGE:
+ - azul/zulu-openjdk:8
+ - azul/zulu-openjdk:11
+ - azul/zulu-openjdk:17
+ - azul/zulu-openjdk:21
+ - azul/zulu-openjdk:22
+ - openjdk:23-ea-oraclelinux9
+ image: $JDK_IMAGE
+ script:
+ - ./mvnw $MAVEN_CLI_OPTS verify -Denforcer.skip=true
+ cache:
+ # inherit all global cache settings
+ <<: *global_cache
+ policy: pull
+ artifacts:
+ reports:
+ junit:
+ - "*/target/surefire-reports/TEST-*.xml"
+ - "**/target/junit-platform/TEST-*.xml"
+sonarcloud-check:
+ stage: check
+ cache:
+ key: "${CI_JOB_NAME}"
+ paths:
+ - .sonar/cache
+ variables:
+ GIT_STRATEGY: clone
+ GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
+ SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
+ script:
+ - |
+ ./mvnw $MAVEN_CLI_OPTS verify sonar:sonar \
+ -Dsonar.qualitygate.wait=true -Dsonar.organization=ongresinc \
+ -Dsonar.coverage.jacoco.xmlReportPaths="${CI_PROJECT_DIR}/coverage-report/target/site/jacoco-aggregate/jacoco.xml" \
+ -P coverage
+ only:
+ - merge_requests
+ - develop
+ - main
+
+static-checks:
+ stage: check
+ needs:
+ - job: build
+ artifacts: true
+ script:
+ - ./mvnw $MAVEN_CLI_OPTS verify -P checks -DskipTests
+ cache:
+ # inherit all global cache settings
+ <<: *global_cache
+ policy: pull
diff --git a/.mvn/maven.config b/.mvn/maven.config
new file mode 100644
index 0000000..7fa4242
--- /dev/null
+++ b/.mvn/maven.config
@@ -0,0 +1 @@
+--strict-checksums
diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java
index c32394f..84d1e60 100644
--- a/.mvn/wrapper/MavenWrapperDownloader.java
+++ b/.mvn/wrapper/MavenWrapperDownloader.java
@@ -1,117 +1,98 @@
/*
- * Copyright 2007-present the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.
*/
-import java.net.*;
-import java.io.*;
-import java.nio.channels.*;
-import java.util.Properties;
-
-public class MavenWrapperDownloader {
-
- private static final String WRAPPER_VERSION = "0.5.5";
- /**
- * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
- */
- private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
- + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
- /**
- * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
- * use instead of the default one.
- */
- private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
- ".mvn/wrapper/maven-wrapper.properties";
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.Authenticator;
+import java.net.PasswordAuthentication;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
- /**
- * Path where the maven-wrapper.jar will be saved to.
- */
- private static final String MAVEN_WRAPPER_JAR_PATH =
- ".mvn/wrapper/maven-wrapper.jar";
+public final class MavenWrapperDownloader
+{
+ private static final String WRAPPER_VERSION = "3.2.0";
- /**
- * Name of the property which should be used to override the default download url for the wrapper.
- */
- private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
+ private static final boolean VERBOSE = Boolean.parseBoolean( System.getenv( "MVNW_VERBOSE" ) );
- public static void main(String args[]) {
- System.out.println("- Downloader started");
- File baseDirectory = new File(args[0]);
- System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
+ public static void main( String[] args )
+ {
+ log( "Apache Maven Wrapper Downloader " + WRAPPER_VERSION );
- // If the maven-wrapper.properties exists, read it and check if it contains a custom
- // wrapperUrl parameter.
- File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
- String url = DEFAULT_DOWNLOAD_URL;
- if(mavenWrapperPropertyFile.exists()) {
- FileInputStream mavenWrapperPropertyFileInputStream = null;
- try {
- mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
- Properties mavenWrapperProperties = new Properties();
- mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
- url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
- } catch (IOException e) {
- System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
- } finally {
- try {
- if(mavenWrapperPropertyFileInputStream != null) {
- mavenWrapperPropertyFileInputStream.close();
- }
- } catch (IOException e) {
- // Ignore ...
- }
- }
+ if ( args.length != 2 )
+ {
+ System.err.println( " - ERROR wrapperUrl or wrapperJarPath parameter missing" );
+ System.exit( 1 );
}
- System.out.println("- Downloading from: " + url);
- File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
- if(!outputFile.getParentFile().exists()) {
- if(!outputFile.getParentFile().mkdirs()) {
- System.out.println(
- "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
- }
+ try
+ {
+ log( " - Downloader started" );
+ final URL wrapperUrl = new URL( args[0] );
+ final String jarPath = args[1].replace( "..", "" ); // Sanitize path
+ final Path wrapperJarPath = Paths.get( jarPath ).toAbsolutePath().normalize();
+ downloadFileFromURL( wrapperUrl, wrapperJarPath );
+ log( "Done" );
}
- System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
- try {
- downloadFileFromURL(url, outputFile);
- System.out.println("Done");
- System.exit(0);
- } catch (Throwable e) {
- System.out.println("- Error downloading");
- e.printStackTrace();
- System.exit(1);
+ catch ( IOException e )
+ {
+ System.err.println( "- Error downloading: " + e.getMessage() );
+ if ( VERBOSE )
+ {
+ e.printStackTrace();
+ }
+ System.exit( 1 );
}
}
- private static void downloadFileFromURL(String urlString, File destination) throws Exception {
- if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
- String username = System.getenv("MVNW_USERNAME");
- char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
- Authenticator.setDefault(new Authenticator() {
+ private static void downloadFileFromURL( URL wrapperUrl, Path wrapperJarPath )
+ throws IOException
+ {
+ log( " - Downloading to: " + wrapperJarPath );
+ if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null )
+ {
+ final String username = System.getenv( "MVNW_USERNAME" );
+ final char[] password = System.getenv( "MVNW_PASSWORD" ).toCharArray();
+ Authenticator.setDefault( new Authenticator()
+ {
@Override
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(username, password);
+ protected PasswordAuthentication getPasswordAuthentication()
+ {
+ return new PasswordAuthentication( username, password );
}
- });
+ } );
+ }
+ try ( InputStream inStream = wrapperUrl.openStream() )
+ {
+ Files.copy( inStream, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING );
+ }
+ log( " - Downloader complete" );
+ }
+
+ private static void log( String msg )
+ {
+ if ( VERBOSE )
+ {
+ System.out.println( msg );
}
- URL website = new URL(urlString);
- ReadableByteChannel rbc;
- rbc = Channels.newChannel(website.openStream());
- FileOutputStream fos = new FileOutputStream(destination);
- fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
- fos.close();
- rbc.close();
}
}
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
index fa87ad7..346d645 100644
--- a/.mvn/wrapper/maven-wrapper.properties
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -1,2 +1,18 @@
-distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip
-wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar
+# 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.6/apache-maven-3.9.6-bin.zip
+wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
diff --git a/.settings/.gitignore b/.settings/.gitignore
deleted file mode 100644
index 0924da4..0000000
--- a/.settings/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/org.eclipse.m2e.core.prefs
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..a3e26a1
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,37 @@
+# Changelog
+All notable changes to this project will be documented in this file.
+
+## [Unreleased]
+
+## [2.1] - 2024-04-01
+### :bug: Bug Fixes
+- `Stringprep::getProvider` was not working on the module path.
+
+### :sparkles: New features
+- The Profile interface now has overloaded methods with `char[]` versions.
+
+### :building_construction: Improvements
+- The Java modules profiles `com.ongres.saslprep` and `com.ongres.nameprep` have implied readability with `com.ongres.stringprep`.
+- Exports the packages of the profiles in the module declaration to allow creating instances without the ServiceLoader lookup.
+- Introduce the annotation `@ProfileName` to declare the name of the profile used for ServiceLoader lookup.
+- Now the released jars are reproducible.
+- Publish CycloneDX SBOM.
+
+## [2.0] - 2021-02-01
+### :boom: Breaking changes
+- Full rewrite of the `stringprep` implementation, this release is compatible with Java 8+.
+
+### :sparkles: New features
+- The stringprep profiles can be created by implementing the `Profile` interface.
+- New module `nameprep` implementing the stringprep `Profile`.
+- Create Multi-release Modular JARs, the modules names are:
+ - `com.ongres.stringprep`
+ - `com.ongres.saslprep`
+ - `com.ongres.nameprep`
+
+### :building_construction: Improvements
+- Refactor of the `stringprep` implementation to make it extensible and modular, now this implemenation is considered feature-complete.
+- Change the module `saslprep` to implement the stringprep `Profile` interface.
+
+[Unreleased]: https://gitlab.com/ongresinc/stringprep/-/compare/2.0...main
+[2.0]: https://gitlab.com/ongresinc/stringprep/-/compare/1.1...2.0
diff --git a/LICENSE b/LICENSE
index 84b3fe0..809c9ff 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright 2019, OnGres.
+Copyright 2019, OnGres, Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
diff --git a/NOTICE b/NOTICE
deleted file mode 100644
index c36a807..0000000
--- a/NOTICE
+++ /dev/null
@@ -1,9 +0,0 @@
-This source code includes source code from other projects. Below the list
-of the project were the source code has been copied together with the
-path of the copied source files, their license, their notice (if any)
-and the modification that have been done.
-
-1. org.apache.velocity with the artifacts velocity and velocity-tools
-
-Module codegenerator needs these dependencies to generate the class StringPrep dynamically.
-The dependency org.apache.velocity is licensed under the Apache 2.0 license (see thirdparty/velocity-LICENSE).
\ No newline at end of file
diff --git a/README.md b/README.md
index 54f4237..1f34d2e 100644
--- a/README.md
+++ b/README.md
@@ -1,41 +1,110 @@
-# StringPrep and SaslPrep implementation
+# Stringprep (RFC 3454) Java implementation
+
+> Preparation of Internationalized Strings ("stringprep")
## Overview
-StringPrep is the preparation of internationalized strings
-([stringprep, RFC 3454](https://tools.ietf.org/html/rfc3454)).
-SaslPrep is a profile of stringprep for user names and passwords
-([saslprep, RFC 4013](https://tools.ietf.org/html/rfc4013)).
+This project implements the [RFC 3454](https://tools.ietf.org/html/rfc3454) Preparation of Internationalized Strings ("stringprep") in pure Java.
-## Goals
+[](https://maven-badges.herokuapp.com/maven-central/com.ongres.stringprep/stringprep)
-This project aims to provide a implementation of these algorithms.
-It is written in Java and provided in a modular, re-usable way, independent of
-other software or programs.
+The stringprep protocol does not stand on its own; it has to be used by other protocols at precisely-defined places in those other protocols.
-Current functionality includes:
+## Profiles
-* Parsers with the different steps for preparing string. The data is obtained from a file with the rules of the RFC.
-* StringPrep dynamic class with the different types of: map, normalize, prohibit and check bidi possibles.
-* SaslPrep with the specific steps of StringPrep.
-* Tests with the RFC example and several tests of each steps.
+### SASLprep (RFC 4013)
+
+`SASLprep` is a profile of stringprep for user names and passwords ([RFC 4013](https://tools.ietf.org/html/rfc4013)).
+
+Import Maven dependency:
+
+[](https://maven-badges.herokuapp.com/maven-central/com.ongres.stringprep/saslprep)
+
+```xml
+
+ com.ongres.stringprep
+ saslprep
+ 2.0
+
+```
+
+### Nameprep (RFC 3491)
+
+`Nameprep` is a Stringprep Profile for Internationalized Domain Names (IDN) ([RFC 3491](https://tools.ietf.org/html/rfc3491)).
+
+Import Maven dependency:
+
+[](https://maven-badges.herokuapp.com/maven-central/com.ongres.stringprep/nameprep)
-## Saslprep
+```xml
+
+ com.ongres.stringprep
+ nameprep
+ 2.0
+
+```
-'saslprep' is the module that contains the saslprep profile of StringPrep.
-Import maven dependency:
+## Usage
-
- com.ongres.stringprep
- saslprep
-
-
+The normal usage is to import the dependency of the Stringprep profile to use, and lookup the provider service that contains the profile.
-## Contributing
+### Example:
+Import the `SASLprep` dependency, this transitively imports the `Stringprep` dependency.
+```xml
+
+ com.ongres.stringprep
+ saslprep
+ 2.0
+
+```
-Please submit [Merge Requests](https://gitlab.com/ongresinc/stringprep) for code contributions.
-Make sure to compile with `mvn compile -P safer` before submitting a MR.
+Get the `SASLprep` provider service:
+```java
+Profile saslPrep = Stringprep.getProvider("SASLprep");
+String prepared = saslPrep.prepareStored("I\u00ADX \u2168");
+prepared.equals("IX IX"); // true
+```
-Releases (on the master branch only) must be verified with:
+You could also (only) use the stringprep dependency to create your own profiles by implementing the `Profile` interface, just override the `profile()` method with the set of options.
- mvn -P safer -Pmaster-branch
\ No newline at end of file
+Anonymous on-the-fly profile usage:
+```java
+Profile saslPrep = () -> EnumSet.of(Option.NORMALIZE_KC, Option.MAP_TO_NOTHING);
+String prepared = saslPrep.prepareStored("I\u00ADX ⑳");
+prepared.equals("IX 20"); // true
+```
+
+> Please note that when two protocols that use different profiles of stringprep interoperate, there may be conflict about what characters are and are not allowed in the final string. Thus, protocol developers should strongly consider re-using existing profiles of stringprep.
+
+### Java Modules (JPMS):
+The Stringprep and profiles implementation are explicit Java modules with the names:
+
+* `com.ongres.stringprep`
+* `com.ongres.saslprep`
+* `com.ongres.nameprep`
+
+If you depend on a specific profile (`saslprep` or `nameprep`) there is an implied readability on `stringprep`, so you will only need to declare in your `module-info.java` the profile module and get the service from the provider.
+
+Example `module-info.java`:
+```java
+module test.app {
+ requires com.ongres.saslprep;
+}
+```
+
+## Goals
+
+This project aims to provide a implementation of these algorithms.
+It is written in Java and provided in a modular, re-usable way, independent of other software or programs.
+
+Current functionality includes:
+
+* Parsers with the different steps for preparing string. The data is obtained from files with the rules of the RFC.
+* Provide a `Profile` interface working as the base for implementing different profiles of Stringprep.
+* Include the preparation of two types of strings "stored strings" and "queries".
+* `SASLprep` profile with the specific options of Stringprep.
+* `Nameprep` profile with the specific options of Stringprep.
+* Tests with the RFC example and several tests of each steps.
+* Multi-release Modular JARs, compatible with Java 8+.
+* Zero-depdency, each profile depends only on the Stringprep module.
+* New Stringprep profiles could be implemented easily and even "on-the-fly".
diff --git a/checks/checkstyle-header.txt b/checks/checkstyle-header.txt
new file mode 100644
index 0000000..7401973
--- /dev/null
+++ b/checks/checkstyle-header.txt
@@ -0,0 +1,4 @@
+^\/\*$
+^ \* Copyright \(C\) 20[12]\d OnGres, Inc\.$
+^ \* SPDX-License-Identifier: BSD-2-Clause$
+^ \*\/$
\ No newline at end of file
diff --git a/checks/checkstyle-suppressions.xml b/checks/checkstyle-suppressions.xml
new file mode 100644
index 0000000..7129fc8
--- /dev/null
+++ b/checks/checkstyle-suppressions.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/checks/checkstyle.xml b/checks/checkstyle.xml
new file mode 100644
index 0000000..64ddd55
--- /dev/null
+++ b/checks/checkstyle.xml
@@ -0,0 +1,310 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/checks/pmd-ruleset.xml b/checks/pmd-ruleset.xml
new file mode 100644
index 0000000..5542431
--- /dev/null
+++ b/checks/pmd-ruleset.xml
@@ -0,0 +1,42 @@
+
+
+
+ Custom Rules
+
+ .*/target/.*
+ .*/generated/.*
+ .*/Tables.java
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/checks/spotbugs-exclude.xml b/checks/spotbugs-exclude.xml
new file mode 100644
index 0000000..708a899
--- /dev/null
+++ b/checks/spotbugs-exclude.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/codegen/pom.xml b/codegen/pom.xml
new file mode 100644
index 0000000..1ed210c
--- /dev/null
+++ b/codegen/pom.xml
@@ -0,0 +1,28 @@
+
+
+ 4.0.0
+
+
+ com.ongres.stringprep
+ stringprep-parent
+ 2.1
+ ../parent/pom.xml
+
+
+ codegen
+ Tables Code Generator
+ Code Generator for StringPrep tables
+
+
+ true
+ ${project.basedir}/../checks
+
+
+
+
+ org.apache.velocity
+ velocity-engine-core
+ 2.3
+
+
+
diff --git a/codegen/src/main/java/com/ongres/stringprep/codegen/GeneratorCode.java b/codegen/src/main/java/com/ongres/stringprep/codegen/GeneratorCode.java
new file mode 100644
index 0000000..bdf40e5
--- /dev/null
+++ b/codegen/src/main/java/com/ongres/stringprep/codegen/GeneratorCode.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2019 OnGres, Inc.
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+package com.ongres.stringprep.codegen;
+
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.NotDirectoryException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import com.ongres.stringprep.codegen.parsers.Parser;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+
+/**
+ * Stringprep tables class generator.
+ */
+public final class GeneratorCode {
+
+ private GeneratorCode() {
+ throw new AssertionError();
+ }
+
+ /**
+ * Generate StringPrep class dynamically.
+ *
+ * @param args with the path used to generate StringPrep class
+ * @throws IOException if a RFC file can't be read
+ */
+ public static void main(String[] args) throws IOException {
+ Path sourceDirectory = Paths.get(System.getProperty("sourceDirectory")).normalize();
+ if (!Files.isDirectory(sourceDirectory)) {
+ throw new NotDirectoryException(sourceDirectory.toString());
+ }
+
+ VelocityEngine velocityEngine = new VelocityEngine();
+ velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADERS,
+ RuntimeConstants.RESOURCE_LOADER_CLASS);
+ velocityEngine.setProperty("resource.loader.class.class",
+ "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
+ velocityEngine.init();
+
+ Template template = velocityEngine.getTemplate("templates/StringPrepTables.vm");
+ VelocityContext ctx = new VelocityContext();
+ ctx.put("parser", new Parser());
+
+ Path path = sourceDirectory.resolve("com/ongres/stringprep/Tables.java");
+ Files.deleteIfExists(path);
+ try (Writer writer = new OutputStreamWriter(Files.newOutputStream(path), StandardCharsets.UTF_8)) {
+ template.merge(ctx, writer);
+ }
+ }
+
+}
diff --git a/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/Parser.java b/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/Parser.java
new file mode 100644
index 0000000..d221d3a
--- /dev/null
+++ b/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/Parser.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2019 OnGres, Inc.
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+package com.ongres.stringprep.codegen.parsers;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * List of the tables parsed to the generator engine.
+ */
+public class Parser {
+
+ public List> getUnassignedCodePoints() {
+ return ParserUnicodeRepertoires.getUnassignedCodePoints();
+ }
+
+ public List getMapToNothing() {
+ return ParserMappingTables.getMapToNothing();
+ }
+
+ public Map> getMapUsedWithNfkc() {
+ return ParserMappingTables.getMapUsedWithNfkc();
+ }
+
+ public Map> getMapUsedWithNoNormalization() {
+ return ParserMappingTables.getMapUsedWithNoNormalization();
+ }
+
+ public List getAsciiSpace() {
+ return ParserProhibitionTables.getAsciiSpace();
+ }
+
+ public List getNonAsciiSpace() {
+ return ParserProhibitionTables.getNonAsciiSpace();
+ }
+
+ public List> getAsciiControl() {
+ return ParserProhibitionTables.getAsciiControl();
+ }
+
+ public List> getNonAsciiControl() {
+ return ParserProhibitionTables.getNonAsciiControl();
+ }
+
+ public List> getPrivateUse() {
+ return ParserProhibitionTables.getPrivateUse();
+ }
+
+ public List> getNonCharacterCodePoints() {
+ return ParserProhibitionTables.getNonCharacterCodePoints();
+ }
+
+ public List> getSurrogateCodes() {
+ return ParserProhibitionTables.getSurrogateCodes();
+ }
+
+ public List> getInappropriatePlainText() {
+ return ParserProhibitionTables.getInappropriatePlainText();
+ }
+
+ public List> getInappropriateCanonicalRepresentation() {
+ return ParserProhibitionTables.getInappropriateCanonicalRepresentation();
+ }
+
+ public List> getChangeDisplayProperties() {
+ return ParserProhibitionTables.getChangeDisplayProperties();
+ }
+
+ public List> getTaggingCharacters() {
+ return ParserProhibitionTables.getTaggingCharacters();
+ }
+
+ public List> getPropertyRorAL() {
+ return ParserBidirectionalTables.getBidirectionalPropertyRorAL();
+ }
+
+ public List> getPropertyL() {
+ return ParserBidirectionalTables.getBidirectionalPropertyL();
+ }
+}
diff --git a/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserBidirectionalTables.java b/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserBidirectionalTables.java
new file mode 100644
index 0000000..1c6eef1
--- /dev/null
+++ b/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserBidirectionalTables.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2019 OnGres, Inc.
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+package com.ongres.stringprep.codegen.parsers;
+
+import java.util.List;
+
+final class ParserBidirectionalTables {
+
+ private ParserBidirectionalTables() {
+ throw new AssertionError();
+ }
+
+ public static List> getBidirectionalPropertyRorAL() {
+ return ParserUtil.parseToListArrayInt("/rfcs/d1.txt");
+ }
+
+ public static List> getBidirectionalPropertyL() {
+ return ParserUtil.parseToListArrayInt("/rfcs/d2.txt");
+ }
+}
diff --git a/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserMappingTables.java b/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserMappingTables.java
new file mode 100644
index 0000000..1b456b8
--- /dev/null
+++ b/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserMappingTables.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2019 OnGres, Inc.
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+package com.ongres.stringprep.codegen.parsers;
+
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+final class ParserMappingTables {
+
+ private static final Pattern LINE_PATTERN = Pattern.compile("([^;]*);([^;]*);[^;]*");
+ private static final Pattern CODE_POINTS_PATTERN = Pattern.compile("\\s*([0-9A-F]+)");
+
+ private ParserMappingTables() {
+ throw new AssertionError();
+ }
+
+ public static List getMapToNothing() {
+ return ParserUtil.parseToListInteger("/rfcs/b1.txt", LINE_PATTERN);
+ }
+
+ public static Map> getMapUsedWithNfkc() {
+ return ParserUtil.parseToMapListInteger("/rfcs/b2.txt", LINE_PATTERN, CODE_POINTS_PATTERN);
+ }
+
+ public static Map> getMapUsedWithNoNormalization() {
+ return ParserUtil.parseToMapListInteger("/rfcs/b3.txt", LINE_PATTERN, CODE_POINTS_PATTERN);
+ }
+}
diff --git a/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserProhibitionTables.java b/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserProhibitionTables.java
new file mode 100644
index 0000000..a04b732
--- /dev/null
+++ b/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserProhibitionTables.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2019 OnGres, Inc.
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+package com.ongres.stringprep.codegen.parsers;
+
+import java.util.List;
+import java.util.regex.Pattern;
+
+final class ParserProhibitionTables {
+
+ private static final Pattern PROHIBITION_PATTERN = Pattern.compile("([^;]*);[^;]*");
+
+ private ParserProhibitionTables() {
+ throw new AssertionError();
+ }
+
+ public static List getAsciiSpace() {
+ return ParserUtil.parseToListInteger("/rfcs/c1.1.txt", PROHIBITION_PATTERN);
+ }
+
+ public static List getNonAsciiSpace() {
+ return ParserUtil.parseToListInteger("/rfcs/c1.2.txt", PROHIBITION_PATTERN);
+ }
+
+ public static List> getAsciiControl() {
+ return ParserUtil.parseToListArrayInt("/rfcs/c2.1.txt", PROHIBITION_PATTERN);
+ }
+
+ public static List> getNonAsciiControl() {
+ return ParserUtil.parseToListArrayInt("/rfcs/c2.2.txt", PROHIBITION_PATTERN);
+ }
+
+ public static List> getPrivateUse() {
+ return ParserUtil.parseToListArrayInt("/rfcs/c3.txt", PROHIBITION_PATTERN);
+ }
+
+ public static List> getNonCharacterCodePoints() {
+ return ParserUtil.parseToListArrayInt("/rfcs/c4.txt", PROHIBITION_PATTERN);
+ }
+
+ public static List> getSurrogateCodes() {
+ return ParserUtil.parseToListArrayInt("/rfcs/c5.txt", PROHIBITION_PATTERN);
+ }
+
+ public static List> getInappropriatePlainText() {
+ return ParserUtil.parseToListArrayInt("/rfcs/c6.txt", PROHIBITION_PATTERN);
+ }
+
+ public static List> getInappropriateCanonicalRepresentation() {
+ return ParserUtil.parseToListArrayInt("/rfcs/c7.txt", PROHIBITION_PATTERN);
+ }
+
+ public static List> getChangeDisplayProperties() {
+ return ParserUtil.parseToListArrayInt("/rfcs/c8.txt", PROHIBITION_PATTERN);
+ }
+
+ public static List> getTaggingCharacters() {
+ return ParserUtil.parseToListArrayInt("/rfcs/c9.txt", PROHIBITION_PATTERN);
+ }
+
+}
diff --git a/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserUnicodeRepertoires.java b/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserUnicodeRepertoires.java
new file mode 100644
index 0000000..d43971b
--- /dev/null
+++ b/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserUnicodeRepertoires.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2019 OnGres, Inc.
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+package com.ongres.stringprep.codegen.parsers;
+
+import java.util.List;
+
+final class ParserUnicodeRepertoires {
+
+ private ParserUnicodeRepertoires() {
+ throw new AssertionError();
+ }
+
+ public static List> getUnassignedCodePoints() {
+ return ParserUtil.parseToListArrayInt("/rfcs/a1.txt");
+ }
+}
diff --git a/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserUtil.java b/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserUtil.java
new file mode 100644
index 0000000..7f83712
--- /dev/null
+++ b/codegen/src/main/java/com/ongres/stringprep/codegen/parsers/ParserUtil.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2019 OnGres, Inc.
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+package com.ongres.stringprep.codegen.parsers;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UncheckedIOException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+final class ParserUtil {
+
+ private static final Pattern SPACE_PATTERN = Pattern.compile("\\s");
+
+ private ParserUtil() {
+ throw new AssertionError();
+ }
+
+ /**
+ * Parse a file with hexadecimal to a list of integers.
+ *
+ * @param file with the RFC file to parse
+ * @param pattern of the lines
+ * @return list of integers
+ */
+ public static List parseToListInteger(String file, Pattern pattern) {
+ InputStream inputStream = ParserUtil.class.getResourceAsStream(file);
+ try (BufferedReader bufferedReader = new BufferedReader(
+ new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
+ String line = null;
+ List codePoints = new ArrayList<>();
+ while (null != (line = bufferedReader.readLine())) {
+ Matcher matcherLine = pattern.matcher(line);
+ if (matcherLine.matches()) {
+ String mappedFrom = SPACE_PATTERN.matcher(matcherLine.group(1)).replaceAll("");
+ codePoints.add("0x" + mappedFrom);
+ }
+ }
+ return Collections.unmodifiableList(codePoints);
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
+ /**
+ * Parse a file with mappings to a map of list of integers.
+ *
+ * @param file with THE RFC file to parse
+ * @param patternLine pattern of the lines
+ * @param mapTo pattern of the conversion
+ * @return map of list of integers
+ */
+ public static Map> parseToMapListInteger(String file, Pattern patternLine,
+ Pattern mapTo) {
+ InputStream inputStream = ParserUtil.class.getResourceAsStream(file);
+ try (BufferedReader bufferedReader = new BufferedReader(
+ new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
+ String line = null;
+ Map> mapWithNoNormalization = new HashMap<>();
+ while (null != (line = bufferedReader.readLine())) {
+ Matcher matcherLine = patternLine.matcher(line);
+ if (matcherLine.matches()) {
+ List codePoints = new ArrayList<>();
+ String mappedFrom = matcherLine.group(1);
+ String mappedTo = matcherLine.group(2);
+ Matcher matcherCodePoints = mapTo.matcher(mappedTo);
+ while (matcherCodePoints.find()) {
+ codePoints.add("0x" + matcherCodePoints.group(1));
+ }
+ String mapped = SPACE_PATTERN.matcher(mappedFrom).replaceAll("");
+ mapWithNoNormalization.put("0x" + mapped, codePoints);
+ }
+ }
+ return Collections.unmodifiableMap(mapWithNoNormalization);
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
+ /**
+ * Parse a file with ranges of hexadecimal to a list of list of integers.
+ *
+ * @param file with the RFC file to parse
+ * @return list of list of integers
+ */
+ public static List> parseToListArrayInt(String file) {
+ return parseToListArrayInt(file, null);
+ }
+
+ /**
+ * Parse a file with ranges of hexadecimal to a list of list of integers.
+ *
+ * @param file with the RFC file to parse
+ * @param pattern of the lines
+ * @return list of list of integers
+ */
+ public static List> parseToListArrayInt(String file, Pattern pattern) {
+ InputStream inputStream = ParserUtil.class.getResourceAsStream(file);
+ try (BufferedReader bufferedReader = new BufferedReader(
+ new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
+ String line = null;
+ List> codePoints = new ArrayList<>();
+ if (null != pattern) {
+ while (null != (line = bufferedReader.readLine())) {
+ Matcher matcherLine = pattern.matcher(line);
+ if (matcherLine.matches()) {
+ fillList(codePoints, SPACE_PATTERN.matcher(matcherLine.group(1)).replaceAll(""));
+ }
+ }
+ } else {
+ while (null != (line = bufferedReader.readLine())) {
+ fillList(codePoints, SPACE_PATTERN.matcher(line).replaceAll(""));
+ }
+ }
+ return Collections.unmodifiableList(codePoints);
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
+ private static void fillList(List> codePoints, String value) {
+ List characters = new ArrayList<>();
+ if (value.contains("-")) {
+ int separator = value.indexOf('-');
+ characters.add("0x" + value.substring(0, separator));
+ characters.add("0x" + value.substring(separator + 1));
+ } else {
+ characters.add("0x" + value);
+ characters.add("0x" + value);
+ }
+ codePoints.add(characters);
+ }
+
+}
diff --git a/codegenerator/src/main/resources/rfcs/a1 b/codegen/src/main/resources/rfcs/a1.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/a1
rename to codegen/src/main/resources/rfcs/a1.txt
diff --git a/codegenerator/src/main/resources/rfcs/b1 b/codegen/src/main/resources/rfcs/b1.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/b1
rename to codegen/src/main/resources/rfcs/b1.txt
diff --git a/codegenerator/src/main/resources/rfcs/b2 b/codegen/src/main/resources/rfcs/b2.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/b2
rename to codegen/src/main/resources/rfcs/b2.txt
diff --git a/codegenerator/src/main/resources/rfcs/b3 b/codegen/src/main/resources/rfcs/b3.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/b3
rename to codegen/src/main/resources/rfcs/b3.txt
diff --git a/codegenerator/src/main/resources/rfcs/c1.1 b/codegen/src/main/resources/rfcs/c1.1.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/c1.1
rename to codegen/src/main/resources/rfcs/c1.1.txt
diff --git a/codegenerator/src/main/resources/rfcs/c1.2 b/codegen/src/main/resources/rfcs/c1.2.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/c1.2
rename to codegen/src/main/resources/rfcs/c1.2.txt
diff --git a/codegenerator/src/main/resources/rfcs/c2.1 b/codegen/src/main/resources/rfcs/c2.1.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/c2.1
rename to codegen/src/main/resources/rfcs/c2.1.txt
diff --git a/codegenerator/src/main/resources/rfcs/c2.2 b/codegen/src/main/resources/rfcs/c2.2.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/c2.2
rename to codegen/src/main/resources/rfcs/c2.2.txt
diff --git a/codegenerator/src/main/resources/rfcs/c3 b/codegen/src/main/resources/rfcs/c3.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/c3
rename to codegen/src/main/resources/rfcs/c3.txt
diff --git a/codegenerator/src/main/resources/rfcs/c4 b/codegen/src/main/resources/rfcs/c4.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/c4
rename to codegen/src/main/resources/rfcs/c4.txt
diff --git a/codegenerator/src/main/resources/rfcs/c5 b/codegen/src/main/resources/rfcs/c5.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/c5
rename to codegen/src/main/resources/rfcs/c5.txt
diff --git a/codegenerator/src/main/resources/rfcs/c6 b/codegen/src/main/resources/rfcs/c6.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/c6
rename to codegen/src/main/resources/rfcs/c6.txt
diff --git a/codegenerator/src/main/resources/rfcs/c7 b/codegen/src/main/resources/rfcs/c7.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/c7
rename to codegen/src/main/resources/rfcs/c7.txt
diff --git a/codegenerator/src/main/resources/rfcs/c8 b/codegen/src/main/resources/rfcs/c8.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/c8
rename to codegen/src/main/resources/rfcs/c8.txt
diff --git a/codegenerator/src/main/resources/rfcs/c9 b/codegen/src/main/resources/rfcs/c9.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/c9
rename to codegen/src/main/resources/rfcs/c9.txt
diff --git a/codegenerator/src/main/resources/rfcs/d1 b/codegen/src/main/resources/rfcs/d1.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/d1
rename to codegen/src/main/resources/rfcs/d1.txt
diff --git a/codegenerator/src/main/resources/rfcs/d2 b/codegen/src/main/resources/rfcs/d2.txt
similarity index 100%
rename from codegenerator/src/main/resources/rfcs/d2
rename to codegen/src/main/resources/rfcs/d2.txt
diff --git a/codegen/src/main/resources/templates/StringPrepTables.vm b/codegen/src/main/resources/templates/StringPrepTables.vm
new file mode 100644
index 0000000..069b497
--- /dev/null
+++ b/codegen/src/main/resources/templates/StringPrepTables.vm
@@ -0,0 +1,323 @@
+/*
+ * Copyright (C) 2019 OnGres, Inc.
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+package com.ongres.stringprep;
+
+// AUTO-GENERATED FILE - DO NOT EDIT!
+
+/**
+ * Expose tables parsed from the StringPrep RFC-3454.
+ */
+public final class Tables {
+
+ private Tables() {
+ throw new AssertionError();
+ }
+
+ /**
+ * Unassigned code points in Unicode 3.2.
+ *
+ * @param codePoint the character (Unicode code point) to be tested.
+ * @return {@code true} if the given {@code codePoint} is
+ * "Unassigned code points in Unicode 3.2".
+ * @see RFC 3454, Appendix A.1
+ */
+ public static boolean unassignedCodePoints(int codePoint) {
+ return #foreach( $unassignedCodePoints in $parser.getUnassignedCodePoints() )
+#if( $unassignedCodePoints.get(0) == $unassignedCodePoints.get(1) )
+codePoint == $unassignedCodePoints.get(0)
+#else
+(codePoint >= $unassignedCodePoints.get(0) && codePoint <= $unassignedCodePoints.get(1))
+#end
+#if($foreach.hasNext) || #end#end
+ ;
+ }
+
+ /**
+ * Commonly mapped to nothing.
+ *
+ * @param codePoint the character (Unicode code point) to be tested.
+ * @return {@code true} if the given {@code codePoint} is "Commonly mapped to nothing".
+ * @see RFC 3454, Appendix B.1
+ */
+ public static boolean mapToNothing(int codePoint) {
+ return #foreach( $mapToNothing in $parser.getMapToNothing() )
+codePoint == $mapToNothing
+#if( $foreach.hasNext ) || #end#end
+ ;
+ }
+
+ /**
+ * Mapping for case-folding used with NFKC.
+ *
+ * @param codePoint the character (Unicode code point) to be mapped.
+ * @return Case-folding used with NFKC for the given {@code codePoint}.
+ * @see RFC 3454, Appendix B.2
+ */
+ public static int[] mapWithNfkc(int codePoint) {
+#set ($mapNfkc = $parser.getMapUsedWithNfkc())
+ switch (codePoint) {
+#foreach($mapUsedWithNfkc in $mapNfkc.keySet())
+ case $mapUsedWithNfkc:
+#set ($valuesNfkc = $mapNfkc.get($mapUsedWithNfkc) )
+ return new int[] {#foreach($value in $valuesNfkc)$value#if($foreach.hasNext), #end#end};
+#end
+ default:
+ return new int[] {codePoint};
+ }
+ }
+
+ /**
+ * Mapping for case-folding used with no normalization.
+ *
+ * @param codePoint the character (Unicode code point) to be mapped.
+ * @return Case-folding used with no normalization for the given {@code codePoint}.
+ * @see RFC 3454, Appendix B.3
+ */
+ public static int[] mapWithoutNormalization(int codePoint) {
+#set ( $mapNormal = $parser.getMapUsedWithNoNormalization() )
+ switch (codePoint) {
+#foreach($mapUsedWithNoNormalization in $mapNormal.keySet() )
+ case $mapUsedWithNoNormalization:
+#set ($valuesNormal = $mapNormal.get($mapUsedWithNoNormalization))
+ return new int[] {#foreach($value in $valuesNormal)$value#if($foreach.hasNext), #end#end};
+#end
+ default:
+ return new int[] {codePoint};
+ }
+ }
+
+ /**
+ * ASCII space characters.
+ *
+ * @param codePoint the character (Unicode code point) to be tested.
+ * @return {@code true} if the given {@code codePoint} is "ASCII space characters".
+ * @see RFC 3454, Appendix C.1.1
+ */
+ public static boolean prohibitionAsciiSpace(int codePoint) {
+ return #foreach( $asciiSpace in $parser.getAsciiSpace() )
+codePoint == $asciiSpace
+#if( $foreach.hasNext ) || #end#end
+ ;
+ }
+
+ /**
+ * Non-ASCII space characters.
+ *
+ * @param codePoint the character (Unicode code point) to be tested.
+ * @return {@code true} if the given {@code codePoint} is "Non-ASCII space characters".
+ * @see RFC 3454, Appendix C.1.2
+ */
+ public static boolean prohibitionNonAsciiSpace(int codePoint) {
+ return #foreach( $nonAsciiSpace in $parser.getNonAsciiSpace() )
+codePoint == $nonAsciiSpace
+#if( $foreach.hasNext ) || #end#end
+ ;
+ }
+
+ /**
+ * ASCII control characters.
+ *
+ * @param codePoint the character (Unicode code point) to be tested.
+ * @return {@code true} if the given {@code codePoint} is "ASCII control characters".
+ * @see RFC 3454, Appendix C.2.1
+ */
+ public static boolean prohibitionAsciiControl(int codePoint) {
+ return #foreach( $asciiControl in $parser.getAsciiControl() )
+#if( $asciiControl.get(0) == $asciiControl.get(1) )
+codePoint == $asciiControl.get(0)
+#else
+(codePoint >= $asciiControl.get(0) && codePoint <= $asciiControl.get(1))
+#end
+#if( $foreach.hasNext ) || #end#end
+ ;
+ }
+
+ /**
+ * Non-ASCII control characters.
+ *
+ * @param codePoint the character (Unicode code point) to be tested.
+ * @return {@code true} if the given {@code codePoint} is "Non-ASCII control characters".
+ * @see RFC 3454, Appendix C.2.2
+ */
+ public static boolean prohibitionNonAsciiControl(int codePoint) {
+ return #foreach( $nonAsciiControl in $parser.getNonAsciiControl() )
+#if( $nonAsciiControl.get(0) == $nonAsciiControl.get(1) )
+codePoint == $nonAsciiControl.get(0)
+#else
+(codePoint >= $nonAsciiControl.get(0) && codePoint <= $nonAsciiControl.get(1))
+#end
+#if( $foreach.hasNext ) || #end#end
+ ;
+ }
+
+ /**
+ * Private use.
+ *
+ * @param codePoint the character (Unicode code point) to be tested.
+ * @return {@code true} if the given {@code codePoint} is "Private use".
+ * @see RFC 3454, Appendix C.3
+ */
+ public static boolean prohibitionPrivateUse(int codePoint) {
+ return #foreach( $privateUse in $parser.getPrivateUse() )
+#if( $privateUse.get(0) == $privateUse.get(1) )
+codePoint == $privateUse.get(0)
+#else
+(codePoint >= $privateUse.get(0) && codePoint <= $privateUse.get(1))
+#end
+#if( $foreach.hasNext ) || #end#end
+ ;
+ }
+
+ /**
+ * Non-character code points.
+ *
+ * @param codePoint the character (Unicode code point) to be tested.
+ * @return {@code true} if the given {@code codePoint} is "Non-character code points".
+ * @see RFC 3454, Appendix C.4
+ */
+ public static boolean prohibitionNonCharacterCodePoints(int codePoint) {
+ return #foreach( $nonCharacterCodePoints in $parser.getNonCharacterCodePoints() )
+#if( $nonCharacterCodePoints.get(0) == $nonCharacterCodePoints.get(1) )
+codePoint == $nonCharacterCodePoints.get(0)
+#else
+(codePoint >= $nonCharacterCodePoints.get(0) && codePoint <= $nonCharacterCodePoints.get(1))
+#end
+#if( $foreach.hasNext ) || #end#end
+ ;
+ }
+
+ /**
+ * Surrogate codes.
+ *
+ * @param codePoint the character (Unicode code point) to be tested.
+ * @return {@code true} if the given {@code codePoint} is "Surrogate codes".
+ * @see RFC 3454, Appendix C.5
+ */
+ public static boolean prohibitionSurrogateCodes(int codePoint) {
+ return #foreach( $surrogateCodes in $parser.getSurrogateCodes() )
+#if( $surrogateCodes.get(0) == $surrogateCodes.get(1) )
+codePoint == $surrogateCodes.get(0)
+#else
+(codePoint >= $surrogateCodes.get(0) && codePoint <= $surrogateCodes.get(1))
+#end
+#if( $foreach.hasNext ) || #end#end
+ ;
+ }
+
+ /**
+ * Inappropriate for plain text.
+ *
+ * @param codePoint the character (Unicode code point) to be tested.
+ * @return {@code true} if the given {@code codePoint} is
+ * "Inappropriate for plain text".
+ * @see RFC 3454, Appendix C.6
+ */
+ public static boolean prohibitionInappropriatePlainText(int codePoint) {
+ return #foreach( $inappropriatePlainText in $parser.getInappropriatePlainText() )
+#if( $inappropriatePlainText.get(0) == $inappropriatePlainText.get(1) )
+codePoint == $inappropriatePlainText.get(0)
+#else
+(codePoint >= $inappropriatePlainText.get(0) && codePoint <= $inappropriatePlainText.get(1))
+#end
+#if( $foreach.hasNext ) || #end#end
+ ;
+ }
+
+ /**
+ * Inappropriate for canonical representation.
+ *
+ * @param codePoint the character (Unicode code point) to be tested.
+ * @return {@code true} if the given {@code codePoint} is
+ * "Inappropriate for canonical representation".
+ * @see RFC 3454, Appendix C.7
+ */
+ public static boolean prohibitionInappropriateCanonicalRepresentation(int codePoint) {
+ return #foreach( $inappropriateCanonicalRepresentation in $parser.getInappropriateCanonicalRepresentation() )
+#if( $inappropriateCanonicalRepresentation.get(0) == $inappropriateCanonicalRepresentation.get(1) )
+codePoint == $inappropriateCanonicalRepresentation.get(0)
+#else
+(codePoint >= $inappropriateCanonicalRepresentation.get(0) && codePoint <= $inappropriateCanonicalRepresentation.get(1))
+#end
+#if( $foreach.hasNext ) || #end#end
+ ;
+ }
+
+ /**
+ * Change display properties or are deprecated.
+ *
+ * @param codePoint the character (Unicode code point) to be tested.
+ * @return {@code true} if the given {@code codePoint} is
+ * "Change display properties or are deprecated".
+ * @see RFC 3454, Appendix C.8
+ */
+ public static boolean prohibitionChangeDisplayProperties(int codePoint) {
+ return #foreach( $changeDisplayProperties in $parser.getChangeDisplayProperties() )
+#if( $changeDisplayProperties.get(0) == $changeDisplayProperties.get(1) )
+codePoint == $changeDisplayProperties.get(0)
+#else
+(codePoint >= $changeDisplayProperties.get(0) && codePoint <= $changeDisplayProperties.get(1))
+#end
+#if( $foreach.hasNext ) || #end#end
+ ;
+ }
+
+ /**
+ * Tagging characters.
+ *
+ * @param codePoint the character (Unicode code point) to be tested.
+ * @return {@code true} if the given {@code codePoint} is "Tagging characters".
+ * @see RFC 3454, Appendix C.9
+ */
+ public static boolean prohibitionTaggingCharacters(int codePoint) {
+ return #foreach( $taggingCharacters in $parser.getTaggingCharacters() )
+#if( $taggingCharacters.get(0) == $taggingCharacters.get(1) )
+codePoint == $taggingCharacters.get(0)
+#else
+(codePoint >= $taggingCharacters.get(0) && codePoint <= $taggingCharacters.get(1))
+#end
+#if( $foreach.hasNext ) || #end#end
+ ;
+ }
+
+ /**
+ * Characters with bidirectional property "R" or "AL".
+ *
+ * @param codePoint the character (Unicode code point) to be tested.
+ * @return {@code true} if the given {@code codePoint} is
+ * "Characters with bidirectional property R or AL".
+ * @see RFC 3454, Appendix D.1
+ */
+ public static boolean bidirectionalPropertyRorAL(int codePoint) {
+ return #foreach( $propertyRorAL in $parser.getPropertyRorAL() )
+#if( $propertyRorAL.get(0) == $propertyRorAL.get(1) )
+codePoint == $propertyRorAL.get(0)
+#else
+(codePoint >= $propertyRorAL.get(0) && codePoint <= $propertyRorAL.get(1))
+#end
+#if( $foreach.hasNext ) || #end#end
+ ;
+ }
+
+ /**
+ * Characters with bidirectional property "L".
+ *
+ * @param codePoint the character (Unicode code point) to be tested.
+ * @return {@code true} if the given {@code codePoint} is
+ * "Characters with bidirectional property L".
+ * @see RFC 3454, Appendix D.2
+ */
+ public static boolean bidirectionalPropertyL(int codePoint) {
+ return #foreach( $propertyL in $parser.getPropertyL() )
+#if( $propertyL.get(0) == $propertyL.get(1) )
+codePoint == $propertyL.get(0)
+#else
+(codePoint >= $propertyL.get(0) && codePoint <= $propertyL.get(1))
+#end
+#if( $foreach.hasNext ) || #end#end
+ ;
+ }
+
+}
diff --git a/thirdparty/velocity-LICENSE b/codegen/velocity-LICENSE
similarity index 100%
rename from thirdparty/velocity-LICENSE
rename to codegen/velocity-LICENSE
diff --git a/codegenerator/.gitignore b/codegenerator/.gitignore
deleted file mode 100644
index b83d222..0000000
--- a/codegenerator/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/codegenerator/pom.xml b/codegenerator/pom.xml
deleted file mode 100644
index 5bd4d81..0000000
--- a/codegenerator/pom.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
- 4.0.0
-
- com.ongres.stringprep
- parent
- 1.1
-
- codegenerator
-
- UTF-8
- 1.7
-
-
-
- junit
- junit
- test
-
-
- org.apache.velocity
- velocity
- 1.7
-
-
- org.apache.velocity
- velocity-tools
- 2.0
-
-
-
diff --git a/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/GeneratorCode.java b/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/GeneratorCode.java
deleted file mode 100644
index 844eccc..0000000
--- a/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/GeneratorCode.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2019, OnGres.
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
- * following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-package com.ongres.stringprep.codegenerator;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.nio.charset.StandardCharsets;
-
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.apache.velocity.app.VelocityEngine;
-
-@SupportedAnnotationTypes("org.code.generator.Generator")
-@SupportedSourceVersion(SourceVersion.RELEASE_7)
-public class GeneratorCode {
-
- /**
- * Generate StringPrep class dynamically.
- * @param args with the path used to generate StringPrep class
- * @throws IOException if a RFC file can't be read
- */
- public static void main(String[] args) throws IOException {
-
- VelocityEngine velocityEngine = new VelocityEngine();
-
- velocityEngine.setProperty(Velocity.RESOURCE_LOADER, "class");
- velocityEngine.setProperty("class.resource.loader.class",
- "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
-
- velocityEngine.init();
- Template template = velocityEngine.getTemplate("templates/StringPrep.vm");
- VelocityContext ctx = new VelocityContext();
- Parser parser = new Parser();
- ctx.put("parser", parser);
- String path = args[0] + "/com/ongres/stringprep/StringPrep.java";
- File file = new File(path);
- if (!file.getParentFile().mkdirs()) {
- throw new IOException("The directory couldn't be created");
- }
- Writer writer = new OutputStreamWriter(new FileOutputStream(file),StandardCharsets.UTF_8);
- template.merge(ctx, writer);
- writer.close();
- }
-}
diff --git a/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/Parser.java b/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/Parser.java
deleted file mode 100644
index f66375e..0000000
--- a/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/Parser.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright 2019, OnGres.
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
- * following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-package com.ongres.stringprep.codegenerator;
-
-import com.ongres.stringprep.codegenerator.parsers.ParserBidirectionalTables;
-import com.ongres.stringprep.codegenerator.parsers.ParserMappingTables;
-import com.ongres.stringprep.codegenerator.parsers.ParserProhibitionTables;
-import com.ongres.stringprep.codegenerator.parsers.ParserUnicodeRepertoires;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-public class Parser {
-
- private final List> unassignedCodePoints;
- private final List mapToNothing;
- private final Map> mapUsedWithNfkc;
- private final Map> mapUsedWithNoNormalization;
- private final List asciiSpace;
- private final List nonAsciiSpace;
- private final List> asciiControl;
- private final List> nonAsciiControl;
- private final List> privateUse;
- private final List> nonCharacterCodePoints;
- private final List> surrogateCodes;
- private final List> inappropriatePlainText;
- private final List> inappropriateCanonicalRepresentation;
- private final List> changeDisplayProperties;
- private final List> taggingCharacters;
- private final List> propertyRorAL;
- private final List> propertyL;
-
- /**
- * Constructor of Parser class used to read all rfc files.
- * @throws IOException if a RFC file can't be read
- */
- public Parser() throws IOException {
- unassignedCodePoints = ParserUnicodeRepertoires.parseUnassignedCodePoints();
- mapToNothing = ParserMappingTables.parseMapToNothing();
- mapUsedWithNfkc = ParserMappingTables.parseMapUsedWithNfkc();
- mapUsedWithNoNormalization = ParserMappingTables.parseMapUsedWithNoNormalization();
- asciiSpace = ParserProhibitionTables.parseAsciiSpace();
- nonAsciiSpace = ParserProhibitionTables.parseNonAsciiSpace();
- asciiControl = ParserProhibitionTables.parseAsciiControl();
- nonAsciiControl = ParserProhibitionTables.parseNonAsciiControl();
- privateUse = ParserProhibitionTables.parsePrivateUse();
- nonCharacterCodePoints = ParserProhibitionTables.parseNonCharacterCodePoints();
- surrogateCodes = ParserProhibitionTables.parseSurrogateCodes();
- inappropriatePlainText = ParserProhibitionTables.parseInappropriatePlainText();
- inappropriateCanonicalRepresentation =
- ParserProhibitionTables.parseInappropriateCanonicalRepresentation();
- changeDisplayProperties = ParserProhibitionTables.parseChangeDisplayProperties();
- taggingCharacters = ParserProhibitionTables.parseTaggingCharacters();
- propertyRorAL = ParserBidirectionalTables.parseBidirectionalPropertyRorAL();
- propertyL = ParserBidirectionalTables.parseBidirectionalPropertyL();
- }
-
- public List> getUnassignedCodePoints() {
- return unassignedCodePoints;
- }
-
- public List getMapToNothing() {
- return mapToNothing;
- }
-
- public Map> getMapUsedWithNfkc() {
- return mapUsedWithNfkc;
- }
-
- public Map> getMapUsedWithNoNormalization() {
- return mapUsedWithNoNormalization;
- }
-
- public List getAsciiSpace() {
- return asciiSpace;
- }
-
- public List getNonAsciiSpace() {
- return nonAsciiSpace;
- }
-
- public List> getAsciiControl() {
- return asciiControl;
- }
-
- public List> getNonAsciiControl() {
- return nonAsciiControl;
- }
-
- public List> getPrivateUse() {
- return privateUse;
- }
-
- public List> getNonCharacterCodePoints() {
- return nonCharacterCodePoints;
- }
-
- public List> getSurrogateCodes() {
- return surrogateCodes;
- }
-
- public List> getInappropriatePlainText() {
- return inappropriatePlainText;
- }
-
- public List> getInappropriateCanonicalRepresentation() {
- return inappropriateCanonicalRepresentation;
- }
-
- public List> getChangeDisplayProperties() {
- return changeDisplayProperties;
- }
-
- public List> getTaggingCharacters() {
- return taggingCharacters;
- }
-
- public List> getPropertyRorAL() {
- return propertyRorAL;
- }
-
- public List> getPropertyL() {
- return propertyL;
- }
-}
diff --git a/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserBidirectionalTables.java b/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserBidirectionalTables.java
deleted file mode 100644
index 9f13f5c..0000000
--- a/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserBidirectionalTables.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2019, OnGres.
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
- * following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-package com.ongres.stringprep.codegenerator.parsers;
-
-import java.io.IOException;
-import java.util.List;
-
-public class ParserBidirectionalTables {
-
- private ParserBidirectionalTables() {
- }
-
- public static List> parseBidirectionalPropertyRorAL() throws IOException {
- return new ParserUtil().parseToListArrayInt("/rfcs/d1");
- }
-
- public static List> parseBidirectionalPropertyL() throws IOException {
- return new ParserUtil().parseToListArrayInt("/rfcs/d2");
- }
-}
diff --git a/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserMappingTables.java b/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserMappingTables.java
deleted file mode 100644
index 06cde48..0000000
--- a/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserMappingTables.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2019, OnGres.
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
- * following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-package com.ongres.stringprep.codegenerator.parsers;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-public class ParserMappingTables {
-
- private ParserMappingTables() {
- }
-
- private static final Pattern LINE_PATTERN = Pattern.compile("([^;]*);([^;]*);[^;]*");
- private static final Pattern CODE_POINTS_PATTERN = Pattern.compile("\\s*([0-9A-F]+)");
-
- public static List parseMapToNothing() throws IOException {
- return new ParserUtil().parseToListInteger("/rfcs/b1", LINE_PATTERN);
- }
-
- public static Map> parseMapUsedWithNfkc() throws IOException {
- return new ParserUtil().parseToMapListInteger("/rfcs/b2", LINE_PATTERN, CODE_POINTS_PATTERN);
- }
-
- public static Map> parseMapUsedWithNoNormalization() throws IOException {
- return new ParserUtil().parseToMapListInteger("/rfcs/b3", LINE_PATTERN, CODE_POINTS_PATTERN);
- }
-}
diff --git a/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserProhibitionTables.java b/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserProhibitionTables.java
deleted file mode 100644
index 390d63e..0000000
--- a/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserProhibitionTables.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2019, OnGres.
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
- * following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-package com.ongres.stringprep.codegenerator.parsers;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.regex.Pattern;
-
-public class ParserProhibitionTables {
-
- private ParserProhibitionTables() {
- }
-
- private static final Pattern PROHIBITION_PATTERN = Pattern.compile("([^;]*);[^;]*");
-
- public static List parseAsciiSpace() throws IOException {
- return new ParserUtil().parseToListInteger("/rfcs/c1.1", PROHIBITION_PATTERN);
- }
-
- public static List parseNonAsciiSpace() throws IOException {
- return new ParserUtil().parseToListInteger("/rfcs/c1.2", PROHIBITION_PATTERN);
- }
-
- public static List> parseAsciiControl() throws IOException {
- return new ParserUtil().parseToListArrayInt("/rfcs/c2.1", PROHIBITION_PATTERN);
- }
-
- public static List> parseNonAsciiControl() throws IOException {
- return new ParserUtil().parseToListArrayInt("/rfcs/c2.2", PROHIBITION_PATTERN);
- }
-
- public static List> parsePrivateUse() throws IOException {
- return new ParserUtil().parseToListArrayInt("/rfcs/c3", PROHIBITION_PATTERN);
- }
-
- public static List> parseNonCharacterCodePoints() throws IOException {
- return new ParserUtil().parseToListArrayInt("/rfcs/c4", PROHIBITION_PATTERN);
- }
-
- public static List> parseSurrogateCodes() throws IOException {
- return new ParserUtil().parseToListArrayInt("/rfcs/c5", PROHIBITION_PATTERN);
- }
-
- public static List> parseInappropriatePlainText() throws IOException {
- return new ParserUtil().parseToListArrayInt("/rfcs/c6", PROHIBITION_PATTERN);
- }
-
- public static List> parseInappropriateCanonicalRepresentation() throws IOException {
- return new ParserUtil().parseToListArrayInt("/rfcs/c7", PROHIBITION_PATTERN);
- }
-
- public static List> parseChangeDisplayProperties() throws IOException {
- return new ParserUtil().parseToListArrayInt("/rfcs/c8", PROHIBITION_PATTERN);
- }
-
- public static List> parseTaggingCharacters() throws IOException {
- return new ParserUtil().parseToListArrayInt("/rfcs/c9", PROHIBITION_PATTERN);
- }
-}
diff --git a/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserUnicodeRepertoires.java b/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserUnicodeRepertoires.java
deleted file mode 100644
index 0d0182c..0000000
--- a/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserUnicodeRepertoires.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2019, OnGres.
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
- * following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-package com.ongres.stringprep.codegenerator.parsers;
-
-import java.io.IOException;
-import java.util.List;
-
-public class ParserUnicodeRepertoires {
-
- private ParserUnicodeRepertoires() {
- }
-
- public static List> parseUnassignedCodePoints() throws IOException {
- return new ParserUtil().parseToListArrayInt("/rfcs/a1");
- }
-}
diff --git a/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserUtil.java b/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserUtil.java
deleted file mode 100644
index 5e3fc72..0000000
--- a/codegenerator/src/main/java/com/ongres/stringprep/codegenerator/parsers/ParserUtil.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright 2019, OnGres.
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
- * following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-package com.ongres.stringprep.codegenerator.parsers;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class ParserUtil {
-
- /**
- * Parse a file with hexadecimal to a list of integers.
- * @param file with the RFC file to parse
- * @param pattern of the lines
- * @return list of integers
- * @throws IOException if a RFC file can't be read
- */
- public List parseToListInteger(
- String file, Pattern pattern) throws NumberFormatException, IOException {
- InputStream inputStream = ParserUtil.class.getResourceAsStream(file);
- BufferedReader bufferedReader = new BufferedReader(
- new InputStreamReader(inputStream, Charset.defaultCharset()));
- String line = null;
- List codePoints = new ArrayList<>();
- while (null != (line = bufferedReader.readLine())) {
- Matcher matcherLine = pattern.matcher(line);
- if (matcherLine.matches()) {
- String mappedFrom = matcherLine.group(1).replaceAll("\\s","");
- codePoints.add(Integer.parseInt(mappedFrom, 16));
- }
- }
- return codePoints;
- }
-
- /**
- * Parse a file with mappings to a map of list of integers.
- * @param file with THE RFC file to parse
- * @param patternLine pattern of the lines
- * @param mapTo pattern of the conversion
- * @return map of list of integers
- * @throws IOException if a RFC file can't be read
- */
- public Map> parseToMapListInteger(
- String file, Pattern patternLine, Pattern mapTo) throws IOException {
- InputStream inputStream = ParserUtil.class.getResourceAsStream(file);
- BufferedReader bufferedReader = new BufferedReader(
- new InputStreamReader(inputStream, Charset.defaultCharset()));
- String line = null;
- Map> mapWithNoNormalization = new HashMap<>();
- while (null != (line = bufferedReader.readLine())) {
- List codePoints = new ArrayList<>();
- Matcher matcherLine = patternLine.matcher(line);
- if (matcherLine.matches()) {
- String mappedFrom = matcherLine.group(1);
- String mappedTo = matcherLine.group(2);
- Matcher matcherCodePoints = mapTo.matcher(mappedTo);
- while (matcherCodePoints.find()) {
- codePoints.add(Integer.parseInt(matcherCodePoints.group(1), 16));
- }
- String mapped = mappedFrom.replaceAll("\\s", "");
- mapWithNoNormalization.put(Integer.parseInt(mapped, 16), codePoints);
- }
- }
- return mapWithNoNormalization;
- }
-
- /**
- * Parse a file with ranges of hexadecimal to a list of list of integers.
- * @param file with the RFC file to parse
- * @return list of list of integers
- * @throws IOException if a RFC file can't be read
- */
- public List> parseToListArrayInt(
- String file) throws NumberFormatException, IOException {
- return parseToListArrayInt(file, null);
- }
-
- /**
- * Parse a file with ranges of hexadecimal to a list of list of integers.
- * @param file with the RFC file to parse
- * @param pattern of the lines
- * @return list of list of integers
- * @throws IOException if a RFC file can't be read
- */
- public List> parseToListArrayInt(
- String file, Pattern pattern) throws NumberFormatException, IOException {
- InputStream inputStream = ParserUtil.class.getResourceAsStream(file);
- BufferedReader bufferedReader = new BufferedReader(
- new InputStreamReader(inputStream, Charset.defaultCharset()));
- String line = null;
- List> codePoints = new ArrayList<>();
- if (null != pattern) {
- while (null != (line = bufferedReader.readLine())) {
- Matcher matcherLine = pattern.matcher(line);
- if (matcherLine.matches()) {
- fillList(codePoints, matcherLine.group(1).replaceAll("\\s", ""));
- }
- }
- } else {
- while (null != (line = bufferedReader.readLine())) {
- fillList(codePoints, line.replaceAll("\\s", ""));
- }
- }
- return codePoints;
- }
-
- private void fillList(List> codePoints,String value) {
- List characters = new ArrayList<>();
- if (value.contains("-")) {
- int separator = value.indexOf('-');
- characters.add(Integer.parseInt(value.substring(0, separator), 16));
- characters.add(Integer.parseInt(value.substring(separator + 1), 16));
- } else {
- characters.add(Integer.parseInt(value, 16));
- characters.add(Integer.parseInt(value, 16));
- }
- codePoints.add(characters);
- }
-
-}
diff --git a/codegenerator/src/main/resources/templates/StringPrep.vm b/codegenerator/src/main/resources/templates/StringPrep.vm
deleted file mode 100644
index 1f04e03..0000000
--- a/codegenerator/src/main/resources/templates/StringPrep.vm
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright 2019, OnGres.
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
- * following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-package com.ongres.stringprep;
-
-import java.io.IOException;
-import java.util.List;
-
-public class StringPrep {
-
- public static boolean unassignedCodePoints(int codepoint) {
- return
- #foreach( $unassignedCodePoints in $parser.getUnassignedCodePoints() ) #if( $unassignedCodePoints.get(0) == $unassignedCodePoints.get(1) ) codepoint == $unassignedCodePoints.get(0) #else codepoint >= $unassignedCodePoints.get(0) && codepoint <= $unassignedCodePoints.get(1) #end #if( $foreach.hasNext )||
-#end
- #end
-
- ;
- }
-
- public static boolean mapToNothing(int codepoint) {
- return
- #foreach( $mapToNothing in $parser.getMapToNothing() ) codepoint == $mapToNothing #if( $foreach.hasNext )||
-#end
- #end
-
- ;
- }
-
- public static int[] mapUsedWithNfkc(int codepoint) {
- #set ( $mapNfkc = $parser.getMapUsedWithNfkc() )
- switch(codepoint) {
-#foreach( $mapUsedWithNfkc in $mapNfkc.keySet() )
- case( $mapUsedWithNfkc ):
-#set ( $valuesNfkc = $mapNfkc.get($mapUsedWithNfkc) )
- return new int[]{#foreach($value in $valuesNfkc) $value #if($foreach.hasNext),#end#end};
-#end
- default:
- return new int[] { codepoint};
- }
- }
-
- public static int[] mapUsedWithNoNormalization(int codepoint) {
- #set ( $mapNormal = $parser.getMapUsedWithNoNormalization() )
- switch(codepoint) {
-#foreach( $mapUsedWithNoNormalization in $mapNormal.keySet() )
- case( $mapUsedWithNoNormalization ):
-#set ( $valuesNormal = $mapNormal.get($mapUsedWithNoNormalization) )
- return new int[]{#foreach($value in $valuesNormal) $value #if($foreach.hasNext),#end#end};
-#end
- default:
- return new int[] { codepoint};
- }
- }
-
- public static boolean prohibitionAsciiSpace(int codepoint) {
- return
- #foreach( $asciiSpace in $parser.getAsciiSpace() ) codepoint == $asciiSpace #if( $foreach.hasNext )||
-#end
- #end
-
- ;
- }
-
- public static boolean prohibitionNonAsciiSpace(int codepoint) {
- return
- #foreach( $nonAsciiSpace in $parser.getNonAsciiSpace() ) codepoint == $nonAsciiSpace #if( $foreach.hasNext )||
-#end
- #end
-
- ;
- }
-
- public static boolean prohibitionAsciiControl(int codepoint) {
- return
- #foreach( $asciiControl in $parser.getAsciiControl() ) #if( $asciiControl.get(0) == $asciiControl.get(1) ) codepoint == $asciiControl.get(0) #else codepoint >= $asciiControl.get(0) && codepoint <= $asciiControl.get(1) #end #if( $foreach.hasNext )||
-#end
- #end
-
- ;
- }
-
- public static boolean prohibitionNonAsciiControl(int codepoint) {
- return
- #foreach( $nonAsciiControl in $parser.getNonAsciiControl() ) #if( $nonAsciiControl.get(0) == $nonAsciiControl.get(1) ) codepoint == $nonAsciiControl.get(0) #else codepoint >= $nonAsciiControl.get(0) && codepoint <= $nonAsciiControl.get(1) #end #if( $foreach.hasNext )||
-#end
- #end
-
- ;
- }
-
- public static boolean prohibitionPrivateUse(int codepoint) {
- return
- #foreach( $privateUse in $parser.getPrivateUse() ) #if( $privateUse.get(0) == $privateUse.get(1) ) codepoint == $privateUse.get(0) #else codepoint >= $privateUse.get(0) && codepoint <= $privateUse.get(1) #end #if( $foreach.hasNext )||
-#end
- #end
-
- ;
- }
-
- public static boolean prohibitionNonCharacterCodePoints(int codepoint) {
- return
- #foreach( $nonCharacterCodePoints in $parser.getNonCharacterCodePoints() ) #if( $nonCharacterCodePoints.get(0) == $nonCharacterCodePoints.get(1) ) codepoint == $nonCharacterCodePoints.get(0) #else codepoint >= $nonCharacterCodePoints.get(0) && codepoint <= $nonCharacterCodePoints.get(1) #end #if( $foreach.hasNext )||
-#end
- #end
-
- ;
- }
-
- public static boolean prohibitionSurrogateCodes(int codepoint) {
- return
- #foreach( $surrogateCodes in $parser.getSurrogateCodes() ) #if( $surrogateCodes.get(0) == $surrogateCodes.get(1) ) codepoint == $surrogateCodes.get(0) #else codepoint >= $surrogateCodes.get(0) && codepoint <= $surrogateCodes.get(1) #end #if( $foreach.hasNext )||
-#end
- #end
-
- ;
- }
-
- public static boolean prohibitionInappropriatePlainText(int codepoint) {
- return
- #foreach( $inappropriatePlainText in $parser.getInappropriatePlainText() ) #if( $inappropriatePlainText.get(0) == $inappropriatePlainText.get(1) ) codepoint == $inappropriatePlainText.get(0) #else codepoint >= $inappropriatePlainText.get(0) && codepoint <= $inappropriatePlainText.get(1) #end #if( $foreach.hasNext )||
-#end
- #end
-
- ;
- }
-
- public static boolean prohibitionInappropriateCanonicalRepresentation(int codepoint) {
- return
- #foreach( $inappropriateCanonicalRepresentation in $parser.getInappropriateCanonicalRepresentation() ) #if( $inappropriateCanonicalRepresentation.get(0) == $inappropriateCanonicalRepresentation.get(1) ) codepoint == $inappropriateCanonicalRepresentation.get(0) #else codepoint >= $inappropriateCanonicalRepresentation.get(0) && codepoint <= $inappropriateCanonicalRepresentation.get(1) #end #if( $foreach.hasNext )||
-#end
- #end
-
- ;
- }
-
- public static boolean prohibitionChangeDisplayProperties(int codepoint) {
- return
- #foreach( $changeDisplayProperties in $parser.getChangeDisplayProperties() ) #if( $changeDisplayProperties.get(0) == $changeDisplayProperties.get(1) ) codepoint == $changeDisplayProperties.get(0) #else codepoint >= $changeDisplayProperties.get(0) && codepoint <= $changeDisplayProperties.get(1) #end #if( $foreach.hasNext )||
-#end
- #end
-
- ;
- }
-
- public static boolean prohibitionTaggingCharacters(int codepoint) {
- return
- #foreach( $taggingCharacters in $parser.getTaggingCharacters() ) #if( $taggingCharacters.get(0) == $taggingCharacters.get(1) ) codepoint == $taggingCharacters.get(0) #else codepoint >= $taggingCharacters.get(0) && codepoint <= $taggingCharacters.get(1) #end #if( $foreach.hasNext )||
-#end
- #end
-
- ;
- }
-
- public static boolean bidirectionalPropertyRorAL(int codepoint) {
- return
- #foreach( $propertyRorAL in $parser.getPropertyRorAL() ) #if( $propertyRorAL.get(0) == $propertyRorAL.get(1) ) codepoint == $propertyRorAL.get(0) #else codepoint >= $propertyRorAL.get(0) && codepoint <= $propertyRorAL.get(1) #end #if( $foreach.hasNext )||
-#end
- #end
-
- ;
- }
-
- public static boolean bidirectionalPropertyL(int codepoint) {
- return
- #foreach( $propertyL in $parser.getPropertyL() ) #if( $propertyL.get(0) == $propertyL.get(1) ) codepoint == $propertyL.get(0) #else codepoint >= $propertyL.get(0) && codepoint <= $propertyL.get(1) #end #if( $foreach.hasNext )||
-#end
- #end
-
- ;
- }
-
- public static boolean bidirectional(List value) throws IllegalArgumentException {
- boolean containPropertyRorAL = false;
- boolean firstCharacterPropertyRorAL = false;
- boolean lastCharacterPropertyRorAL = false;
- boolean containPropertyL = false;
- for (int i=0; i
+
+ 4.0.0
+
+
+ com.ongres.stringprep
+ stringprep-parent
+ 2.1
+ ../parent/pom.xml
+
+
+ coverage-report
+ pom
+
+ JaCoCo Coverage Report
+
+
+ true
+ true
+
+
+
+
+ com.ongres.stringprep
+ stringprep
+ ${project.version}
+
+
+ com.ongres.stringprep
+ saslprep
+ ${project.version}
+
+
+ com.ongres.stringprep
+ nameprep
+ ${project.version}
+
+
+
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+
+
+ com/ongres/stringprep/Tables*
+ META-INF/versions/**
+
+
+
+
+ report-aggregate
+
+ report-aggregate
+
+ verify
+
+
+
+
+
+
diff --git a/debian/changelog b/debian/changelog
index 85028f3..d327390 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,23 @@
+libstringprep-java (2.1-1) unstable; urgency=medium
+
+ * Team upload.
+ * New upstream release
+ - Updated the Maven build
+ - libstringprep-java 2.1 breaks libscram-java (<< 2.0)
+ * Enabled the unit tests
+ * Standards-Version updated to 4.7.0
+
+ -- Emmanuel Bourg Mon, 10 Feb 2025 09:22:06 +0100
+
+libstringprep-java (1.1-3) unstable; urgency=medium
+
+ * Team upload.
+ * Address FTBFS with build-helper-maven-plugin 3.3.0 (Closes: #1022277)
+ * Bump Standards-Version to 4.6.1
+ * Set Rules-Requires-Root: no in debian/control
+
+ -- tony mancill Tue, 25 Oct 2022 22:04:02 -0700
+
libstringprep-java (1.1-2) unstable; urgency=medium
* Source-only upload.
diff --git a/debian/control b/debian/control
index d2c7532..53ec920 100644
--- a/debian/control
+++ b/debian/control
@@ -7,18 +7,16 @@ Uploaders:
Build-Depends:
debhelper-compat (= 13),
default-jdk,
- junit4,
- libbuild-helper-maven-plugin-java,
+ junit5,
libmaven-exec-plugin-java,
- libmaven-javadoc-plugin-java,
- libmaven-source-plugin-java,
maven-debian-helper (>= 2.1),
Build-Depends-Indep:
default-jdk-doc,
-Standards-Version: 4.5.0
+Standards-Version: 4.7.0
Vcs-Git: https://salsa.debian.org/java-team/libstringprep-java.git
Vcs-Browser: https://salsa.debian.org/java-team/libstringprep-java
Homepage: https://gitlab.com/ongresinc/stringprep
+Rules-Requires-Root: no
Package: libstringprep-java
Architecture: all
@@ -26,6 +24,7 @@ Multi-Arch: foreign
Depends:
${maven:Depends},
${misc:Depends},
+Breaks: libscram-java (<< 2.0)
Description: Stringprep (RFC 3454) Java implementation
This project implements the RFC 3454 Preparation of Internationalized Strings
("stringprep") in pure Java.
diff --git a/debian/copyright b/debian/copyright
index 06f8507..732614a 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -8,7 +8,8 @@ Copyright:
License: 2-clause-BSD
Files: debian/*
-Copyright: 2021, Christoph Berg
+Copyright: 2021-2022, Christoph Berg
+ 2022, tony mancill
License: 2-clause-BSD
License: 2-clause-BSD
diff --git a/debian/libstringprep-java.poms b/debian/libstringprep-java.poms
index 0417132..ca0d36d 100644
--- a/debian/libstringprep-java.poms
+++ b/debian/libstringprep-java.poms
@@ -25,4 +25,8 @@
# --site-xml=: Optional, the location for site.xml if it needs to be installed.
# Empty by default. [mh_install]
#
-pom.xml --has-package-version
+pom.xml --has-package-version
+parent/pom.xml --has-package-version
+stringprep/pom.xml --has-package-version
+saslprep/pom.xml --has-package-version
+nameprep/pom.xml --has-package-version
diff --git a/debian/maven.ignoreRules b/debian/maven.ignoreRules
index e69de29..6220a5a 100644
--- a/debian/maven.ignoreRules
+++ b/debian/maven.ignoreRules
@@ -0,0 +1,2 @@
+org.apache.maven.plugins maven-enforcer-plugin
+
diff --git a/debian/maven.properties b/debian/maven.properties
index 3b73c63..55d6188 100644
--- a/debian/maven.properties
+++ b/debian/maven.properties
@@ -3,5 +3,4 @@
# maven.test.skip=true
# project.build.sourceEncoding=UTF-8
-maven.test.skip=true
-maven.javadoc.skip=true
+maven.test.skip=false
diff --git a/debian/maven.rules b/debian/maven.rules
index 2ebbcdb..e69de29 100644
--- a/debian/maven.rules
+++ b/debian/maven.rules
@@ -1 +0,0 @@
-junit junit jar s/4\..*/4.x/ * *
diff --git a/debian/rules b/debian/rules
index 16b8910..2d33f6a 100755
--- a/debian/rules
+++ b/debian/rules
@@ -2,7 +2,3 @@
%:
dh $@
-
-override_dh_auto_test:
- # disabled for now
- # [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (generate-stringprep) on project stringprep: An exception occured while executing the Java class. The directory couldn't be created -> [Help 1]
diff --git a/debian/watch b/debian/watch
index cc5a8ba..3aec3c2 100644
--- a/debian/watch
+++ b/debian/watch
@@ -1,3 +1,3 @@
version=4
-options="uversionmangle=s/.beta/~beta/" \
-https://gitlab.com/ongresinc/stringprep/-/tags .*/stringprep-(.*)\.tar\.gz
+options="searchmode=plain, uversionmangle=s/.beta/~beta/" \
+https://gitlab.com/ongresinc/stringprep/tags?sort=updated_desc -/archive/[\d.]+/stringprep-@ANY_VERSION@@ARCHIVE_EXT@
diff --git a/mvnw b/mvnw
index d2f0ea3..8d937f4 100755
--- a/mvnw
+++ b/mvnw
@@ -19,7 +19,7 @@
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
-# Maven2 Start Up Batch script
+# Apache Maven Wrapper startup batch script, version 3.2.0
#
# Required ENV vars:
# ------------------
@@ -27,7 +27,6 @@
#
# Optional ENV vars
# -----------------
-# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@@ -36,6 +35,10 @@
if [ -z "$MAVEN_SKIP_RC" ] ; then
+ if [ -f /usr/local/etc/mavenrc ] ; then
+ . /usr/local/etc/mavenrc
+ fi
+
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
@@ -50,7 +53,7 @@ fi
cygwin=false;
darwin=false;
mingw=false
-case "`uname`" in
+case "$(uname)" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
@@ -58,9 +61,9 @@ case "`uname`" in
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
- export JAVA_HOME="`/usr/libexec/java_home`"
+ JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME
else
- export JAVA_HOME="/Library/Java/Home"
+ JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
fi
fi
;;
@@ -68,68 +71,38 @@ esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
- JAVA_HOME=`java-config --jre-home`
+ JAVA_HOME=$(java-config --jre-home)
fi
fi
-if [ -z "$M2_HOME" ] ; then
- ## resolve links - $0 may be a link to maven's home
- PRG="$0"
-
- # need this for relative symlinks
- while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG="`dirname "$PRG"`/$link"
- fi
- done
-
- saveddir=`pwd`
-
- M2_HOME=`dirname "$PRG"`/..
-
- # make it fully qualified
- M2_HOME=`cd "$M2_HOME" && pwd`
-
- cd "$saveddir"
- # echo Using m2 at $M2_HOME
-fi
-
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
[ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+ CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME="`(cd "$M2_HOME"; pwd)`"
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+ [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] &&
+ JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)"
fi
if [ -z "$JAVA_HOME" ]; then
- javaExecutable="`which javac`"
- if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+ javaExecutable="$(which javac)"
+ if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
- readLink=`which readlink`
- if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+ readLink=$(which readlink)
+ if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
if $darwin ; then
- javaHome="`dirname \"$javaExecutable\"`"
- javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+ javaHome="$(dirname "\"$javaExecutable\"")"
+ javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac"
else
- javaExecutable="`readlink -f \"$javaExecutable\"`"
+ javaExecutable="$(readlink -f "\"$javaExecutable\"")"
fi
- javaHome="`dirname \"$javaExecutable\"`"
- javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+ javaHome="$(dirname "\"$javaExecutable\"")"
+ javaHome=$(expr "$javaHome" : '\(.*\)/bin')
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
@@ -145,7 +118,7 @@ if [ -z "$JAVACMD" ] ; then
JAVACMD="$JAVA_HOME/bin/java"
fi
else
- JAVACMD="`which java`"
+ JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)"
fi
fi
@@ -159,12 +132,9 @@ if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
-CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
-
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
-
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
@@ -180,96 +150,99 @@ find_maven_basedir() {
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
- wdir=`cd "$wdir/.."; pwd`
+ wdir=$(cd "$wdir/.." || exit 1; pwd)
fi
# end of workaround
done
- echo "${basedir}"
+ printf '%s' "$(cd "$basedir" || exit 1; pwd)"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
- echo "$(tr -s '\n' ' ' < "$1")"
+ # Remove \r in case we run on Windows within Git Bash
+ # and check out the repository with auto CRLF management
+ # enabled. Otherwise, we may read lines that are delimited with
+ # \r\n and produce $'-Xarg\r' rather than -Xarg due to word
+ # splitting rules.
+ tr -s '\r\n' ' ' < "$1"
fi
}
-BASE_DIR=`find_maven_basedir "$(pwd)"`
+log() {
+ if [ "$MVNW_VERBOSE" = true ]; then
+ printf '%s\n' "$1"
+ fi
+}
+
+BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
+MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR
+log "$MAVEN_PROJECTBASEDIR"
+
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
-if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
- if [ "$MVNW_VERBOSE" = true ]; then
- echo "Found .mvn/wrapper/maven-wrapper.jar"
- fi
+wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
+if [ -r "$wrapperJarPath" ]; then
+ log "Found $wrapperJarPath"
else
- if [ "$MVNW_VERBOSE" = true ]; then
- echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
- fi
+ log "Couldn't find $wrapperJarPath, downloading it ..."
+
if [ -n "$MVNW_REPOURL" ]; then
- jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
+ wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
else
- jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
+ wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
fi
- while IFS="=" read key value; do
- case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
+ while IFS="=" read -r key value; do
+ # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
+ safeValue=$(echo "$value" | tr -d '\r')
+ case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;;
esac
- done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
- if [ "$MVNW_VERBOSE" = true ]; then
- echo "Downloading from: $jarUrl"
- fi
- wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
+ done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
+ log "Downloading from: $wrapperUrl"
+
if $cygwin; then
- wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
+ wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
fi
if command -v wget > /dev/null; then
- if [ "$MVNW_VERBOSE" = true ]; then
- echo "Found wget ... using wget"
- fi
+ log "Found wget ... using wget"
+ [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
- wget "$jarUrl" -O "$wrapperJarPath"
+ wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
else
- wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
+ wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
- if [ "$MVNW_VERBOSE" = true ]; then
- echo "Found curl ... using curl"
- fi
+ log "Found curl ... using curl"
+ [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
- curl -o "$wrapperJarPath" "$jarUrl" -f
+ curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
else
- curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
+ curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
fi
-
else
- if [ "$MVNW_VERBOSE" = true ]; then
- echo "Falling back to using Java to download"
- fi
- javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ log "Falling back to using Java to download"
+ javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
- javaClass=`cygpath --path --windows "$javaClass"`
+ javaSource=$(cygpath --path --windows "$javaSource")
+ javaClass=$(cygpath --path --windows "$javaClass")
fi
- if [ -e "$javaClass" ]; then
- if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
- if [ "$MVNW_VERBOSE" = true ]; then
- echo " - Compiling MavenWrapperDownloader.java ..."
- fi
- # Compiling the Java class
- ("$JAVA_HOME/bin/javac" "$javaClass")
+ if [ -e "$javaSource" ]; then
+ if [ ! -e "$javaClass" ]; then
+ log " - Compiling MavenWrapperDownloader.java ..."
+ ("$JAVA_HOME/bin/javac" "$javaSource")
fi
- if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
- # Running the downloader
- if [ "$MVNW_VERBOSE" = true ]; then
- echo " - Running MavenWrapperDownloader.java ..."
- fi
- ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
+ if [ -e "$javaClass" ]; then
+ log " - Running MavenWrapperDownloader.java ..."
+ ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
fi
fi
fi
@@ -278,33 +251,58 @@ fi
# End of extension
##########################################################################################
-export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
-if [ "$MVNW_VERBOSE" = true ]; then
- echo $MAVEN_PROJECTBASEDIR
+# If specified, validate the SHA-256 sum of the Maven wrapper jar file
+wrapperSha256Sum=""
+while IFS="=" read -r key value; do
+ case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;;
+ esac
+done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
+if [ -n "$wrapperSha256Sum" ]; then
+ wrapperSha256Result=false
+ if command -v sha256sum > /dev/null; then
+ if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then
+ wrapperSha256Result=true
+ fi
+ elif command -v shasum > /dev/null; then
+ if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then
+ wrapperSha256Result=true
+ fi
+ else
+ echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available."
+ echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties."
+ exit 1
+ fi
+ if [ $wrapperSha256Result = false ]; then
+ echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
+ echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
+ echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
+ exit 1
+ fi
fi
+
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+ JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
[ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
- MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
+ MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
-MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+# shellcheck disable=SC2086 # safe args
exec "$JAVACMD" \
$MAVEN_OPTS \
+ $MAVEN_DEBUG_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
- "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/mvnw.cmd b/mvnw.cmd
index b26ab24..c4586b5 100644
--- a/mvnw.cmd
+++ b/mvnw.cmd
@@ -18,15 +18,14 @@
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
-@REM Maven2 Start Up Batch script
+@REM Apache Maven Wrapper startup batch script, version 3.2.0
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
-@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
-@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@@ -46,8 +45,8 @@ if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
-if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
+if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
+if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
:skipRcPre
@setlocal
@@ -120,10 +119,10 @@ SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
+set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
-FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
- IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+ IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@@ -134,11 +133,11 @@ if exist %WRAPPER_JAR% (
)
) else (
if not "%MVNW_REPOURL%" == "" (
- SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
+ SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
- echo Downloading from: %DOWNLOAD_URL%
+ echo Downloading from: %WRAPPER_URL%
)
powershell -Command "&{"^
@@ -146,7 +145,7 @@ if exist %WRAPPER_JAR% (
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
- "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
+ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
@@ -154,11 +153,35 @@ if exist %WRAPPER_JAR% (
)
@REM End of extension
+@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
+SET WRAPPER_SHA_256_SUM=""
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+ IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
+)
+IF NOT %WRAPPER_SHA_256_SUM%=="" (
+ powershell -Command "&{"^
+ "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
+ "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
+ " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
+ " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
+ " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
+ " exit 1;"^
+ "}"^
+ "}"
+ if ERRORLEVEL 1 goto error
+)
+
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
-%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+%MAVEN_JAVA_EXE% ^
+ %JVM_CONFIG_MAVEN_PROPS% ^
+ %MAVEN_OPTS% ^
+ %MAVEN_DEBUG_OPTS% ^
+ -classpath %WRAPPER_JAR% ^
+ "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
+ %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
@@ -168,15 +191,15 @@ set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
+if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
-if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
+if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
+if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
-if "%MAVEN_BATCH_PAUSE%" == "on" pause
+if "%MAVEN_BATCH_PAUSE%"=="on" pause
-if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
+if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
-exit /B %ERROR_CODE%
+cmd /C exit /B %ERROR_CODE%
diff --git a/nameprep/pom.xml b/nameprep/pom.xml
new file mode 100644
index 0000000..643e473
--- /dev/null
+++ b/nameprep/pom.xml
@@ -0,0 +1,56 @@
+
+
+ 4.0.0
+
+
+ com.ongres.stringprep
+ stringprep-parent
+ 2.1
+ ../parent/pom.xml
+
+
+ nameprep
+ Nameprep (RFC 3491)
+ Nameprep: A Stringprep Profile for Internationalized Domain Names (IDN)
+
+
+ ${project.basedir}/../checks
+
+
+
+
+ com.ongres.stringprep
+ stringprep
+ ${project.version}
+
+
+
+
+
+ coverage
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+
+
+
+
+
+ run-its
+
+
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+
+
+ org.apache.maven.plugins
+ maven-invoker-plugin
+
+
+
+
+
+
diff --git a/nameprep/src/it/jpms-nameprep/invoker.properties b/nameprep/src/it/jpms-nameprep/invoker.properties
new file mode 100644
index 0000000..93b7001
--- /dev/null
+++ b/nameprep/src/it/jpms-nameprep/invoker.properties
@@ -0,0 +1,3 @@
+# build project if JRE version is 11 or higher
+invoker.java.version = 11+
+invoker.goals = test
diff --git a/nameprep/src/it/jpms-nameprep/pom.xml b/nameprep/src/it/jpms-nameprep/pom.xml
new file mode 100644
index 0000000..2f138a6
--- /dev/null
+++ b/nameprep/src/it/jpms-nameprep/pom.xml
@@ -0,0 +1,60 @@
+
+
+ 4.0.0
+
+ com.ongres.stringprep.it
+ jpms-nameprep
+ JPMS Nameprep
+ 2.1
+
+
+ UTF-8
+ 11
+ 11
+ 11
+
+
+
+
+ com.ongres.stringprep
+ nameprep
+ ${project.version}
+
+
+ org.junit.jupiter
+ junit-jupiter
+ 5.10.2
+ test
+
+
+
+
+
+
+
+ maven-compiler-plugin
+ 3.13.0
+
+
+ maven-jar-plugin
+ 3.3.0
+
+
+
+
+
+
+ de.sormuras.junit
+ junit-platform-maven-plugin
+ 1.1.7
+ true
+
+ ABSOLUTE
+ JAVA
+
+
+
+
+
diff --git a/nameprep/src/it/jpms-nameprep/src/test/java/module-info.java b/nameprep/src/it/jpms-nameprep/src/test/java/module-info.java
new file mode 100644
index 0000000..ed3e871
--- /dev/null
+++ b/nameprep/src/it/jpms-nameprep/src/test/java/module-info.java
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2021 OnGres, Inc.
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+open module test.nameprep {
+ requires com.ongres.nameprep;
+
+ requires transitive org.junit.jupiter.engine;
+ requires transitive org.junit.jupiter.api;
+ requires transitive org.junit.jupiter.params;
+}
\ No newline at end of file
diff --git a/nameprep/src/it/jpms-nameprep/src/test/java/test/nameprep/NameprepTest.java b/nameprep/src/it/jpms-nameprep/src/test/java/test/nameprep/NameprepTest.java
new file mode 100644
index 0000000..ef8c7cb
--- /dev/null
+++ b/nameprep/src/it/jpms-nameprep/src/test/java/test/nameprep/NameprepTest.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2021 OnGres, Inc.
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+package test.nameprep;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.util.EnumSet;
+
+import com.ongres.nameprep.Nameprep;
+import com.ongres.stringprep.Option;
+import com.ongres.stringprep.Profile;
+import com.ongres.stringprep.Stringprep;
+import org.junit.jupiter.api.Test;
+
+class NameprepTest {
+
+ @Test
+ void getProvider() {
+ assertDoesNotThrow(() -> Stringprep.getProvider("Nameprep"));
+ assertThrows(IllegalArgumentException.class, () -> Stringprep.getProvider("SASLprep"));
+ }
+
+ @Test
+ void service() {
+ Profile service = Stringprep.getProvider("Nameprep");
+ assertEquals(EnumSet.of(Option.MAP_TO_NOTHING, // [StringPrep, B.1]
+ Option.CASE_FOLD_NFKC, // [StringPrep, B.2]
+ Option.NORMALIZE_KC, // Normalization form KC
+ Option.FORBID_NON_ASCII_SPACES, // [StringPrep, C.1.2]
+ Option.FORBID_NON_ASCII_CONTROL, // [StringPrep, C.2.2]
+ Option.FORBID_PRIVATE_USE, // [StringPrep, C.3]
+ Option.FORBID_NON_CHARACTER, // [StringPrep, C.4]
+ Option.FORBID_SURROGATE, // [StringPrep, C.5]
+ Option.FORBID_INAPPROPRIATE_FOR_PLAIN_TEXT, // [StringPrep, C.6]
+ Option.FORBID_INAPPROPRIATE_FOR_CANON_REP, // [StringPrep, C.7]
+ Option.FORBID_CHANGE_DISPLAY_AND_DEPRECATED, // [StringPrep, C.8]
+ Option.FORBID_TAGGING, // [StringPrep, C.9]
+ Option.CHECK_BIDI), // Bidirectional Characters
+ service.profile());
+ String withUnassignedChar = "\u0380";
+ assertDoesNotThrow(() -> service.prepareQuery(withUnassignedChar));
+ assertThrows(IllegalArgumentException.class, () -> service.prepareStored(withUnassignedChar));
+ }
+
+ @Test
+ void newInstance() {
+ // Access the exported package
+ Nameprep profile = new Nameprep();
+ String example1 = "I\u00ADX \u2168";
+ assertEquals("ix ix", profile.prepareStored(example1));
+ assertEquals("ix ix", profile.prepareQuery(example1));
+ }
+
+}
diff --git a/nameprep/src/it/settings.xml b/nameprep/src/it/settings.xml
new file mode 100644
index 0000000..8890c85
--- /dev/null
+++ b/nameprep/src/it/settings.xml
@@ -0,0 +1,35 @@
+
+
+
+
+ it-repo
+
+ true
+
+
+
+ local.central
+ @localRepositoryUrl@
+
+ true
+
+
+ true
+
+
+
+
+
+ local.central
+ @localRepositoryUrl@
+
+ true
+
+
+ true
+
+
+
+
+
+
diff --git a/nameprep/src/main/java/com/ongres/nameprep/Nameprep.java b/nameprep/src/main/java/com/ongres/nameprep/Nameprep.java
new file mode 100644
index 0000000..7756bf2
--- /dev/null
+++ b/nameprep/src/main/java/com/ongres/nameprep/Nameprep.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2021 OnGres, Inc.
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+package com.ongres.nameprep;
+
+import java.util.EnumSet;
+import java.util.Set;
+
+import com.ongres.stringprep.Option;
+import com.ongres.stringprep.Profile;
+import com.ongres.stringprep.ProfileName;
+
+/**
+ * Nameprep: A Stringprep Profile for Internationalized Domain Names (IDN).
+ *
+ *
This document specifies processing rules that will allow users to enter internationalized
+ * domain names (IDNs) into applications and have the highest chance of getting the content of the
+ * strings correct. It is a profile of stringprep. These processing rules are only intended for
+ * internationalized domain names, not for arbitrary text.
+ */
+@ProfileName("Nameprep")
+public final class Nameprep implements Profile {
+
+ private final EnumSet