|
26 | 26 | * |
27 | 27 | * @param type the key store type, for example {@code JKS} or {@code PKCS11}. A |
28 | 28 | * {@code null} value will use {@link KeyStore#getDefaultType()}). |
| 29 | + * @param alias the alias used when setting entries in the {@link KeyStore} |
| 30 | + * @param password the password used |
| 31 | + * {@link KeyStore#setKeyEntry(String, java.security.Key, char[], java.security.cert.Certificate[]) |
| 32 | + * setting key entries} in the {@link KeyStore} |
29 | 33 | * @param certificate the certificate content (either the PEM content itself or something |
30 | 34 | * that can be loaded by {@link ResourceUtils#getURL}) |
31 | 35 | * @param privateKey the private key content (either the PEM content itself or something |
|
35 | 39 | * @author Phillip Webb |
36 | 40 | * @since 3.1.0 |
37 | 41 | */ |
38 | | -public record PemSslStoreDetails(String type, String certificate, String privateKey, String privateKeyPassword) { |
| 42 | +public record PemSslStoreDetails(String type, String alias, String password, String certificate, String privateKey, |
| 43 | + String privateKeyPassword) { |
39 | 44 |
|
| 45 | + /** |
| 46 | + * Create a new {@link PemSslStoreDetails} instance. |
| 47 | + * @param type the key store type, for example {@code JKS} or {@code PKCS11}. A |
| 48 | + * {@code null} value will use {@link KeyStore#getDefaultType()}). |
| 49 | + * @param alias the alias used when setting entries in the {@link KeyStore} |
| 50 | + * @param password the password used |
| 51 | + * {@link KeyStore#setKeyEntry(String, java.security.Key, char[], java.security.cert.Certificate[]) |
| 52 | + * setting key entries} in the {@link KeyStore} |
| 53 | + * @param certificate the certificate content (either the PEM content itself or |
| 54 | + * something that can be loaded by {@link ResourceUtils#getURL}) |
| 55 | + * @param privateKey the private key content (either the PEM content itself or |
| 56 | + * something that can be loaded by {@link ResourceUtils#getURL}) |
| 57 | + * @param privateKeyPassword a password used to decrypt an encrypted private key |
| 58 | + * @since 3.2.0 |
| 59 | + */ |
| 60 | + public PemSslStoreDetails { |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * Create a new {@link PemSslStoreDetails} instance. |
| 65 | + * @param type the key store type, for example {@code JKS} or {@code PKCS11}. A |
| 66 | + * {@code null} value will use {@link KeyStore#getDefaultType()}). |
| 67 | + * @param certificate the certificate content (either the PEM content itself or |
| 68 | + * something that can be loaded by {@link ResourceUtils#getURL}) |
| 69 | + * @param privateKey the private key content (either the PEM content itself or |
| 70 | + * something that can be loaded by {@link ResourceUtils#getURL}) |
| 71 | + * @param privateKeyPassword a password used to decrypt an encrypted private key |
| 72 | + */ |
| 73 | + public PemSslStoreDetails(String type, String certificate, String privateKey, String privateKeyPassword) { |
| 74 | + this(type, null, null, certificate, privateKey, null); |
| 75 | + } |
| 76 | + |
| 77 | + /** |
| 78 | + * Create a new {@link PemSslStoreDetails} instance. |
| 79 | + * @param type the key store type, for example {@code JKS} or {@code PKCS11}. A |
| 80 | + * {@code null} value will use {@link KeyStore#getDefaultType()}). |
| 81 | + * @param certificate the certificate content (either the PEM content itself or |
| 82 | + * something that can be loaded by {@link ResourceUtils#getURL}) |
| 83 | + * @param privateKey the private key content (either the PEM content itself or |
| 84 | + * something that can be loaded by {@link ResourceUtils#getURL}) |
| 85 | + */ |
40 | 86 | public PemSslStoreDetails(String type, String certificate, String privateKey) { |
41 | 87 | this(type, certificate, privateKey, null); |
42 | 88 | } |
43 | 89 |
|
| 90 | + /** |
| 91 | + * Return a new {@link PemSslStoreDetails} instance with a new alias. |
| 92 | + * @param alias the new alias |
| 93 | + * @return a new {@link PemSslStoreDetails} instance |
| 94 | + * @since 3.2.0 |
| 95 | + */ |
| 96 | + public PemSslStoreDetails withAlias(String alias) { |
| 97 | + return new PemSslStoreDetails(this.type, alias, this.password, this.certificate, this.privateKey, |
| 98 | + this.privateKeyPassword); |
| 99 | + } |
| 100 | + |
| 101 | + /** |
| 102 | + * Return a new {@link PemSslStoreDetails} instance with a new password. |
| 103 | + * @param password the new password |
| 104 | + * @return a new {@link PemSslStoreDetails} instance |
| 105 | + * @since 3.2.0 |
| 106 | + */ |
| 107 | + public PemSslStoreDetails withPassword(String password) { |
| 108 | + return new PemSslStoreDetails(this.type, this.alias, password, this.certificate, this.privateKey, |
| 109 | + this.privateKeyPassword); |
| 110 | + } |
| 111 | + |
44 | 112 | /** |
45 | 113 | * Return a new {@link PemSslStoreDetails} instance with a new private key. |
46 | 114 | * @param privateKey the new private key |
47 | 115 | * @return a new {@link PemSslStoreDetails} instance |
48 | 116 | */ |
49 | 117 | public PemSslStoreDetails withPrivateKey(String privateKey) { |
50 | | - return new PemSslStoreDetails(this.type, this.certificate, privateKey, this.privateKeyPassword); |
| 118 | + return new PemSslStoreDetails(this.type, this.alias, this.password, this.certificate, privateKey, |
| 119 | + this.privateKeyPassword); |
51 | 120 | } |
52 | 121 |
|
53 | 122 | /** |
54 | 123 | * Return a new {@link PemSslStoreDetails} instance with a new private key password. |
55 | | - * @param password the new private key password |
| 124 | + * @param privateKeyPassword the new private key password |
56 | 125 | * @return a new {@link PemSslStoreDetails} instance |
57 | 126 | */ |
58 | | - public PemSslStoreDetails withPrivateKeyPassword(String password) { |
59 | | - return new PemSslStoreDetails(this.type, this.certificate, this.privateKey, password); |
| 127 | + public PemSslStoreDetails withPrivateKeyPassword(String privateKeyPassword) { |
| 128 | + return new PemSslStoreDetails(this.type, this.alias, this.password, this.certificate, this.privateKey, |
| 129 | + privateKeyPassword); |
60 | 130 | } |
61 | 131 |
|
62 | 132 | boolean isEmpty() { |
|
0 commit comments