Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Core Interfaces's Maven group ID is `io.apimatic`, and its artifact ID is `core-
| [`ExceptionCreator`](./src/main/java/io/apimatic/coreinterfaces/type/functional/ExceptionCreator.java) | Functional interface to create the SDK exception |
| [`Serializer`](./src/main/java/io/apimatic/coreinterfaces/type/functional/Serializer.java) | Functional interface to apply the serialization function |
| [`ContextInitializer`](./src/main/java/io/apimatic/coreinterfaces/type/functional/ContextInitializer.java) | Functional Interface to apply the context initialization function for the response models |
| [`SignatureVerifier`](./src/main/java/io/apimatic/coreinterfaces/security/SignatureVerifier.java) | Defines a contract for verifying the signature of an HTTP request |
| [`VerificationResult`](./src/main/java/io/apimatic/coreinterfaces/security/VerificationResult.java) | Represents the result of an operation that can either succeed or fail with an error message |

## Enumerations

Expand Down
5 changes: 4 additions & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ sonar.sourceEncoding=UTF-8

sonar.sources=src/main/java

sonar.java.binaries=target/classes
sonar.java.binaries=target/classes

# Skip coverage
sonar.coverage.exclusions=**
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.apimatic.coreinterfaces.security;

import io.apimatic.coreinterfaces.http.request.Request;

import java.util.concurrent.CompletableFuture;

/**
* Defines a contract for verifying the signature of an HTTP request.
*/
public interface SignatureVerifier {

/**
* Verifies the signature of the specified HTTP request.
*
* @param request The HTTP request data to verify.
* @return A {@link CompletableFuture} containing the outcome of the verification process.
*/
CompletableFuture<VerificationResult> verifyAsync(Request request);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package io.apimatic.coreinterfaces.security;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
* Represents the result of an operation that can either succeed
* or fail with an error message.
*/
public interface VerificationResult {

/**
* Indicates whether the verification succeeded.
*
* @return true if successful; false otherwise.
*/
boolean isSuccess();

/**
* Gets the collection of error messages, if any.
* Always returns a read-only list (never null).
*
* @return unmodifiable list of errors, empty if success.
*/
List<String> getErrors();

/**
* Creates a successful result.
*
* @return a success result
*/
static VerificationResult success() {
return new VerificationResult() {
@Override
public boolean isSuccess() {
return true;
}

@Override
public List<String> getErrors() {
return Collections.emptyList();
}
};
}

/**
* Creates a failed result with the given error messages.
*
* @param errors list of error messages
* @return a failure result
*/
static VerificationResult failure(String... errors) {
return new VerificationResult() {
@Override
public boolean isSuccess() {
return false;
}

@Override
public List<String> getErrors() {
return Collections.unmodifiableList(errors != null
? Arrays.asList(errors) : Collections.emptyList());
}
};
}
}
Loading