From 8c86de79d9b531585051e9c3914769ccf18f5540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branislav=20Bedn=C3=A1r?= <60175324+branislavbednar@users.noreply.github.com> Date: Tue, 9 Jan 2024 08:01:31 +0100 Subject: [PATCH] AUTOPAY-26733: Add Servlet-friendly methods to http-signatures library (#66) * AUTOPAY-26733: Add Servlet-friendly methods to http-signatures library * AUTOPAY-26733: Add Servlet-friendly methods to http-signatures library * AUTOPAY-26733: Add Servlet-friendly methods to http-signatures library License header updated * AUTOPAY-26733: Add Servlet-friendly methods to http-signatures library JavaDoc and Readme updated --------- Co-authored-by: Robert Borys --- Jenkinsfile | 2 +- LICENSE | 2 +- README.md | 6 ++ pom.xml | 2 +- .../autopay/http/digest/DigestAlgorithm.java | 2 +- .../autopay/http/digest/DigestCalculator.java | 2 +- .../autopay/http/digest/DigestException.java | 2 +- .../autopay/http/digest/DigestHeaders.java | 2 +- .../autopay/http/digest/DigestVerifier.java | 2 +- .../http/signature/CheckedFunction.java | 2 +- .../autopay/http/signature/Component.java | 2 +- .../http/signature/ComponentFactory.java | 2 +- .../autopay/http/signature/DataSigner.java | 2 +- .../autopay/http/signature/DataVerifier.java | 2 +- .../http/signature/DerivedComponent.java | 2 +- .../http/signature/DerivedComponentType.java | 2 +- .../signature/EllipticCurveValidator.java | 2 +- .../http/signature/HeaderComponent.java | 2 +- .../autopay/http/signature/PublicKeyInfo.java | 2 +- .../http/signature/SignatureAlgorithm.java | 2 +- .../http/signature/SignatureComponents.java | 2 +- .../http/signature/SignatureContext.java | 101 +++++++++++++++++- .../http/signature/SignatureException.java | 2 +- .../http/signature/SignatureHeaders.java | 2 +- .../http/signature/SignatureKeyAlgorithm.java | 2 +- .../http/signature/SignatureKeyFactory.java | 2 +- .../signature/SignatureParameterType.java | 2 +- .../http/signature/SignatureParameters.java | 2 +- .../http/signature/SignatureResult.java | 2 +- .../http/signature/SignatureSigner.java | 2 +- .../autopay/http/signature/SignatureSpec.java | 2 +- .../http/signature/SignatureVerifier.java | 2 +- .../http/signature/VerificationSpec.java | 2 +- .../http/structured/CharacterValidator.java | 2 +- .../http/structured/StructuredBoolean.java | 2 +- .../http/structured/StructuredBytes.java | 2 +- .../http/structured/StructuredCollection.java | 2 +- .../http/structured/StructuredDecimal.java | 2 +- .../http/structured/StructuredDictionary.java | 2 +- .../http/structured/StructuredException.java | 2 +- .../http/structured/StructuredField.java | 2 +- .../http/structured/StructuredInnerList.java | 2 +- .../http/structured/StructuredInteger.java | 2 +- .../http/structured/StructuredItem.java | 2 +- .../http/structured/StructuredList.java | 2 +- .../http/structured/StructuredMap.java | 2 +- .../http/structured/StructuredParameters.java | 2 +- .../http/structured/StructuredParser.java | 2 +- .../http/structured/StructuredString.java | 2 +- .../http/structured/StructuredToken.java | 2 +- .../http/digest/DigestCalculatorTest.java | 2 +- .../http/digest/DigestVerifierTest.java | 2 +- .../http/signature/DataSignerTest.java | 2 +- .../http/signature/DataVerifierTest.java | 2 +- .../autopay/http/signature/ObjectMother.java | 2 +- .../http/signature/PublicKeyInfoTest.java | 2 +- .../SignatureBaseSpecificationTest.java | 2 +- .../signature/SignatureComponentsTest.java | 2 +- .../http/signature/SignatureContextTest.java | 99 ++++++++++++++++- .../signature/SignatureParameterTypeTest.java | 2 +- .../http/signature/SignatureResultTest.java | 2 +- .../http/signature/SignatureSignerTest.java | 2 +- .../http/signature/SignatureSpecTest.java | 2 +- .../signature/SignatureSpecificationTest.java | 2 +- .../http/signature/SignatureVerifierTest.java | 2 +- .../http/signature/VerificationSpecTest.java | 2 +- .../autopay/http/structured/MapUtil.java | 2 +- .../structured/StructuredBooleanTest.java | 2 +- .../http/structured/StructuredBytesTest.java | 2 +- .../structured/StructuredDecimalTest.java | 2 +- .../structured/StructuredDictionaryTest.java | 2 +- .../structured/StructuredInnerListTest.java | 2 +- .../structured/StructuredIntegerTest.java | 2 +- .../http/structured/StructuredItemTest.java | 2 +- .../http/structured/StructuredListTest.java | 2 +- .../structured/StructuredParametersTest.java | 2 +- .../http/structured/StructuredParserTest.java | 2 +- .../http/structured/StructuredStringTest.java | 2 +- .../http/structured/StructuredTokenTest.java | 2 +- .../spec/StructuredSpecificationTest.java | 2 +- .../http/structured/spec/TestRecord.java | 2 +- .../structured/spec/TestRecordMapper.java | 2 +- 82 files changed, 283 insertions(+), 81 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2ae3c38..2943dfc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Visma Autopay AS + * Copyright (c) 2022-2024 Visma Autopay AS * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/LICENSE b/LICENSE index 54f8ab2..9d1a734 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022-2023 Visma Autopay AS +Copyright (c) 2022-2024 Visma Autopay AS Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index c9233c4..e862632 100644 --- a/README.md +++ b/README.md @@ -254,6 +254,8 @@ var requestContext = SignatureContext.builder() .method("POST") // Can be provided as a String or URI .targetUri("https://example.com/foo") + // Or from HttpServletRequest object + .targetUri(request.getRequestURL(), request.getQueryString()) // Status for response signature .status(200) @@ -264,6 +266,10 @@ var requestContext = SignatureContext.builder() .headers(Map.of("Header-One", "valueOne", "Header-Two", "valueTwo")) // Or as a "MultivaluedMap", often used in frameworks .headers(Map.of("Header-One", List.of("valueOne", "valueTwo"))) + // Or from HttpServletRequest object + .headers(request.getHeaderNames(), request::getHeaders) + // Or from HttpServletResponse object + .headers(response.getHeaderNames(), response::getHeaders) // Context of related request if used in response signature .relatedRequest(relatedRequestContext) diff --git a/pom.xml b/pom.xml index 7da08c1..5e459bc 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@