Skip to content

Commit

Permalink
refactor: fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jgiovaresco committed Jul 18, 2023
1 parent 9cb3d8c commit cbbcf7f
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.nimbusds.jose.JWSHeader;
import com.nimbusds.jose.KeySourceException;
import com.nimbusds.jose.proc.JWSKeySelector;
import com.nimbusds.jose.proc.JWSVerificationKeySelector;
import com.nimbusds.jose.proc.SecurityContext;
import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.proc.JWTClaimsSetAwareJWSKeySelector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import com.nimbusds.jose.proc.JWSKeySelector;
import com.nimbusds.jose.proc.JWSVerificationKeySelector;
import com.nimbusds.jose.proc.SecurityContext;
import com.nimbusds.jwt.JWTClaimsSet;
import java.util.Set;

/**
* Specific implementation of {@link JWSKeySelector} that disable matching of kid and allows matching JWT with a given key that does not define key id.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.nimbusds.jose.jwk.JWKSelector;
import com.nimbusds.jose.jwk.source.JWKSource;
import com.nimbusds.jose.proc.SecurityContext;
import com.nimbusds.jwt.proc.JWTProcessor;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Maybe;
import io.reactivex.rxjava3.schedulers.Schedulers;
import java.net.MalformedURLException;
import java.text.ParseException;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package io.gravitee.policy.jwt.jwk.source;

import com.nimbusds.jose.util.Resource;
import com.nimbusds.jwt.proc.JWTProcessor;
import io.reactivex.rxjava3.core.Single;

/**
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/io/gravitee/policy/jwt/utils/JWKBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,11 @@

import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.JWSAlgorithm;
import com.nimbusds.jose.jwk.ECKey;
import com.nimbusds.jose.jwk.JWK;
import com.nimbusds.jose.jwk.OctetSequenceKey;
import com.nimbusds.jose.jwk.RSAKey;
import java.security.KeyException;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@
*/
package io.gravitee.policy.v3.jwt.jwks.retriever;

import static io.gravitee.common.util.VertxProxyOptionsUtils.*;
import static io.gravitee.common.util.VertxProxyOptionsUtils.setSystemProxy;

import com.nimbusds.jose.util.Resource;
import io.gravitee.node.api.configuration.Configuration;
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.Vertx;
import io.vertx.core.http.*;
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpClientRequest;
import io.vertx.core.http.HttpClientResponse;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.RequestOptions;
import java.net.URL;
import java.util.concurrent.CompletableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;

/**
* @author David BRASSELY (david.brassely at graviteesource.com)
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/io/gravitee/policy/jwt/JWTPolicyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void shouldVerifyTokenWithClientId(String clientIdField, String expectedClientId
}

@Test
void shouldVerifyTokenFromRequest() throws BadJOSEException, ParseException, JOSEException {
void shouldVerifyTokenFromRequest() throws BadJOSEException, JOSEException {
final Metrics metrics = mock(Metrics.class);
final HttpHeaders headers = mock(HttpHeaders.class);
final JWTClaimsSet claimsSet = new JWTClaimsSet.Builder()
Expand All @@ -193,7 +193,7 @@ void shouldVerifyTokenFromRequest() throws BadJOSEException, ParseException, JOS
}

@Test
void shouldVerifyTokenAndExtractClaimsWhenExtractClaimsIsConfigured() throws BadJOSEException, ParseException, JOSEException {
void shouldVerifyTokenAndExtractClaimsWhenExtractClaimsIsConfigured() throws BadJOSEException, JOSEException {
final Metrics metrics = mock(Metrics.class);
final HttpHeaders headers = mock(HttpHeaders.class);
final JWTClaimsSet claimsSet = new JWTClaimsSet.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/
package io.gravitee.policy.jwt;

import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.ok;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static io.gravitee.policy.jwt.alg.Signature.HMAC_HS256;
import static io.gravitee.policy.v3.jwt.resolver.KeyResolver.GIVEN_KEY;
import static io.vertx.core.http.HttpMethod.GET;
Expand All @@ -34,9 +37,7 @@
import io.gravitee.apim.gateway.tests.sdk.AbstractPolicyTest;
import io.gravitee.apim.gateway.tests.sdk.annotations.DeployApi;
import io.gravitee.apim.gateway.tests.sdk.annotations.GatewayTest;
import io.gravitee.apim.gateway.tests.sdk.configuration.GatewayConfigurationBuilder;
import io.gravitee.definition.model.Api;
import io.gravitee.definition.model.ExecutionMode;
import io.gravitee.definition.model.Plan;
import io.gravitee.gateway.api.service.Subscription;
import io.gravitee.gateway.api.service.SubscriptionService;
Expand Down
7 changes: 5 additions & 2 deletions src/test/java/io/gravitee/policy/jwt/jwk/AbstractJWKTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
package io.gravitee.policy.jwt.jwk;

import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.spy;

import com.nimbusds.jose.*;
import com.nimbusds.jose.Algorithm;
import com.nimbusds.jose.JWSAlgorithm;
import com.nimbusds.jose.JWSHeader;
import com.nimbusds.jose.JWSObject;
import com.nimbusds.jose.JWSSigner;
import com.nimbusds.jose.crypto.MACSigner;
import com.nimbusds.jose.crypto.RSASSASigner;
import com.nimbusds.jose.jwk.RSAKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;

import com.nimbusds.jose.KeySourceException;
import com.nimbusds.jose.jwk.JWK;
Expand All @@ -35,7 +40,6 @@
import java.security.KeyPair;
import java.security.interfaces.RSAPublicKey;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
*/
package io.gravitee.policy.jwt.utils;

import com.nimbusds.jose.util.X509CertUtils;
import io.gravitee.policy.jwt.utils.PublicKeyHelper;
import java.security.cert.X509Certificate;
import java.security.interfaces.RSAPublicKey;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.nimbusds.jose.crypto.MACSigner;
import com.nimbusds.jose.jwk.OctetSequenceKey;
import io.gravitee.policy.jwt.alg.Signature;
import io.gravitee.policy.v3.jwt.JWTPolicyV3Test;
import java.security.SecureRandom;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
*/
package io.gravitee.policy.v3.jwt;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;

import io.gravitee.apim.gateway.tests.sdk.annotations.GatewayTest;
import io.gravitee.apim.gateway.tests.sdk.configuration.GatewayConfigurationBuilder;
import io.gravitee.definition.model.Api;
import io.gravitee.definition.model.ExecutionMode;
import io.gravitee.gateway.api.service.Subscription;
import io.gravitee.gateway.api.service.SubscriptionService;
Expand Down

0 comments on commit cbbcf7f

Please sign in to comment.