Skip to content

Commit

Permalink
Bruk riktig environment for å sette Principal (#1062)
Browse files Browse the repository at this point in the history
  • Loading branch information
jolarsen authored Jan 25, 2022
1 parent dc83caa commit 3d4e738
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import no.nav.foreldrepenger.konfig.Environment;

public final class ConsumerId implements Principal, Destroyable {
public static final String SYSTEMUSER_USERNAME = "systembruker.username";


private static final Environment ENV = Environment.current();
public static final String SYSTEMUSER_USERNAME_PROPERTY = "systembruker.username";
public static final String SYSTEMUSER_USERNAME = ENV.getProperty(SYSTEMUSER_USERNAME_PROPERTY);

private String id;
private boolean destroyed;
Expand All @@ -19,7 +21,7 @@ public ConsumerId(String consumerId) {
}

public ConsumerId() {
id = ENV.getRequiredProperty(SYSTEMUSER_USERNAME);
id = SYSTEMUSER_USERNAME;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package no.nav.vedtak.sikkerhet.context.containers;

import java.security.Principal;
import java.util.Objects;
import java.util.regex.Pattern;

import javax.security.auth.Destroyable;
Expand All @@ -21,7 +22,7 @@ public SluttBruker(String uid, IdentType identType) {
}

public static SluttBruker internBruker(String uid) {
if (ConsumerId.SYSTEMUSER_USERNAME.equals(uid)) {
if (Objects.equals(ConsumerId.SYSTEMUSER_USERNAME, uid)) {
return new SluttBruker(uid, IdentType.Prosess);
} else if (uid != null && (VALID_AKTØRID.matcher(uid).matches() || VALID_PERSONIDENT.matcher(uid).matches())) {
return new SluttBruker(uid, IdentType.EksternBruker);
Expand Down
2 changes: 1 addition & 1 deletion felles/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</modules>

<properties>
<hibernate.version>5.6.3.Final</hibernate.version>
<hibernate.version>5.6.4.Final</hibernate.version>
<jakarta.activation.version>1.2.2</jakarta.activation.version>
<jakarta.persistence.version>2.2.3</jakarta.persistence.version>
<jakarta.enterprise.version>2.0.2</jakarta.enterprise.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void setupAll() throws Exception {
System.setProperty(OidcProviderConfig.OPEN_AM_CLIENT_ID, "OIDC");
System.setProperty(OpenAmProperties.OPEN_ID_CONNECT_ISSO_HOST, OidcTokenGenerator.ISSUER);
System.setProperty(OpenAmProperties.OPEN_ID_CONNECT_ISSO_ISSUER, OidcTokenGenerator.ISSUER);
System.setProperty(ConsumerId.SYSTEMUSER_USERNAME, "JUnit Test");
System.setProperty(ConsumerId.SYSTEMUSER_USERNAME_PROPERTY, "JUnit Test");

Map<String, String> testData = Map.of(
OpenAmProperties.ISSUER_KEY, OidcTokenGenerator.ISSUER,
Expand Down
2 changes: 1 addition & 1 deletion integrasjon/pdl-klient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<plugin>
<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-codegen-maven-plugin</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
<executions>
<execution>
<goals>
Expand Down
2 changes: 1 addition & 1 deletion integrasjon/rest-klient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<dependency>
<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-java-codegen</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
Expand Down
2 changes: 1 addition & 1 deletion integrasjon/saf-klient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<plugin>
<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-codegen-maven-plugin</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class SecurityConstants {

public static final String STS_URL_KEY = "securityTokenService.url";
public static final String SYSTEMUSER_USERNAME = ConsumerId.SYSTEMUSER_USERNAME;
public static final String SYSTEMUSER_USERNAME = ConsumerId.SYSTEMUSER_USERNAME_PROPERTY;
public static final String SYSTEMUSER_PASSWORD = "systembruker.password";

private SecurityConstants() {
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
<konfig.version>1.1.4</konfig.version>
<jersey.version>2.35</jersey.version>
<logback.version>1.2.10</logback.version>
<slf4j.version>1.7.33</slf4j.version>
<slf4j.version>1.7.35</slf4j.version>
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<junit5.version>5.8.2</junit5.version>
<mockito.version>4.2.0</mockito.version>
<mockito.version>4.3.0</mockito.version>
<assertj.version>3.22.0</assertj.version>
<no.nav.security.version>1.3.9</no.nav.security.version>
<no.nav.security.version>1.3.10</no.nav.security.version>
<micrometer.version>1.8.2</micrometer.version>
<additionalparam>-Xdoclint:none</additionalparam>
<argLine>-Dfile.encoding=UTF-8</argLine>
Expand Down

0 comments on commit 3d4e738

Please sign in to comment.