From f399b9cc1ce5f535d00aef867e5fa14353d3dd96 Mon Sep 17 00:00:00 2001 From: ogesaku Date: Fri, 13 Jan 2023 23:17:15 +0100 Subject: [PATCH] Initialize --- .editorconfig | 11 + .github/dependabot.yml | 6 + .github/workflows/build.yml | 48 ++ .github/workflows/release.yml | 173 ++++++ .gitignore | 10 + .idea/codeStyles/Project.xml | 50 ++ .idea/codeStyles/codeStyleConfig.xml | 5 + LICENSE | 21 + README.md | 76 +++ build.gradle | 22 + gradle/publish.gradle | 95 ++++ gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 59821 bytes gradle/wrapper/gradle-wrapper.properties | 5 + gradlew | 234 +++++++++ gradlew.bat | 89 ++++ settings.gradle | 12 + .../java/com/coditory/quark/uri/BitSets.java | 110 ++++ .../java/com/coditory/quark/uri/Hosts.java | 154 ++++++ .../quark/uri/InetAddressValidator.java | 168 ++++++ .../quark/uri/InvalidHttpUrlException.java | 11 + .../quark/uri/InvalidUriException.java | 7 + .../java/com/coditory/quark/uri/Nullable.java | 33 ++ .../com/coditory/quark/uri/PercentCodec.java | 148 ++++++ .../coditory/quark/uri/PercentDecoder.java | 107 ++++ .../coditory/quark/uri/PercentEncoder.java | 137 +++++ .../java/com/coditory/quark/uri/Ports.java | 82 +++ .../com/coditory/quark/uri/Preconditions.java | 62 +++ .../java/com/coditory/quark/uri/Strings.java | 49 ++ .../com/coditory/quark/uri/Throwables.java | 40 ++ .../com/coditory/quark/uri/UriAuthority.java | 97 ++++ .../com/coditory/quark/uri/UriBuilder.java | 494 ++++++++++++++++++ .../com/coditory/quark/uri/UriComponents.java | 424 +++++++++++++++ .../quark/uri/UriComponentsParser.java | 147 ++++++ .../coditory/quark/uri/UriPartValidator.java | 88 ++++ .../java/com/coditory/quark/uri/UriRfc.java | 94 ++++ .../coditory/quark/uri/UriRfcCharacters.java | 28 + .../com/coditory/quark/uri/UrlValidator.java | 185 +++++++ src/main/resources/a/b/c/homepage/i18n.yml | 1 + src/main/resources/a/b/c/other/i18n.yml | 1 + src/main/resources/a/b/d/listing/i18n.yml | 2 + src/main/resources/logback.xml | 14 + .../com/coditory/quark/uri/HostsSpec.groovy | 19 + .../quark/uri/InetAddressValidatorSpec.groovy | 89 ++++ .../quark/uri/PercentCodecSpec.groovy | 68 +++ .../com/coditory/quark/uri/PortsSpec.groovy | 55 ++ .../coditory/quark/uri/UriBuilderSpec.groovy | 108 ++++ .../UriBuilder_parseAndRecreateUriSpec.groovy | 85 +++ .../uri/UriBuilder_parseHttpUrlSpec.groovy | 49 ++ .../uri/UriBuilder_parseUriPartsSpec.groovy | 142 +++++ .../quark/uri/UriBuilder_parseUriSpec.groovy | 123 +++++ .../uri/UriBuilder_queryParamsSpec.groovy | 112 ++++ .../quark/uri/UrlValidatorSpec.groovy | 53 ++ .../coditory/quark/uri/base/Alphabets.groovy | 48 ++ .../quark/uri/base/CapturingAppender.groovy | 102 ++++ src/test/java/readme/ReadmeSamples.java | 47 ++ 55 files changed, 4640 insertions(+) create mode 100644 .editorconfig create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml create mode 100755 .gitignore create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 build.gradle create mode 100644 gradle/publish.gradle create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat create mode 100644 settings.gradle create mode 100644 src/main/java/com/coditory/quark/uri/BitSets.java create mode 100644 src/main/java/com/coditory/quark/uri/Hosts.java create mode 100644 src/main/java/com/coditory/quark/uri/InetAddressValidator.java create mode 100644 src/main/java/com/coditory/quark/uri/InvalidHttpUrlException.java create mode 100644 src/main/java/com/coditory/quark/uri/InvalidUriException.java create mode 100644 src/main/java/com/coditory/quark/uri/Nullable.java create mode 100644 src/main/java/com/coditory/quark/uri/PercentCodec.java create mode 100644 src/main/java/com/coditory/quark/uri/PercentDecoder.java create mode 100644 src/main/java/com/coditory/quark/uri/PercentEncoder.java create mode 100644 src/main/java/com/coditory/quark/uri/Ports.java create mode 100644 src/main/java/com/coditory/quark/uri/Preconditions.java create mode 100644 src/main/java/com/coditory/quark/uri/Strings.java create mode 100644 src/main/java/com/coditory/quark/uri/Throwables.java create mode 100644 src/main/java/com/coditory/quark/uri/UriAuthority.java create mode 100644 src/main/java/com/coditory/quark/uri/UriBuilder.java create mode 100644 src/main/java/com/coditory/quark/uri/UriComponents.java create mode 100644 src/main/java/com/coditory/quark/uri/UriComponentsParser.java create mode 100644 src/main/java/com/coditory/quark/uri/UriPartValidator.java create mode 100644 src/main/java/com/coditory/quark/uri/UriRfc.java create mode 100644 src/main/java/com/coditory/quark/uri/UriRfcCharacters.java create mode 100644 src/main/java/com/coditory/quark/uri/UrlValidator.java create mode 100644 src/main/resources/a/b/c/homepage/i18n.yml create mode 100644 src/main/resources/a/b/c/other/i18n.yml create mode 100644 src/main/resources/a/b/d/listing/i18n.yml create mode 100644 src/main/resources/logback.xml create mode 100644 src/test/groovy/com/coditory/quark/uri/HostsSpec.groovy create mode 100644 src/test/groovy/com/coditory/quark/uri/InetAddressValidatorSpec.groovy create mode 100644 src/test/groovy/com/coditory/quark/uri/PercentCodecSpec.groovy create mode 100644 src/test/groovy/com/coditory/quark/uri/PortsSpec.groovy create mode 100644 src/test/groovy/com/coditory/quark/uri/UriBuilderSpec.groovy create mode 100644 src/test/groovy/com/coditory/quark/uri/UriBuilder_parseAndRecreateUriSpec.groovy create mode 100644 src/test/groovy/com/coditory/quark/uri/UriBuilder_parseHttpUrlSpec.groovy create mode 100644 src/test/groovy/com/coditory/quark/uri/UriBuilder_parseUriPartsSpec.groovy create mode 100644 src/test/groovy/com/coditory/quark/uri/UriBuilder_parseUriSpec.groovy create mode 100644 src/test/groovy/com/coditory/quark/uri/UriBuilder_queryParamsSpec.groovy create mode 100644 src/test/groovy/com/coditory/quark/uri/UrlValidatorSpec.groovy create mode 100644 src/test/groovy/com/coditory/quark/uri/base/Alphabets.groovy create mode 100644 src/test/groovy/com/coditory/quark/uri/base/CapturingAppender.groovy create mode 100644 src/test/java/readme/ReadmeSamples.java diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c8dbe2d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space + +[*.{yml, json}] +indent_size = 2 diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..dfa800a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "gradle" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..acd0f3e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,48 @@ +name: Build + +on: + workflow_dispatch: + push: + +jobs: + build: + runs-on: ubuntu-latest + if: github.event_name != 'push' || startsWith(github.ref, 'refs/tags/') == false + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Skip duplicates and docs + id: skip + uses: fkirc/skip-duplicate-actions@v5 + with: + paths_ignore: '["**/README.md", "LICENSE", ".gitignore", ".editorconfig", ".idea/**"]' + + - name: Validate gradle wrapper + if: steps.skip.outputs.should_skip != 'true' + uses: gradle/wrapper-validation-action@v1 + + - name: Setup JDK + if: steps.skip.outputs.should_skip != 'true' + uses: actions/setup-java@v3 + with: + java-version: 17 + cache: gradle + distribution: temurin + + - name: Build with gradle + if: steps.skip.outputs.should_skip != 'true' + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + run: ./gradlew build jacocoTestReport coveralls --scan + + dependabot: + needs: [ build ] + runs-on: ubuntu-latest + if: ${{ github.triggering_actor == 'dependabot' && github.event_name == 'pull_request'}} + steps: + - name: Auto-merge Dependabot PRs + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..10f1ed1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,173 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version: + type: string + description: | + Release version in semantic format (like: 1.2.3). + Default: a version with incremented patch number. + required: false + publish: + type: choice + description: Artifact publication. + options: + - AUTO + - SKIP + - RELEASE + - SNAPSHOT + required: true + default: AUTO + release: + types: [ published ] + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Validate build succeeded + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + declare -r BUILD_SUCCESS="$(gh api \ + -H "Accept: application/vnd.github+json" \ + /repos/${{ github.repository }}/actions/runs?status=success\&head_sha=${{ github.sha }} \ + | jq 'limit(1; .workflow_runs[] | select(.name == "Build" and .conclusion == "success"))')" + if [ -z "$BUILD_SUCCESS" ]; then + echo "Commit did not pass Build!" + exit 1 + fi + + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.CI_TOKEN }} + + - name: Get versions + id: versions + env: + NEXT_INPUT_VERSION: ${{ inputs.version }} + TAG_NAME: ${{ github.event.release.tag_name }} + run: | + declare -r GIT_VERSION="$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' | sort -V | tail -n 1 | cut -c2-)" + declare -r VERSION=${GIT_VERSION:-0.0.0} + declare -r MAJOR="$(echo "$VERSION" | cut -d. -f1)" + declare -r MINOR="$(echo "$VERSION" | cut -d. -f2)" + declare -r PATCH="$(echo "$VERSION" | cut -d. -f3)" + declare -r NEXT_TAG_VERSION="$([[ "$TAG_NAME" =~ v.* ]] \ + && (echo "$TAG_NAME" | cut -c2-) \ + || echo "$TAG_NAME")" + declare -r NEXT_MANUAL_VERSION="${NEXT_INPUT_VERSION:-$NEXT_TAG_VERSION}" + declare -r NEXT_PATCH_VERSION="$MAJOR.$MINOR.$(( $PATCH + 1 ))" + declare -r NEXT_VERSION="${NEXT_MANUAL_VERSION:-$NEXT_PATCH_VERSION}" + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT + echo -e "VERSION: $VERSION\nNEXT_VERSION: $NEXT_VERSION" + + - name: Import GPG key + id: gpg + uses: crazy-max/ghaction-import-gpg@v5 + if: | + github.event_name != 'release' + && github.ref == 'refs/heads/master' + && inputs.publish != 'SNAPSHOT' + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + git_user_signingkey: true + git_commit_gpgsign: true + git_committer_name: Coditory Bot + git_committer_email: bot@coditory.com + + - name: Update version in README (master only) + if: steps.gpg.conclusion == 'success' + env: + PREV_VERSION: ${{ steps.versions.outputs.version }} + NEXT_VERSION: ${{ steps.versions.outputs.next_version }} + run: | + declare -r ESC_PREV_VERSION="${PREV_VERSION//./\\.}" + echo "Changing: $PREV_VERSION -> $NEXT_VERSION" + sed -i "s|${ESC_PREV_VERSION}|${NEXT_VERSION}|" README.md + if [ -n "$(git status --porcelain)" ]; then + git add -A + git commit -a -m "Update version $PREV_VERSION -> $NEXT_VERSION" -m "[ci skip]" + git push origin master + else + echo "Nothing changed. Skipping commit." + fi + + - name: Setup JDK + if: inputs.publish != 'SKIP' + uses: actions/setup-java@v3 + with: + java-version: 17 + cache: gradle + distribution: temurin + + - name: Publish release + if: | + github.event_name == 'release' + || inputs.publish == 'RELEASE' + || (inputs.publish == 'AUTO' && github.ref == 'refs/heads/master') + env: + NEXT_VERSION: ${{ steps.versions.outputs.next_version }} + SIGNING_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + SIGNING_PASSWORD: ${{ secrets.GPG_PASSPHRASE }} + NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} + NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} + run: | + ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=$NEXT_VERSION -Ppublish --info + echo "Published release: $NEXT_VERSION" + + - name: Generate release notes + id: notes + if: | + github.event_name != 'release' + && github.ref == 'refs/heads/master' + && inputs.publish != 'SNAPSHOT' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PREV_VERSION: ${{ steps.versions.outputs.version }} + NEXT_VERSION: ${{ steps.versions.outputs.next_version }} + run: | + declare -r NOTES="$(gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + /repos/${{ github.repository }}/releases/generate-notes \ + -f tag_name="v$NEXT_VERSION" \ + -f target_commitish='master' \ + -f previous_tag_name="v$PREV_VERSION" \ + | jq -r '.body')" + declare -r ESCAPED="${NOTES//$'\n'/'%0A'}" + echo "notes=$ESCAPED" >> $GITHUB_OUTPUT + + - name: Create github release (master only) + if: steps.notes.conclusion == 'success' + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + body: ${{ steps.notes.outputs.notes }} + draft: ${{ inputs.publish == 'SKIP' }} + tag: v${{ steps.versions.outputs.next_version }} + token: ${{ secrets.GITHUB_TOKEN }} + artifacts: "build/libs/*.jar" + + - name: Publish snapshot + if: | + github.event_name == 'workflow_dispatch' + && ( + inputs.publish == 'SNAPSHOT' + || inputs.publish == 'AUTO' && github.ref != 'refs/heads/master' + ) + env: + NEXT_VERSION: ${{ steps.versions.outputs.next_version }} + SIGNING_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + SIGNING_PASSWORD: ${{ secrets.GPG_PASSPHRASE }} + NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} + NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} + run: | + declare -r MIDDLE="$([ "$GITHUB_REF" == "refs/heads/master" ] && echo "" || echo "-${GITHUB_REF#refs/heads/}")" + ./gradlew publishToSonatype -Pversion="${NEXT_VERSION}${MIDDLE}-SNAPSHOT" -Ppublish + echo "Published snapshot: ${NEXT_VERSION}${MIDDLE}-SNAPSHOT" diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..861a639 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# Gradle +build +.gradle +!gradle/wrapper/gradle-wrapper.jar + +# IntelliJ +out +*.iml +.idea/* +!.idea/codeStyles diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..3882c43 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..0f7bc51 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..76c8e2a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Paweł Mendelski + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..4d4c761 --- /dev/null +++ b/README.md @@ -0,0 +1,76 @@ +# Quark URI + +[![Build](https://github.com/coditory/quark-uri/actions/workflows/build.yml/badge.svg)](https://github.com/coditory/quark-uri/actions/workflows/build.yml) +[![Coverage Status](https://coveralls.io/repos/github/coditory/quark-uri/badge.svg)](https://coveralls.io/github/coditory/quark-uri) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.coditory.quark/quark-uri/badge.svg)](https://mvnrepository.com/artifact/com.coditory.quark/quark-uri) + +**🚧 This library as under heavy development until release of version `1.x.x` 🚧** + +> Just a URI manipulation library for Java. Provides URI builder and parser. + +- lightweight, exactly 1 minimalistic dependency +- single purpose, not part of a framework +- does percent encoding and decoding +- adds option to encode/decode `+` character as a space + +## Installation + +Add to your `build.gradle`: + +```gradle +dependencies { + implementation "com.coditory.quark:quark-uri:0.0.1" +} +``` + +## Basic usage + +Build uri string +```java +UriBuilder.fromUri("https://coditory.com?w=W&a=A") + .addPathSegment("about") + .addQueryParam("a", "X") + .addQueryParam("a", "X") + .addQueryParam("a", "Y") + .addQueryParam("b", "Y") + .addQueryParam("e", "") + .buildUriString(); +// Result: +// https://coditory.com/about?w=W&a=A&a=X&a=X&a=Y&b=Y&e= +``` + +Build uri components +```java +UriComponents uriComponents = UriBuilder.fromUri("https://coditory.com?w=W&a=A") + .addPathSegment("about") + .addQueryParam("a", "X") + .addQueryParam("a", "X") + .addQueryParam("a", "Y") + .addQueryParam("b", "Y") + .addQueryParam("e", "") + .buildUriComponents(); +// uriComponents is a value object, that provides access to all parts of parsed uri +// Result: +// UriComponents{scheme="https", host="coditory.com", pathSegments=[about], queryParams={w=[W], a=[A, X, X, Y], b=[Y], e=[]}} +``` + +Parses encoded spaces and pluses: +``` +UriComponents plusesAsSpaces = UriBuilder.fromUri("/abc?a+b=A+B").buildUriComponents(); +UriComponents encodedSpaces = UriBuilder.fromUri("/abc?a%20b=A%20B").buildUriComponents(); +assert plusesAsSpaces == encodedSpaces +// Result: +// UriComponents{rootPath=true, pathSegments=[abc], queryParams={a b=[A B]}} +``` + +By default encodes spaces as `%20` +``` +UriBuilder.fromUri("https://coditory.com/a+bc/d%20ef/") + .addPathSegment("x y ") + .setFragment("frag ment") + .addQueryParam("f oo", "b ar") + .addQueryParam("x", "y+z") + .buildUriString(); +// Result: +// https://coditory.com/a+bc/d%20ef/x%20y%20?f%20oo=b%20ar&x=y%2Bz#frag%20ment +``` \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..0e04d97 --- /dev/null +++ b/build.gradle @@ -0,0 +1,22 @@ +plugins { + id 'java-library' + id 'groovy' + id 'jacoco' + id 'signing' + id 'com.github.kt3k.coveralls' version '2.12.0' + id 'com.coditory.build' version '0.1.19' + id 'io.github.gradle-nexus.publish-plugin' version '1.1.0' apply false +} + +group = 'com.coditory.quark' +description = 'Coditory Quark URI builder library' + +dependencies { + api 'org.jetbrains:annotations:23.1.0' + testImplementation 'ch.qos.logback:logback-classic:1.4.5' + testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0' +} + +if (project.hasProperty('publish')) { + apply from: "gradle/publish.gradle" +} diff --git a/gradle/publish.gradle b/gradle/publish.gradle new file mode 100644 index 0000000..2372783 --- /dev/null +++ b/gradle/publish.gradle @@ -0,0 +1,95 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' +apply plugin: 'io.github.gradle-nexus.publish-plugin' + +jar { + from(rootProject.projectDir) { + include "LICENSE" + into "META-INF" + } +} + +task javadocJar(type: Jar) { + from javadoc + archiveClassifier = 'javadoc' +} + +task sourcesJar(type: Jar) { + from sourceSets.main.allJava + archiveClassifier = 'sources' +} + +artifacts { + archives javadocJar + archives sourcesJar +} + +publishing { + publications { + mavenJava(MavenPublication) { + artifactId = archivesBaseName + from components.java + artifact sourcesJar + artifact javadocJar + + versionMapping { + usage('java-api') { + fromResolutionOf('runtimeClasspath') + } + usage('java-runtime') { + fromResolutionResult() + } + } + + pom { + name = archivesBaseName + description = project.description + url = 'https://github.com/coditory/quark-uri' + organization { + name = "Coditory" + url = "https://coditory.com" + } + licenses { + license { + name = 'MIT License' + url = 'https://opensource.org/licenses/MIT' + } + } + developers { + developer { + id = 'coditory' + name = 'Coditory' + email = 'admin@coditory.com' + } + } + scm { + connection = 'scm:git@github.com:coditory/quark-uri.git' + developerConnection = 'scm:git@github.com:coditory/quark-uri.git' + url = 'https://github.com/coditory/quark-uri' + } + issueManagement { + system = "GitHub" + url = "https://github.com/coditory/quark-uri/issues" + } + } + } + } +} + +signing { + if (System.getenv('SIGNING_KEY') && System.getenv('SIGNING_PASSWORD')) { + useInMemoryPgpKeys(System.getenv('SIGNING_KEY'), System.getenv('SIGNING_PASSWORD')) + } + sign publishing.publications.mavenJava +} + +nexusPublishing { + connectTimeout = Duration.ofMinutes(5) + clientTimeout = Duration.ofMinutes(5) + repositories { + sonatype { + username = project.findProperty('nexusUsername') ?: System.getenv('NEXUS_USERNAME') + password = project.findProperty('nexusPassword') ?: System.getenv('NEXUS_PASSWORD') + } + } +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..41d9927a4d4fb3f96a785543079b8df6723c946b GIT binary patch literal 59821 zcma&NV|1p`(k7gaZQHhOJ9%QKV?D8LCmq{1JGRYE(y=?XJw0>InKkE~^UnAEs2gk5 zUVGPCwX3dOb!}xiFmPB95NK!+5D<~S0s;d1zn&lrfAn7 zC?Nb-LFlib|DTEqB8oDS5&$(u1<5;wsY!V`2F7^=IR@I9so5q~=3i_(hqqG<9SbL8Q(LqDrz+aNtGYWGJ2;p*{a-^;C>BfGzkz_@fPsK8{pTT~_VzB$E`P@> z7+V1WF2+tSW=`ZRj3&0m&d#x_lfXq`bb-Y-SC-O{dkN2EVM7@!n|{s+2=xSEMtW7( zz~A!cBpDMpQu{FP=y;sO4Le}Z)I$wuFwpugEY3vEGfVAHGqZ-<{vaMv-5_^uO%a{n zE_Zw46^M|0*dZ`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100644 index 0000000..f42e62f --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..1b6c787 --- /dev/null +++ b/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# 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 +# +# https://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. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..ac1b06f --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..749ca35 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,12 @@ +plugins { + id("com.gradle.enterprise").version("3.5") +} + +rootProject.name = "quark-uri" + +gradleEnterprise { + buildScan { + termsOfServiceUrl = "https://gradle.com/terms-of-service" + termsOfServiceAgree = "yes" + } +} diff --git a/src/main/java/com/coditory/quark/uri/BitSets.java b/src/main/java/com/coditory/quark/uri/BitSets.java new file mode 100644 index 0000000..0033ad4 --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/BitSets.java @@ -0,0 +1,110 @@ +package com.coditory.quark.uri; + +import org.jetbrains.annotations.NotNull; + +import java.util.BitSet; + +import static com.coditory.quark.uri.Preconditions.expectNonNull; + +final class BitSets { + private BitSets() { + throw new UnsupportedOperationException("Do not instantiate utility class"); + } + + public static BitSet of(String text) { + expectNonNull(text, "text"); + if (text.length() == 0) { + return new BitSet(0); + } + int max = text.codePoints().max().getAsInt(); + BitSet bitSet = new BitSet(max + 1); + text.codePoints() + .forEach(bitSet::set); + return bitSet; + } + + public static BitSet set(BitSet bitSet, int bitIndex, boolean value) { + expectNonNull(bitSet, "bitSet"); + BitSet result = new BitSet(Math.max(bitSet.length(), bitIndex + 1)); + result.or(bitSet); + result.set(bitIndex, value); + return result; + } + + public static BitSet unmodifiableBitSet(BitSet bitSet) { + expectNonNull(bitSet, "bitSet"); + return new UnmodifiableBitSet(bitSet); + } + + static final class UnmodifiableBitSet extends BitSet { + public UnmodifiableBitSet(@NotNull BitSet original) { + expectNonNull(original, "original"); + super.or(original); + } + + @Override + public void flip(int bitIndex) { + throw new UnsupportedOperationException(); + } + + @Override + public void flip(int fromIndex, int toIndex) { + throw new UnsupportedOperationException(); + } + + @Override + public void set(int bitIndex) { + throw new UnsupportedOperationException(); + } + + @Override + public void set(int bitIndex, boolean value) { + throw new UnsupportedOperationException(); + } + + @Override + public void set(int fromIndex, int toIndex) { + throw new UnsupportedOperationException(); + } + + @Override + public void set(int fromIndex, int toIndex, boolean value) { + throw new UnsupportedOperationException(); + } + + @Override + public void clear(int bitIndex) { + throw new UnsupportedOperationException(); + } + + @Override + public void clear(int fromIndex, int toIndex) { + throw new UnsupportedOperationException(); + } + + @Override + public void clear() { + throw new UnsupportedOperationException(); + } + + @Override + public void and(@NotNull BitSet set) { + throw new UnsupportedOperationException(); + } + + @Override + public void or(@NotNull BitSet set) { + throw new UnsupportedOperationException(); + } + + @Override + public void xor(@NotNull BitSet set) { + throw new UnsupportedOperationException(); + } + + @Override + public void andNot(@NotNull BitSet set) { + throw new UnsupportedOperationException(); + } + } +} diff --git a/src/main/java/com/coditory/quark/uri/Hosts.java b/src/main/java/com/coditory/quark/uri/Hosts.java new file mode 100644 index 0000000..be967eb --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/Hosts.java @@ -0,0 +1,154 @@ +package com.coditory.quark.uri; + +import org.jetbrains.annotations.NotNull; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.function.Predicate; +import java.util.function.Supplier; +import java.util.regex.Pattern; + +import static com.coditory.quark.uri.Preconditions.expectNonBlank; +import static com.coditory.quark.uri.Preconditions.expectNonNull; + +public final class Hosts { + private Hosts() { + throw new UnsupportedOperationException("Do not instantiate utility class"); + } + + /** + * @return local host name. Example: john-macbook-pro + */ + @NotNull + public static String getLocalHostName() { + return LocalHostNameResolver.LOCAL_HOST_NAME; + } + + /** + * @return local host ip address. Example: 127.0.1.1 + */ + @NotNull + public static String getLocalHostAddress() { + return LocalHostAddressResolver.LOCAL_HOST_ADDRESS; + } + + /** + * Java Language Specification specifies that a class initialization occurs + * the first time its methods or fields are used. + * Nested static class can be used to implement lazy initialization. + * + * @link https://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.4.2 + */ + private static class LocalHostNameResolver { + private static final Predicate IP_ADDRESS = Pattern.compile("(\\d{1,3}\\.){3}\\d{1,3}").asPredicate(); + static final String LOCAL_HOST_NAME = ResolverWithOsCommandFallback + .resolveWithOsFallback( + "local host name", + LocalHostNameResolver::resolveLocalHostNameUsingJVM, + "hostname -f" + ); + + private LocalHostNameResolver() { + throw new IllegalStateException("This is a utility class and cannot be instantiated"); + } + + private static String resolveLocalHostNameUsingJVM() { + InetAddress localhost = getLocalHost(); + String canonicalHostName = localhost.getCanonicalHostName(); + String hostName = localhost.getHostName(); + return IP_ADDRESS.test(canonicalHostName) + ? hostName + : canonicalHostName; + } + + private static InetAddress getLocalHost() { + try { + return InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + throw new RuntimeException("Could not get localhost address", e); + } + } + } + + private static class LocalHostAddressResolver { + static final String LOCAL_HOST_ADDRESS = ResolverWithOsCommandFallback + .resolveWithOsFallback( + "local host address", + LocalHostAddressResolver::resolveLocalHostAddress, + "hostname -i" + ); + + private LocalHostAddressResolver() { + throw new IllegalStateException("This is a utility class and cannot be instantiated"); + } + + private static String resolveLocalHostAddress() { + InetAddress localhost = getLocalHost(); + return localhost.getHostAddress(); + } + + private static InetAddress getLocalHost() { + try { + return InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + throw new RuntimeException("Could not get localhost address", e); + } + } + } + + private static class ResolverWithOsCommandFallback { + static String resolveWithOsFallback(String name, Supplier jvmSupplier, String systemCommand) { + return new ResolverWithOsCommandFallback(name, jvmSupplier, systemCommand) + .resolve(); + } + + private final String name; + private final Supplier jvmSupplier; + private final String[] systemCommand; + + ResolverWithOsCommandFallback(String name, Supplier jvmSupplier, String systemCommand) { + expectNonBlank(systemCommand, "systemCommand"); + this.name = expectNonBlank(name, "name"); + this.jvmSupplier = expectNonNull(jvmSupplier, "jvmSupplier"); + this.systemCommand = systemCommand.split(" "); + } + + String resolve() { + try { + return resolveUsingJVM(); + } catch (Exception exception) { + return resolveUsingOs(); + } + } + + private String resolveUsingJVM() { + return jvmSupplier.get(); + } + + private String resolveUsingOs() { + try ( + InputStream is = Runtime.getRuntime() + .exec(systemCommand) + .getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(is)) + ) { + StringBuilder builder = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + builder.append(line).append("\n"); + } + return builder.toString().trim(); + } catch (IOException exception) { + String cmd = String.join(" ", systemCommand); + throw new RuntimeException( + "Could not resolve " + name + ". OS does not support command: " + cmd, + exception + ); + } + } + } +} diff --git a/src/main/java/com/coditory/quark/uri/InetAddressValidator.java b/src/main/java/com/coditory/quark/uri/InetAddressValidator.java new file mode 100644 index 0000000..f42925c --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/InetAddressValidator.java @@ -0,0 +1,168 @@ +package com.coditory.quark.uri; + +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static com.coditory.quark.uri.Strings.isNullOrBlank; + +public final class InetAddressValidator { + private InetAddressValidator() { + throw new UnsupportedOperationException("Do not instantiate utility class"); + } + + private static final int MAX_BYTE = 128; + private static final int IPV4_MAX_OCTET_VALUE = 255; + private static final int MAX_UNSIGNED_SHORT = 0xffff; + private static final int BASE_16 = 16; + private static final Pattern IPV4_REGEX = Pattern.compile("^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$"); + private static final int IPV6_MAX_HEX_GROUPS = 8; + private static final int IPV6_MAX_HEX_DIGITS_PER_GROUP = 4; + + public static void validateInetAddress(@Nullable String inetAddress) { + if (!isValidInetV4Address(inetAddress) && !isValidInetV6Address(inetAddress)) { + throw new IllegalArgumentException("Expected valid ip address. Got: " + inetAddress); + } + } + + public static void validateInetV4Address(@Nullable String inetAddress) { + if (!isValidInetV4Address(inetAddress)) { + throw new IllegalArgumentException("Expected valid ip v4 address. Got: " + inetAddress); + } + } + + public static void validateInetV6Address(@Nullable String inetAddress) { + if (!isValidInetV6Address(inetAddress)) { + throw new IllegalArgumentException("Expected valid ip v6 address. Got: " + inetAddress); + } + } + + public static boolean isValidInetAddress(@Nullable String inetAddress) { + return isValidInetV4Address(inetAddress) || isValidInetV6Address(inetAddress); + } + + public static boolean isValidInetV4Address(@Nullable String inet4Address) { + if (inet4Address == null || inet4Address.isBlank()) { + return false; + } + Matcher matcher = IPV4_REGEX.matcher(inet4Address); + if (!matcher.matches()) { + return false; + } + for (int j = 0; j < matcher.groupCount(); j++) { + String ipSegment = matcher.group(j + 1); + if (isNullOrBlank(ipSegment)) { + return false; + } + if (ipSegment.length() > 1 && ipSegment.startsWith("0")) { + return false; + } + Integer iIpSegment = parseIntegerOrNull(ipSegment); + if (iIpSegment == null || iIpSegment > IPV4_MAX_OCTET_VALUE) { + return false; + } + } + return true; + } + + private static Integer parseIntegerOrNull(String text) { + if (text == null) { + return null; + } + try { + return Integer.parseInt(text); + } catch (RuntimeException e) { + return null; + } + } + + public static boolean isValidInetV6Address(@Nullable String inet6Address) { + if (inet6Address == null || inet6Address.isBlank()) { + return false; + } + String[] parts; + parts = inet6Address.split("/", -1); + if (parts.length > 2) { + return false; + } + if (parts.length == 2) { + if (parts[1].matches("\\d{1,3}")) { + int bits = Integer.parseInt(parts[1]); + if (bits < 0 || bits > MAX_BYTE) { + return false; + } + } else { + return false; + } + } + parts = parts[0].split("%", -1); + if (parts.length > 2) { + return false; + } else if (parts.length == 2) { + if (!parts[1].matches("[^\\s/%]+")) { + return false; + } + } + inet6Address = parts[0]; + boolean containsCompressedZeroes = inet6Address.contains("::"); + if (containsCompressedZeroes && (inet6Address.indexOf("::") != inet6Address.lastIndexOf("::"))) { + return false; + } + if ((inet6Address.startsWith(":") && !inet6Address.startsWith("::")) + || (inet6Address.endsWith(":") && !inet6Address.endsWith("::"))) { + return false; + } + String[] octets = inet6Address.split(":"); + if (containsCompressedZeroes) { + List octetList = new ArrayList<>(Arrays.asList(octets)); + if (inet6Address.endsWith("::")) { + octetList.add(""); + } else if (inet6Address.startsWith("::") && !octetList.isEmpty()) { + octetList.remove(0); + } + octets = octetList.toArray(new String[0]); + } + if (octets.length > IPV6_MAX_HEX_GROUPS) { + return false; + } + int validOctets = 0; + int emptyOctets = 0; // consecutive empty chunks + for (int index = 0; index < octets.length; index++) { + String octet = octets[index]; + if (octet.length() == 0) { + emptyOctets++; + if (emptyOctets > 1) { + return false; + } + } else { + emptyOctets = 0; + if (index == octets.length - 1 && octet.contains(".")) { + if (!isValidInetV4Address(octet)) { + return false; + } + validOctets += 2; + continue; + } + if (octet.length() > IPV6_MAX_HEX_DIGITS_PER_GROUP) { + return false; + } + int octetInt = 0; + try { + octetInt = Integer.parseInt(octet, BASE_16); + } catch (NumberFormatException e) { + return false; + } + if (octetInt < 0 || octetInt > MAX_UNSIGNED_SHORT) { + return false; + } + } + validOctets++; + } + return validOctets <= IPV6_MAX_HEX_GROUPS + && (validOctets == IPV6_MAX_HEX_GROUPS || containsCompressedZeroes); + } +} diff --git a/src/main/java/com/coditory/quark/uri/InvalidHttpUrlException.java b/src/main/java/com/coditory/quark/uri/InvalidHttpUrlException.java new file mode 100644 index 0000000..d3fe3f9 --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/InvalidHttpUrlException.java @@ -0,0 +1,11 @@ +package com.coditory.quark.uri; + +public final class InvalidHttpUrlException extends RuntimeException { + InvalidHttpUrlException(String message) { + super(message); + } + + InvalidHttpUrlException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/src/main/java/com/coditory/quark/uri/InvalidUriException.java b/src/main/java/com/coditory/quark/uri/InvalidUriException.java new file mode 100644 index 0000000..79c7245 --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/InvalidUriException.java @@ -0,0 +1,7 @@ +package com.coditory.quark.uri; + +public final class InvalidUriException extends RuntimeException { + InvalidUriException(String message) { + super(message); + } +} diff --git a/src/main/java/com/coditory/quark/uri/Nullable.java b/src/main/java/com/coditory/quark/uri/Nullable.java new file mode 100644 index 0000000..e55370d --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/Nullable.java @@ -0,0 +1,33 @@ +package com.coditory.quark.uri; + +import java.util.function.Consumer; +import java.util.function.Function; + +import static com.coditory.quark.uri.Preconditions.expectNonNull; + +final class Nullable { + private Nullable() { + throw new UnsupportedOperationException("Do not instantiate utility class"); + } + + static R mapNotNull(T object, Function mapper) { + expectNonNull(mapper, "mapper"); + return object != null + ? mapper.apply(object) + : null; + } + + static R mapNotNull(T object, Function mapper, R defaultValue) { + expectNonNull(mapper, "mapper"); + return object != null + ? mapper.apply(object) + : defaultValue; + } + + static void onNotNull(T object, Consumer consumer) { + expectNonNull(consumer, "consumer"); + if (object != null) { + consumer.accept(object); + } + } +} diff --git a/src/main/java/com/coditory/quark/uri/PercentCodec.java b/src/main/java/com/coditory/quark/uri/PercentCodec.java new file mode 100644 index 0000000..16bf4d7 --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/PercentCodec.java @@ -0,0 +1,148 @@ +package com.coditory.quark.uri; + +import org.jetbrains.annotations.NotNull; + +import java.nio.charset.Charset; +import java.util.BitSet; + +import static com.coditory.quark.uri.Preconditions.expectNonNull; +import static com.coditory.quark.uri.UriRfcCharacters.URI_UNRESERVED; +import static java.nio.charset.StandardCharsets.UTF_8; + +public final class PercentCodec { + public static final PercentCodec PERCENT_CODEC = PercentCodec.builder() + .decodeSpaceAsPlus(false) + .charset(UTF_8) + .safeCharactersAsUriUnreserved() + .build(); + + public static final PercentCodec PERCENT_PLUS_CODEC = PercentCodec.builder() + .decodeSpaceAsPlus(true) + .charset(UTF_8) + .safeCharactersAsUriUnreserved() + .build(); + + public static String encodeUriComponent(String component) { + return PERCENT_CODEC.encode(component); + } + + public static String decodeUriComponent(String component) { + return PERCENT_CODEC.decode(component); + } + + public static String encodeUriComponentWithPlusAsSpace(String component) { + return PERCENT_PLUS_CODEC.encode(component); + } + + public static String decodeUriComponentWithPlusAsSpace(String component) { + return PERCENT_PLUS_CODEC.decode(component); + } + + private final PercentEncoder encoder; + private final PercentDecoder decoder; + + PercentCodec(PercentEncoder encoder, PercentDecoder decoder) { + this.encoder = encoder; + this.decoder = decoder; + } + + @NotNull + public String encode(@NotNull String input) { + return encoder.encode(input); + } + + public boolean encode(@NotNull String input, @NotNull StringBuilder out) { + return encoder.encode(input, out); + } + + public boolean encode(@NotNull String input, @NotNull StringBuilder out, @NotNull Charset charset) { + return encoder.encode(input, out, charset); + } + + @NotNull + public String decode(@NotNull String input) { + return decoder.decode(input); + } + + public boolean decode(@NotNull String input, @NotNull StringBuilder out) { + return decoder.decode(input, out); + } + + public boolean decode(@NotNull String input, @NotNull StringBuilder out, @NotNull Charset charset) { + return decoder.decode(input, out, charset); + } + + @NotNull + public static PercentCodecBuilder builder() { + return new PercentCodecBuilder(); + } + + public static class PercentCodecBuilder { + private BitSet safeCharacters = BitSets.of(URI_UNRESERVED); + private boolean decodeSpaceAsPlus = false; + private boolean encodeSpaceAsPlus = false; + private Charset charset = UTF_8; + + @NotNull + public PercentCodecBuilder addSafeCharacters(@NotNull String safeCharacters) { + expectNonNull(safeCharacters, "safeCharacters"); + this.safeCharacters.or(BitSets.of(safeCharacters)); + return this; + } + + @NotNull + public PercentCodecBuilder safeCharacters(@NotNull String safeCharacters) { + expectNonNull(safeCharacters, "safeCharacters"); + this.safeCharacters = BitSets.of(safeCharacters); + return this; + } + + @NotNull + public PercentCodecBuilder safeCharactersAsUriUnreserved() { + return safeCharacters(URI_UNRESERVED); + } + + @NotNull + public PercentCodecBuilder decodeSpaceAsPlus(boolean spaceAsPlus) { + this.decodeSpaceAsPlus = spaceAsPlus; + return this; + } + + @NotNull + public PercentCodecBuilder encodeSpaceAsPlus(boolean spaceAsPlus) { + this.encodeSpaceAsPlus = spaceAsPlus; + return this; + } + + @NotNull + public PercentCodecBuilder spaceAsPlus(boolean spaceAsPlus) { + this.decodeSpaceAsPlus = spaceAsPlus; + this.encodeSpaceAsPlus = spaceAsPlus; + return this; + } + + @NotNull + public PercentCodecBuilder charset(Charset charset) { + expectNonNull(charset, "charset"); + this.charset = charset; + return this; + } + + @NotNull + public PercentCodec build() { + if (encodeSpaceAsPlus || decodeSpaceAsPlus) { + safeCharacters = BitSets.set(safeCharacters, '+', false); + } + PercentEncoder encoder = PercentEncoder.builder() + .safeCharacters(safeCharacters) + .spaceAsPlus(encodeSpaceAsPlus) + .charset(charset) + .build(); + PercentDecoder decoder = PercentDecoder.builder() + .spaceAsPlus(decodeSpaceAsPlus) + .charset(charset) + .build(); + return new PercentCodec(encoder, decoder); + } + } +} diff --git a/src/main/java/com/coditory/quark/uri/PercentDecoder.java b/src/main/java/com/coditory/quark/uri/PercentDecoder.java new file mode 100644 index 0000000..55f9fc3 --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/PercentDecoder.java @@ -0,0 +1,107 @@ +package com.coditory.quark.uri; + +import java.nio.charset.Charset; + +import static com.coditory.quark.uri.Preconditions.expectNonNull; +import static java.nio.charset.StandardCharsets.UTF_8; + +final class PercentDecoder { + private final Charset charset; + private final boolean spaceAsPlus; + + private PercentDecoder(boolean spaceAsPlus, Charset charset) { + this.spaceAsPlus = spaceAsPlus; + this.charset = expectNonNull(charset, "charset"); + } + + String decode(String text) { + StringBuilder dst = new StringBuilder(); + decode(text, dst); + return dst.toString(); + } + + boolean decode(String text, StringBuilder dst) { + return decode(text, dst, charset); + } + + boolean decode(String text, StringBuilder dst, Charset charset) { + expectNonNull(dst, "dst"); + expectNonNull(text, "text"); + expectNonNull(charset, "charset"); + boolean needToChange = false; + int length = text.length(); + StringBuilder sb = new StringBuilder(length > 500 ? length / 2 : length); + int i = 0; + byte[] bytes = null; + while (i < length) { + char c = text.charAt(i); + switch (c) { + case '+' -> { + if (!spaceAsPlus) { + sb.append('+'); + } else { + sb.append(' '); + needToChange = true; + } + i++; + } + case '%' -> { + try { + if (bytes == null) { + bytes = new byte[(length - i) / 3]; + } + int pos = 0; + while ((i + 2) < length && c == '%') { + int v = Integer.parseInt(text, i + 1, i + 3, 16); + if (v < 0) { + throw new IllegalArgumentException("Illegal hex characters in escape (%) pattern - negative value"); + } + bytes[pos++] = (byte) v; + i += 3; + if (i < length) { + c = text.charAt(i); + } + } + if (i < length && c == '%') { + throw new IllegalArgumentException("Incomplete trailing escape (%) pattern"); + } + sb.append(new String(bytes, 0, pos, charset)); + } catch (NumberFormatException e) { + throw new IllegalArgumentException("Illegal hex characters in escape (%) pattern - " + e.getMessage()); + } + needToChange = true; + } + default -> { + sb.append(c); + i++; + } + } + } + dst.append(sb); + return needToChange; + } + + static PercentDecoderBuilder builder() { + return new PercentDecoderBuilder(); + } + + static class PercentDecoderBuilder { + private boolean spaceAsPlus = false; + private Charset charset = UTF_8; + + public PercentDecoderBuilder spaceAsPlus(boolean spaceAsPlus) { + this.spaceAsPlus = spaceAsPlus; + return this; + } + + public PercentDecoderBuilder charset(Charset charset) { + expectNonNull(charset, "charset"); + this.charset = charset; + return this; + } + + public PercentDecoder build() { + return new PercentDecoder(spaceAsPlus, charset); + } + } +} diff --git a/src/main/java/com/coditory/quark/uri/PercentEncoder.java b/src/main/java/com/coditory/quark/uri/PercentEncoder.java new file mode 100644 index 0000000..b98658a --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/PercentEncoder.java @@ -0,0 +1,137 @@ +package com.coditory.quark.uri; + +import java.io.CharArrayWriter; +import java.nio.charset.Charset; +import java.util.BitSet; + +import static com.coditory.quark.uri.BitSets.unmodifiableBitSet; +import static com.coditory.quark.uri.Preconditions.expectNonNull; +import static com.coditory.quark.uri.UriRfcCharacters.URI_UNRESERVED; +import static java.nio.charset.StandardCharsets.UTF_8; + +final class PercentEncoder { + private static final int CASE_DIFF = ('a' - 'A'); + private final boolean spaceAsPlus; + private final Charset charset; + private final BitSet safeCharacters; + + private PercentEncoder(BitSet safeCharacters, boolean spaceAsPlus, Charset charset) { + this.spaceAsPlus = spaceAsPlus; + this.charset = expectNonNull(charset, "charset"); + this.safeCharacters = expectNonNull(safeCharacters, "safeCharacters"); + } + + String encode(String text) { + StringBuilder dst = new StringBuilder(); + encode(text, dst); + return dst.toString(); + } + + boolean encode(String text, StringBuilder dst) { + return encode(text, dst, charset); + } + + boolean encode(String text, StringBuilder dst, Charset charset) { + expectNonNull(dst, "dst"); + expectNonNull(text, "text"); + expectNonNull(charset, "charset"); + boolean needToChange = false; + StringBuilder out = new StringBuilder(text.length()); + CharArrayWriter charArrayWriter = new CharArrayWriter(); + + for (int i = 0; i < text.length(); ) { + int cp = text.codePointAt(i); + if (cp == ' ' && spaceAsPlus) { + out.append('+'); + needToChange = true; + i++; + } else if (safeCharacters.get(cp) && (cp != '+' || !spaceAsPlus)) { + out.appendCodePoint(cp); + i += Character.charCount(cp); + } else { + do { + char c = text.charAt(i); + charArrayWriter.write(c); + if (c >= 0xD800 && c <= 0xDBFF) { + if ((i + 1) < text.length()) { + char d = text.charAt(i + 1); + if (d >= 0xDC00 && d <= 0xDFFF) { + charArrayWriter.write(d); + i++; + } + } + } + i++; + } while (i < text.length() && !safeCharacters.get(text.codePointAt(i))); + charArrayWriter.flush(); + byte[] bytes = new String(charArrayWriter.toCharArray()) + .getBytes(charset); + for (byte aByte : bytes) { + out.append('%'); + char c = Character.forDigit((aByte >> 4) & 0xF, 16); + if (Character.isLetter(c)) { + c -= CASE_DIFF; + } + out.append(c); + c = Character.forDigit(aByte & 0xF, 16); + if (Character.isLetter(c)) { + c -= CASE_DIFF; + } + out.append(c); + } + charArrayWriter.reset(); + needToChange = true; + } + } + dst.append(out); + return needToChange; + } + + static PercentEncoderBuilder builder() { + return new PercentEncoderBuilder(); + } + + static class PercentEncoderBuilder { + private BitSet safeCharacters = BitSets.of(URI_UNRESERVED); + private boolean spaceAsPlus = false; + private Charset charset = UTF_8; + + PercentEncoderBuilder addSafeCharacters(String safeCharacters) { + expectNonNull(safeCharacters, "safeCharacters"); + return safeCharacters(BitSets.of(safeCharacters)); + } + + PercentEncoderBuilder safeCharactersAsUriUnreserved() { + return safeCharacters(URI_UNRESERVED); + } + + PercentEncoderBuilder safeCharacters(BitSet safeCharacters) { + expectNonNull(safeCharacters, "safeCharacters"); + this.safeCharacters = unmodifiableBitSet(safeCharacters); + return this; + } + + PercentEncoderBuilder safeCharacters(String safeCharacters) { + expectNonNull(safeCharacters, "safeCharacters"); + return safeCharacters(BitSets.of(safeCharacters)); + } + + PercentEncoderBuilder spaceAsPlus(boolean spaceAsPlus) { + this.spaceAsPlus = spaceAsPlus; + return this; + } + + PercentEncoderBuilder charset(Charset charset) { + expectNonNull(charset, "charset"); + this.charset = charset; + return this; + } + + PercentEncoder build() { + if (spaceAsPlus) { + safeCharacters = BitSets.set(safeCharacters, '+', false); + } + return new PercentEncoder(safeCharacters, spaceAsPlus, charset); + } + } +} diff --git a/src/main/java/com/coditory/quark/uri/Ports.java b/src/main/java/com/coditory/quark/uri/Ports.java new file mode 100644 index 0000000..5b6e2bb --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/Ports.java @@ -0,0 +1,82 @@ +package com.coditory.quark.uri; + +import java.io.IOException; +import java.net.DatagramSocket; +import java.net.ServerSocket; + +import static com.coditory.quark.uri.Preconditions.expect; + +public final class Ports { + private Ports() { + throw new UnsupportedOperationException("Do not instantiate utility class"); + } + + public final static int SCHEME_DEFAULT_PORT_NUMBER = -1; + public final static int MIN_PORT_VALUE = 0; + public final static int MAX_PORT_VALUE = 65535; + + public static boolean isValidPortNumberOrSchemeDefault(int port) { + return port >= SCHEME_DEFAULT_PORT_NUMBER && port <= MAX_PORT_VALUE; + } + + public static boolean isValidPortNumber(int port) { + return port >= MIN_PORT_VALUE && port <= MAX_PORT_VALUE; + } + + public static boolean isSchemeDefault(int port) { + return port == SCHEME_DEFAULT_PORT_NUMBER; + } + + public static void validatePortNumberOrSchemeDefault(int port) { + if (!isValidPortNumberOrSchemeDefault(port)) { + String message = String.format("Expected port number in range [%d, %d]. Got: %d", + SCHEME_DEFAULT_PORT_NUMBER, MAX_PORT_VALUE, port); + throw new IllegalArgumentException(message); + } + } + + public static void validatePortNumber(int port) { + if (!isValidPortNumber(port)) { + String message = String.format("Expected port number in range [%d, %d]. Got: %d", + MIN_PORT_VALUE, MAX_PORT_VALUE, port); + throw new IllegalArgumentException(message); + } + } + + public static int nextAvailablePort() { + try { + try (ServerSocket socket = new ServerSocket(0)) { + return socket.getLocalPort(); + } + } catch (IOException exception) { + throw new IllegalStateException("Could not get available port", exception); + } + } + + public static int nextAvailablePort(int min, int max) { + expect(min <= max, "Expected min <= max. Got: %d > %d", min, max); + validatePortNumber(min); + validatePortNumber(max); + for (int port = min; port <= max; ++port) { + if (isPortAvailable(port)) { + return port; + } + } + throw new IllegalStateException("Could not get available port between: " + min + " and " + max); + } + + public static boolean isPortAvailable(int port) { + validatePortNumber(port); + try { + try (ServerSocket socket = new ServerSocket(port)) { + socket.setReuseAddress(true); + try (DatagramSocket datagramSocket = new DatagramSocket(port)) { + datagramSocket.setReuseAddress(true); + return true; + } + } + } catch (IOException e) { + return false; + } + } +} diff --git a/src/main/java/com/coditory/quark/uri/Preconditions.java b/src/main/java/com/coditory/quark/uri/Preconditions.java new file mode 100644 index 0000000..9f9642d --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/Preconditions.java @@ -0,0 +1,62 @@ +package com.coditory.quark.uri; + +import org.jetbrains.annotations.Nullable; + +import java.util.Objects; + +final class Preconditions { + private Preconditions() { + throw new UnsupportedOperationException("Do not instantiate utility class"); + } + + static void expect(boolean check, String message, Object... args) { + if (!check) { + throw new IllegalArgumentException(String.format(message, args)); + } + } + + static T expectNonNull(@Nullable T value, String name) { + if (value == null) { + String message = message("Expected non-null value", name); + throw new IllegalArgumentException(message); + } + return value; + } + + static String expectNonEmpty(@Nullable String value, String name) { + if (value == null || value.isEmpty()) { + String message = message("Expected non-null and non-empty value", name, value); + throw new IllegalArgumentException(message); + } + return value; + } + + static String expectNonBlank(@Nullable String value, String name) { + if (value == null || value.isBlank()) { + String message = message("Expected non-null and non-blank value", name, value); + throw new IllegalArgumentException(message); + } + return value; + } + + static String expectNoWhitespaces(@Nullable String value, String name) { + if (value == null || Strings.containsWhitespace(value)) { + String message = message("Expected non-null value with no whitespaces", name, value); + throw new IllegalArgumentException(message); + } + return value; + } + + private static String message(String expectation, String fieldName, Object value) { + String field = fieldName != null ? (": " + fieldName) : ""; + String stringValue = value instanceof String + ? ("\"" + value + "\"") + : Objects.toString(value); + return expectation + field + ". Got: " + stringValue; + } + + private static String message(String expectation, String fieldName) { + String field = fieldName != null ? (": " + fieldName) : ""; + return expectation + field; + } +} diff --git a/src/main/java/com/coditory/quark/uri/Strings.java b/src/main/java/com/coditory/quark/uri/Strings.java new file mode 100644 index 0000000..2b9955e --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/Strings.java @@ -0,0 +1,49 @@ +package com.coditory.quark.uri; + +import java.util.Locale; + +import static com.coditory.quark.uri.Preconditions.expectNonNull; + +final class Strings { + private Strings() { + throw new UnsupportedOperationException("Do not instantiate utility class"); + } + + static boolean isNullOrEmpty(String text) { + return text == null || text.isEmpty(); + } + + static boolean isNotNullOrEmpty(String text) { + return !isNullOrEmpty(text); + } + + static boolean isNullOrBlank(String text) { + return text == null || text.isBlank(); + } + + static boolean isNotNullOrBlank(String text) { + return !isNullOrBlank(text); + } + + static String emptyToNull(String text) { + return text == null || text.isEmpty() + ? null + : text; + } + + static String blankToNull(String text) { + return text == null || text.isBlank() + ? null + : text; + } + + static String lowerCase(String text) { + expectNonNull(text, "text"); + return text.toLowerCase(Locale.ROOT); + } + + public static boolean containsWhitespace(String text) { + expectNonNull(text, "text"); + return text.codePoints().anyMatch(Character::isWhitespace); + } +} diff --git a/src/main/java/com/coditory/quark/uri/Throwables.java b/src/main/java/com/coditory/quark/uri/Throwables.java new file mode 100644 index 0000000..7e3dbb1 --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/Throwables.java @@ -0,0 +1,40 @@ +package com.coditory.quark.uri; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static com.coditory.quark.uri.Preconditions.expectNonNull; + +final class Throwables { + private Throwables() { + throw new UnsupportedOperationException("Do not instantiate utility class"); + } + + @SuppressWarnings("unchecked") + static T getRootCauseOfType(Throwable throwable, Class type) { + expectNonNull(throwable, "throwable"); + expectNonNull(type, "type"); + List list = getCauses(throwable); + Collections.reverse(list); + Throwable result = list.stream() + .filter(type::isInstance) + .findFirst() + .orElse(null); + return (T) result; + } + + static List getCauses(Throwable throwable) { + expectNonNull(throwable, "throwable"); + List list = new ArrayList<>(); + Set visited = new HashSet<>(); + while (throwable != null && !visited.contains(throwable)) { + list.add(throwable); + visited.add(throwable); + throwable = throwable.getCause(); + } + return list; + } +} diff --git a/src/main/java/com/coditory/quark/uri/UriAuthority.java b/src/main/java/com/coditory/quark/uri/UriAuthority.java new file mode 100644 index 0000000..a8c68b3 --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/UriAuthority.java @@ -0,0 +1,97 @@ +package com.coditory.quark.uri; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Locale; +import java.util.Objects; + +import static com.coditory.quark.uri.Nullable.mapNotNull; +import static com.coditory.quark.uri.Ports.SCHEME_DEFAULT_PORT_NUMBER; +import static com.coditory.quark.uri.Ports.validatePortNumberOrSchemeDefault; +import static com.coditory.quark.uri.Preconditions.expectNoWhitespaces; +import static com.coditory.quark.uri.Preconditions.expectNonEmpty; + +public final class UriAuthority { + private static final UriAuthority EMPTY = new UriAuthority(null, null, SCHEME_DEFAULT_PORT_NUMBER); + + @NotNull + public static UriAuthority empty() { + return EMPTY; + } + + @NotNull + public static UriAuthority of(@Nullable String userInfo, @Nullable String hostname, int port) { + if (hostname != null) { + expectNoWhitespaces(hostname, "hostname"); + } + if (userInfo != null) { + expectNonEmpty(userInfo, "userInfo"); + } + validatePortNumberOrSchemeDefault(port); + if (userInfo == null && hostname == null && Ports.isSchemeDefault(port)) { + return empty(); + } + return new UriAuthority( + userInfo, + mapNotNull(hostname, h -> h.toLowerCase(Locale.ROOT)), + port + ); + } + + private final String userInfo; + private final String hostname; + private final int port; + + private UriAuthority(@Nullable String userInfo, @Nullable String hostname, int port) { + this.userInfo = userInfo; + this.hostname = hostname; + this.port = port; + } + + @Nullable + public String getUserInfo() { + return userInfo; + } + + @Nullable + public String getHostname() { + return hostname; + } + + public int getPort() { + return port; + } + + public boolean usesSchemeDefaultPort() { + return port == SCHEME_DEFAULT_PORT_NUMBER; + } + + public boolean isEmpty() { + return this.equals(EMPTY); + } + + @Override + public String toString() { + return "UriAuthority{" + + "userInfo='" + userInfo + '\'' + + ", hostname='" + hostname + '\'' + + ", port=" + port + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + UriAuthority that = (UriAuthority) o; + return port == that.port + && Objects.equals(userInfo, that.userInfo) + && Objects.equals(hostname, that.hostname); + } + + @Override + public int hashCode() { + return Objects.hash(userInfo, hostname, port); + } +} diff --git a/src/main/java/com/coditory/quark/uri/UriBuilder.java b/src/main/java/com/coditory/quark/uri/UriBuilder.java new file mode 100644 index 0000000..4ae37b9 --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/UriBuilder.java @@ -0,0 +1,494 @@ +package com.coditory.quark.uri; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.net.URI; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import static com.coditory.quark.uri.Ports.SCHEME_DEFAULT_PORT_NUMBER; +import static com.coditory.quark.uri.Ports.validatePortNumberOrSchemeDefault; +import static com.coditory.quark.uri.Preconditions.expectNonBlank; +import static com.coditory.quark.uri.Preconditions.expectNonNull; +import static com.coditory.quark.uri.Strings.emptyToNull; +import static com.coditory.quark.uri.Strings.isNotNullOrBlank; +import static com.coditory.quark.uri.Strings.isNotNullOrEmpty; +import static com.coditory.quark.uri.Strings.isNullOrEmpty; +import static com.coditory.quark.uri.Strings.lowerCase; +import static com.coditory.quark.uri.UriComponentsParser.parseQuery; +import static com.coditory.quark.uri.UriRfc.PATH_SEGMENT; + +public final class UriBuilder { + @NotNull + public static UriBuilder from(@NotNull UriComponents uriComponents) { + expectNonNull(uriComponents, "uriComponents"); + UriBuilder builder = new UriBuilder(); + builder.scheme = uriComponents.getScheme(); + builder.ssp = uriComponents.getSchemeSpecificPart(); + builder.fragment = uriComponents.getFragment(); + if (!uriComponents.isOpaque()) { + builder.userInfo = uriComponents.getUserInfo(); + builder.protocolRelative = uriComponents.isProtocolRelative(); + builder.host = uriComponents.getHost(); + builder.port = uriComponents.getPort(); + builder.setRootPath(uriComponents.isRootPath()); + builder.setPathSegments(uriComponents.getPathSegments()); + builder.setQueryMultiParams(uriComponents.getQueryParams()); + } + return builder; + } + + @NotNull + public static UriBuilder from(@NotNull URI uri) { + expectNonNull(uri, "uri"); + return new UriBuilder().setUri(uri); + } + + @NotNull + public static UriBuilder from(@NotNull URL url) { + expectNonNull(url, "url"); + URI uri; + try { + uri = url.toURI(); + } catch (Exception e) { + throw new IllegalArgumentException("Could not convert url to uri", e); + } + return new UriBuilder().setUri(uri); + } + + @NotNull + public static UriBuilder fromUri(@NotNull String uri) { + expectNonNull(uri, "uri"); + return UriComponentsParser.parseUri(uri); + } + + @Nullable + public static UriBuilder fromUriOrNull(@Nullable String uri) { + if (uri == null) { + return null; + } + try { + return fromUri(uri); + } catch (RuntimeException e) { + return null; + } + } + + @NotNull + public static UriBuilder fromHttpUrl(@NotNull String url) { + expectNonNull(url, "url"); + return UriComponentsParser.parseHttpUrl(url); + } + + @Nullable + public static UriBuilder fromHttpUrlOrNull(@Nullable String url) { + if (url == null) { + return null; + } + try { + return fromHttpUrl(url); + } catch (RuntimeException e) { + return null; + } + } + + private String scheme; + private String ssp; + private String userInfo; + private String host; + private int port = SCHEME_DEFAULT_PORT_NUMBER; + private boolean protocolRelative = false; + private boolean rootPath = false; + private final List pathSegments = new ArrayList<>(); + private final Map> queryParams = new LinkedHashMap<>(); + private String fragment; + + UriBuilder() { + } + + @NotNull + public UriBuilder setUri(@NotNull URI uri) { + expectNonNull(uri, "uri"); + this.scheme = uri.getScheme(); + if (uri.isOpaque()) { + this.ssp = uri.getRawSchemeSpecificPart(); + resetHierarchicalComponents(); + } else { + if (uri.getRawUserInfo() != null) { + this.userInfo = uri.getRawUserInfo(); + } + if (uri.getHost() != null) { + this.host = uri.getHost(); + } + if (uri.getPort() != -1) { + this.port = uri.getPort(); + } + if (isNotNullOrEmpty(uri.getRawPath())) { + setPath(uri.getRawPath()); + } + if (isNotNullOrEmpty(uri.getRawQuery())) { + this.queryParams.clear(); + setQuery(uri.getRawQuery()); + } + resetSchemeSpecificPart(); + } + if (uri.getRawFragment() != null) { + this.fragment = uri.getRawFragment(); + } + return this; + } + + @NotNull + public UriBuilder copy() { + return from(buildUriComponents()); + } + + @NotNull + public UriComponents buildUriComponents() { + return this.ssp != null + ? UriComponents.buildOpaque(scheme, ssp, fragment) + : UriComponents.buildHierarchical(scheme, userInfo, host, port, protocolRelative, rootPath, pathSegments, queryParams, fragment); + } + + @NotNull + public URI buildUri() { + return buildUriComponents().toUri(); + } + + @NotNull + public String buildUriString() { + return buildUriComponents().toUriString(); + } + + @NotNull + public UriBuilder setScheme(@Nullable String scheme) { + if (isNotNullOrBlank(scheme)) { + if (scheme.equals("//")) { + this.scheme = null; + this.protocolRelative = true; + } else { + this.scheme = lowerCase(scheme); + this.protocolRelative = false; + } + resetSchemeSpecificPart(); + } else { + this.scheme = null; + } + return this; + } + + @NotNull + public UriBuilder setProtocolRelative(boolean protocolRelative) { + this.scheme = null; + this.protocolRelative = protocolRelative; + return this; + } + + @NotNull + public UriBuilder removeScheme() { + this.scheme = null; + return this; + } + + @NotNull + public UriBuilder setSchemeSpecificPart(@Nullable String ssp) { + if (isNotNullOrBlank(ssp)) { + this.ssp = ssp; + resetHierarchicalComponents(); + } else { + this.ssp = null; + } + return this; + } + + @NotNull + public UriBuilder removeSchemeSpecificPart() { + this.ssp = null; + return this; + } + + @NotNull + public UriBuilder setUserInfo(@Nullable String userInfo) { + if (isNotNullOrBlank(userInfo)) { + this.userInfo = userInfo; + resetSchemeSpecificPart(); + } else { + this.userInfo = null; + } + return this; + } + + @NotNull + public UriBuilder removeUserInfo() { + this.userInfo = null; + return this; + } + + @NotNull + public UriBuilder setHost(@Nullable String host) { + if (isNotNullOrBlank(host)) { + this.host = lowerCase(host); + this.rootPath = true; + resetSchemeSpecificPart(); + } else { + this.host = null; + } + return this; + } + + @NotNull + public UriBuilder removeHost() { + this.host = null; + return this; + } + + @NotNull + public UriBuilder setDefaultPort() { + this.port = -1; + return this; + } + + @NotNull + public UriBuilder setPort(int port) { + validatePortNumberOrSchemeDefault(port); + this.port = port; + if (port > -1) { + resetSchemeSpecificPart(); + } + return this; + } + + @NotNull + public UriBuilder setPath(@Nullable String path) { + this.pathSegments.clear(); + this.rootPath = this.host != null; + addSubPath(path); + return this; + } + + @NotNull + public UriBuilder addSubPath(@Nullable String subPath) { + if (isNotNullOrEmpty(subPath)) { + if (this.pathSegments.isEmpty()) { + rootPath = subPath.startsWith("/") || this.host != null; + } + List newSegments = Arrays.stream(subPath.split("/")) + .filter(Strings::isNotNullOrEmpty) + .map(PATH_SEGMENT::validateAndDecode) + .toList(); + this.pathSegments.addAll(newSegments); + if (!newSegments.isEmpty()) { + resetSchemeSpecificPart(); + } + } + return this; + } + + @NotNull + public UriBuilder setRootPath(boolean rootPath) { + this.rootPath = rootPath; + resetSchemeSpecificPart(); + return this; + } + + @NotNull + public UriBuilder setPathSegments(@NotNull List pathSegments) { + expectNonNull(pathSegments, "pathSegments"); + this.pathSegments.clear(); + addPathSegments(pathSegments); + return this; + } + + @NotNull + public UriBuilder addPathSegment(@Nullable String pathSegment) { + if (isNullOrEmpty(pathSegment)) { + return this; + } + addPathSegments(List.of(pathSegment)); + return this; + } + + @NotNull + public UriBuilder addPathSegments(@Nullable List pathSegments) { + expectNonNull(pathSegments, "pathSegments"); + List filtered = pathSegments.stream() + .filter(Strings::isNotNullOrEmpty) + .toList(); + this.pathSegments.addAll(filtered); + if (!filtered.isEmpty()) { + resetSchemeSpecificPart(); + } + return this; + } + + @NotNull + public UriBuilder setQuery(@NotNull String query) { + expectNonNull(query, "query"); + setQueryMultiParams(parseQuery(query)); + return this; + } + + @NotNull + public UriBuilder setQueryParams(@NotNull Map params) { + expectNonNull(params, "params"); + this.queryParams.clear(); + params.forEach(this::putQueryParam); + return this; + } + + @NotNull + public UriBuilder setQueryMultiParams(@NotNull Map> params) { + expectNonNull(params, "params"); + this.queryParams.clear(); + params.forEach(this::putQueryParam); + return this; + } + + @NotNull + public UriBuilder putQueryParams(@NotNull Map params) { + expectNonNull(params, "params"); + params.entrySet().stream() + .filter(e -> isNotNullOrBlank(e.getKey())) + .forEach(entry -> putQueryParam(entry.getKey(), entry.getValue())); + return this; + } + + @NotNull + public UriBuilder putQueryMultiParams(@NotNull Map> params) { + expectNonNull(params, "params"); + params.entrySet().stream() + .filter(e -> isNotNullOrBlank(e.getKey())) + .filter(e -> e.getValue() != null) + .forEach(entry -> putQueryParam(entry.getKey(), entry.getValue())); + return this; + } + + @NotNull + public UriBuilder putQueryParam(@NotNull String name, @NotNull String value) { + expectNonBlank(name, "name"); + expectNonNull(value, "value"); + List values = new ArrayList<>(); + values.add(value); + return putQueryParam(name, values); + } + + @NotNull + public UriBuilder putQueryParam(@NotNull String name, @NotNull Collection values) { + expectNonBlank(name, "name"); + expectNonNull(values, "values"); + if (values.isEmpty()) { + this.queryParams.remove(name); + } else { + this.queryParams.put(name, new ArrayList<>(values)); + } + resetSchemeSpecificPart(); + return this; + } + + @NotNull + public UriBuilder addQueryParams(@NotNull Map params) { + expectNonNull(params, "params"); + params.entrySet().stream() + .filter(e -> isNotNullOrBlank(e.getKey())) + .forEach(entry -> addQueryParam(entry.getKey(), entry.getValue())); + resetSchemeSpecificPart(); + return this; + } + + @NotNull + public UriBuilder addQueryMultiParams(@NotNull Map> params) { + expectNonNull(params, "params"); + params.entrySet().stream() + .filter(e -> isNotNullOrBlank(e.getKey())) + .filter(e -> e.getValue() != null && !e.getValue().isEmpty()) + .forEach(entry -> addQueryParam(entry.getKey(), entry.getValue())); + resetSchemeSpecificPart(); + return this; + } + + @NotNull + public UriBuilder addQueryParam(@NotNull String name, @NotNull String value) { + expectNonBlank(name, "name"); + expectNonNull(value, "value"); + return addQueryParam(name, List.of(value)); + } + + @NotNull + public UriBuilder addQueryParam(@NotNull String name, @NotNull Collection values) { + expectNonBlank(name, "name"); + expectNonNull(values, "values"); + List noNullValues = values.stream() + .filter(Objects::nonNull) + .toList(); + if (noNullValues.isEmpty()) { + return this; + } + this.queryParams.compute(name, (key, prevValues) -> { + List result = prevValues != null + ? prevValues + : new ArrayList<>(); + result.addAll(noNullValues); + return result; + }); + resetSchemeSpecificPart(); + return this; + } + + @NotNull + public UriBuilder removeQueryParams() { + this.queryParams.clear(); + return this; + } + + @NotNull + public UriBuilder removeQueryParam(@NotNull String name) { + expectNonNull(name, "name"); + this.queryParams.remove(name); + return this; + } + + @NotNull + public UriBuilder removeQueryParam(@NotNull String name, @Nullable String value) { + expectNonNull(name, "name"); + List values = this.queryParams.get(name); + if (values != null && value != null) { + values.remove(value); + } + return this; + } + + @NotNull + public UriBuilder setFragment(@Nullable String fragment) { + this.fragment = emptyToNull(fragment); + return this; + } + + @NotNull + public UriBuilder removeFragment() { + this.fragment = null; + return this; + } + + private void resetHierarchicalComponents() { + this.userInfo = null; + this.host = null; + this.port = SCHEME_DEFAULT_PORT_NUMBER; + this.pathSegments.clear(); + this.queryParams.clear(); + } + + private void resetSchemeSpecificPart() { + this.ssp = null; + } + + void validate() { + buildUriComponents(); + } +} diff --git a/src/main/java/com/coditory/quark/uri/UriComponents.java b/src/main/java/com/coditory/quark/uri/UriComponents.java new file mode 100644 index 0000000..f296626 --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/UriComponents.java @@ -0,0 +1,424 @@ +package com.coditory.quark.uri; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.net.URI; +import java.net.URL; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Stream; + +import static com.coditory.quark.uri.Nullable.mapNotNull; +import static com.coditory.quark.uri.Nullable.onNotNull; +import static com.coditory.quark.uri.Preconditions.expectNonBlank; +import static com.coditory.quark.uri.Preconditions.expectNonNull; +import static com.coditory.quark.uri.Strings.isNotNullOrEmpty; +import static com.coditory.quark.uri.Strings.isNullOrEmpty; +import static com.coditory.quark.uri.UriPartValidator.checkPort; +import static com.coditory.quark.uri.UriRfc.FRAGMENT; +import static com.coditory.quark.uri.UriRfc.PATH_SEGMENT; +import static com.coditory.quark.uri.UriRfc.QUERY_PARAM; +import static com.coditory.quark.uri.UriRfc.SCHEME; +import static com.coditory.quark.uri.UriRfc.SCHEME_SPECIFIC_PART; +import static com.coditory.quark.uri.UriRfc.USER_INFO; +import static java.util.Collections.unmodifiableMap; +import static java.util.stream.Collectors.joining; +import static java.util.stream.Collectors.toMap; + +public final class UriComponents { + @NotNull + public static UriComponents fromUri(@NotNull String uri) { + expectNonNull(uri, "uri"); + return builderFromUri(uri).buildUriComponents(); + } + + @Nullable + public static UriComponents fromUriOrNull(@Nullable String uri) { + if (uri == null) { + return null; + } + try { + return fromUri(uri); + } catch (RuntimeException e) { + return null; + } + } + + @NotNull + public static UriComponents fromHttpUrl(@NotNull String url) { + expectNonNull(url, "url"); + return builderFromHttpUrl(url).buildUriComponents(); + } + + @Nullable + static UriComponents fromHttpUrlOrNull(@Nullable String url) { + if (url == null) { + return null; + } + try { + return fromHttpUrl(url); + } catch (RuntimeException e) { + return null; + } + } + + @NotNull + public static UriComponents from(@NotNull URI uri) { + expectNonNull(uri, "uri"); + return builderFrom(uri).buildUriComponents(); + } + + @NotNull + public static UriComponents from(@NotNull URL url) { + expectNonNull(url, "url"); + return builderFrom(url).buildUriComponents(); + } + + @NotNull + public static UriBuilder builder() { + return new UriBuilder(); + } + + @NotNull + public static UriBuilder builderFrom(@NotNull UriComponents uriComponents) { + expectNonNull(uriComponents, "uriComponents"); + return UriBuilder.from(uriComponents); + } + + @NotNull + public static UriBuilder builderFrom(@NotNull URL url) { + expectNonNull(url, "url"); + return UriBuilder.from(url); + } + + @NotNull + public static UriBuilder builderFrom(@NotNull URI uri) { + expectNonNull(uri, "uri"); + return UriBuilder.from(uri); + } + + @NotNull + public static UriBuilder builderFromUri(@NotNull String uri) { + expectNonNull(uri, "uri"); + return UriBuilder.fromUri(uri); + } + + @NotNull + public static UriBuilder builderFromHttpUrl(@NotNull String url) { + expectNonNull(url, "url"); + return UriBuilder.fromHttpUrl(url); + } + + static UriComponents buildOpaque( + String scheme, + String ssp, + @Nullable String fragment + ) { + expectNonBlank(scheme, "scheme"); + expectNonBlank(ssp, "ssp"); + return new UriComponents(scheme, ssp, null, null, -1, false, false, null, null, fragment); + } + + static UriComponents buildHierarchical( + @Nullable String scheme, + @Nullable String userInfo, + @Nullable String host, + int port, + boolean protocolRelative, + boolean rootRelative, + @Nullable List pathSegments, + @Nullable Map> queryParams, + @Nullable String fragment + ) { + if (isNullOrEmpty(host)) { + if (isNotNullOrEmpty(userInfo)) { + throw new InvalidUriException("URI with user info must include host"); + } + if (port >= 0) { + throw new InvalidUriException("URI with port must include host"); + } + } + if (scheme != null && protocolRelative) { + throw new InvalidUriException("URI cannot be protocol relative and have a scheme"); + } + onNotNull(scheme, UriPartValidator::checkScheme); + onNotNull(host, UriPartValidator::checkHost); + if (port >= 0) { + checkPort(port); + } + return new UriComponents(scheme, null, userInfo, host, port, protocolRelative, rootRelative, pathSegments, queryParams, fragment); + } + + private final String ssp; + private final String scheme; + private final String userInfo; + private final String host; + private final int port; + private final boolean protocolRelative; + private final boolean rootPath; + private final List pathSegments; + private final Map> queryParams; + private final String fragment; + + private UriComponents( + String scheme, + String ssp, + String userInfo, + String host, + int port, + boolean protocolRelative, + boolean rootPath, List pathSegments, + Map> queryParams, + String fragment + ) { + this.scheme = scheme; + this.ssp = ssp; + this.userInfo = userInfo; + this.host = host; + this.port = port; + this.protocolRelative = protocolRelative; + this.rootPath = rootPath; + this.pathSegments = pathSegments == null ? List.of() : List.copyOf(pathSegments); + this.queryParams = queryParams == null ? Map.of() : unmodifiableMap(new LinkedHashMap<>(queryParams)); + this.fragment = fragment; + } + + public boolean isOpaque() { + return ssp != null; + } + + @Nullable + public String getSchemeSpecificPart() { + return ssp; + } + + @Nullable + public String getScheme() { + return scheme; + } + + @Nullable + public String getUserInfo() { + return userInfo; + } + + @Nullable + public String getHost() { + return host; + } + + public int getPort() { + return port; + } + + public boolean isRootPath() { + return rootPath; + } + + public boolean isProtocolRelative() { + return protocolRelative; + } + + @NotNull + public List getPathSegments() { + return pathSegments; + } + + @NotNull + public Map> getQueryParams() { + return queryParams; + } + + @NotNull + public Map getSingleValueQueryParams() { + return queryParams.entrySet() + .stream() + .collect(toMap(Map.Entry::getKey, e -> e.getValue().get(0))); + } + + @Nullable + public UriAuthority getUriAuthority() { + if (isOpaque()) { + return null; + } + UriAuthority authority = UriAuthority.of(userInfo, host, port); + return authority.isEmpty() ? null : authority; + } + + @Nullable + public String getQueryString() { + if (this.queryParams.isEmpty()) { + return null; + } + StringBuilder queryBuilder = new StringBuilder(); + this.queryParams.forEach((name, values) -> { + if (values == null || values.isEmpty()) { + if (queryBuilder.length() != 0) { + queryBuilder.append('&'); + } + queryBuilder.append(QUERY_PARAM.encode(name)); + } else { + for (Object value : values) { + if (queryBuilder.length() != 0) { + queryBuilder.append('&'); + } + queryBuilder.append(QUERY_PARAM.encode(name)) + .append('=') + .append(QUERY_PARAM.encode(value.toString())); + } + } + }); + return queryBuilder.toString(); + } + + @Nullable + public String getPath() { + if (pathSegments.isEmpty()) { + return null; + } + String path = pathSegments.stream() + .map(PATH_SEGMENT::encode) + .collect(joining("/")); + String prefix = rootPath ? "/" : ""; + return prefix + path; + } + + @Nullable + public String getFragment() { + return fragment; + } + + public boolean isHttpUrl() { + return !isOpaque() && ("http".equals(scheme) || "https".equals(scheme)); + } + + public boolean isValidHttpUrl() { + return UrlValidator.isValidUrl(this); + } + + @NotNull + public URL toUrl() { + try { + return new URL(toUriString()); + } catch (Exception e) { + throw new IllegalStateException("Could not build URI", e); + } + } + + @NotNull + public URI toUri() { + try { + return new URI(toUriString()); + } catch (Exception e) { + throw new IllegalStateException("Could not build URI", e); + } + } + + @NotNull + public String toUriString() { + return ssp != null + ? toOpaqueUriString() + : toHierarchicalUriString(); + } + + private String toOpaqueUriString() { + StringBuilder uriBuilder = new StringBuilder(); + if (scheme != null) { + uriBuilder.append(SCHEME.encode(scheme)) + .append(':'); + } + uriBuilder.append(SCHEME_SPECIFIC_PART.encode(ssp)); + if (fragment != null) { + uriBuilder.append('#') + .append(FRAGMENT.encode(fragment)); + } + return uriBuilder.toString(); + } + + private String toHierarchicalUriString() { + StringBuilder uriBuilder = new StringBuilder(); + if (scheme != null) { + uriBuilder.append(SCHEME.encode(scheme)) + .append("://"); + } else if (protocolRelative) { + uriBuilder.append("//"); + } + if (userInfo != null || host != null) { + if (userInfo != null) { + uriBuilder.append(USER_INFO.encode(this.userInfo)) + .append('@'); + } + if (host != null) { + uriBuilder.append(this.host); + } + if (port != -1) { + uriBuilder.append(':') + .append(this.port); + } + } + String path = getPath(); + String query = getQueryString(); + if (path != null) { + if (!path.equals("/") || query != null || fragment != null || host == null) { + uriBuilder.append(path); + } + } else if (rootPath && host == null) { + uriBuilder.append("/"); + } + if (query != null) { + uriBuilder.append('?') + .append(query); + } + if (fragment != null) { + uriBuilder.append('#') + .append(FRAGMENT.encode(fragment)); + } + return uriBuilder.toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + UriComponents that = (UriComponents) o; + return port == that.port + && protocolRelative == that.protocolRelative + && rootPath == that.rootPath + && Objects.equals(ssp, that.ssp) + && Objects.equals(scheme, that.scheme) + && Objects.equals(userInfo, that.userInfo) + && Objects.equals(host, that.host) + && Objects.equals(pathSegments, that.pathSegments) + && Objects.equals(queryParams, that.queryParams) + && Objects.equals(fragment, that.fragment); + } + + @Override + public int hashCode() { + return Objects.hash( + ssp, scheme, userInfo, host, port, protocolRelative, rootPath, pathSegments, queryParams, fragment + ); + } + + @Override + public String toString() { + String content = Stream.of( + mapNotNull(ssp, it -> "ssp=\"" + it + '"', ""), + mapNotNull(scheme, it -> "scheme=\"" + it + '"', ""), + mapNotNull(userInfo, it -> "userInfo=\"" + it + '"', ""), + mapNotNull(host, it -> "host=\"" + it + '"', ""), + port != Ports.SCHEME_DEFAULT_PORT_NUMBER ? ("port=" + port) : "", + protocolRelative ? "protocolRelative=true" : "", + host == null && rootPath ? "rootPath=true" : "", + !pathSegments.isEmpty() ? "pathSegments=" + pathSegments : "", + !queryParams.isEmpty() ? "queryParams=" + queryParams : "", + mapNotNull(fragment, it -> "fragment=\"" + it + '"', "") + ) + .filter(chunk -> !chunk.isEmpty()) + .collect(joining(", ")); + return "UriComponents{" + content + '}'; + } +} diff --git a/src/main/java/com/coditory/quark/uri/UriComponentsParser.java b/src/main/java/com/coditory/quark/uri/UriComponentsParser.java new file mode 100644 index 0000000..54e714f --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/UriComponentsParser.java @@ -0,0 +1,147 @@ +package com.coditory.quark.uri; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static com.coditory.quark.uri.Nullable.onNotNull; +import static com.coditory.quark.uri.Preconditions.expectNonNull; +import static com.coditory.quark.uri.Strings.isNotNullOrEmpty; + +class UriComponentsParser { + private static final Pattern QUERY_PARAM_PATTERN = Pattern.compile("([^&=]+)(=?)([^&]+)?"); + private static final String SCHEME_PATTERN = "([^:/?#]+):"; + private static final String USERINFO_PATTERN = "([^@\\[/?#]*)"; + private static final String HOST_IPV4_PATTERN = "[^\\[/?#:]*"; + private static final String HOST_IPV6_PATTERN = "\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]"; + private static final String HOST_PATTERN = "(" + HOST_IPV6_PATTERN + "|" + HOST_IPV4_PATTERN + ")"; + private static final String PORT_PATTERN = "([^/?#]*)"; + private static final String PATH_PATTERN = "([^?#]*)"; + private static final String QUERY_PATTERN = "([^#]*)"; + private static final String LAST_PATTERN = "(.*)"; + + // Regex patterns that matches URIs. See RFC 3986, appendix B + private static final Pattern URI_PATTERN = Pattern.compile( + "^(" + SCHEME_PATTERN + ")?" + + "(//(" + USERINFO_PATTERN + "@)?" + HOST_PATTERN + "(:" + PORT_PATTERN + ")?" + ")?" + + PATH_PATTERN + "(\\?" + QUERY_PATTERN + ")?" + "(#" + LAST_PATTERN + ")?"); + + static UriBuilder parseHttpUrl(String uri) { + expectNonNull(uri, "uri"); + try { + UriBuilder builder = UriComponentsParser.parseUri(uri); + UriComponents components = builder.buildUriComponents(); + if (!components.isHttpUrl()) { + throw new InvalidHttpUrlException("Invalid http url: \"" + uri + "\""); + } + return builder; + } catch (InvalidUriException e) { + InvalidUriException root = Throwables.getRootCauseOfType(e, InvalidUriException.class); + String suffix = root == null ? "" : ". Cause: " + root.getMessage(); + throw new InvalidHttpUrlException("Could not parse http url: \"" + uri + "\"" + suffix, root); + } catch (RuntimeException e) { + throw new InvalidHttpUrlException("Could not parse http url: \"" + uri + "\"", e); + } + } + + static UriBuilder parseHttpUrlOrNull(String uri) { + expectNonNull(uri, "uri"); + UriBuilder builder = UriComponentsParser.parseUriOrNull(uri); + if (builder == null) { + return null; + } + UriComponents components = builder.buildUriComponents(); + if (!components.isHttpUrl()) { + return null; + } + return builder; + } + + static UriBuilder parseUri(String uri) { + expectNonNull(uri, "uri"); + Matcher matcher = URI_PATTERN.matcher(uri); + if (!matcher.matches()) { + throw new InvalidUriException("Could not parse uri: \"" + uri + "\""); + } + try { + return parseUri(uri, matcher); + } catch (InvalidUriException e) { + throw new InvalidUriException("Could not parse uri: \"" + uri + "\". Cause: " + e.getMessage()); + } catch (RuntimeException e) { + throw new InvalidUriException("Could not parse uri: \"" + uri + "\""); + } + } + + static UriBuilder parseUriOrNull(String uri) { + expectNonNull(uri, "uri"); + Matcher matcher = URI_PATTERN.matcher(uri); + if (!matcher.matches()) { + return null; + } + try { + return parseUri(uri, matcher); + } catch (RuntimeException e) { + return null; + } + } + + private static UriBuilder parseUri(String uri, Matcher matcher) { + UriBuilder builder = new UriBuilder(); + String scheme = matcher.group(2); + String userInfo = matcher.group(5); + String host = matcher.group(6); + String port = matcher.group(8); + String path = matcher.group(9); + String query = matcher.group(11); + String fragment = matcher.group(13); + boolean opaque = false; + if (isNotNullOrEmpty(scheme)) { + String rest = uri.substring(scheme.length()); + if (!rest.startsWith(":/")) { + opaque = true; + } + builder.setScheme(UriRfc.SCHEME.validateAndDecode(scheme)); + } else if (uri.startsWith("//")) { + builder.setProtocolRelative(true); + } + if (opaque) { + String ssp = uri.substring(scheme.length()).substring(1); + if (isNotNullOrEmpty(fragment)) { + ssp = ssp.substring(0, ssp.length() - (fragment.length() + 1)); + } + builder.setSchemeSpecificPart(UriRfc.SCHEME_SPECIFIC_PART.validateAndDecode(ssp)); + } else { + onNotNull(userInfo, it -> builder.setUserInfo(UriRfc.USER_INFO.validateAndDecode(it))); + onNotNull(host, it -> builder.setHost(UriRfc.HOST.validateAndDecode(it))); + onNotNull(port, it -> { + String decodedPort = UriRfc.PORT.validateAndDecode(it); + builder.setPort(Integer.parseInt(decodedPort)); + }); + onNotNull(path, builder::setPath); + onNotNull(query, q -> builder.setQueryMultiParams(parseQuery(q))); + } + onNotNull(fragment, it -> builder.setFragment(UriRfc.FRAGMENT.validateAndDecode(it))); + builder.validate(); + return builder; + } + + static Map> parseQuery(String query) { + expectNonNull(query, "query"); + Matcher matcher = QUERY_PARAM_PATTERN.matcher(query); + UriRfc.QUERY.checkValidEncoded(query); + Map> result = new LinkedHashMap<>(); + while (matcher.find()) { + String name = matcher.group(1); + String decodedName = UriRfc.QUERY_PARAM.validateAndDecode(name); + String value = matcher.group(3); + String normalizedValue = value != null ? value : ""; + result + .computeIfAbsent(decodedName, k -> new ArrayList<>()) + .add(UriRfc.QUERY_PARAM.validateAndDecode(normalizedValue)); + } + return result; + } +} diff --git a/src/main/java/com/coditory/quark/uri/UriPartValidator.java b/src/main/java/com/coditory/quark/uri/UriPartValidator.java new file mode 100644 index 0000000..42c014b --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/UriPartValidator.java @@ -0,0 +1,88 @@ +package com.coditory.quark.uri; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static com.coditory.quark.uri.InetAddressValidator.isValidInetV4Address; + +final class UriPartValidator { + private static final String SPECIAL_CHARS = ";/@&=,.?:+$"; + private static final String VALID_CHARS = "[^\\s" + SPECIAL_CHARS + "]"; + private static final String ATOM = VALID_CHARS + '+'; + private static final Pattern SCHEME_PATTERN = Pattern.compile("^\\p{Alpha}[\\p{Alnum}\\+\\-\\.]*"); + private static final Pattern ATOM_PATTERN = Pattern.compile("^(" + ATOM + ").*?$"); + private static final Pattern DOMAIN_PATTERN = Pattern.compile("^" + ATOM + "(\\." + ATOM + ")*$"); + private static final Pattern ALPHA_PATTERN = Pattern.compile("^[a-zA-Z]"); + + static boolean isValidScheme(String scheme) { + return scheme != null && SCHEME_PATTERN.matcher(scheme).matches(); + } + + static void checkScheme(String scheme) { + if (!isValidScheme(scheme)) { + throw new InvalidUriException("Invalid scheme: " + scheme); + } + } + + static boolean isValidHost(String host) { + boolean hostname = false; + boolean ipV4Address = isValidInetV4Address(host); + if (!ipV4Address) { + hostname = DOMAIN_PATTERN.matcher(host).matches(); + } + if (hostname) { + char[] chars = host.toCharArray(); + int size = 1; + for (char element : chars) { + if (element == '.') { + size++; + } + } + String[] domainSegment = new String[size]; + boolean match = true; + int segmentCount = 0; + int segmentLength = 0; + + while (match) { + Matcher atomMatcher = ATOM_PATTERN.matcher(host); + match = atomMatcher.matches(); + if (match) { + domainSegment[segmentCount] = atomMatcher.group(1); + segmentLength = domainSegment[segmentCount].length() + 1; + host = segmentLength >= host.length() + ? "" + : host.substring(segmentLength); + + segmentCount++; + } + } + String topLevel = domainSegment[segmentCount - 1]; + if (topLevel.length() < 2 || topLevel.length() > 4) { + return false; + } + if (!ALPHA_PATTERN.matcher(topLevel.substring(0, 1)).matches()) { + return false; + } + if (segmentCount < 2) { + return false; + } + } + return hostname || ipV4Address; + } + + static void checkHost(String host) { + if (!isValidHost(host)) { + throw new InvalidUriException("Invalid host: " + host); + } + } + + static boolean isValidPort(int port) { + return Ports.isValidPortNumber(port); + } + + static void checkPort(int port) { + if (!isValidPort(port)) { + throw new InvalidUriException("Invalid port: " + port); + } + } +} diff --git a/src/main/java/com/coditory/quark/uri/UriRfc.java b/src/main/java/com/coditory/quark/uri/UriRfc.java new file mode 100644 index 0000000..b1b4e19 --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/UriRfc.java @@ -0,0 +1,94 @@ +package com.coditory.quark.uri; + +import java.util.BitSet; + +import static com.coditory.quark.uri.Preconditions.expectNonNull; +import static java.util.Locale.ROOT; + +enum UriRfc { + SCHEME(UriRfcCharacters.SCHEME_ALLOWED), + SCHEME_SPECIFIC_PART(UriRfcCharacters.SCHEME_SPECIFIC_PART_ALLOWED), + USER_INFO(UriRfcCharacters.USER_INFO_ALLOWED), + HOST(UriRfcCharacters.HOST_IPV6_ALLOWED), + PORT(UriRfcCharacters.PORT_ALLOWED), + PATH_SEGMENT(UriRfcCharacters.PATH_SEGMENT_ALLOWED), + QUERY(UriRfcCharacters.QUERY_ALLOWED, true), + QUERY_PARAM(UriRfcCharacters.QUERY_PARAM_ALLOWED, true), + FRAGMENT(UriRfcCharacters.FRAGMENT_ALLOWED); + + private final BitSet allowed; + private final PercentCodec codec; + + UriRfc(String allowed) { + this(allowed, false); + } + + UriRfc(String allowed, boolean decodeSpaceAsPlus) { + this.allowed = BitSets.of(allowed); + String encode = decodeSpaceAsPlus + ? allowed.replaceAll("\\+", "") + : allowed; + this.codec = PercentCodec.builder() + .safeCharacters(encode) + .decodeSpaceAsPlus(decodeSpaceAsPlus) + .build(); + } + + String validateAndDecode(String source) { + checkValidEncoded(source); + return decode(source); + } + + String decode(String source) { + StringBuilder builder = new StringBuilder(); + decode(source, builder); + return builder.toString(); + } + + void decode(String source, StringBuilder builder) { + codec.decode(source, builder); + } + + String encode(String source) { + StringBuilder builder = new StringBuilder(); + encode(source, builder); + return builder.toString(); + } + + void encode(String source, StringBuilder builder) { + codec.encode(source, builder); + } + + void checkValidEncoded(String source) { + String error = checkValidEncodedWithErrorMessage(source); + if (error != null) { + throw new InvalidUriException(error); + } + } + + private String checkValidEncodedWithErrorMessage(String source) { + expectNonNull(source, "source"); + int length = source.length(); + for (int i = 0; i < length; i++) { + char ch = source.charAt(i); + if (ch == '%') { + if ((i + 2) < length) { + char hex1 = source.charAt(i + 1); + char hex2 = source.charAt(i + 2); + int u = Character.digit(hex1, 16); + int l = Character.digit(hex2, 16); + if (u == -1 || l == -1) { + return "Invalid encoded sequence \"" + source.substring(i) + "\""; + } + i += 2; + } else { + return "Invalid encoded sequence \"" + source.substring(i) + "\""; + } + } else if (!allowed.get(ch)) { + return "Invalid character '" + ch + "' for " + name().toLowerCase(ROOT) + " in \"" + source + "\""; + } + } + return null; + } + +} diff --git a/src/main/java/com/coditory/quark/uri/UriRfcCharacters.java b/src/main/java/com/coditory/quark/uri/UriRfcCharacters.java new file mode 100644 index 0000000..ab9e684 --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/UriRfcCharacters.java @@ -0,0 +1,28 @@ +package com.coditory.quark.uri; + +final class UriRfcCharacters { + private UriRfcCharacters() { + throw new UnsupportedOperationException("Do not instantiate utility class"); + } + + private static final String ALPHABETIC_UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + private static final String ALPHABETIC_LOWER = "abcdefghijklmnopqrstuvwxyz"; + private static final String ALPHABETIC = ALPHABETIC_UPPER + ALPHABETIC_LOWER; + private static final String NUMERIC = "0123456789"; + private static final String ALPHANUMERIC = ALPHABETIC + NUMERIC; + static final String URI_DELIMITER = ":/?#[]@"; + static final String URI_SUB_DELIMITER = "!$&'()*+,;="; + static final String URI_RESERVED = URI_DELIMITER + URI_SUB_DELIMITER; + static final String URI_UNRESERVED = ALPHABETIC + NUMERIC + "-._~"; + static final String URI_PCHAR = ":@" + URI_UNRESERVED + URI_SUB_DELIMITER; + + static final String SCHEME_ALLOWED = ALPHANUMERIC + "+-."; + static final String SCHEME_SPECIFIC_PART_ALLOWED = SCHEME_ALLOWED + URI_PCHAR + URI_RESERVED; + static final String USER_INFO_ALLOWED = URI_UNRESERVED + URI_SUB_DELIMITER + ":"; + static final String HOST_IPV6_ALLOWED = URI_UNRESERVED + URI_SUB_DELIMITER + "[]:"; + static final String PORT_ALLOWED = NUMERIC; + static final String PATH_SEGMENT_ALLOWED = URI_PCHAR; + static final String QUERY_ALLOWED = URI_PCHAR + "/?"; + static final String QUERY_PARAM_ALLOWED = QUERY_ALLOWED.replaceFirst("=", "").replaceFirst("&", ""); + static final String FRAGMENT_ALLOWED = URI_PCHAR + "/?"; +} diff --git a/src/main/java/com/coditory/quark/uri/UrlValidator.java b/src/main/java/com/coditory/quark/uri/UrlValidator.java new file mode 100644 index 0000000..cb12ca2 --- /dev/null +++ b/src/main/java/com/coditory/quark/uri/UrlValidator.java @@ -0,0 +1,185 @@ +package com.coditory.quark.uri; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static com.coditory.quark.uri.InetAddressValidator.isValidInetV4Address; +import static com.coditory.quark.uri.Preconditions.expectNonNull; +import static com.coditory.quark.uri.Strings.isNullOrEmpty; + +public final class UrlValidator { + private static final UrlValidator INSTANCE = builder().build(); + + public static UrlValidator instance() { + return INSTANCE; + } + + public static boolean isValidUrl(String url) { + return INSTANCE.isValid(url); + } + + public static boolean isValidUrl(UriComponents uriComponents) { + return INSTANCE.isValid(uriComponents); + } + + private static final String ALPHA_CHARS = "a-zA-Z"; + private static final String SPECIAL_CHARS = ";/@&=,.?:+$"; + private static final String VALID_CHARS = "[^\\s" + SPECIAL_CHARS + "]"; + private static final String ATOM = VALID_CHARS + '+'; + private static final Pattern SCHEME_PATTERN = Pattern.compile("^\\p{Alpha}[\\p{Alnum}\\+\\-\\.]*"); + private static final Pattern PATH_PATTERN = Pattern.compile("^(/[-\\w:@&?=+,.!/~*'%$_;]*)?$"); + private static final Pattern DOMAIN_PATTERN = Pattern.compile("^" + ATOM + "(\\." + ATOM + ")*$"); + private static final Pattern ATOM_PATTERN = Pattern.compile("^(" + ATOM + ").*?$"); + private static final Pattern ALPHA_PATTERN = Pattern.compile("^[" + ALPHA_CHARS + "]"); + private final boolean allowFragments; + private final Set allowedSchemes; + + UrlValidator(boolean allowFragments, Set allowedSchemes) { + this.allowFragments = allowFragments; + this.allowedSchemes = Set.copyOf(allowedSchemes); + } + + public boolean isValid(String url) { + expectNonNull(url, "url"); + UriComponents uriComponents; + try { + uriComponents = UriComponents.fromHttpUrl(url); + } catch (Exception e) { + return false; + } + return isValid(uriComponents); + } + + public boolean isValid(UriComponents uriComponents) { + expectNonNull(uriComponents, "uriComponents"); + if (!isValidScheme(uriComponents.getScheme())) { + return false; + } + if (!isValidHost(uriComponents.getHost())) { + return false; + } + if (!isValidPath(uriComponents.getPath())) { + return false; + } + if (!isValidFragment(uriComponents.getFragment())) { + return false; + } + return true; + } + + boolean isValidScheme(@Nullable String scheme) { + if (scheme == null) { + return false; + } + if (!SCHEME_PATTERN.matcher(scheme).matches()) { + return false; + } + return allowedSchemes == null || allowedSchemes.contains(scheme); + } + + boolean isValidHost(@Nullable String host) { + if (isNullOrEmpty(host)) { + return false; + } + boolean hostname = false; + boolean ipV4Address = isValidInetV4Address(host); + if (!ipV4Address) { + hostname = DOMAIN_PATTERN.matcher(host).matches(); + } + if (hostname) { + char[] chars = host.toCharArray(); + int size = 1; + for (char element : chars) { + if (element == '.') { + size++; + } + } + String[] domainSegment = new String[size]; + boolean match = true; + int segmentCount = 0; + int segmentLength = 0; + while (match) { + Matcher atomMatcher = ATOM_PATTERN.matcher(host); + match = atomMatcher.matches(); + if (match) { + domainSegment[segmentCount] = atomMatcher.group(1); + segmentLength = domainSegment[segmentCount].length() + 1; + host = + (segmentLength >= host.length()) + ? "" + : host.substring(segmentLength); + + segmentCount++; + } + } + String topLevel = domainSegment[segmentCount - 1]; + if (topLevel.length() < 2 || topLevel.length() > 4) { + return false; + } + if (!ALPHA_PATTERN.matcher(topLevel.substring(0, 1)).matches()) { + return false; + } + if (segmentCount < 2) { + return false; + } + } + return hostname || ipV4Address; + } + + boolean isValidPath(@Nullable String path) { + if (isNullOrEmpty(path)) { + return true; + } + if (!PATH_PATTERN.matcher(path).matches()) { + return false; + } + int slashCount = countToken("/", path); + int dot2Count = countToken("..", path); + return dot2Count <= 0 || (slashCount - 2) > dot2Count; + } + + boolean isValidFragment(@Nullable String fragment) { + return fragment == null || allowFragments; + } + + private int countToken(String token, String target) { + int tokenIndex = 0; + int count = 0; + while (tokenIndex != -1) { + tokenIndex = target.indexOf(token, tokenIndex); + if (tokenIndex > -1) { + tokenIndex++; + count++; + } + } + return count; + } + + @NotNull + public static UrlValidatorBuilder builder() { + return new UrlValidatorBuilder(); + } + + public static class UrlValidatorBuilder { + private boolean allowFragments = true; + private Set allowedSchemes = Set.of("http", "https"); + + public UrlValidatorBuilder allowFragments(boolean allowFragments) { + this.allowFragments = allowFragments; + return this; + } + + public UrlValidatorBuilder allowedSchemes(Set allowedSchemes) { + this.allowedSchemes = expectNonNull(allowedSchemes, "allowedSchemes"); + return this; + } + + public UrlValidator build() { + return new UrlValidator(allowFragments, allowedSchemes); + } + } +} diff --git a/src/main/resources/a/b/c/homepage/i18n.yml b/src/main/resources/a/b/c/homepage/i18n.yml new file mode 100644 index 0000000..e276c04 --- /dev/null +++ b/src/main/resources/a/b/c/homepage/i18n.yml @@ -0,0 +1 @@ +hello.pl: HomepageX123 {0 | single (one (detail)) (more {0} ${some.ref})} diff --git a/src/main/resources/a/b/c/other/i18n.yml b/src/main/resources/a/b/c/other/i18n.yml new file mode 100644 index 0000000..8347de1 --- /dev/null +++ b/src/main/resources/a/b/c/other/i18n.yml @@ -0,0 +1 @@ +other.pl: Other diff --git a/src/main/resources/a/b/d/listing/i18n.yml b/src/main/resources/a/b/d/listing/i18n.yml new file mode 100644 index 0000000..37f1485 --- /dev/null +++ b/src/main/resources/a/b/d/listing/i18n.yml @@ -0,0 +1,2 @@ +hello: + pl: "Siema from listing" \ No newline at end of file diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000..946b702 --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,14 @@ + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + diff --git a/src/test/groovy/com/coditory/quark/uri/HostsSpec.groovy b/src/test/groovy/com/coditory/quark/uri/HostsSpec.groovy new file mode 100644 index 0000000..f005e40 --- /dev/null +++ b/src/test/groovy/com/coditory/quark/uri/HostsSpec.groovy @@ -0,0 +1,19 @@ +package com.coditory.quark.uri + +import spock.lang.Specification + +class HostsSpec extends Specification { + def "should retrieve non blank localHostAddress"() { + when: + String localHostAddress = Hosts.localHostAddress + then: + !localHostAddress.isBlank() + } + + def "should retrieve non blank localHostName"() { + when: + String localHostName = Hosts.localHostName + then: + !localHostName.isBlank() + } +} diff --git a/src/test/groovy/com/coditory/quark/uri/InetAddressValidatorSpec.groovy b/src/test/groovy/com/coditory/quark/uri/InetAddressValidatorSpec.groovy new file mode 100644 index 0000000..1406b6a --- /dev/null +++ b/src/test/groovy/com/coditory/quark/uri/InetAddressValidatorSpec.groovy @@ -0,0 +1,89 @@ +package com.coditory.quark.uri + +import spock.lang.Specification +import spock.lang.Unroll + +class InetAddressValidatorSpec extends Specification { + private static final List validIpV4 = [ + "127.0.0.1", + "8.8.8.8" + ] + private static final List invalidIpV4 = [ + "127.0.0.1.1", + "127.0.1", + "127.0..1", + "127.888.0.1", + ] + private static final List validIpV6 = [ + "2001:db8:3333:4444:5555:6666:7777:8888", + "2001:db8::1234:5678", + "::1234:5678" + ] + private static final List invalidIpV6 = [ + ":::1234:5678", + "2001:db8:3333:4444:5555:6666:7777:8888:8888", + ] + + @Unroll + def "should validate valid inet address: #address"() { + when: + InetAddressValidator.validateInetAddress(address) + then: + noExceptionThrown() + where: + address << validIpV4 + validIpV6 + } + + @Unroll + def "should validate invalid inet address: #address"() { + when: + InetAddressValidator.validateInetAddress(address) + then: + IllegalArgumentException e = thrown(IllegalArgumentException) + e.message == "Expected valid ip address. Got: " + address + where: + address << invalidIpV4 + invalidIpV6 + } + + @Unroll + def "should validate valid inet v4 address: #address"() { + when: + InetAddressValidator.validateInetV4Address(address) + then: + noExceptionThrown() + where: + address << validIpV4 + } + + @Unroll + def "should validate invalid inet v4 address: #address"() { + when: + InetAddressValidator.validateInetV4Address(address) + then: + IllegalArgumentException e = thrown(IllegalArgumentException) + e.message == "Expected valid ip v4 address. Got: " + address + where: + address << invalidIpV4 + validIpV6 + invalidIpV6 + } + + @Unroll + def "should validate valid inet v6 address: #address"() { + when: + InetAddressValidator.validateInetV6Address(address) + then: + noExceptionThrown() + where: + address << validIpV6 + } + + @Unroll + def "should validate invalid inet v6 address: #address"() { + when: + InetAddressValidator.validateInetV6Address(address) + then: + IllegalArgumentException e = thrown(IllegalArgumentException) + e.message == "Expected valid ip v6 address. Got: " + address + where: + address << invalidIpV6 + validIpV4 + invalidIpV4 + } +} diff --git a/src/test/groovy/com/coditory/quark/uri/PercentCodecSpec.groovy b/src/test/groovy/com/coditory/quark/uri/PercentCodecSpec.groovy new file mode 100644 index 0000000..e60a3d3 --- /dev/null +++ b/src/test/groovy/com/coditory/quark/uri/PercentCodecSpec.groovy @@ -0,0 +1,68 @@ +package com.coditory.quark.uri + +import spock.lang.Specification +import spock.lang.Unroll + +import static com.coditory.quark.uri.base.Alphabets.ASCII_CONTROL_CODES +import static com.coditory.quark.uri.base.Alphabets.ASCII_PRINTABLE +import static com.coditory.quark.uri.base.Alphabets.URI_UNRESERVED + +class PercentCodecSpec extends Specification { + @Unroll + def "should encode and decode string: #input"() { + when: + String encoded = PercentCodec.encodeUriComponent(input) + then: + encoded == expected + + when: + String decoded = PercentCodec.decodeUriComponent(encoded) + then: + decoded == input + + where: + input || expected + "" || "" + " \t\n+" || "%20%20%09%0A%2B" + "a𝄞b" || "a%F0%9D%84%9Eb" + "語" || "%E8%AA%9E" + "®" || "%C2%AE" + "🌉" || "%F0%9F%8C%89" + "語®🌉" || "%E8%AA%9E%C2%AE%F0%9F%8C%89" + URI_UNRESERVED || "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~" + ASCII_PRINTABLE || "%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~" + ASCII_CONTROL_CODES || "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%7F" + } + + def "should encode space with plus when configured"() { + given: + PercentCodec codec = PercentCodec.builder() + .spaceAsPlus(true) + .build() + when: + String encoded = codec.encode(" \t\n") + then: + encoded == "++%09%0A" + + when: + String decoded = codec.decode(encoded) + then: + decoded == " \t\n" + } + + def "should use configured safe characters"() { + given: + PercentCodec codec = PercentCodec.builder() + .safeCharacters("abc語") + .build() + when: + String encoded = codec.encode("ABCabc®語") + then: + encoded == "%41%42%43abc%C2%AE語" + + when: + String decoded = codec.decode(encoded) + then: + decoded == "ABCabc®語" + } +} diff --git a/src/test/groovy/com/coditory/quark/uri/PortsSpec.groovy b/src/test/groovy/com/coditory/quark/uri/PortsSpec.groovy new file mode 100644 index 0000000..fe2530f --- /dev/null +++ b/src/test/groovy/com/coditory/quark/uri/PortsSpec.groovy @@ -0,0 +1,55 @@ +package com.coditory.quark.uri + +import spock.lang.Specification +import spock.lang.Unroll + +class PortsSpec extends Specification { + def "should find two available ports"() { + when: + int port = Ports.nextAvailablePort() + then: + port >= 0 && port < 65535 + } + + @Unroll + def "should validate valid port number: #port"() { + when: + Ports.validatePortNumber(port) + then: + noExceptionThrown() + where: + port << [0, 1, 1024, 65535] + } + + @Unroll + def "should validate invalid port number: #port"() { + when: + Ports.validatePortNumber(port) + then: + IllegalArgumentException e = thrown(IllegalArgumentException) + e.getMessage() == "Expected port number in range [0, 65535]. Got: " + port + where: + port << [-1, 65536] + } + + @Unroll + def "should validate valid port number or scheme default: #port"() { + when: + Ports.validatePortNumberOrSchemeDefault(port) + then: + noExceptionThrown() + where: + port << [-1, 1, 1024, 65535] + } + + @Unroll + def "should validate invalid port number or scheme default: #port"() { + when: + Ports.validatePortNumberOrSchemeDefault(port) + then: + IllegalArgumentException e = thrown(IllegalArgumentException) + e.getMessage() == "Expected port number in range [-1, 65535]. Got: " + port + where: + port << [-2, 65536] + } +} diff --git a/src/test/groovy/com/coditory/quark/uri/UriBuilderSpec.groovy b/src/test/groovy/com/coditory/quark/uri/UriBuilderSpec.groovy new file mode 100644 index 0000000..3759d79 --- /dev/null +++ b/src/test/groovy/com/coditory/quark/uri/UriBuilderSpec.groovy @@ -0,0 +1,108 @@ +package com.coditory.quark.uri + +import spock.lang.Specification +import spock.lang.Unroll + +class UriBuilderSpec extends Specification { + def "should build uri from new builder instance"() { + when: + String result = new UriBuilder() + .setScheme("https") + .setUserInfo("john.doe") + .setHost("coditory.com") + .setPort(8081) + .setPath("/test/test2") + .addPathSegment("test3") + .addQueryParam("a", "a1") + .addQueryParam("a", "a2") + .addQueryParam("b", "b1") + .putQueryParam("b", "b2") + .setFragment("x") + .buildUriString() + then: + result == "https://john.doe@coditory.com:8081/test/test2/test3?a=a1&a=a2&b=b2#x" + } + + def "should normalize path slashes"() { + when: + String result = UriBuilder.fromUri("https://coditory.com/abc//def/") + .addSubPath("//ghi////jkl//") + .addPathSegment("mno/pqr") + .buildUriString() + then: + result == "https://coditory.com/abc/def/ghi/jkl/mno%2Fpqr" + } + + def "should encode spaces"() { + when: + String result = UriBuilder.fromUri("https://coditory.com/a+bc//d%20ef/") + .addPathSegment("x y ") + .setFragment("frag ment") + .addQueryParam("f oo", "b ar") + .addQueryParam("x", "y+z") + .buildUriString() + then: + result == "https://coditory.com/a+bc/d%20ef/x%20y%20?f%20oo=b%20ar&x=y%2Bz#frag%20ment" + } + + def "should replace each uri component"() { + when: + String result = UriBuilder.fromUri("https://john.doe@coditory.com:8081/test/test2/test3?a=a1&a=a2&b=b2#x") + .setScheme("http") + .removeUserInfo() + .setHost("coditory.xyz") + .setDefaultPort() + .setPath("/abc") + .setQueryParams(w: "W") + .setFragment("y") + .buildUriString() + then: + result == "http://coditory.xyz/abc?w=W#y" + } + + @Unroll + def "should build uri without #field"() { + given: + UriBuilder builder = UriBuilder.fromUri("https://john.doe@coditory.com:8081/test/test2/test3?a=a1&a=a2&b=b2#x") + when: + modifier(builder) + then: + builder.buildUriString() == uri + where: + field | modifier || uri + "scheme" | { UriBuilder b -> b.removeScheme() } || "john.doe@coditory.com:8081/test/test2/test3?a=a1&a=a2&b=b2#x" + "scheme - relative" | { UriBuilder b -> b.setProtocolRelative(true) } || "//john.doe@coditory.com:8081/test/test2/test3?a=a1&a=a2&b=b2#x" + "userInfo" | { UriBuilder b -> b.removeUserInfo() } || "https://coditory.com:8081/test/test2/test3?a=a1&a=a2&b=b2#x" + "fragment" | { UriBuilder b -> b.removeFragment() } || "https://john.doe@coditory.com:8081/test/test2/test3?a=a1&a=a2&b=b2" + "queryParams" | { UriBuilder b -> b.removeQueryParams() } || "https://john.doe@coditory.com:8081/test/test2/test3#x" + "queryParam-a" | { UriBuilder b -> b.removeQueryParam("a") } || "https://john.doe@coditory.com:8081/test/test2/test3?b=b2#x" + "queryParam-a-a2" | { UriBuilder b -> b.removeQueryParam("a", "a2") } || "https://john.doe@coditory.com:8081/test/test2/test3?a=a1&b=b2#x" + } + + @Unroll + def "should throw error when building uri without host but with scheme and port or userinfo"() { + when: + UriBuilder.fromUri("https://john.doe@coditory.com/test/test2/test3?a=a1&a=a2&b=b2#x") + .removeHost() + .buildUriComponents() + then: + InvalidUriException e = thrown(InvalidUriException) + e.message == "URI with user info must include host" + when: + UriBuilder.fromUri("https://coditory.com:8008/test/test2/test3?a=a1&a=a2&b=b2#x") + .removeHost() + .buildUriComponents() + then: + e = thrown(InvalidUriException) + e.message == "URI with port must include host" + } + + def "should copy uriBuilder instance"() { + when: + UriBuilder first = UriBuilder.fromUri("https://coditory.com/abc") + UriBuilder second = first.copy().addQueryParam("a", "X") + then: + first.buildUriString() == "https://coditory.com/abc" + second.buildUriString() == "https://coditory.com/abc?a=X" + } +} diff --git a/src/test/groovy/com/coditory/quark/uri/UriBuilder_parseAndRecreateUriSpec.groovy b/src/test/groovy/com/coditory/quark/uri/UriBuilder_parseAndRecreateUriSpec.groovy new file mode 100644 index 0000000..1e58d4e --- /dev/null +++ b/src/test/groovy/com/coditory/quark/uri/UriBuilder_parseAndRecreateUriSpec.groovy @@ -0,0 +1,85 @@ +package com.coditory.quark.uri + +import spock.lang.Specification +import spock.lang.Unroll + +class UriBuilder_parseAndRecreateUriSpec extends Specification { + @Unroll + def "should parse and recreate uri: #uri"() { + when: + UriBuilder result = UriBuilder.fromUri(uri) + then: + expectEquals(result, uri) + where: + uri << [ + "file:///~/calendar", + "coditory.com", + "//coditory.com", + "https://coditory.com", + "http://coditory.com", + "http://john:doe@coditory.com:8080/help?a=a1&a=a2&b=b1#frag", + "http://coditory.com?a=a1&a=a2&b=b1#frag", + "", + "/", + "/abc/def", + "?a=a1&a=a2&b=b1", + "?test=%E8%AA%9E", + "?%E8%AA%9E=test", + "#%E8%AA%9E", + "/%E8%AA%9E", + "../../../demo/jfc/SwingSet2/src/SwingSet2.java", + "../../../demo/../jfc/SwingSet2/src/SwingSet2.java" + ] + } + + @Unroll + def "should normalize path: #uri"() { + when: + UriBuilder result = UriBuilder.fromUri(uri) + then: + result.buildUriString() == expected + where: + uri || expected + "https://coditory.com//test" || "https://coditory.com/test" + "https://coditory.com/test/" || "https://coditory.com/test" + "https://coditory.com/test//" || "https://coditory.com/test" + } + + @Unroll + def "should handle plus sign: #uri"() { + when: + UriBuilder result = UriBuilder.fromUri(uri) + then: + result.buildUriString() == expected + where: + uri || expected + "https://coditory.com/+" || "https://coditory.com/+" + "https://coditory.com?a+b=c+d" || "https://coditory.com?a%20b=c%20d" + "https://coditory.com#a+b" || "https://coditory.com#a+b" + "https://coditory.com/foo+bar?a+b=c+d#x+" || "https://coditory.com/foo+bar?a%20b=c%20d#x+" + "https://coditory.com/foo%2Bbar?a%2Bb=c%2Bd#x%2B" || "https://coditory.com/foo+bar?a%2Bb=c%2Bd#x+" + } + + @Unroll + def "should parse and recreate opaque uri: #uri"() { + when: + UriBuilder result = UriBuilder.fromUri(uri) + then: + expectEquals(result, uri) + where: + uri << [ + "mailto:java-net@java.sun.com", + "news:comp.lang.java", + "urn:isbn:096139210x", + "mailto:someone@yoursite.com?subject=Mail%20from%20Our%20Site", + "mailto:%E8%AA%9Edef@yoursite.com?subject=Mail%20from%20Our%20Site#frag%E8%AA%9E" + ] + } + + private void expectEquals(UriBuilder builder, String expected) { + String uriString = builder.buildUriString() + assert uriString == expected + uriString = builder.buildUri().toString() + assert uriString == expected + } +} diff --git a/src/test/groovy/com/coditory/quark/uri/UriBuilder_parseHttpUrlSpec.groovy b/src/test/groovy/com/coditory/quark/uri/UriBuilder_parseHttpUrlSpec.groovy new file mode 100644 index 0000000..5bcfac9 --- /dev/null +++ b/src/test/groovy/com/coditory/quark/uri/UriBuilder_parseHttpUrlSpec.groovy @@ -0,0 +1,49 @@ +package com.coditory.quark.uri + +import spock.lang.Specification +import spock.lang.Unroll + +class UriBuilder_parseHttpUrlSpec extends Specification { + @Unroll + def "should create URL from valid http url: #input"() { + when: + UriComponents result = UriBuilder.fromUri(input).buildUriComponents() + then: + result.isValidHttpUrl() == true + and: + result.toUrl() == new URL(input) + where: + input << [ + "https://coditory.com", + "http://coditory.com", + "http://john:doe@coditory.com:8080/help?a=a1&a=a2&b=b1#frag", + "http://coditory.com?a=a1&a=a2&b=b1#frag" + ] + } + + @Unroll + def "should detect invalid http url: #input"() { + when: + UriComponents result = UriBuilder.fromUri(input).buildUriComponents() + then: + result.isValidHttpUrl() == false + where: + input << [ + "ftp://coditory.com", + "htttps://coditory.com", + "coditory.com", + "", + "/", + "/abc/def", + "?a=a1&a=a2&b=b1", + "?test=%E8%AA%9E", + "?%E8%AA%9E=test", + "#%E8%AA%9E", + "/%E8%AA%9E", + "../../../demo/jfc/SwingSet2/src/SwingSet2.java", + "mailto:java-net@java.sun.com", + "news:comp.lang.java", + "urn:isbn:096139210x" + ] + } +} diff --git a/src/test/groovy/com/coditory/quark/uri/UriBuilder_parseUriPartsSpec.groovy b/src/test/groovy/com/coditory/quark/uri/UriBuilder_parseUriPartsSpec.groovy new file mode 100644 index 0000000..20fcc08 --- /dev/null +++ b/src/test/groovy/com/coditory/quark/uri/UriBuilder_parseUriPartsSpec.groovy @@ -0,0 +1,142 @@ +package com.coditory.quark.uri + +import spock.lang.Specification +import spock.lang.Unroll + +class UriBuilder_parseUriPartsSpec extends Specification { + @Unroll + def "should parse scheme and host: #input"() { + when: + UriComponents result = UriComponents.fromUri(input) + then: + result.scheme == expected + and: + result.host == "coditory.com" + where: + input || expected + "//coditory.com" || null + "https://coditory.com" || "https" + "http://coditory.com" || "http" + "unknown://coditory.com" || "unknown" + } + + def "should handle plus sign"() { + when: + UriComponents result = UriComponents.fromUri("https://coditory.com/foo+bar?a+b=c+d#x+y") + then: + result.pathSegments == ["foo+bar"] + result.queryParams == ["a b": ["c d"]] + result.fragment == "x+y" + } + + def "should parse protocol relative uri"() { + when: + UriComponents result = UriComponents.fromUri("//coditory.com") + then: + result.protocolRelative == true + result.scheme == null + result.isOpaque() == false + result.schemeSpecificPart == null + } + + @Unroll + def "should parse user info: #input"() { + when: + UriComponents result = UriComponents.fromUri(input) + then: + result.userInfo == expected + where: + input || expected + "https://john@coditory.com" || "john" + "https://user:pass123@coditory.com" || "user:pass123" + } + + @Unroll + def "should parse path segments: #input"() { + when: + UriComponents result = UriComponents.fromUri(input) + then: + result.pathSegments == expected + and: + result.rootPath == rootPath + where: + input || rootPath | expected + "//coditory.com" || true | [] + "https://coditory.com//" || true | [] + "https://////coditory.com/////" || true | ["coditory.com"] + "http://coditory.com///test/////test2//////" || true | ["test", "test2"] + "/test" || true | ["test"] + "../test" || false | ["..", "test"] + "test" || false | ["test"] + "test//test2///" || false | ["test", "test2"] + "/a+b/c%20d" || true | ["a+b", "c d"] + "/%F0%9D%84%9E/%E8%AA%9E/a" || true | ["𝄞", "語", "a"] + } + + @Unroll + def "should parse query params: #query"() { + when: + UriComponents result = UriComponents.fromUri("https://coditory.com" + query) + then: + result.queryParams == expected + + and: + result.singleValueQueryParams == expectedSingleValue + + where: + query | expected | expectedSingleValue + "" | [:] | [:] + "?" | [:] | [:] + "?a" | [a: [""]] | [a: ""] + "?a=" | [a: [""]] | [a: ""] + "?a=&a=" | [a: ["", ""]] | [a: ""] + "?a=b" | [a: ["b"]] | [a: "b"] + "?a=b&a=c" | [a: ["b", "c"]] | [a: "b"] + "?a=b&a=b" | [a: ["b", "b"]] | [a: "b"] + "?a=b&c=d" | [a: ["b"], c: ["d"]] | [a: "b", c: "d"] + "?a+b=c+d" | ["a b": ["c d"]] | ["a b": "c d"] + "?a%20b=c%20d" | ["a b": ["c d"]] | ["a b": "c d"] + "?a=%E8%AA%9E" | [a: ["語"]] | [a: "語"] + } + + @Unroll + def "should parse fragment: #fragment"() { + when: + UriComponents result = UriComponents.fromUri("https://coditory.com" + fragment) + then: + result.fragment == expected + + where: + fragment | expected + "" | null + "#" | null + "#a" | "a" + "#a%20b" | "a b" + "#a%E8%AA%9Eb" | "a語b" + } + + @Unroll + def "should throw error when parsing invalid uri string: #uri"() { + when: + UriBuilder.fromUri(uri) + then: + InvalidUriException e = thrown(InvalidUriException) + e.message == "Could not parse uri: \"$uri\". Cause: $message" + where: + uri | message + "https://john.doe@" | "URI with user info must include host" + "https://john.doe@:8080" | "URI with user info must include host" + "https://coditory.com:80a" | "Invalid character 'a' for port in \"80a\"" + "https://coditory.com:a80" | "Invalid character 'a' for port in \"a80\"" + "https://:8080" | "URI with port must include host" + "https://codi tory.com" | "Invalid character ' ' for host in \"codi tory.com\"" + "ht tps://coditory.com" | "Invalid character ' ' for scheme in \"ht tps\"" + "https://jo hn.doe@coritory.com" | "Invalid character ' ' for user_info in \"jo hn.doe\"" + "/ /" | "Invalid character ' ' for path_segment in \" \"" + "/test?a b=c" | "Invalid character ' ' for query in \"a b=c\"" + "/test?a=b c" | "Invalid character ' ' for query in \"a=b c\"" + "/test?a=b=c" | "Invalid character '=' for query_param in \"b=c\"" + "/test#a b" | "Invalid character ' ' for fragment in \"a b\"" + "/test#a#b" | "Invalid character '#' for fragment in \"a#b\"" + } +} diff --git a/src/test/groovy/com/coditory/quark/uri/UriBuilder_parseUriSpec.groovy b/src/test/groovy/com/coditory/quark/uri/UriBuilder_parseUriSpec.groovy new file mode 100644 index 0000000..75e034a --- /dev/null +++ b/src/test/groovy/com/coditory/quark/uri/UriBuilder_parseUriSpec.groovy @@ -0,0 +1,123 @@ +package com.coditory.quark.uri + +import spock.lang.Specification + +class UriBuilder_parseUriSpec extends Specification { + def "should parse UriComponents from complex http url"() { + when: + UriComponents result = UriComponents.fromUri("https://john:doe@coditory.com:8080/help/test?a=a1&a=a2&b=b1#frag") + then: + result.schemeSpecificPart == null + result.opaque == false + result.scheme == "https" + result.userInfo == "john:doe" + result.uriAuthority == UriAuthority.of("john:doe", "coditory.com", 8080) + result.host == "coditory.com" + result.port == 8080 + result.path == "/help/test" + result.pathSegments == ["help", "test"] + result.protocolRelative == false + result.rootPath == true + result.queryString == "a=a1&a=a2&b=b1" + result.queryParams == [ + a: ['a1', 'a2'], + b: ['b1'] + ] + result.fragment == "frag" + result.isHttpUrl() == true + } + + def "should parse UriComponents from basic http url"() { + when: + UriComponents result = UriBuilder + .fromUri("http://coditory.com/help/test?a=a1&a=a2&b=b1#frag") + .buildUriComponents() + then: + result.schemeSpecificPart == null + result.opaque == false + result.scheme == "http" + result.userInfo == null + result.uriAuthority == UriAuthority.of(null, "coditory.com", -1) + result.host == "coditory.com" + result.port == -1 + result.path == "/help/test" + result.pathSegments == ["help", "test"] + result.rootPath == true + result.queryString == "a=a1&a=a2&b=b1" + result.queryParams == [ + a: ['a1', 'a2'], + b: ['b1'] + ] + result.fragment == "frag" + result.isHttpUrl() == true + } + + def "should parse UriComponents from uri starting with path"() { + when: + UriComponents result = UriBuilder + .fromUri("/help/test?a=a1&a=a2&b=b1#frag") + .buildUriComponents() + then: + result.schemeSpecificPart == null + result.opaque == false + result.scheme == null + result.userInfo == null + result.uriAuthority == null + result.host == null + result.port == -1 + result.path == "/help/test" + result.pathSegments == ["help", "test"] + result.rootPath == true + result.queryString == "a=a1&a=a2&b=b1" + result.queryParams == [ + a: ['a1', 'a2'], + b: ['b1'] + ] + result.fragment == "frag" + result.isHttpUrl() == false + } + + def "should parse UriComponents from uri with scheme and host only"() { + when: + UriComponents result = UriBuilder + .fromUri("https://coditory.com") + .buildUriComponents() + then: + result.schemeSpecificPart == null + result.opaque == false + result.scheme == "https" + result.userInfo == null + result.uriAuthority == UriAuthority.of(null, "coditory.com", -1) + result.host == "coditory.com" + result.port == -1 + result.path == null + result.pathSegments == [] + result.rootPath == true + result.queryString == null + result.queryParams == [:] + result.fragment == null + result.isHttpUrl() == true + } + + def "should parse UriComponents from opaque uri"() { + when: + UriComponents result = UriBuilder + .fromUri("mailto:%E8%AA%9Edef@yoursite.com?subject=Mail%20from%20Our%20Site#frag%E8%AA%9E") + .buildUriComponents() + then: + result.schemeSpecificPart == "語def@yoursite.com?subject=Mail from Our Site" + result.opaque == true + result.scheme == "mailto" + result.userInfo == null + result.uriAuthority == null + result.host == null + result.port == -1 + result.path == null + result.pathSegments == [] + result.rootPath == false + result.queryString == null + result.queryParams == [:] + result.fragment == "frag語" + result.isHttpUrl() == false + } +} diff --git a/src/test/groovy/com/coditory/quark/uri/UriBuilder_queryParamsSpec.groovy b/src/test/groovy/com/coditory/quark/uri/UriBuilder_queryParamsSpec.groovy new file mode 100644 index 0000000..4054aad --- /dev/null +++ b/src/test/groovy/com/coditory/quark/uri/UriBuilder_queryParamsSpec.groovy @@ -0,0 +1,112 @@ +package com.coditory.quark.uri + +import spock.lang.Specification + +class UriBuilder_queryParamsSpec extends Specification { + def "should add query params with addQueryParam"() { + when: + String result = UriBuilder.fromUri("https://coditory.com?w=W&a=A") + .addQueryParam("a", "X") + .addQueryParam("a", "X") + .addQueryParam("a", "Y") + .addQueryParam("b", "Y") + .addQueryParam("e", "") + .buildUriString() + then: + result == "https://coditory.com?w=W&a=A&a=X&a=X&a=Y&b=Y&e=" + } + + def "should add query params with addQueryMultiParams"() { + when: + String result = UriBuilder.fromUri("https://coditory.com?w=W&a=A") + .addQueryMultiParams([ + a : ["X", "X", "Y"], + b : ["Y"], + e1: [], + e2: [""] + ]) + .buildUriString() + then: + result == "https://coditory.com?w=W&a=A&a=X&a=X&a=Y&b=Y&e2=" + } + + def "should add query params with addQueryParams"() { + when: + String result = UriBuilder.fromUri("https://coditory.com?w=W&a=A") + .addQueryParams([ + a: "X", + b: "Y", + e: "" + ]) + .buildUriString() + then: + result == "https://coditory.com?w=W&a=A&a=X&b=Y&e=" + } + + def "should add query params with putQueryParam"() { + when: + String result = UriBuilder.fromUri("https://coditory.com?w=W&a=A") + .putQueryParam("a", "X") + .putQueryParam("a", "X") + .putQueryParam("a", "Y") + .putQueryParam("b", "Y") + .putQueryParam("e", "") + .buildUriString() + then: + result == "https://coditory.com?w=W&a=Y&b=Y&e=" + } + + def "should add query params with putQueryMultiParams"() { + when: + String result = UriBuilder.fromUri("https://coditory.com?w=W&a=A") + .putQueryMultiParams([ + a : ["X", "X", "Y"], + b : ["Y"], + e1: [], + e2: [""] + ]) + .buildUriString() + then: + result == "https://coditory.com?w=W&a=X&a=X&a=Y&b=Y&e2=" + } + + def "should add query params with putQueryParams"() { + when: + String result = UriBuilder.fromUri("https://coditory.com?w=W&a=A") + .putQueryParams([ + a: "X", + b: "Y", + e: "" + ]) + .buildUriString() + then: + result == "https://coditory.com?w=W&a=X&b=Y&e=" + } + + def "should remove query param by name"() { + when: + String result = UriBuilder.fromUri("https://coditory.com?a=X&a=Y&b=Z") + .removeQueryParam("a") + .buildUriString() + then: + result == "https://coditory.com?b=Z" + } + + def "should remove query param by name and value"() { + when: + String result = UriBuilder.fromUri("https://coditory.com?a=X&a=Y&b=Z") + .removeQueryParam("a", "Y") + .buildUriString() + then: + result == "https://coditory.com?a=X&b=Z" + } + + def "should remove all query params"() { + when: + String result = UriBuilder.fromUri("https://coditory.com?a=X&a=Y&b=Z") + .removeQueryParams() + .buildUriString() + then: + result == "https://coditory.com" + } +} diff --git a/src/test/groovy/com/coditory/quark/uri/UrlValidatorSpec.groovy b/src/test/groovy/com/coditory/quark/uri/UrlValidatorSpec.groovy new file mode 100644 index 0000000..7e427f8 --- /dev/null +++ b/src/test/groovy/com/coditory/quark/uri/UrlValidatorSpec.groovy @@ -0,0 +1,53 @@ +package com.coditory.quark.uri + + +import spock.lang.Specification +import spock.lang.Unroll + +class UrlValidatorSpec extends Specification { + @Unroll + def "should pass url validation: #input"() { + expect: + UrlValidator.isValidUrl(input) == true + where: + input << [ + "http://coditory.com", + "http://coditory.com/abc", + "http://coditory.com/a%20b", + "http://coditory.com/a%E8%AA%9Eb", + "http://coditory.com/a/b/c", + "http://coditory.com/test?a=b&a=b&a=c" + ] + } + + @Unroll + def "should fail url validation: #input"() { + expect: + UrlValidator.isValidUrl(input) == false + where: + input << [ + // invalid scheme + "htttp://coditory.com", + "htp://coditory.com", + "://coditory.com", + "1ht://coditory.com", + "coditory.com", + // invalid host + "http://co+ditory.com", + "http://coditory.1co", + "http://coditory.", + "http://.com", + "http://", + // invalid port + "http://coditory.com:-5", + "http://coditory.com:65636", + "http://coditory.com:80a", + "http://coditory.com:a80", + // invalid path + "http://coditory.com/..", + "http://coditory.com/../", + "http://coditory.com/../file", + "http://coditory.com/abc/../../file", + ] + } +} diff --git a/src/test/groovy/com/coditory/quark/uri/base/Alphabets.groovy b/src/test/groovy/com/coditory/quark/uri/base/Alphabets.groovy new file mode 100644 index 0000000..30483dc --- /dev/null +++ b/src/test/groovy/com/coditory/quark/uri/base/Alphabets.groovy @@ -0,0 +1,48 @@ +package com.coditory.quark.uri.base + +class Alphabets { + public static final String ALPHABETIC_UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + public static final String ALPHABETIC_LOWER = "abcdefghijklmnopqrstuvwxyz" + public static final String ALPHABETIC = ALPHABETIC_UPPER + ALPHABETIC_LOWER + public static final String NUMERIC = "0123456789" + public static final String ALPHANUMERIC = ALPHABETIC + NUMERIC + public static final String ASCII = asciiAlphabetWithControlCodes(0, 127) + public static final String ASCII_PRINTABLE = asciiAlphabet(32, 127) + public static final String ASCII_CONTROL_CODES = asciiAlphabetWithControlCodes(0, 32) + '\u007F' + + public static final String CYRYLLIC_CHARACTERS = "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя" + public static final String GREEK_CHARACTERS = "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωΆΈΉΊΌΎΏάέήόίύώΪΫϊϋΰΐ" + public static final String POLISH_CHARACTERS = "ĄąĆćĘꣳŃńÓ󌜏źŻż" + public static final String CZECH_CHARACTERS = "ÁČĎÉĚÍŇÓŘŠŤÚŮÝŽáčďéěíňóřšťúůýž" + public static final String SLOVAK_CHARACTERS = "ÁÄČĎžÉÍĹĽŇÓÔŔŠŤÚÝŽáäčďžéíĺľňóôŕšťúýž" + public static final String ESPERANTO_CHARACTERS = "ĈĉĜĝĤĥĴĵŜŝŬŭ" + public static final String GERMAN_CHARACTERS = "ÄäÖöÜüẞß" + public static final String NORDIC_CHARACTERS = "åÅæÆøØÄäÖö" + public static final String TURKISH_CHARACTERS = "ğĞçCıIiİöÖŞşüÜ" + + /** + * Unreserved uri characters + * https://tools.ietf.org/html/rfc3986#section-2.3 + */ + public static final String URI_UNRESERVED = ALPHANUMERIC + "-._~"; + /** + * @link https://tools.ietf.org/html/rfc3986#section-3.5 + */ + public static final String URI_SEGMENT_UNRESERVED = URI_UNRESERVED + "!\$&'()*+,;=:@"; + /** + * @link https://tools.ietf.org/html/rfc3986#section-3.5 + */ + public static final String URI_FRAGMENT_UNRESERVED = URI_SEGMENT_UNRESERVED + "+/?"; + + private static String asciiAlphabet(int asciiFromInclusive, int asciiToExclusive) { + return asciiAlphabetWithControlCodes(asciiFromInclusive, asciiToExclusive) + } + + private static String asciiAlphabetWithControlCodes(int asciiFromInclusive, int asciiToExclusive) { + char[] chars = new char[asciiToExclusive - asciiFromInclusive]; + for (int i = asciiFromInclusive; i < asciiToExclusive; ++i) { + chars[i - asciiFromInclusive] = i + } + return String.valueOf(chars); + } +} diff --git a/src/test/groovy/com/coditory/quark/uri/base/CapturingAppender.groovy b/src/test/groovy/com/coditory/quark/uri/base/CapturingAppender.groovy new file mode 100644 index 0000000..3c52ae3 --- /dev/null +++ b/src/test/groovy/com/coditory/quark/uri/base/CapturingAppender.groovy @@ -0,0 +1,102 @@ +package com.coditory.quark.uri.base + +import ch.qos.logback.classic.Level +import ch.qos.logback.classic.spi.LoggingEvent +import ch.qos.logback.core.AppenderBase +import org.slf4j.Marker +import spock.util.concurrent.BlockingVariable + +import java.util.function.Predicate + +class CapturingAppender extends AppenderBase { + private int loggerCalls = 0 + private final List capturedEvents = new ArrayList<>() + private final BlockingVariable called = new BlockingVariable(0.2) // 200ms + + CapturingAppender() { + start() + } + + @Override + protected void append(LoggingEvent event) { + capturedEvents.add(event) + called.set(true) + } + + void waitForFirstLog() { + called.get() + } + + synchronized int getLoggerCalls() { + return loggerCalls + } + + synchronized void reset() { + capturedEvents.clear() + } + + synchronized List getLogsByMessagePrefix(String prefix) { + return capturedEvents + .findAll { it.message.startsWith(prefix) } + .collect { it.toString() } + } + + synchronized int capturedEvents() { + return capturedEvents.size() + } + + synchronized int countCapturedEvents(Predicate predicate) { + return capturedEvents.count { predicate.test(it) } + } + + synchronized int countCapturedEvents(String message) { + return capturedEvents.count { it.message == message } + } + + synchronized int countCapturedEvents(String message, List params) { + return capturedEvents.count { + it.message == message && + it.argumentArray == params.toArray() + } + } + + synchronized int countCapturedEvents(Level level) { + return capturedEvents.count { it.level == level } + } + + synchronized int countCapturedEvents(String message, List params, String exceptionMessage) { + return capturedEvents.count { + it.message == message && + it.argumentArray == params.toArray() && + it.throwableProxy.message == exceptionMessage + } + } + + synchronized int countCapturedEvents(Marker marker) { + return capturedEvents.count { it.marker == marker } + } + + synchronized int countCapturedEvents(Level level, String message, List params, String exceptionMessage) { + return capturedEvents.count { + it.level == level && + it.message == message && + it.argumentArray == params?.toArray() && + it.throwableProxy.message == exceptionMessage + } + } + + synchronized int countCapturedEvents(Level level, String message, List params) { + return capturedEvents.count { + it.level == level && + it.message == message && + it.argumentArray == params.toArray() + } + } + + synchronized int countCapturedEvents(Level level, String message) { + return capturedEvents.count { + it.level == level && + it.message == message + } + } +} diff --git a/src/test/java/readme/ReadmeSamples.java b/src/test/java/readme/ReadmeSamples.java new file mode 100644 index 0000000..a4bada6 --- /dev/null +++ b/src/test/java/readme/ReadmeSamples.java @@ -0,0 +1,47 @@ +package readme; + +import com.coditory.quark.uri.UriBuilder; +import com.coditory.quark.uri.UriComponents; + +public class ReadmeSamples { + public static void main(String[] args) { + String result = UriBuilder.fromUri("https://coditory.com?w=W&a=A") + .addPathSegment("about") + .addQueryParam("a", "X") + .addQueryParam("a", "X") + .addQueryParam("a", "Y") + .addQueryParam("b", "Y") + .addQueryParam("e", "") + .buildUriString(); + System.out.println(result); + + UriComponents uriComponents = UriBuilder.fromUri("https://coditory.com?w=W&a=A") + .addPathSegment("about") + .addQueryParam("a", "X") + .addQueryParam("a", "X") + .addQueryParam("a", "Y") + .addQueryParam("b", "Y") + .addQueryParam("e", "") + .buildUriComponents(); + System.out.println(uriComponents); + + result = UriBuilder.fromUri("https://coditory.com?w=W&a=A") + .addPathSegment("a b") + .addQueryParam("x y", " X Y ") + .buildUriString(); + System.out.println(result); + + result = UriBuilder.fromUri("https://coditory.com/a+bc/d%20ef/") + .addPathSegment("x y ") + .setFragment("frag ment") + .addQueryParam("f oo", "b ar") + .addQueryParam("x", "y+z") + .buildUriString(); + System.out.println(result); + + uriComponents = UriBuilder.fromUri("/abc?a+b=A+B").buildUriComponents(); + System.out.println(uriComponents); + uriComponents = UriBuilder.fromUri("/abc?a%20b=A%20B").buildUriComponents(); + System.out.println(uriComponents); + } +}