sonatype-lift[bot] commented on code in PR #1284:
URL: https://github.com/apache/solr/pull/1284#discussion_r1066388488
##########
solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.java:
##########
@@ -297,6 +283,54 @@ public void init(Map<String, Object> pluginConfig) {
lastInitTime = Instant.now();
}
+ /**
+ * Given a configuration object of a file name or list of file names, read
X509 certificates from
+ * each file
+ */
+ @SuppressWarnings("unchecked")
+ Collection<X509Certificate> readSslCertsFromFileOrList(Object
trustedCertsFileObj) {
+ Collection<X509Certificate> certs = new HashSet<>();
+ if (trustedCertsFileObj instanceof String) {
+ String trustedCertsFile = (String) trustedCertsFileObj;
+ log.info("Reading trustedCerts from file {}", trustedCertsFile);
+ try {
+ certs.addAll(parseCertsFromFile(trustedCertsFile));
+ } catch (IOException e) {
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR, "Failed to read file " +
trustedCertsFile, e);
+ }
+ } else if (trustedCertsFileObj instanceof List) {
+ List<String> trustedCertsFileList = (List<String>) trustedCertsFileObj;
+ log.info("Reading trustedCerts from list of files {}",
trustedCertsFileList);
+ trustedCertsFileList.forEach(
+ f -> {
+ try {
+ certs.addAll(parseCertsFromFile(f));
+ } catch (IOException e) {
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR, "Failed to read file "
+ f, e);
+ }
+ });
+ } else {
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR, "trustedCertsFile is neither a
String or List");
+ }
+ return certs;
+ }
+
+ /**
+ * Given a filename string, validate the file and then read any X509
certificates from it
+ *
+ * @return list of certificates found in file
+ */
+ Collection<? extends X509Certificate> parseCertsFromFile(String
certFileName) throws IOException {
+ Path certFilePath = Paths.get(certFileName);
Review Comment:
I've recorded this as ignored for this pull request.
If you change your mind, just comment `@sonatype-lift unignore`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]