diff --git a/felles/abac/src/main/java/no/nav/vedtak/sikkerhet/pdp/PdpConsumerImpl.java b/felles/abac/src/main/java/no/nav/vedtak/sikkerhet/pdp/PdpConsumerImpl.java index 9a174e221..ea21e2827 100644 --- a/felles/abac/src/main/java/no/nav/vedtak/sikkerhet/pdp/PdpConsumerImpl.java +++ b/felles/abac/src/main/java/no/nav/vedtak/sikkerhet/pdp/PdpConsumerImpl.java @@ -73,7 +73,7 @@ public XacmlResponse evaluate(XacmlRequest xacmlRequest) { try { return send(request); } catch (IntegrasjonException e) { - LOG.info("F-157387 IntegrasjonException ved kall {} til PDP", 2 - i, e); + LOG.trace("F-157387 IntegrasjonException ved kall {} til PDP", 2 - i, e); } } return send(request); diff --git a/felles/abac/src/main/java/no/nav/vedtak/sikkerhet/pdp/PdpKlientImpl.java b/felles/abac/src/main/java/no/nav/vedtak/sikkerhet/pdp/PdpKlientImpl.java index 3cc5a4d89..1b07f8392 100644 --- a/felles/abac/src/main/java/no/nav/vedtak/sikkerhet/pdp/PdpKlientImpl.java +++ b/felles/abac/src/main/java/no/nav/vedtak/sikkerhet/pdp/PdpKlientImpl.java @@ -72,8 +72,6 @@ private static AbacResultat resultatFraResponse(XacmlResponse response) { return AbacResultat.AVSLÅTT_EGEN_ANSATT; } var ukjentadvice = denyAdvice.toString(); - // TODO (JOL): fjerne etter midlertidig logging ifm overgang - LOG.info("Deny fra PDP uten kjent årsak, advice var: {}", ukjentadvice); return AbacResultat.AVSLÅTT_ANNEN_ÅRSAK; } diff --git a/felles/klient/src/main/java/no/nav/vedtak/klient/http/DefaultHttpClient.java b/felles/klient/src/main/java/no/nav/vedtak/klient/http/DefaultHttpClient.java index 9a97dd74e..ee4e8b41e 100644 --- a/felles/klient/src/main/java/no/nav/vedtak/klient/http/DefaultHttpClient.java +++ b/felles/klient/src/main/java/no/nav/vedtak/klient/http/DefaultHttpClient.java @@ -71,7 +71,7 @@ private HttpResponse doSendExpectBytearrayRetry(HttpRequest httpRequest) try { return doSendExpectBytearray(httpRequest); } catch (IntegrasjonException e) { - LOG.info("F-157390 IntegrasjonException ved kall {} til endepunkt {}", RETRIES - i, httpRequest.uri(), e); + LOG.trace("F-157390 IntegrasjonException ved kall {} til endepunkt {}", RETRIES - i, e); } } return doSendExpectBytearray(httpRequest); @@ -83,7 +83,7 @@ private HttpResponse doSendExpectStringRetry(HttpRequest httpRequest) { try { return doSendExpectString(httpRequest); } catch (IntegrasjonException e) { - LOG.info("F-157390 IntegrasjonException ved kall {} til endepunkt {}", RETRIES - i, httpRequest.uri(), e); + LOG.trace("F-157390 IntegrasjonException ved kall {} til endepunkt {}", RETRIES - i, e); } } return doSendExpectString(httpRequest); diff --git a/felles/oidc/src/main/java/no/nav/vedtak/sikkerhet/oidc/token/impl/AzureBrukerTokenKlient.java b/felles/oidc/src/main/java/no/nav/vedtak/sikkerhet/oidc/token/impl/AzureBrukerTokenKlient.java index 822e9633a..0ea45e8b1 100644 --- a/felles/oidc/src/main/java/no/nav/vedtak/sikkerhet/oidc/token/impl/AzureBrukerTokenKlient.java +++ b/felles/oidc/src/main/java/no/nav/vedtak/sikkerhet/oidc/token/impl/AzureBrukerTokenKlient.java @@ -89,7 +89,6 @@ public Optional refreshIdToken(OpenIDToken expiredToken, String sco public OpenIDToken oboExchangeToken(String uid, OpenIDToken incomingToken, String scopes) { var tokenFromCache = getCachedToken(uid, scopes); if (tokenFromCache != null && tokenFromCache.isNotExpired()) { - LOG.trace("Fant cached token for scope {}", scopes); return tokenFromCache.copy(); } var data = "client_id=" + clientId + diff --git a/felles/sikkerhet/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/ContainerLogin.java b/felles/sikkerhet/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/ContainerLogin.java index 73d95a66d..7ecdcaca6 100644 --- a/felles/sikkerhet/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/ContainerLogin.java +++ b/felles/sikkerhet/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/ContainerLogin.java @@ -27,7 +27,7 @@ * (eks. prosesstask) slik at disse er autentisert. */ public class ContainerLogin { - private static final Logger log = LoggerFactory.getLogger(ContainerLogin.class); + private static final Logger LOG = LoggerFactory.getLogger(ContainerLogin.class); private final LoginContext loginContext; @@ -52,7 +52,7 @@ public void logout() { try { loginContext.logout(); } catch (LoginException e) { - log.warn("Noe gikk galt ved utlogging", e); + LOG.warn("Noe gikk galt ved utlogging", e); } MDCOperations.removeUserId(); MDCOperations.removeConsumerId(); diff --git a/felles/sikkerhet/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/ThreadLocalLoginModule.java b/felles/sikkerhet/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/ThreadLocalLoginModule.java index 3a2032d57..4c0bf6b50 100644 --- a/felles/sikkerhet/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/ThreadLocalLoginModule.java +++ b/felles/sikkerhet/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/ThreadLocalLoginModule.java @@ -25,18 +25,15 @@ public class ThreadLocalLoginModule extends LoginModuleBase { public ThreadLocalLoginModule() { super(LOG); - LOG.trace("Create"); } @Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { - LOG.trace("Initialize loginmodule"); this.subject = subject; } @Override public boolean login() throws LoginException { - LOG.trace("Enter login method"); setLoginSuccess(true); return true; } @@ -44,12 +41,10 @@ public boolean login() throws LoginException { @Override public void doCommit() throws LoginException { getSubjectHandler().setSubject(subject); - LOG.trace("Login committed"); } @Override protected void cleanUpSubject() { - LOG.trace("Cleanup subject"); getSubjectHandler().setSubject(null); } @@ -59,7 +54,6 @@ protected void cleanUpLocalState() throws LoginException { } private ThreadLocalSubjectHandler getSubjectHandler() { - LOG.trace("get subject handler"); var subjectHandler = SubjectHandler.getSubjectHandler(); if (!(subjectHandler instanceof ThreadLocalSubjectHandler)) { throw new IllegalArgumentException(ThreadLocalLoginModule.class.getSimpleName() + " krever subject handler av klasse " @@ -68,4 +62,4 @@ private ThreadLocalSubjectHandler getSubjectHandler() { return (ThreadLocalSubjectHandler) subjectHandler; } -} \ No newline at end of file +} diff --git a/felles/sikkerhet/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/oidc/OIDCLoginModule.java b/felles/sikkerhet/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/oidc/OIDCLoginModule.java index 8005616df..396a0eaa7 100644 --- a/felles/sikkerhet/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/oidc/OIDCLoginModule.java +++ b/felles/sikkerhet/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/oidc/OIDCLoginModule.java @@ -35,7 +35,7 @@ */ public class OIDCLoginModule extends LoginModuleBase { - private static final Logger logger = LoggerFactory.getLogger(OIDCLoginModule.class); + private static final Logger LOG = LoggerFactory.getLogger(OIDCLoginModule.class); // Set during initialize() private Subject subject; @@ -51,12 +51,11 @@ public class OIDCLoginModule extends LoginModuleBase { private OidcCredential oidcCredential; public OIDCLoginModule() { - super(logger); + super(LOG); } @Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { - logger.trace("Initialize loginmodule with {} and {}", subject, callbackHandler); this.subject = subject; this.callbackHandler = callbackHandler; } @@ -69,7 +68,6 @@ public boolean login() throws LoginException { if (OidcLogin.LoginResult.SUCCESS.equals(resultat.loginResult())) { sluttBruker = resultat.subject(); setLoginSuccess(true); - logger.trace("Login successful for user {}", sluttBruker); return true; } if (OidcLogin.LoginResult.ID_TOKEN_EXPIRED.equals(resultat.loginResult())) { @@ -96,8 +94,6 @@ public void doCommit() throws LoginException { subject.getPrincipals().add(this.consumerId); subject.getPublicCredentials().add(authenticationLevelCredential); subject.getPublicCredentials().add(oidcCredential); - - logger.trace("Login committed for user {}", sluttBruker); } @Override @@ -141,8 +137,6 @@ protected void cleanUpLocalState() throws LoginException { * Called by login() to acquire the ID Token. */ protected OpenIDToken getSSOToken() throws LoginException { - logger.trace("Getting the SSO-token from callback"); - if (callbackHandler == null) { throw new LoginException("No callbackhandler provided"); } @@ -153,7 +147,7 @@ protected OpenIDToken getSSOToken() throws LoginException { callbackHandler.handle(new Callback[] { tokenCallback }); return tokenCallback.getToken(); } catch (IOException | UnsupportedCallbackException e) { - logger.debug("Error while handling getting token from callbackhandler: ", e); + LOG.debug("Error while handling getting token from callbackhandler: ", e); LoginException le = new LoginException(); le.initCause(e); throw le; diff --git a/felles/sikkerhet/src/test/java/no/nav/vedtak/sikkerhet/oidc/KeyStoreTool.java b/felles/sikkerhet/src/test/java/no/nav/vedtak/sikkerhet/oidc/KeyStoreTool.java index bdfae9967..918355cb5 100644 --- a/felles/sikkerhet/src/test/java/no/nav/vedtak/sikkerhet/oidc/KeyStoreTool.java +++ b/felles/sikkerhet/src/test/java/no/nav/vedtak/sikkerhet/oidc/KeyStoreTool.java @@ -23,7 +23,7 @@ public class KeyStoreTool { private static RsaJsonWebKey jwk = null; - private static final Logger log = LoggerFactory.getLogger(KeyStoreTool.class); + private static final Logger LOG = LoggerFactory.getLogger(KeyStoreTool.class); static { @@ -44,7 +44,7 @@ public class KeyStoreTool { //KeyStoreTool.keystore = ks; } catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | IOException | UnrecoverableEntryException e) { - log.error("Error during loading of keystore. Do you have your keystore in order, soldier?", e); + LOG.error("Error during loading of keystore. Do you have your keystore in order, soldier?", e); throw new RuntimeException(e); } @@ -53,7 +53,7 @@ public class KeyStoreTool { jwk.setPrivateKey(myPrivateKey); jwk.setKeyId("1"); } catch (JoseException e) { - log.error("Error during init of JWK: " + e); + LOG.error("Error during init of JWK: " + e); throw new RuntimeException(e); } diff --git a/integrasjon/dokarkiv-klient/src/main/java/no/nav/vedtak/felles/integrasjon/dokarkiv/AbstractDokArkivKlient.java b/integrasjon/dokarkiv-klient/src/main/java/no/nav/vedtak/felles/integrasjon/dokarkiv/AbstractDokArkivKlient.java index 1c7de423e..05479bf33 100644 --- a/integrasjon/dokarkiv-klient/src/main/java/no/nav/vedtak/felles/integrasjon/dokarkiv/AbstractDokArkivKlient.java +++ b/integrasjon/dokarkiv-klient/src/main/java/no/nav/vedtak/felles/integrasjon/dokarkiv/AbstractDokArkivKlient.java @@ -36,13 +36,11 @@ protected AbstractDokArkivKlient(RestClient client) { @Override public OpprettJournalpostResponse opprettJournalpost(OpprettJournalpostRequest request, boolean ferdigstill) { try { - LOG.info("DOKARKIV Oppretter journalpost"); var opprett = ferdigstill ? UriBuilder.fromUri(restConfig.endpoint()).queryParam("forsoekFerdigstill", "true").build() : restConfig.endpoint(); var restRequest = RestRequest.newPOSTJson(request, opprett, restConfig); var res = restKlient.sendExpectConflict(restRequest, OpprettJournalpostResponse.class); - LOG.info("DOKARKIV Opprettet journalpost OK"); return res; } catch (Exception e) { LOG.info("DOKARKIV OPPRETT feilet for {}", request, e); @@ -53,12 +51,10 @@ public OpprettJournalpostResponse opprettJournalpost(OpprettJournalpostRequest r @Override public boolean oppdaterJournalpost(String journalpostId, OppdaterJournalpostRequest request) { try { - LOG.info("DOKARKIV Oppdaterer journalpost"); var oppdater = URI.create(restConfig.endpoint().toString() + String.format("/%s", journalpostId)); var method = new RestRequest.Method(RestRequest.WebMethod.PUT, RestRequest.jsonPublisher(request)); var restRequest = RestRequest.newRequest(method, oppdater, restConfig); restKlient.send(restRequest, String.class); - LOG.info("DOKARKIV Oppdatert journalpost OK"); return true; } catch (Exception e) { LOG.info("DOKARKIV OPPDATER {} feilet for {}", journalpostId, request, e); @@ -69,12 +65,10 @@ public boolean oppdaterJournalpost(String journalpostId, OppdaterJournalpostRequ @Override public boolean ferdigstillJournalpost(String journalpostId, String enhet) { try { - LOG.info("DOKARKIV Ferdigstiller journalpost"); var ferdigstill = URI.create(restConfig.endpoint().toString() + String.format("/%s/ferdigstill", journalpostId)); var method = new RestRequest.Method(RestRequest.WebMethod.PATCH, RestRequest.jsonPublisher(new FerdigstillJournalpostRequest(enhet))); var request = RestRequest.newRequest(method, ferdigstill, restConfig); restKlient.send(request, String.class); - LOG.info("DOKARKIV Ferdigstilt journalpost OK"); return true; } catch (Exception e) { LOG.info("DOKARKIV FERDIGSTILL {} feilet for {}", journalpostId, enhet, e); diff --git a/integrasjon/person-klient/src/main/java/no/nav/vedtak/felles/integrasjon/person/AbstractPersonKlient.java b/integrasjon/person-klient/src/main/java/no/nav/vedtak/felles/integrasjon/person/AbstractPersonKlient.java index 34e800655..99c7bac8c 100644 --- a/integrasjon/person-klient/src/main/java/no/nav/vedtak/felles/integrasjon/person/AbstractPersonKlient.java +++ b/integrasjon/person-klient/src/main/java/no/nav/vedtak/felles/integrasjon/person/AbstractPersonKlient.java @@ -101,7 +101,6 @@ public > T query(GraphQLOperationRequest q, GraphQLRe } private > T query(GraphQLRequest req, Class clazz) { - LOG.trace("Henter resultat for {} fra {}", clazz.getName(), restConfig.endpoint()); var method = new RestRequest.Method(RestRequest.WebMethod.POST, HttpRequest.BodyPublishers.ofString(req.toHttpJsonBody())); var restRequest = RestRequest.newRequest(method, restConfig.endpoint(), restConfig) .header("TEMA", tema.name()); @@ -109,7 +108,6 @@ private > T query(GraphQLRequest req, Class clazz) if (res.hasErrors()) { return errorHandler.handleError(res.getErrors(), restConfig.endpoint(), PDL_ERROR_RESPONSE); } - LOG.trace("Hentet resultat for {} fra {} OK", clazz.getName(), restConfig.endpoint()); return res; } diff --git a/integrasjon/saf-klient/src/main/java/no/nav/vedtak/felles/integrasjon/saf/AbstractSafKlient.java b/integrasjon/saf-klient/src/main/java/no/nav/vedtak/felles/integrasjon/saf/AbstractSafKlient.java index f122cda2d..7b11414d8 100644 --- a/integrasjon/saf-klient/src/main/java/no/nav/vedtak/felles/integrasjon/saf/AbstractSafKlient.java +++ b/integrasjon/saf-klient/src/main/java/no/nav/vedtak/felles/integrasjon/saf/AbstractSafKlient.java @@ -70,7 +70,6 @@ public List hentTilknyttedeJournalposter(TilknyttedeJournalposterQu @Override public byte[] hentDokument(HentDokumentQuery q) { - LOG.trace("Henter dokument"); var path = UriBuilder.fromUri(restConfig.endpoint()).path(HENTDOKUMENT) .resolveTemplate("journalpostId", q.journalpostId()) .resolveTemplate("dokumentInfoId", q.dokumentId()) @@ -78,7 +77,6 @@ public byte[] hentDokument(HentDokumentQuery q) { .build(); var request = RestRequest.newGET(path, restConfig); var doc = restKlient.sendReturnByteArray(request); - LOG.info("Hentet dokument OK"); return doc; } @@ -88,14 +86,12 @@ public > T query(GraphQLOperationRequest req, GraphQL } private > T query(GraphQLRequest req, Class clazz) { - LOG.trace("Eksekverer GraphQL query {}", req.getClass().getSimpleName()); var method = new RestRequest.Method(RestRequest.WebMethod.POST, HttpRequest.BodyPublishers.ofString(req.toHttpJsonBody())); var request = RestRequest.newRequest(method, graphql, restConfig); var res = restKlient.send(request, clazz); if (res.hasErrors()) { return errorHandler.handleError(res.getErrors(), restConfig.endpoint(), F_240613); } - LOG.info("Eksekvert GraphQL query OK"); return res; } diff --git "a/integrasjon/spokelse-klient/src/main/java/no/nav/vedtak/felles/integrasjon/spokelse/AbstractSp\303\270kelseKlient.java" "b/integrasjon/spokelse-klient/src/main/java/no/nav/vedtak/felles/integrasjon/spokelse/AbstractSp\303\270kelseKlient.java" index 8a0486c00..af6f4c75c 100644 --- "a/integrasjon/spokelse-klient/src/main/java/no/nav/vedtak/felles/integrasjon/spokelse/AbstractSp\303\270kelseKlient.java" +++ "b/integrasjon/spokelse-klient/src/main/java/no/nav/vedtak/felles/integrasjon/spokelse/AbstractSp\303\270kelseKlient.java" @@ -1,5 +1,6 @@ package no.nav.vedtak.felles.integrasjon.spokelse; +import java.time.Duration; import java.util.Arrays; import java.util.List; @@ -42,7 +43,7 @@ public List hentGrunnlag(String fnr) { var path = UriBuilder.fromUri(restConfig.endpoint()) .queryParam("fodselsnummer", fnr) .build(); - var request = RestRequest.newGET(path, restConfig); + var request = RestRequest.newGET(path, restConfig).timeout(Duration.ofSeconds(40)); var grunnlag = restKlient.send(request, SykepengeVedtak[].class); return Arrays.asList(grunnlag); } catch (Exception e) { diff --git a/integrasjon/webservice/src/main/java/no/nav/vedtak/felles/integrasjon/felles/ws/SAMLLogoutInterceptor.java b/integrasjon/webservice/src/main/java/no/nav/vedtak/felles/integrasjon/felles/ws/SAMLLogoutInterceptor.java index ef8e9adcf..6fc156c75 100644 --- a/integrasjon/webservice/src/main/java/no/nav/vedtak/felles/integrasjon/felles/ws/SAMLLogoutInterceptor.java +++ b/integrasjon/webservice/src/main/java/no/nav/vedtak/felles/integrasjon/felles/ws/SAMLLogoutInterceptor.java @@ -17,7 +17,7 @@ public class SAMLLogoutInterceptor implements PhaseInterceptor { - private static final Logger LOGGER = LoggerFactory.getLogger(SAMLLogoutInterceptor.class); + private static final Logger LOG = LoggerFactory.getLogger(SAMLLogoutInterceptor.class); private LoginContext loginContext; public SAMLLogoutInterceptor(LoginContext loginContext) { @@ -38,7 +38,7 @@ private void logout() { try { loginContext.logout(); } catch (LoginException e) { - LOGGER.warn("Feilet utlogging", e); + LOG.warn("Feilet utlogging", e); } } diff --git a/integrasjon/webservice/src/main/java/no/nav/vedtak/felles/integrasjon/felles/ws/VLFaultListener.java b/integrasjon/webservice/src/main/java/no/nav/vedtak/felles/integrasjon/felles/ws/VLFaultListener.java index db2c3f01c..f3e5d7b4b 100644 --- a/integrasjon/webservice/src/main/java/no/nav/vedtak/felles/integrasjon/felles/ws/VLFaultListener.java +++ b/integrasjon/webservice/src/main/java/no/nav/vedtak/felles/integrasjon/felles/ws/VLFaultListener.java @@ -14,7 +14,7 @@ public class VLFaultListener implements FaultListener { - private static final Logger logger = LoggerFactory.getLogger(VLFaultListener.class); + private static final Logger LOG = LoggerFactory.getLogger(VLFaultListener.class); private final Set> unntak = new HashSet<>(); @@ -28,9 +28,9 @@ public boolean faultOccurred(Exception exception, String description, Message me } if (rootCause instanceof VLException) { - logger.warn("VL exception", rootCause); + LOG.warn("VL exception", rootCause); } else { - logger.error("Uventet exception: {}", LoggerUtils.removeLineBreaks(description), rootCause); // NOSONAR + LOG.error("Uventet exception: {}", LoggerUtils.removeLineBreaks(description), rootCause); // NOSONAR } return false; } diff --git a/integrasjon/webservice/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/saml/SamlInfo.java b/integrasjon/webservice/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/saml/SamlInfo.java index ac4998e69..59cd9bf94 100644 --- a/integrasjon/webservice/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/saml/SamlInfo.java +++ b/integrasjon/webservice/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/saml/SamlInfo.java @@ -3,32 +3,5 @@ /** * Contains info from SAML token */ -class SamlInfo { - private final String uid; - private final String identType; - private final int authLevel; - private final String consumerId; - - public SamlInfo(String uid, String identType, int authLevel, String consumerId) { - this.uid = uid; - this.identType = identType; - this.authLevel = authLevel; - this.consumerId = consumerId; - } - - public String getUid() { - return uid; - } - - public String getIdentType() { - return identType; - } - - public int getAuthLevel() { - return authLevel; - } - - public String getConsumerId() { - return consumerId; - } +record SamlInfo(String uid, String identType, int authLevel, String consumerId) { } diff --git a/integrasjon/webservice/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/saml/SamlLoginModule.java b/integrasjon/webservice/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/saml/SamlLoginModule.java index a7e016ed7..4b7451406 100644 --- a/integrasjon/webservice/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/saml/SamlLoginModule.java +++ b/integrasjon/webservice/src/main/java/no/nav/vedtak/sikkerhet/loginmodule/saml/SamlLoginModule.java @@ -45,7 +45,7 @@ public class SamlLoginModule extends LoginModuleBase { private static final String AUTHENTICATION_LEVEL = "authenticationLevel"; private static final String CONSUMER_ID = "consumerId"; - private static Logger logger = LoggerFactory.getLogger(SamlLoginModule.class); + private static final Logger LOG = LoggerFactory.getLogger(SamlLoginModule.class); private Subject subject; private CallbackHandler callbackHandler; @@ -59,60 +59,60 @@ public class SamlLoginModule extends LoginModuleBase { private ConsumerId consumerId; public SamlLoginModule() { - super(logger); + super(LOG); } @Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { - logger.trace("Initialize loginmodule"); + LOG.trace("Initialize loginmodule"); this.subject = subject; this.callbackHandler = callbackHandler; - logger.trace("Initializing with subject: {} callbackhandler: {}", subject, callbackHandler); + LOG.trace("Initializing with subject: {} callbackhandler: {}", subject, callbackHandler); } @Override public boolean login() throws LoginException { try { - logger.trace("enter login"); + LOG.trace("enter login"); PasswordCallback passwordCallback = new PasswordCallback("Return SAML-assertion as password", false); callbackHandler.handle(new Callback[] { passwordCallback }); samlAssertion = toSamlAssertion(new String(passwordCallback.getPassword())); samlInfo = getSamlInfo(samlAssertion); setLoginSuccess(true); - logger.trace("Login successful for user {} with authentication level {}", samlInfo.getUid(), samlInfo.getAuthLevel()); + LOG.trace("Login successful for user {} with authentication level {}", samlInfo.uid(), samlInfo.authLevel()); return true; } catch (Exception e) { samlAssertion = null; samlInfo = null; - logger.trace("leave login: exception"); + LOG.trace("leave login: exception"); throw new LoginException(e.toString());// NOPMD } } @Override public void doCommit() throws LoginException { - sluttBruker = new SluttBruker(samlInfo.getUid(), getIdentType()); - authenticationLevelCredential = new AuthenticationLevelCredential(samlInfo.getAuthLevel()); + sluttBruker = new SluttBruker(samlInfo.uid(), getIdentType()); + authenticationLevelCredential = new AuthenticationLevelCredential(samlInfo.authLevel()); Element samlElement = samlAssertion.getDOM(); samlAssertionCredential = new SAMLAssertionCredential(samlElement); - consumerId = new ConsumerId(samlInfo.getConsumerId()); + consumerId = new ConsumerId(samlInfo.consumerId()); subject.getPrincipals().add(sluttBruker); subject.getPrincipals().add(consumerId); subject.getPublicCredentials().add(authenticationLevelCredential); subject.getPublicCredentials().add(samlAssertionCredential); - logger.trace("Login committed for subject with uid: {} authentication level: {} and consumerId: {}", + LOG.trace("Login committed for subject with uid: {} authentication level: {} and consumerId: {}", sluttBruker.getName(), authenticationLevelCredential.getAuthenticationLevel(), consumerId); } private IdentType getIdentType() throws LoginException { IdentType identType; try { - identType = IdentType.valueOf(samlInfo.getIdentType()); + identType = IdentType.valueOf(samlInfo.identType()); } catch (IllegalArgumentException e) { - LoginException le = new LoginException("Could not commit. Unknown ident type: " + samlInfo.getIdentType() + " " + e); + LoginException le = new LoginException("Could not commit. Unknown ident type: " + samlInfo.identType() + " " + e); le.initCause(e); throw le; } @@ -174,8 +174,8 @@ private static SamlInfo getSamlInfo(Assertion samlToken) { authLevel = attributeValue; } else if (CONSUMER_ID.equalsIgnoreCase(attributeName)) { consumerId = attributeValue; - } else if (logger.isDebugEnabled()) { - logger.debug("Skipping SAML Attribute name: {} value: {}", LoggerUtils.removeLineBreaks(attribute.getName()), + } else if (LOG.isDebugEnabled()) { + LOG.debug("Skipping SAML Attribute name: {} value: {}", LoggerUtils.removeLineBreaks(attribute.getName()), LoggerUtils.removeLineBreaks(attributeValue)); // NOSONAR } } diff --git a/integrasjon/webservice/src/main/java/no/nav/vedtak/sts/client/NAVSTSClient.java b/integrasjon/webservice/src/main/java/no/nav/vedtak/sts/client/NAVSTSClient.java index 74bf63b75..bcdd41700 100644 --- a/integrasjon/webservice/src/main/java/no/nav/vedtak/sts/client/NAVSTSClient.java +++ b/integrasjon/webservice/src/main/java/no/nav/vedtak/sts/client/NAVSTSClient.java @@ -17,7 +17,7 @@ public class NAVSTSClient extends STSClient { private static final Environment ENV = Environment.current(); - private static final Logger logger = LoggerFactory.getLogger(NAVSTSClient.class); + private static final Logger LOG = LoggerFactory.getLogger(NAVSTSClient.class); public static final String DISABLE_CACHE_KEY = "NAVSTSClient.DISABLE_CACHE"; private static TokenStore tokenStore; private static SluttBruker systemSluttBruker = new SluttBruker(ENV.getProperty("systembruker.username"), IdentType.Systemressurs); @@ -57,18 +57,18 @@ public SecurityToken requestSecurityToken(String appliesTo, String action, Strin if (samlToken != null) { SecurityToken token = new SecurityToken(samlToken.getSamlId(), samlToken.getTokenAsElement(), null); token.setPrincipal(principal); - if (logger.isTraceEnabled()) { - logger.trace("Will use SAML-token found in subjectHandler: {}", tokenToString(token)); + if (LOG.isTraceEnabled()) { + LOG.trace("Will use SAML-token found in subjectHandler: {}", tokenToString(token)); } return token; } if (Boolean.getBoolean(DISABLE_CACHE_KEY)) { - logger.debug("Cache is disabled, fetching from STS for user {}", userId); + LOG.debug("Cache is disabled, fetching from STS for user {}", userId); SecurityToken token = super.requestSecurityToken(appliesTo, action, requestType, binaryExchange); token.setPrincipal(principal); - if (logger.isTraceEnabled()) { - logger.trace("Retrived token from STS: {}", tokenToString(token)); + if (LOG.isTraceEnabled()) { + LOG.trace("Retrived token from STS: {}", tokenToString(token)); } return token; } @@ -81,21 +81,21 @@ public SecurityToken requestSecurityToken(String appliesTo, String action, Strin SecurityToken token = tokenStore.getToken(key); String keyUtenSignatur = stripJwtSignatur(key); if (token == null) { - logger.debug("Missing token for user {}, cache key {}, fetching it from STS", userId, keyUtenSignatur); // NOSONAR + LOG.debug("Missing token for user {}, cache key {}, fetching it from STS", userId, keyUtenSignatur); // NOSONAR token = super.requestSecurityToken(appliesTo, action, requestType, binaryExchange); token.setPrincipal(principal); tokenStore.add(key, token); } else if (token.isExpired()) { - logger.debug("Token for user {}, cache key {} is expired ({}) fetching a new one from STS", userId, keyUtenSignatur, token.getExpires()); // NOSONAR + LOG.debug("Token for user {}, cache key {} is expired ({}) fetching a new one from STS", userId, keyUtenSignatur, token.getExpires()); // NOSONAR tokenStore.remove(key); token = super.requestSecurityToken(appliesTo, action, requestType, binaryExchange); token.setPrincipal(principal); tokenStore.add(key, token); } else { - logger.debug("Retrived token for user {}, cache key {} from tokenStore", userId, keyUtenSignatur); // NOSONAR + LOG.debug("Retrived token for user {}, cache key {} from tokenStore", userId, keyUtenSignatur); // NOSONAR } - if (logger.isTraceEnabled()) { - logger.trace("Retrived token: {}", tokenToString(token)); + if (LOG.isTraceEnabled()) { + LOG.trace("Retrived token: {}", tokenToString(token)); } return token; } @@ -138,7 +138,7 @@ private void ensureTokenStoreExists() { private synchronized void createTokenStore() throws Exception { if (tokenStore == null) { - logger.debug("Creating tokenStore"); + LOG.debug("Creating tokenStore"); tokenStore = TokenStoreFactory.newInstance().newTokenStore(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, message); } } diff --git a/integrasjon/webservice/src/main/java/no/nav/vedtak/sts/client/OnBehalfOfWithOidcCallbackHandler.java b/integrasjon/webservice/src/main/java/no/nav/vedtak/sts/client/OnBehalfOfWithOidcCallbackHandler.java index 5fa58bb1b..d5b044fc5 100644 --- a/integrasjon/webservice/src/main/java/no/nav/vedtak/sts/client/OnBehalfOfWithOidcCallbackHandler.java +++ b/integrasjon/webservice/src/main/java/no/nav/vedtak/sts/client/OnBehalfOfWithOidcCallbackHandler.java @@ -14,8 +14,6 @@ import javax.xml.parsers.ParserConfigurationException; import org.apache.cxf.ws.security.trust.delegation.DelegationCallback; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.InputSource; @@ -25,8 +23,6 @@ public class OnBehalfOfWithOidcCallbackHandler implements CallbackHandler { - private static final Logger logger = LoggerFactory.getLogger(OnBehalfOfWithOidcCallbackHandler.class); - static Element getElement() throws IOException { return lagOnBehalfOfElement(); }