Skip to content

Commit

Permalink
Renames subclasses of ClientCredential for consistency in relation to…
Browse files Browse the repository at this point in the history
… naming of configuration properties.
  • Loading branch information
rfc3092 committed Dec 16, 2024
1 parent 1ab9b0e commit 6e21ad5
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package no.nav.registre.testnorge.profil.service;

import lombok.extern.slf4j.Slf4j;
import no.nav.testnav.libs.securitycore.domain.azuread.AzureNavClientCredential;
import no.nav.testnav.libs.securitycore.domain.azuread.AzureClientCredential;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
Expand All @@ -22,13 +22,13 @@
@Service
public class AzureAdTokenService {
private final WebClient webClient;
private final AzureNavClientCredential clientCredential;
private final AzureClientCredential clientCredential;
private final GetAuthenticatedToken getAuthenticatedToken;

public AzureAdTokenService(
@Value("${http.proxy:#{null}}") String proxyHost,
@Value("${AAD_ISSUER_URI}") String issuerUrl,
AzureNavClientCredential clientCredential,
AzureClientCredential clientCredential,
GetAuthenticatedToken getAuthenticatedToken
) {
log.info("Init custom AzureAd token exchange.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import no.nav.testnav.libs.securitycore.domain.ResourceServerType;
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
import no.nav.testnav.libs.securitycore.domain.Token;
import no.nav.testnav.libs.securitycore.domain.azuread.AzureNavClientCredential;
import no.nav.testnav.libs.securitycore.domain.azuread.AzureClientCredential;
import no.nav.testnav.libs.securitycore.domain.azuread.ClientCredential;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand Down Expand Up @@ -39,7 +39,7 @@ public class AzureAdTokenService implements TokenService {
public AzureAdTokenService(
@Value("${http.proxy:#{null}}") String proxyHost,
@Value("${AAD_ISSUER_URI}") String issuerUrl,
AzureNavClientCredential azureNavClientCredential,
AzureClientCredential azureClientCredential,
GetAuthenticatedToken getAuthenticatedToken
) {
log.info("Init AzureAd token exchange.");
Expand All @@ -63,7 +63,7 @@ public AzureAdTokenService(
}
this.webClient = builder.build();
this.getAuthenticatedToken = getAuthenticatedToken;
this.clientCredential = azureNavClientCredential;
this.clientCredential = azureClientCredential;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package no.nav.testnav.libs.reactivesecurity.exchange.azuread;

import lombok.extern.slf4j.Slf4j;
import no.nav.testnav.libs.securitycore.domain.azuread.AzureNavProxyClientCredential;
import no.nav.testnav.libs.securitycore.domain.azuread.AzureNavClientCredential;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
Expand Down Expand Up @@ -29,13 +29,13 @@ public class NavAzureAdTokenService implements ExchangeToken {

public NavAzureAdTokenService(
@Value("${http.proxy:#{null}}") String proxyHost,
AzureNavProxyClientCredential azureNavProxyClientCredential
AzureNavClientCredential azureNavClientCredential
) {
this.clientCredential = azureNavProxyClientCredential;
this.clientCredential = azureNavClientCredential;
log.info("Init AzureAd Nav token service.");
WebClient.Builder builder = WebClient
.builder()
.baseUrl(azureNavProxyClientCredential.getTokenEndpoint())
.baseUrl(azureNavClientCredential.getTokenEndpoint())
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);

if (proxyHost != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import no.nav.testnav.libs.securitycore.command.azuread.OnBehalfOfExchangeCommand;
import no.nav.testnav.libs.securitycore.domain.AccessToken;
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
import no.nav.testnav.libs.securitycore.domain.azuread.AzureNavClientCredential;
import no.nav.testnav.libs.securitycore.domain.azuread.AzureClientCredential;
import no.nav.testnav.libs.securitycore.domain.azuread.ClientCredential;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
Expand All @@ -25,7 +25,7 @@ public class AzureAdTokenExchange implements ExchangeToken {
public AzureAdTokenExchange(
@Value("${AAD_ISSUER_URI}") String issuerUrl,
TokenResolver tokenResolver,
AzureNavClientCredential clientCredential) {
AzureClientCredential clientCredential) {

this.webClient = WebClient
.builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package no.nav.testnav.libs.securitycore.domain.azuread;

public class AzureClientCredential extends ClientCredential {

AzureClientCredential(String clientId, String clientSecret) {
super(clientId, clientSecret);
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package no.nav.testnav.libs.securitycore.domain.azuread;

import lombok.EqualsAndHashCode;
import lombok.Getter;

@Getter
@EqualsAndHashCode(callSuper = false)
public class AzureNavClientCredential extends ClientCredential {

AzureNavClientCredential(String clientId, String clientSecret) {
private final String tokenEndpoint;

AzureNavClientCredential(String tokenEndpoint, String clientId, String clientSecret) {
super(clientId, clientSecret);
this.tokenEndpoint = tokenEndpoint;
}

}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ public class ClientCredentialConfig {
@Value("${AZURE_NAV_APP_CLIENT_SECRET:#{null}}")
private String azureNavClientSecret;

@Bean("azureNavClientCredential")
@Bean("azureClientCredential")
@Profile("!test")
@ConditionalOnMissingBean(AzureNavClientCredential.class)
public AzureNavClientCredential azureNavClientCredential() {
@ConditionalOnMissingBean(AzureClientCredential.class)
public AzureClientCredential azureNavClientCredential() {
Assert.hasLength(azureClientId, AZURE_MISSING);
Assert.hasLength(azureClientSecret, AZURE_MISSING);
return new AzureNavClientCredential(azureClientId, azureClientSecret);
return new AzureClientCredential(azureClientId, azureClientSecret);
}

@Bean("azureNavClientCredential")
@Bean("azureClientCredential")
@Profile("test")
@ConditionalOnMissingBean(AzureNavClientCredential.class)
public AzureNavClientCredential azureNavClientCredentialTest() {
return new AzureNavClientCredential(TEST_CLIENT_ID, TEST_CLIENT_SECRET);
@ConditionalOnMissingBean(AzureClientCredential.class)
public AzureClientCredential azureNavClientCredentialTest() {
return new AzureClientCredential(TEST_CLIENT_ID, TEST_CLIENT_SECRET);
}

@Bean("azureTrygdeetatenClientCredential")
Expand All @@ -69,23 +69,23 @@ public AzureTrygdeetatenClientCredential azureTrygdeetatenClientCredentialTest()
return new AzureTrygdeetatenClientCredential(TEST_TOKEN_ENDPOINT, TEST_CLIENT_ID, TEST_CLIENT_SECRET);
}

@Bean("azureNavProxyClientCredential")
@Bean("azureNavClientCredential")
@Profile("!test")
@ConditionalOnMissingBean(AzureNavProxyClientCredential.class)
@ConditionalOnMissingBean(AzureNavClientCredential.class)
@ConditionalOnProperty("AZURE_NAV_OPENID_CONFIG_TOKEN_ENDPOINT")
public AzureNavProxyClientCredential azureNavProxyClientCredential(
public AzureNavClientCredential azureNavProxyClientCredential(
@Value("AZURE_NAV_OPENID_CONFIG_TOKEN_ENDPOINT") String azureNavTokenEndpoint
) {
Assert.hasLength(azureNavClientId, PROXY_MISSING);
Assert.hasLength(azureNavClientSecret, PROXY_MISSING);
return new AzureNavProxyClientCredential(azureNavTokenEndpoint, azureNavClientId, azureNavClientSecret);
return new AzureNavClientCredential(azureNavTokenEndpoint, azureNavClientId, azureNavClientSecret);
}

@Bean("azureNavProxyClientCredential")
@Bean("azureNavClientCredential")
@Profile("test")
@ConditionalOnMissingBean(AzureNavProxyClientCredential.class)
public AzureNavProxyClientCredential azureNavProxyClientCredentialTest() {
return new AzureNavProxyClientCredential(TEST_TOKEN_ENDPOINT, TEST_CLIENT_ID, TEST_CLIENT_SECRET);
@ConditionalOnMissingBean(AzureNavClientCredential.class)
public AzureNavClientCredential azureNavProxyClientCredentialTest() {
return new AzureNavClientCredential(TEST_TOKEN_ENDPOINT, TEST_CLIENT_ID, TEST_CLIENT_SECRET);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import no.nav.testnav.libs.securitycore.command.azuread.ClientCredentialExchangeCommand;
import no.nav.testnav.libs.securitycore.domain.AccessToken;
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
import no.nav.testnav.libs.securitycore.domain.azuread.AzureNavClientCredential;
import no.nav.testnav.libs.securitycore.domain.azuread.AzureClientCredential;
import no.nav.testnav.libs.securitycore.domain.azuread.ClientCredential;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
Expand All @@ -28,7 +28,7 @@ public class AzureAdTokenService implements ExchangeToken {
public AzureAdTokenService(
@Value("${http.proxy:#{null}}") String proxyHost,
@Value("${AAD_ISSUER_URI}") String issuerUrl,
AzureNavClientCredential clientCredential
AzureClientCredential clientCredential
) {
log.info("Init AzureAd token exchange.");
WebClient.Builder builder = WebClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import no.nav.testnav.libs.securitycore.domain.ResourceServerType;
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
import no.nav.testnav.libs.securitycore.domain.Token;
import no.nav.testnav.libs.securitycore.domain.azuread.AzureNavClientCredential;
import no.nav.testnav.libs.securitycore.domain.azuread.AzureClientCredential;
import no.nav.testnav.libs.securitycore.domain.azuread.ClientCredential;
import no.nav.testnav.libs.servletsecurity.action.GetAuthenticatedToken;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -34,7 +34,7 @@ public class AzureAdTokenService implements TokenService {
public AzureAdTokenService(
@Value("${http.proxy:#{null}}") String proxyHost,
@Value("${AAD_ISSUER_URI}") String issuerUrl,
AzureNavClientCredential clientCredential,
AzureClientCredential clientCredential,
GetAuthenticatedToken getAuthenticatedToken
) {
log.info("Init AzureAd token exchange.");
Expand Down

0 comments on commit 6e21ad5

Please sign in to comment.