Skip to content

Commit

Permalink
sonar findings
Browse files Browse the repository at this point in the history
  • Loading branch information
strehle committed Sep 18, 2023
1 parent 2782dfa commit 379fe73
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class ClientJwtChangeRequest {

public static final String JWKS_URI = "jwks_uri";
public static final String JWKS = "jwks";

public enum ChangeMode {
UPDATE,
ADD,
DELETE
}
@JsonProperty("kid")
private String keyId;
@JsonProperty("jwks_uri")
@JsonProperty(JWKS_URI)
private String jsonWebKeyUri;
@JsonProperty("jwks")
@JsonProperty(JWKS)
private String jsonWebKeySet;
@JsonProperty("client_id")
private String clientId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.cloudfoundry.identity.uaa.client;

import static java.util.Optional.ofNullable;
import static org.cloudfoundry.identity.uaa.client.ClientJwtConfiguration.JWKS;
import static org.cloudfoundry.identity.uaa.client.ClientJwtConfiguration.JWKS_URI;
import static org.cloudfoundry.identity.uaa.oauth.token.TokenConstants.GRANT_TYPE_AUTHORIZATION_CODE;
import static org.cloudfoundry.identity.uaa.oauth.token.TokenConstants.GRANT_TYPE_IMPLICIT;
import static org.cloudfoundry.identity.uaa.oauth.token.TokenConstants.GRANT_TYPE_REFRESH_TOKEN;
Expand Down Expand Up @@ -204,15 +206,15 @@ private void addNewClients() {
}
for (String key : Arrays.asList("resource-ids", "scope", "authorized-grant-types", "authorities",
"redirect-uri", "secret", "id", "override", "access-token-validity",
"refresh-token-validity", "show-on-homepage", "app-launch-url", "app-icon", "jwks", "jwks_uri")) {
"refresh-token-validity", "show-on-homepage", "app-launch-url", "app-icon", JWKS, JWKS_URI)) {
info.remove(key);
}

client.setAdditionalInformation(info);

if (map.get("jwks_uri") instanceof String || map.get("jwks") instanceof String) {
String jwksUri = (String) map.get("jwks_uri");
String jwks = (String) map.get("jwks");
if (map.get(JWKS_URI) instanceof String || map.get(JWKS) instanceof String) {
String jwksUri = (String) map.get(JWKS_URI);
String jwks = (String) map.get(JWKS);
ClientJwtConfiguration keyConfig = ClientJwtConfiguration.parse(jwksUri, jwks);
if (keyConfig != null && keyConfig.getCleanString() != null) {
keyConfig.writeValue(client);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.nimbusds.jose.jwk.JWK;
import com.nimbusds.jose.jwk.JWKSet;
import org.cloudfoundry.identity.uaa.oauth.client.ClientJwtChangeRequest;
import org.cloudfoundry.identity.uaa.oauth.jwk.JsonWebKey;
import org.cloudfoundry.identity.uaa.oauth.jwk.JsonWebKeyHelper;
import org.cloudfoundry.identity.uaa.oauth.jwk.JsonWebKeySet;
Expand All @@ -29,13 +30,16 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class ClientJwtConfiguration implements Cloneable{

public static final String JWKS_URI = ClientJwtChangeRequest.JWKS_URI;
public static final String JWKS = ClientJwtChangeRequest.JWKS;

@JsonIgnore
private static final int MAX_KEY_SIZE = 10;

@JsonProperty("jwks_uri")
@JsonProperty(JWKS_URI)
private String jwksUri;

@JsonProperty("jwks")
@JsonProperty(JWKS)
private JsonWebKeySet<JsonWebKey> jwkSet;

public ClientJwtConfiguration() {
Expand Down

0 comments on commit 379fe73

Please sign in to comment.