diff --git a/pom.xml b/pom.xml index 6e62492..6786d25 100644 --- a/pom.xml +++ b/pom.xml @@ -234,7 +234,7 @@ org.gaul modernizer-maven-plugin - 2.9.0 + 3.0.0 ${targetJdk} diff --git a/src/main/java/net/tirasa/connid/bundles/googleapps/credentialsgenerator/CredentialsGeneratorApplication.java b/src/main/java/net/tirasa/connid/bundles/googleapps/credentialsgenerator/CredentialsGeneratorApplication.java index 1b9b397..745b783 100644 --- a/src/main/java/net/tirasa/connid/bundles/googleapps/credentialsgenerator/CredentialsGeneratorApplication.java +++ b/src/main/java/net/tirasa/connid/bundles/googleapps/credentialsgenerator/CredentialsGeneratorApplication.java @@ -29,11 +29,12 @@ import com.google.api.client.json.JsonFactory; import com.google.api.client.json.gson.GsonFactory; import java.awt.Desktop; -import java.io.File; -import java.io.FileReader; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; @@ -101,8 +102,8 @@ public static void main(final String[] args) { sa.run(args); } - private void getConfigurationMap(final File clientJson) throws IOException, URISyntaxException { - GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new FileReader(clientJson)); + private void getConfigurationMap(final Path clientJson) throws IOException, URISyntaxException { + GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, Files.newBufferedReader(clientJson)); CONFIG_MAP.put("clientId", clientSecrets.getDetails().getClientId()); CONFIG_MAP.put("clientSecret", clientSecrets.getDetails().getClientSecret()); @@ -142,12 +143,12 @@ public ServletRegistrationBean codeProcessorServlet() { @Override public void run(final String... args) throws IOException, URISyntaxException { if (args.length == 1) { - File clientJson = new File(args[0]); - if (clientJson.isDirectory()) { - clientJson = new File(clientJson, CLIENTSECRETS_LOCATION); + Path clientJson = Paths.get(args[0]); + if (Files.isDirectory(clientJson)) { + clientJson = clientJson.resolve(CLIENTSECRETS_LOCATION); } - if (clientJson.exists() && clientJson.isFile()) { + if (Files.isReadable(clientJson) && Files.isRegularFile(clientJson)) { getConfigurationMap(clientJson); } else { LOG.error("Invalid client secret path: {}", clientJson);