Search in sources :

Example 1 with TekniskException

use of no.nav.vedtak.exception.TekniskException in project fp-felles by navikt.

the class SpøkelseKlient method hentGrunnlag.

@Override
public List<SykepengeVedtak> hentGrunnlag(String fnr) {
    try {
        var request = new URIBuilder(uri).addParameter("fodselsnummer", fnr).build();
        var grunnlag = restClient.get(request, SykepengeVedtak[].class);
        return Arrays.asList(grunnlag);
    } catch (Exception e) {
        LOG.info("SPokelse felles: feil ved oppslag mot {}, returnerer ingen grunnlag", uriString, e);
        throw new TekniskException("FP-180126", String.format("SPokelse %s gir feil, ta opp med team sykepenger.", uriString), e);
    }
}
Also used : TekniskException(no.nav.vedtak.exception.TekniskException) TekniskException(no.nav.vedtak.exception.TekniskException) URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 2 with TekniskException

use of no.nav.vedtak.exception.TekniskException in project fp-felles by navikt.

the class SAMLTokenSignedInInterceptor method handleMessage.

@Override
public void handleMessage(SoapMessage msg) {
    super.handleMessage(msg);
    SecurityContext securityContext = msg.get(SecurityContext.class);
    SAMLTokenPrincipal samlTokenPrincipal = (SAMLTokenPrincipal) securityContext.getUserPrincipal();
    Assertion assertion = samlTokenPrincipal.getToken().getSaml2();
    try {
        String result = getSamlAssertionAsString(assertion);
        LoginContext loginContext = createLoginContext(loginContextConfiguration, result);
        loginContext.login();
        msg.getInterceptorChain().add(new SAMLLogoutInterceptor(loginContext));
        MDCOperations.putUserId(SubjectHandler.getSubjectHandler().getUid());
        MDCOperations.putConsumerId(SubjectHandler.getSubjectHandler().getConsumerId());
    } catch (LoginException | TransformerException e) {
        throw new TekniskException("F-499051", "Noe gikk galt ved innlogging", e);
    }
}
Also used : SAMLTokenPrincipal(org.apache.wss4j.common.principal.SAMLTokenPrincipal) LoginContext(javax.security.auth.login.LoginContext) SecurityContext(org.apache.cxf.security.SecurityContext) Assertion(org.opensaml.saml.saml2.core.Assertion) LoginException(javax.security.auth.login.LoginException) TekniskException(no.nav.vedtak.exception.TekniskException) TransformerException(javax.xml.transform.TransformerException)

Example 3 with TekniskException

use of no.nav.vedtak.exception.TekniskException in project fp-felles by navikt.

the class XmlUtils method createUnmodifiableMap.

public static Map<String, Map.Entry<Class<?>, Schema>> createUnmodifiableMap(String jaxbClassName, List<String> namespaces, List<String> xsdLocations) {
    if (namespaces.size() != xsdLocations.size()) {
        throw new IllegalArgumentException();
    }
    Map<String, Map.Entry<Class<?>, Schema>> tempMap;
    try {
        final Class<?> jaxbClass = Class.forName(jaxbClassName);
        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        tempMap = new HashMap<>();
        for (int i = 0; i < namespaces.size(); i++) {
            var schema = schemaFactory.newSchema(new StreamSource(XmlUtils.class.getClassLoader().getResource(xsdLocations.get(i)).toExternalForm()));
            tempMap.put(namespaces.get(i), new SimpleEntry<>(jaxbClass, schema));
        }
    } catch (SAXException e) {
        throw new TekniskException("F-350888", "Feilet på instansiering av schema for xsd-validering.", e);
    } catch (ClassNotFoundException e) {
        throw new TekniskException("F-991095", String.format("Fant ikke jaxb-class '%s'", jaxbClassName), e);
    }
    return Collections.unmodifiableMap(tempMap);
}
Also used : SchemaFactory(javax.xml.validation.SchemaFactory) StreamSource(javax.xml.transform.stream.StreamSource) SAXException(org.xml.sax.SAXException) SimpleEntry(java.util.AbstractMap.SimpleEntry) TekniskException(no.nav.vedtak.exception.TekniskException)

Example 4 with TekniskException

use of no.nav.vedtak.exception.TekniskException in project fp-felles by navikt.

the class AbstractOidcRestClient method put.

protected String put(URI endpoint, Object dto, Set<Header> headers, ResponseHandler<String> responseHandler) {
    HttpPut put = new HttpPut(endpoint);
    String json = toJson(dto);
    put.setEntity(new StringEntity(json, UTF_8));
    headers.forEach(put::addHeader);
    try {
        return this.execute(put, responseHandler);
    } catch (IOException e) {
        throw new TekniskException("F-432937", String.format("Kunne ikke PUT  mot %s", endpoint), e);
    }
}
Also used : StringEntity(org.apache.http.entity.StringEntity) TekniskException(no.nav.vedtak.exception.TekniskException) IOException(java.io.IOException) HttpPut(org.apache.http.client.methods.HttpPut)

Example 5 with TekniskException

use of no.nav.vedtak.exception.TekniskException in project fp-felles by navikt.

the class LdapInnlogging method lagLdapContext.

public static LdapContext lagLdapContext() {
    String authMode = ENV.getProperty("ldap.auth", "simple");
    String url = getRequiredProperty("ldap.url");
    // NOSONAR //metodeparameter krever Hashtable
    Hashtable<String, Object> environment = new Hashtable<>();
    environment.put(Context.INITIAL_CONTEXT_FACTORY, ENV.getProperty("ldap.ctxfactory", "com.sun.jndi.ldap.LdapCtxFactory"));
    environment.put(Context.PROVIDER_URL, url);
    environment.put(Context.SECURITY_AUTHENTICATION, authMode);
    if ("simple".equals(authMode)) {
        String user = getRequiredProperty("ldap.username") + "@" + getRequiredProperty("ldap.domain");
        environment.put(Context.SECURITY_CREDENTIALS, getRequiredProperty("ldap.password"));
        environment.put(Context.SECURITY_PRINCIPAL, user);
    } else if ("none".equals(authMode)) {
    // do nothing
    } else {
    // støtter ikke [java.naming.security.authentication]="strong" eller andre.
    // Ignorerer også foreløpig.
    }
    try {
        return new InitialLdapContext(environment, null);
    } catch (NamingException e) {
        throw new TekniskException("F-222862", String.format("Klarte ikke koble til LDAP på URL %s", url));
    }
}
Also used : Hashtable(java.util.Hashtable) InitialLdapContext(javax.naming.ldap.InitialLdapContext) TekniskException(no.nav.vedtak.exception.TekniskException) NamingException(javax.naming.NamingException)

Aggregations

TekniskException (no.nav.vedtak.exception.TekniskException)36 IOException (java.io.IOException)7 URIBuilder (org.apache.http.client.utils.URIBuilder)5 NamingException (javax.naming.NamingException)4 StringEntity (org.apache.http.entity.StringEntity)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 InetSocketAddress (java.net.InetSocketAddress)3 DokumentdataMapper (no.nav.foreldrepenger.fpformidling.brevproduksjon.mapper.felles.DokumentdataMapper)3 DokumentFelles (no.nav.foreldrepenger.fpformidling.dokumentdata.DokumentFelles)3 URISyntaxException (java.net.URISyntaxException)2 SimpleEntry (java.util.AbstractMap.SimpleEntry)2 Matcher (java.util.regex.Matcher)2 Attribute (javax.naming.directory.Attribute)2 Response (javax.ws.rs.core.Response)2 TransformerException (javax.xml.transform.TransformerException)2 StreamSource (javax.xml.transform.stream.StreamSource)2 LovhjemmelComparator (no.nav.foreldrepenger.fpformidling.brevproduksjon.mapper.felles.LovhjemmelComparator)2 DokumentData (no.nav.foreldrepenger.fpformidling.dokumentdata.DokumentData)2 DistribuerJournalpostRequest (no.nav.foreldrepenger.fpformidling.integrasjon.dokdist.dto.DistribuerJournalpostRequest)2 Test (org.junit.jupiter.api.Test)2