Skip to content

Commit d733aeb

Browse files
authored
TFP-6445 eget api for andre apps (#7642)
1 parent 0d3784d commit d733aeb

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package no.nav.foreldrepenger.web.app.konfig;
2+
3+
4+
import java.util.Collections;
5+
import java.util.HashMap;
6+
import java.util.HashSet;
7+
import java.util.Map;
8+
import java.util.Set;
9+
10+
import jakarta.ws.rs.ApplicationPath;
11+
import jakarta.ws.rs.core.Application;
12+
13+
import org.glassfish.jersey.server.ServerProperties;
14+
15+
import no.nav.foreldrepenger.web.app.tjenester.RestImplementationClasses;
16+
17+
/**
18+
* Konfigurer Prometheus og Healthchecks
19+
*/
20+
@ApplicationPath(ServiceApiConfig.SERVICE_URI)
21+
public class ServiceApiConfig extends Application {
22+
23+
public static final String SERVICE_URI = "/service/api";
24+
25+
@Override
26+
public Set<Class<?>> getClasses() {
27+
Set<Class<?>> classes = new HashSet<>();
28+
// Grensesnitt for satellitt-appplikasjoner
29+
classes.addAll(RestImplementationClasses.getServiceClasses());
30+
// Applikasjonsoppsett
31+
classes.addAll(FellesConfigClasses.getFellesConfigClasses());
32+
33+
return Collections.unmodifiableSet(classes);
34+
}
35+
36+
@Override
37+
public Map<String, Object> getProperties() {
38+
Map<String, Object> properties = new HashMap<>();
39+
// Ref Jersey doc
40+
properties.put(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
41+
properties.put(ServerProperties.PROCESSING_RESPONSE_ERRORS_ENABLED, true);
42+
return properties;
43+
}
44+
}

web/src/main/java/no/nav/foreldrepenger/web/app/tjenester/RestImplementationClasses.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,22 @@ public static Collection<Class<?>> getImplementationClasses() {
124124
return Set.copyOf(classes);
125125
}
126126

127+
public static Collection<Class<?>> getServiceClasses() {
128+
Set<Class<?>> classes = new HashSet<>();
129+
130+
// Satellitt-applikasjoner
131+
classes.add(FordelRestTjeneste.class);
132+
classes.add(HendelserRestTjeneste.class); // Abonnent
133+
classes.add(LosRestTjeneste.class);
134+
classes.add(TilbakeRestTjeneste.class);
135+
classes.add(FpOversiktRestTjeneste.class);
136+
137+
// Formidlingstjenester
138+
classes.add(FormidlingRestTjeneste.class);
139+
140+
return Set.copyOf(classes);
141+
}
142+
127143
public static Set<Class<?>> getForvaltningClasses() {
128144
Set<Class<?>> classes = new HashSet<>();
129145

web/src/main/java/no/nav/foreldrepenger/web/server/jetty/JettyServer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import no.nav.foreldrepenger.web.app.konfig.ApiConfig;
3737
import no.nav.foreldrepenger.web.app.konfig.EksternApiConfig;
3838
import no.nav.foreldrepenger.web.app.konfig.InternalApiConfig;
39+
import no.nav.foreldrepenger.web.app.konfig.ServiceApiConfig;
3940

4041
public class JettyServer {
4142

@@ -169,7 +170,7 @@ private static ConstraintSecurityHandler simpleConstraints() {
169170
handler.addConstraintMapping(pathConstraint(Constraint.ALLOWED, InternalApiConfig.INTERNAL_URI + "/*"));
170171
// Slipp gjennom til autentisering i JaxRs / auth-filter
171172
handler.addConstraintMapping(pathConstraint(Constraint.ALLOWED, ApiConfig.API_URI + "/*"));
172-
// Slipp gjennom til autentisering i JaxRs / auth-filter
173+
handler.addConstraintMapping(pathConstraint(Constraint.ALLOWED, ServiceApiConfig.SERVICE_URI + "/*"));
173174
handler.addConstraintMapping(pathConstraint(Constraint.ALLOWED, EksternApiConfig.EKSTERN_API_URI + "/*"));
174175
// Alt annet av paths og metoder forbudt - 403
175176
handler.addConstraintMapping(pathConstraint(Constraint.FORBIDDEN, "/*"));

0 commit comments

Comments
 (0)