diff --git a/mapping.properties b/mapping.properties new file mode 100644 index 0000000..d576117 --- /dev/null +++ b/mapping.properties @@ -0,0 +1,4 @@ +# This contains the authorized repository=groupId where: +# - repository is the repository where the extension is hosted +# - groupId is the groupId of the extension +quarkiverse-release/quarkus-slack=io.quarkiverse.slack diff --git a/validate_repository.java b/validate_repository.java index 786892d..73ada37 100644 --- a/validate_repository.java +++ b/validate_repository.java @@ -1,9 +1,27 @@ -import java.io.File; +import java.io.FileInputStream; +import java.util.Properties; public class validate_repository { - public static void main(String[] args) { - System.out.println(new File(System.getenv("ARTIFACT_DIR")).exists()); - System.out.println("Hello, World"); + public static void main(String[] args) throws Exception { +// Path artifactDir = Path.of(System.getenv("ARTIFACT_DIR")); + String repository = System.getenv("REPOSITORY"); + String name = System.getenv("NAME"); +// String version = System.getenv("VERSION"); + // Verify if the repository pattern is valid + Properties prop = groupIdMapping(); + // Check if the artifacts are from the authorized group Id + if (!prop.containsKey(repository)) { + throw new Exception("Unauthorized group Id"); + } + //TODO: Perform other checks here + } + + private static Properties groupIdMapping() throws Exception { + Properties prop = new Properties(); + try (FileInputStream fis = new FileInputStream("mapping.properties")) { + prop.load(fis); + } + return prop; } }