Skip to content

Commit 8cb7f99

Browse files
committed
resolve sonarcloud warnings
1 parent 3bfbb2f commit 8cb7f99

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ public static byte[] aesDecrypt(byte[] data, byte[] key) throws Exception {
136136
// Sonar warns that a random IV should be used for encryption
137137
// but we are decrypting here.
138138
final IvParameterSpec ivSpec = new IvParameterSpec(Arrays.copyOf(key, 16));
139+
@SuppressWarnings("java:S5542")
140+
// Sonar warns that cncryption algorithms should be used with secure mode and padding scheme
141+
// but ChangeNotifications implementation uses this algorithm for decryption.
142+
// https://learn.microsoft.com/en-us/graph/change-notifications-with-resource-data?tabs=java#decrypting-resource-data
139143
final Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
140144
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "AES"), ivSpec);
141145
return cipher.doFinal(data);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ boolean isTokenValid(
163163
}
164164
}
165165

166-
if (body.get("azp", String.class) != graphNotificationPublisher) {
166+
if (!body.get("azp", String.class).equals(graphNotificationPublisher)) {
167167
throw new IllegalArgumentException("Invalid token publisher. Expected Graph notification publisher (azp): " + graphNotificationPublisher);
168168
}
169169

0 commit comments

Comments
 (0)