Skip to content

Commit

Permalink
Continue setting JsonWebKeySet appTid collection but mark API as depr…
Browse files Browse the repository at this point in the history
…ecated
  • Loading branch information
finkmanAtSap committed Sep 12, 2023
1 parent ed7c8b4 commit 896d550
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

class JsonWebKeySet {

private final Set<JsonWebKey> jsonWebKeys = new HashSet<>();
private final Map<String, Boolean> appTidAccepted = new HashMap<>();
@Deprecated
private final Set<String> appTidAccepted = new HashSet<>();

@Nullable
public JsonWebKey getKeyByAlgorithmAndId(JwtSignatureAlgorithm keyAlgorithm, String keyId) {
Expand Down Expand Up @@ -45,16 +44,24 @@ private Stream<JsonWebKey> getTokenStreamWithTypeAndKeyId(JwtSignatureAlgorithm
.filter(jwk -> kid.equals(jwk.getId()));
}

@Deprecated
public boolean containsAppTid(String appTid) {
return appTidAccepted.containsKey(appTid);
return appTidAccepted.contains(appTid);
}

@Deprecated
public boolean isAppTidAccepted(String appTid) {
return appTidAccepted.get(appTid);
return appTidAccepted.contains(appTid);
}

@Deprecated
public JsonWebKeySet withAppTid(String appTid, boolean isAccepted) {
appTidAccepted.put(appTid, isAccepted);
if(isAccepted) {
appTidAccepted.add(appTid);
} else {
appTidAccepted.remove(appTid);
}

return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public PublicKey getPublicKey(JwtSignatureAlgorithm keyAlgorithm, String keyId,
private JsonWebKeySet retrieveTokenKeysAndUpdateCache(CacheKey cacheKey) throws OAuth2ServiceException {
String jwksJson = getTokenKeyService().retrieveTokenKeys(cacheKey.keyUri(), cacheKey.appTid(), cacheKey.clientId(), cacheKey.azp());

JsonWebKeySet keySet = JsonWebKeySetFactory.createFromJson(jwksJson);
JsonWebKeySet keySet = JsonWebKeySetFactory.createFromJson(jwksJson).withAppTid(cacheKey.appTid(), true);

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
JsonWebKeySet.withAppTid
should be avoided because it has been deprecated.
getCache().put(cacheKey.toString(), keySet);

return keySet;
Expand Down

0 comments on commit 896d550

Please sign in to comment.