1919import com .microsoft .kiota .serialization .ParseNodeFactoryRegistry ;
2020
2121import jakarta .annotation .Nonnull ;
22+ import jakarta .annotation .Nullable ;
2223
2324/**
2425 * DecryptableContent interface
@@ -29,53 +30,53 @@ public interface DecryptableContent {
2930 * Sets the data
3031 * @param data resource data
3132 */
32- public void setData (String data );
33+ public void setData (@ Nullable final String data );
3334 /**
3435 * Gets the data
3536 * @return the data
3637 */
37- public String getData ();
38+ public @ Nullable String getData ();
3839 /**
3940 * Sets the data key
4041 * @param dataKey asymmetric key used to sign data
4142 */
42- public void setDataKey (String dataKey );
43+ public void setDataKey (@ Nullable final String dataKey );
4344 /**
4445 * Gets the data key
4546 * @return the data key
4647 */
47- public String getDataKey ();
48+ public @ Nullable String getDataKey ();
4849
4950 /**
5051 * Sets the data signature
5152 * @param signature signature of the data
5253 */
53- public void setDataSignature (String signature );
54+ public void setDataSignature (@ Nullable final String signature );
5455 /**
5556 * Gets the data signature
5657 * @return data signature
5758 */
58- public String getDataSignature ();
59+ public @ Nullable String getDataSignature ();
5960 /**
6061 * Sets the encryption certificate id
6162 * @param encryptionCertificateId certificate Id used when subscribing
6263 */
63- public void setEncryptionCertificateId (String encryptionCertificateId );
64+ public void setEncryptionCertificateId (@ Nullable final String encryptionCertificateId );
6465 /**
6566 * Gets the encryption certificate id
6667 * @return the encryption certificate id
6768 */
68- public String getEncryptionCertificateId ();
69+ public @ Nullable String getEncryptionCertificateId ();
6970 /**
7071 * Sets the encryption certificate thumbprint
7172 * @param encryptionCertificateThumbprint certificate thumbprint
7273 */
73- public void setEncryptionCertificateThumbprint (String encryptionCertificateThumbprint );
74+ public void setEncryptionCertificateThumbprint (@ Nullable final String encryptionCertificateThumbprint );
7475 /**
7576 * Gets the encryption certificate thumbprint
7677 * @return the encryption certificate thumbprint
7778 */
78- public String getEncryptionCertificateThumbprint ();
79+ public @ Nullable String getEncryptionCertificateThumbprint ();
7980
8081 /**
8182 * Validates the signature of the resource data, decrypts resource data and deserializes the data to a Parsable
@@ -88,7 +89,7 @@ public interface DecryptableContent {
8889 * @return decrypted resource data
8990 * @throws Exception if an error occurs while decrypting the data
9091 */
91- public static <T extends Parsable > T decrypt (@ Nonnull final DecryptableContent decryptableContent , @ Nonnull final CertificateKeyProvider certificateKeyProvider , @ Nonnull final ParsableFactory <T > factory ) throws Exception {
92+ public static @ Nonnull <T extends Parsable > T decrypt (@ Nonnull final DecryptableContent decryptableContent , @ Nonnull final CertificateKeyProvider certificateKeyProvider , @ Nonnull final ParsableFactory <T > factory ) throws Exception {
9293 Objects .requireNonNull (certificateKeyProvider );
9394 final String decryptedContent = decryptAsString (decryptableContent , certificateKeyProvider );
9495 final ParseNode rootParseNode = ParseNodeFactoryRegistry .defaultInstance .getParseNode (
@@ -105,7 +106,7 @@ public static <T extends Parsable> T decrypt(@Nonnull final DecryptableContent d
105106 * @return decrypted resource data
106107 * @throws Exception if an error occurs while decrypting the data
107108 */
108- public static String decryptAsString (@ Nonnull final DecryptableContent content , @ Nonnull final CertificateKeyProvider certificateKeyProvider ) throws Exception {
109+ public static @ Nonnull String decryptAsString (@ Nonnull final DecryptableContent content , @ Nonnull final CertificateKeyProvider certificateKeyProvider ) throws Exception {
109110 Objects .requireNonNull (certificateKeyProvider );
110111 final Key privateKey = certificateKeyProvider .getCertificateKey (content .getEncryptionCertificateId (), content .getEncryptionCertificateThumbprint ());
111112 final Cipher cipher = Cipher .getInstance ("RSA/None/OAEPWithSHA1AndMGF1Padding" );
@@ -130,7 +131,7 @@ public static String decryptAsString(@Nonnull final DecryptableContent content,
130131 * @return decrypted resource data
131132 * @throws Exception if an error occurs while decrypting the data
132133 */
133- public static byte [] aesDecrypt (byte [] data , byte [] key ) throws Exception {
134+ public static @ Nonnull byte [] aesDecrypt (@ Nonnull final byte [] data , @ Nonnull final byte [] key ) throws Exception {
134135 try {
135136 @ SuppressWarnings ("java:S3329" )
136137 // Sonar warns that a random IV should be used for encryption
@@ -160,6 +161,6 @@ public interface CertificateKeyProvider {
160161 * @param certificateThumbprint certificate thumbprint
161162 * @return Private key used to sign the certificate
162163 */
163- public Key getCertificateKey (String certificateId , String certificateThumbprint );
164+ public @ Nonnull Key getCertificateKey (@ Nullable final String certificateId , @ Nullable final String certificateThumbprint );
164165 }
165166}
0 commit comments