|
| 1 | +package no.nav.etterlatte.config |
| 2 | + |
| 3 | +import no.nav.etterlatte.auth.sts.ServiceUserConfig |
| 4 | +import no.nav.etterlatte.auth.sts.wrapInStsClient |
| 5 | +import no.nav.system.os.eksponering.simulerfpservicewsbinding.SimulerFpService |
| 6 | +import org.apache.cxf.ext.logging.LoggingFeature |
| 7 | +import org.apache.cxf.feature.Feature |
| 8 | +import org.apache.cxf.jaxws.JaxWsProxyFactoryBean |
| 9 | +import org.apache.cxf.ws.addressing.WSAddressingFeature |
| 10 | +import org.slf4j.LoggerFactory |
| 11 | +import javax.xml.namespace.QName |
| 12 | + |
| 13 | +class SimuleringOppdragConfig(config: Config, private val enableLogging: Boolean = false) { |
| 14 | + |
| 15 | + private val simuleringOppdragUrl = config.simuleringOppdragUrl |
| 16 | + private val sts = config.sts |
| 17 | + private val logger = LoggerFactory.getLogger(javaClass) |
| 18 | + |
| 19 | + fun createSimuleringOppdragService(): SimulerFpService { |
| 20 | + logger.info("Bruker simuleringOppdrag url $simuleringOppdragUrl") |
| 21 | + |
| 22 | + val enabledFeatures = mutableListOf<Feature>().apply { |
| 23 | + add(WSAddressingFeature()) |
| 24 | + if (enableLogging) add(LoggingFeature().apply { |
| 25 | + setVerbose(true) |
| 26 | + setPrettyLogging(true) |
| 27 | + }) |
| 28 | + } |
| 29 | + |
| 30 | + return JaxWsProxyFactoryBean().apply { |
| 31 | + address = simuleringOppdragUrl |
| 32 | + wsdlURL = WSDL |
| 33 | + serviceName = SERVICE |
| 34 | + endpointName = PORT |
| 35 | + serviceClass = SimulerFpService::class.java |
| 36 | + features = enabledFeatures |
| 37 | + }.wrapInStsClient(sts.soapUrl, ServiceUserConfig(sts.serviceuser.name, sts.serviceuser.password), true) |
| 38 | + } |
| 39 | + |
| 40 | + private companion object { |
| 41 | + private const val WSDL = "wsdl/no/nav/system/os/eksponering/simulerfpservicewsbinding.wsdl" |
| 42 | + private const val NAMESPACE = "http://nav.no/system/os/eksponering/simulerFpServiceWSBinding" |
| 43 | + private val SERVICE = QName(NAMESPACE, "simulerFpService") |
| 44 | + private val PORT = QName(NAMESPACE, "simulerFpServicePort") |
| 45 | + } |
| 46 | +} |
0 commit comments