2727
2828import com .fasterxml .jackson .annotation .JsonProperty ;
2929
30+ import org .springframework .lang .Nullable ;
3031import org .springframework .util .Assert ;
3132import org .springframework .util .Base64Utils ;
3233import org .springframework .vault .VaultException ;
3839 * {@link X509Certificate}.
3940 *
4041 * @author Mark Paluch
42+ * @author Alex Bremora
4143 * @see #getPrivateKeySpec()
4244 * @see #getX509Certificate()
4345 * @see #getIssuingCaCertificate()
@@ -46,26 +48,11 @@ public class CertificateBundle extends Certificate {
4648
4749 private final String privateKey ;
4850
51+ @ Nullable
4952 private final String privateKeyType ;
5053
5154 private final List <String > caChain ;
5255
53- /**
54- * Create a new {@link CertificateBundle}.
55- * @param serialNumber the serial number.
56- * @param certificate the certificate.
57- * @param issuingCaCertificate the issuing CA certificate.
58- * @param caChain the CA chain.
59- * @param privateKey the private key.
60- * @deprecated since 2.3.3, use {@link #CertificateBundle(String, String, String, List, String, String)} instead.
61- */
62- @ Deprecated
63- CertificateBundle (String serialNumber , String certificate , String issuingCaCertificate ,
64- List <String > caChain , String privateKey ) {
65-
66- this (serialNumber , certificate , issuingCaCertificate , caChain , privateKey , null );
67- }
68-
6956 /**
7057 * Create a new {@link CertificateBundle}.
7158 * @param serialNumber the serial number.
@@ -78,7 +65,7 @@ public class CertificateBundle extends Certificate {
7865 CertificateBundle (@ JsonProperty ("serial_number" ) String serialNumber ,
7966 @ JsonProperty ("certificate" ) String certificate , @ JsonProperty ("issuing_ca" ) String issuingCaCertificate ,
8067 @ JsonProperty ("ca_chain" ) List <String > caChain , @ JsonProperty ("private_key" ) String privateKey ,
81- @ JsonProperty ("private_key_type" ) String privateKeyType ) {
68+ @ Nullable @ JsonProperty ("private_key_type" ) String privateKeyType ) {
8269
8370 super (serialNumber , certificate , issuingCaCertificate );
8471 this .privateKey = privateKey ;
@@ -93,11 +80,8 @@ public class CertificateBundle extends Certificate {
9380 * @param certificate must not be empty or {@literal null}.
9481 * @param issuingCaCertificate must not be empty or {@literal null}.
9582 * @param privateKey must not be empty or {@literal null}.
96- * @return the {@link CertificateBundle}
97- * @deprecated since 2.3.3, use {@link #of(String, String, String, String, String)}
98- * instead.
83+ * @return the {@link CertificateBundle} instead.
9984 */
100- @ Deprecated
10185 public static CertificateBundle of (String serialNumber , String certificate , String issuingCaCertificate ,
10286 String privateKey ) {
10387
@@ -107,7 +91,7 @@ public static CertificateBundle of(String serialNumber, String certificate, Stri
10791 Assert .hasText (privateKey , "Private key must not be empty" );
10892
10993 return new CertificateBundle (serialNumber , certificate , issuingCaCertificate ,
110- Collections .singletonList (issuingCaCertificate ), privateKey );
94+ Collections .singletonList (issuingCaCertificate ), privateKey , null );
11195 }
11296
11397 /**
@@ -119,9 +103,10 @@ public static CertificateBundle of(String serialNumber, String certificate, Stri
119103 * @param privateKey must not be empty or {@literal null}.
120104 * @param privateKeyType must not be empty or {@literal null}.
121105 * @return the {@link CertificateBundle}
106+ * @since 2.4
122107 */
123108 public static CertificateBundle of (String serialNumber , String certificate , String issuingCaCertificate ,
124- String privateKey , String privateKeyType ) {
109+ String privateKey , @ Nullable String privateKeyType ) {
125110
126111 Assert .hasText (serialNumber , "Serial number must not be empty" );
127112 Assert .hasText (certificate , "Certificate must not be empty" );
@@ -141,8 +126,10 @@ public String getPrivateKey() {
141126 }
142127
143128 /**
144- * @return the private key type.
129+ * @return the private key type, can be {@literal null}.
130+ * @since 2.4
145131 */
132+ @ Nullable
146133 public String getPrivateKeyType () {
147134 return this .privateKeyType ;
148135 }
0 commit comments