com.synopsys.integration.coverity.authentication.AuthenticationKeyFileUtility Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of coverity-common Show documentation
Show all versions of coverity-common Show documentation
A library for using various capabilities of Coverity.
The newest version!
/*
* coverity-common
*
* Copyright (c) 2021 Synopsys, Inc.
*
* Use subject to the terms and conditions of the Synopsys End User Software License and Maintenance Agreement. All rights reserved worldwide.
*/
package com.synopsys.integration.coverity.authentication;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import com.google.gson.Gson;
public class AuthenticationKeyFileUtility {
private final Gson gson;
public static AuthenticationKeyFileUtility defaultUtility() {
return new AuthenticationKeyFileUtility(new Gson());
}
public AuthenticationKeyFileUtility(final Gson gson) {
this.gson = gson;
}
public AuthenticationKeyFile readAuthenticationKeyFile(final Path pathToAuthenticationKeyFile) throws IOException {
try (BufferedReader reader = Files.newBufferedReader(pathToAuthenticationKeyFile)) {
return gson.fromJson(reader, AuthenticationKeyFile.class);
}
}
public AuthenticationKeyFile readAuthenticationKeyFile(final InputStream authenticationKeyFileContents) throws IOException {
try (InputStreamReader reader = new InputStreamReader(authenticationKeyFileContents)) {
return gson.fromJson(reader, AuthenticationKeyFile.class);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy