+ private static String apiKey = null;
+ private static String kafkaUsername = null;
+ private static AAFAuthn<?> aafAuthn;
+ private static AbsAAFLur<AAFPermission> aafLur;
+ private static boolean enableCadi = false;
+ private static final Logger logger = LoggerFactory.getLogger(Cadi3AAFProvider.class);
+
+ static {
+ if (System.getProperty("enableCadi") != null) {
+ if (System.getProperty("enableCadi").equals("true")) {
+ enableCadi = true;
+ }
+ }
+ else{
+ if (System.getenv("enableCadi") != null && System.getenv("enableCadi").equals("true")) {
+ enableCadi = true;
+ }
+ }
+ Configuration config = Configuration.getConfiguration();
+ try {
+ if (config == null) {
+ logger.error("CRITICAL ERROR|Check java.security.auth.login.config VM argument|");
+ } else {
+ // read the section for KafkaServer
+ AppConfigurationEntry[] entries = config.getAppConfigurationEntry("KafkaServer");
+ if (entries == null) {
+ logger.error(
+ "CRITICAL ERROR|Check config contents passed in java.security.auth.login.config VM argument|");
+ kafkaUsername = "kafkaUsername";
+ apiKey = "apiKey";
+
+ } else {
+ for (int i = 0; i < entries.length; i++) {
+ AppConfigurationEntry entry = entries[i];
+ Map<String, ?> optionsMap = entry.getOptions();
+ kafkaUsername = (String) optionsMap.get("username");
+ apiKey = (String) optionsMap.get("password");
+ }
+ }
+ }
+ } catch (Exception e) {
+ logger.error("CRITICAL ERROR: JAAS configuration incorrectly set: " + e.getMessage());
+ }
+ }
+
+ public static String getKafkaUsername() {
+ return kafkaUsername;
+ }
+
+ public static boolean isCadiEnabled() {
+
+ return enableCadi;
+ }