Skip to content

Commit

Permalink
Sjekker om modig greiene brukes fortsatt. (#753)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsladek authored Apr 11, 2021
1 parent 138b3ee commit 71b5e0b
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

import javax.security.auth.Subject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import no.nav.vedtak.exception.TekniskException;
import no.nav.vedtak.sikkerhet.domene.AuthenticationLevelCredential;
import no.nav.vedtak.sikkerhet.domene.ConsumerId;
Expand All @@ -19,18 +22,23 @@
public abstract class SubjectHandler {
public abstract Subject getSubject();

private static final Logger LOG = LoggerFactory.getLogger(SubjectHandler.class);

private static final Environment ENV = Environment.current();

public static final String SUBJECTHANDLER_KEY = "no.nav.modig.core.context.subjectHandlerImplementationClass";

public static SubjectHandler getSubjectHandler() {

var modigSubjectHandler = ENV.getProperty(SUBJECTHANDLER_KEY);
try {
return SubjectHandler.class.cast(
Class.forName(ENV.getProperty(SUBJECTHANDLER_KEY, JettySubjectHandler.class.getName())).getDeclaredConstructor().newInstance());
if (modigSubjectHandler != null) {
LOG.info("Bruker Modig SubjectHandler: {}", modigSubjectHandler);
return (SubjectHandler) Class.forName(modigSubjectHandler).getDeclaredConstructor().newInstance();
}
} catch (Exception e) {
throw new IllegalStateException("Klarte ikke å konfigurere plattformavhengig SubjectHandler", e);
}
return new JettySubjectHandler();
}

public String getUid() {
Expand Down

0 comments on commit 71b5e0b

Please sign in to comment.