Skip to content

Commit 5d36d3c

Browse files
committed
add missing nullable and nonnull annotations
1 parent 8cb7f99 commit 5d36d3c

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

src/main/java/com/microsoft/graph/core/models/DecryptableContent.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.microsoft.kiota.serialization.ParseNodeFactoryRegistry;
2020

2121
import 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
}

src/main/java/com/microsoft/graph/core/models/DiscoverUrlAdapter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import io.jsonwebtoken.JwsHeader;
1717
import io.jsonwebtoken.LocatorAdapter;
1818
import jakarta.annotation.Nonnull;
19+
import jakarta.annotation.Nullable;
1920

2021
/**
2122
* DiscoverUrlAdapter class
@@ -40,7 +41,7 @@ public DiscoverUrlAdapter(@Nonnull final String keyDiscoveryUrl)
4041
}
4142

4243
@Override
43-
protected Key locate(JwsHeader header) {
44+
protected @Nullable Key locate(@Nonnull JwsHeader header) {
4445
Objects.requireNonNull(header);
4546
try {
4647
String keyId = header.getKeyId();
@@ -52,7 +53,7 @@ protected Key locate(JwsHeader header) {
5253
}
5354

5455
@Override
55-
protected Key locate(JweHeader header) {
56+
protected @Nullable Key locate(@Nonnull JweHeader header) {
5657
return null;
5758
}
5859

src/main/java/com/microsoft/graph/core/models/EncryptableSubscription.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.Objects;
77

88
import jakarta.annotation.Nonnull;
9+
import jakarta.annotation.Nullable;
910

1011
/**
1112
* EncryptableSubscription interface
@@ -16,13 +17,13 @@ public interface EncryptableSubscription {
1617
* Sets the encryption certificate
1718
* @param certificate Base-64 encoded certificate to be used by Microsoft Graph to encrypt resource data
1819
*/
19-
public void setEncryptionCertificate(String certificate);
20+
public void setEncryptionCertificate(@Nullable final String certificate);
2021

2122
/**
2223
* Returns the encryption certificate
2324
* @return encryption certificate
2425
*/
25-
public String getEncryptionCertificate();
26+
public @Nullable String getEncryptionCertificate();
2627

2728
/**
2829
* Converts an X.509 Certificate object to Base-64 string and adds to the encryptableSubscription provided

src/main/java/com/microsoft/graph/core/models/TokenValidable.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.UUID;
88

99
import jakarta.annotation.Nonnull;
10+
import jakarta.annotation.Nullable;
1011
import io.jsonwebtoken.Claims;
1112
import io.jsonwebtoken.Jws;
1213
import io.jsonwebtoken.Jwts;
@@ -26,25 +27,25 @@ public interface TokenValidable<U extends DecryptableContent, T extends Encrypte
2627
* Sets collection of validation tokens
2728
* @param validationTokens tokens
2829
*/
29-
public void setValidationTokens(List<String> validationTokens);
30+
public void setValidationTokens(@Nullable final List<String> validationTokens);
3031

3132
/**
3233
* Returns validation tokens
3334
* @return list of tokens
3435
*/
35-
public List<String> getValidationTokens();
36+
public @Nullable List<String> getValidationTokens();
3637

3738
/**
3839
* Sets collection of encrypted token bearers
3940
* @param value collection of encrypted token bearers
4041
*/
41-
public void setValue(List<T> value);
42+
public void setValue(@Nullable final List<T> value);
4243

4344
/**
4445
* Get collection of encrypted token bearers
4546
* @return encrypted token bearers
4647
*/
47-
public List<T> getValue();
48+
public @Nullable List<T> getValue();
4849

4950
/**
5051
* Validates the tokens

0 commit comments

Comments
 (0)