Skip to content

Commit 65c61bb

Browse files
authored
Legg til hentPersonBolk for effektiv beskyttelseshenting (#1274)
* Legg til hentPersonBolk for effektiv beskyttelseshenting * Fjerne en del imports
1 parent b88921a commit 65c61bb

File tree

5 files changed

+85
-19
lines changed

5 files changed

+85
-19
lines changed

felles/auth-filter/src/main/java/no/nav/vedtak/sikkerhet/jaxrs/AuthenticationFilterDelegate.java

-13
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,6 @@
2828
import no.nav.vedtak.sikkerhet.oidc.validator.OidcTokenValidator;
2929
import no.nav.vedtak.sikkerhet.oidc.validator.OidcTokenValidatorConfig;
3030
import no.nav.vedtak.sikkerhet.oidc.validator.OidcTokenValidatorResult;
31-
import org.jose4j.jwt.MalformedClaimException;
32-
import org.slf4j.Logger;
33-
import org.slf4j.LoggerFactory;
34-
35-
import javax.ws.rs.WebApplicationException;
36-
import javax.ws.rs.container.ContainerRequestContext;
37-
import javax.ws.rs.container.ResourceInfo;
38-
import javax.ws.rs.core.Cookie;
39-
import javax.ws.rs.core.HttpHeaders;
40-
import javax.ws.rs.core.Response;
41-
import java.lang.reflect.Method;
42-
import java.time.Instant;
43-
import java.util.Optional;
4431

4532
/**
4633
* Bruksanvisning inntil alle er over og det evt samles her:

integrasjon/person-klient/src/main/java/no/nav/vedtak/felles/integrasjon/person/AbstractPersonKlient.java

+30-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,40 @@
11
package no.nav.vedtak.felles.integrasjon.person;
22

3+
import java.net.HttpURLConnection;
4+
import java.net.http.HttpRequest;
5+
import java.util.List;
6+
import java.util.Set;
7+
38
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLOperationRequest;
49
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLRequest;
510
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
611
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResult;
712

8-
import no.nav.pdl.*;
13+
import no.nav.pdl.GeografiskTilknytning;
14+
import no.nav.pdl.GeografiskTilknytningResponseProjection;
15+
import no.nav.pdl.HentGeografiskTilknytningQueryRequest;
16+
import no.nav.pdl.HentGeografiskTilknytningQueryResponse;
17+
import no.nav.pdl.HentIdenterBolkQueryRequest;
18+
import no.nav.pdl.HentIdenterBolkQueryResponse;
19+
import no.nav.pdl.HentIdenterBolkResult;
20+
import no.nav.pdl.HentIdenterBolkResultResponseProjection;
21+
import no.nav.pdl.HentIdenterQueryRequest;
22+
import no.nav.pdl.HentIdenterQueryResponse;
23+
import no.nav.pdl.HentPersonBolkQueryRequest;
24+
import no.nav.pdl.HentPersonBolkQueryResponse;
25+
import no.nav.pdl.HentPersonBolkResult;
26+
import no.nav.pdl.HentPersonBolkResultResponseProjection;
27+
import no.nav.pdl.HentPersonQueryRequest;
28+
import no.nav.pdl.HentPersonQueryResponse;
29+
import no.nav.pdl.Identliste;
30+
import no.nav.pdl.IdentlisteResponseProjection;
31+
import no.nav.pdl.Person;
32+
import no.nav.pdl.PersonResponseProjection;
933
import no.nav.vedtak.felles.integrasjon.rest.RestClient;
1034
import no.nav.vedtak.felles.integrasjon.rest.RestConfig;
1135
import no.nav.vedtak.felles.integrasjon.rest.RestRequest;
1236
import no.nav.vedtak.felles.integrasjon.rest.TokenFlow;
1337

14-
import java.net.HttpURLConnection;
15-
import java.net.http.HttpRequest;
16-
import java.util.List;
17-
import java.util.Set;
18-
1938
public abstract class AbstractPersonKlient implements Persondata {
2039

2140
private static Set<TokenFlow> REQUIRED_TOKEN = Set.of(TokenFlow.ADAPTIVE_ADD_CONSUMER);
@@ -66,6 +85,11 @@ public Person hentPerson(HentPersonQueryRequest q, PersonResponseProjection p, b
6685
}
6786
}
6887

88+
@Override
89+
public List<HentPersonBolkResult> hentPersonBolk(HentPersonBolkQueryRequest q, HentPersonBolkResultResponseProjection p) {
90+
return query(q, p, HentPersonBolkQueryResponse.class).hentPersonBolk();
91+
}
92+
6993
@Override
7094
public Identliste hentIdenter(HentIdenterQueryRequest q, IdentlisteResponseProjection p) {
7195
return query(q, p, HentIdenterQueryResponse.class).hentIdenter();

integrasjon/person-klient/src/main/java/no/nav/vedtak/felles/integrasjon/person/Persondata.java

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
import no.nav.pdl.HentIdenterBolkResult;
1919
import no.nav.pdl.HentIdenterBolkResultResponseProjection;
2020
import no.nav.pdl.HentIdenterQueryRequest;
21+
import no.nav.pdl.HentPersonBolkQueryRequest;
22+
import no.nav.pdl.HentPersonBolkResult;
23+
import no.nav.pdl.HentPersonBolkResultResponseProjection;
2124
import no.nav.pdl.HentPersonQueryRequest;
2225
import no.nav.pdl.IdentGruppe;
2326
import no.nav.pdl.IdentInformasjon;
@@ -61,6 +64,8 @@ public interface Persondata {
6164

6265
Person hentPerson(HentPersonQueryRequest q, PersonResponseProjection p, boolean ignoreNotFound);
6366

67+
List<HentPersonBolkResult> hentPersonBolk(HentPersonBolkQueryRequest q, HentPersonBolkResultResponseProjection p);
68+
6469
GeografiskTilknytning hentGT(HentGeografiskTilknytningQueryRequest q, GeografiskTilknytningResponseProjection p);
6570

6671
<T extends GraphQLResult<?>> T query(GraphQLOperationRequest q, GraphQLResponseProjection p, Class<T> clazz);

integrasjon/person-klient/src/test/java/no/nav/vedtak/felles/integrasjon/person/PersondataKlientTest.java

+27
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@
2424

2525
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLError;
2626

27+
import no.nav.pdl.AdressebeskyttelseGradering;
28+
import no.nav.pdl.AdressebeskyttelseResponseProjection;
2729
import no.nav.pdl.HentIdenterBolkQueryRequest;
2830
import no.nav.pdl.HentIdenterBolkQueryResponse;
2931
import no.nav.pdl.HentIdenterBolkResultResponseProjection;
3032
import no.nav.pdl.HentIdenterQueryRequest;
3133
import no.nav.pdl.HentIdenterQueryResponse;
34+
import no.nav.pdl.HentPersonBolkQueryRequest;
35+
import no.nav.pdl.HentPersonBolkQueryResponse;
36+
import no.nav.pdl.HentPersonBolkResultResponseProjection;
3237
import no.nav.pdl.HentPersonQueryRequest;
3338
import no.nav.pdl.HentPersonQueryResponse;
3439
import no.nav.pdl.IdentInformasjon;
@@ -79,6 +84,28 @@ void skal_returnere_person() {
7984
assertThat(rq.validateDelayedHeaders(Set.of("Authorization", "Nav-Consumer-Token", "Nav-Consumer-Id"))).isTrue();
8085
}
8186

87+
@Test
88+
void skal_returnere_bolk_med_person() {
89+
var resource = getClass().getClassLoader().getResource("pdl/personBolkResponse.json");
90+
var response = DefaultJsonMapper.fromJson(resource, HentPersonBolkQueryResponse.class);
91+
when(restClient.send(any(RestRequest.class), any())).thenReturn(response);
92+
93+
94+
var query = new HentPersonBolkQueryRequest();
95+
query.setIdenter(List.of("12345678901"));
96+
var projection = new HentPersonBolkResultResponseProjection()
97+
.person(new PersonResponseProjection()
98+
.navn(new NavnResponseProjection().fornavn())
99+
.adressebeskyttelse(new AdressebeskyttelseResponseProjection().gradering()));
100+
101+
var personer = pdlKlient.hentPersonBolk(query, projection);
102+
103+
assertThat(personer).hasSize(1);
104+
assertThat(personer.get(0).getIdent()).isEqualTo("12345678901");
105+
assertThat(personer.get(0).getPerson().getAdressebeskyttelse()).hasSize(1);
106+
assertThat(personer.get(0).getPerson().getAdressebeskyttelse().get(0).getGradering()).isEqualTo(AdressebeskyttelseGradering.UGRADERT);
107+
}
108+
82109
@Test
83110
void skal_returnere_ident() {
84111
var resource = getClass().getClassLoader().getResource("pdl/identerResponse.json");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"data": {
3+
"hentPersonBolk": [
4+
{
5+
"ident": "12345678901",
6+
"person": {
7+
"navn": [
8+
{
9+
"fornavn": "Jul",
10+
"etternavn": "Nissen",
11+
"mellomnavn": "E."
12+
}
13+
],
14+
"adressebeskyttelse": [
15+
{
16+
"gradering": "UGRADERT"
17+
}
18+
]
19+
}
20+
}
21+
]
22+
}
23+
}

0 commit comments

Comments
 (0)