1 /** 2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 * SPDX-License-Identifier: Apache-2.0. 4 */ 5 6 package software.amazon.awssdk.crt.io; 7 8 /** 9 * Top level configuration for the custom TLS key operations. 10 */ 11 public class TlsContextCustomKeyOperationOptions { 12 private TlsKeyOperationHandler operationHandler; 13 private String certificateFilePath; 14 private String certificateFileContents; 15 16 /** 17 * Creates a new TlsContextCustomKeyOperationOptions and sets the TlsKeyOperationHandler that 18 * will be invoked when there is a TLS key operation that needs to be performed. 19 * 20 * Through the TlsKeyOperationHandler you can add your own private key operations during the 21 * mutual TLS handshake. 22 * 23 * @param operationHandler The operation handler to use when performing a TLS key operation. 24 */ TlsContextCustomKeyOperationOptions(TlsKeyOperationHandler operationHandler)25 public TlsContextCustomKeyOperationOptions(TlsKeyOperationHandler operationHandler) { 26 this.operationHandler = operationHandler; 27 } 28 29 /** 30 * Use this X.509 certificate (file on disk). The certificate may be specified 31 * by other means instead (ex: {@link withCertificateFileContents}) 32 * 33 * @param path path to PEM-formatted certificate file on disk. 34 * @return The TlsContextCustomKeyOperationOptions after setting the path 35 */ withCertificateFilePath(String path)36 public TlsContextCustomKeyOperationOptions withCertificateFilePath(String path) { 37 this.certificateFilePath = path; 38 return this; 39 } 40 41 /** 42 * Use this X.509 certificate (contents in memory). The certificate may be 43 * specified by other means instead (ex: {@link withCertificateFilePath}) 44 * 45 * @param contents contents of PEM-formatted certificate file. 46 * @return The TlsContextCustomKeyOperationOptions after certificate contents 47 */ withCertificateFileContents(String contents)48 public TlsContextCustomKeyOperationOptions withCertificateFileContents(String contents) { 49 this.certificateFileContents = contents; 50 return this; 51 } 52 53 /** 54 * Returns the path to the X.509 certificate file on disk if it has been set. 55 * 56 * @return The path to the certificate file 57 */ getCertificateFilePath()58 public String getCertificateFilePath() { 59 return certificateFilePath; 60 } 61 62 /** 63 * Returns the contents of the X.509 certificate if it has been set. 64 * 65 * @return The contents of the certificate 66 */ getCertificateFileContents()67 public String getCertificateFileContents() { 68 return certificateFileContents; 69 } 70 71 /** 72 * Returns the TlsKeyOperationHandler assigned to this class. 73 * 74 * @return The operation handler that will be used 75 */ getOperationHandler()76 public TlsKeyOperationHandler getOperationHandler() { 77 return operationHandler; 78 } 79 80 } 81