-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2.x] Extracts demo configuration setup into a java tool, adds suppor…
…t for Bundled JDK for this tool and updates DEVELOPER_GUIDE.md (#3845) ### Description Backports following commits related to demo configuration tool from main to 2.x: - [x] [17748b9](17748b9) from #3669 - [x] [4496440](4496440) from #3734 - [x] [06d8c29](06d8c29) from #3777 - [x] [e698315](e698315) from #3807 - [x] [9d11524](9d11524) from #3843 - [x] [62aed21](62aed21) from #3850 - [x] [ceabe13](ceabe13) from #3844 ### Issues Resolved - Related to #3827 ### Testing - automated tests ### Check List - [x] New functionality includes testing - [x] New functionality has been documented - [x] Commits are signed per the DCO using --signoff By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check [here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin). --------- Signed-off-by: Darshit Chanpura <[email protected]> Signed-off-by: Darshit Chanpura <[email protected]>
- Loading branch information
1 parent
bffc8a0
commit ea9546e
Showing
21 changed files
with
2,354 additions
and
988 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/org/opensearch/security/tools/democonfig/CertificateGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
package org.opensearch.security.tools.democonfig; | ||
|
||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
/** | ||
* This class creates demo certificate files | ||
*/ | ||
public class CertificateGenerator { | ||
|
||
private final Installer installer; | ||
|
||
public CertificateGenerator(Installer installer) { | ||
this.installer = installer; | ||
} | ||
|
||
/** | ||
* Creates demo super-admin, node and root certificates by iterating through Certificates enum | ||
*/ | ||
public void createDemoCertificates() { | ||
for (Certificates cert : Certificates.values()) { | ||
String filePath = this.installer.OPENSEARCH_CONF_DIR + File.separator + cert.getFileName(); | ||
writeCertificateToFile(filePath, cert.getContent()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper method to write the certificates to their own file | ||
* @param filePath the file which needs to be written | ||
* @param content the content which needs to be written to this file | ||
*/ | ||
static void writeCertificateToFile(String filePath, String content) { | ||
try { | ||
FileWriter fileWriter = new FileWriter(filePath, StandardCharsets.UTF_8); | ||
fileWriter.write(content); | ||
fileWriter.close(); | ||
} catch (IOException e) { | ||
System.err.println("Error writing certificate file: " + filePath); | ||
System.exit(-1); | ||
} | ||
} | ||
} |
Oops, something went wrong.