Skip to content

Commit

Permalink
[ALS-5858] AIM-AHEAD PIC-SURE: Landing page shows 0 studies (#156)
Browse files Browse the repository at this point in the history
* [ALS-5858] In order to upsert user studies we needed many of the same configuration values depended on by FENCE. I have refactored common JAXRSConfigurations to methods. They are now reused across different idp provider configurations.
  • Loading branch information
Gcolon021 committed Feb 27, 2024
1 parent dff78e3 commit 6d4a27b
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import edu.harvard.hms.dbmi.avillach.auth.data.repository.RoleRepository;
import edu.harvard.hms.dbmi.avillach.auth.rest.TokenService;
import io.swagger.jaxrs.config.BeanConfig;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.slf4j.Logger;
Expand Down Expand Up @@ -102,7 +103,7 @@ public class JAXRSConfiguration extends Application {
public static String fence_allowed_query_types;
public static String defaultAdminRoleName = "PIC-SURE Top Admin";
public static String spClientSecret;

public static String connectionId;
public static String clientId;
public static long tokenExpirationTime;
Expand Down Expand Up @@ -193,42 +194,13 @@ public void checkIDPProvider(Context ctx) {
fence_client_secret = (String) ctx.lookup("java:global/fence_client_secret");
fence_redirect_url = (String) ctx.lookup("java:global/fence_redirect_url");

fence_parent_consent_group_concept_path = (String) ctx.lookup("java:global/fence_parent_consent_group_concept_path");
if (fence_parent_consent_group_concept_path == null) {
logger.error("checkIDPProvider() Empty parent consent group concept path from standalone.xml. Using default!");
fence_parent_consent_group_concept_path = "\\\\_Consents\\\\Short Study Accession with Consent code\\\\";
}

fence_harmonized_consent_group_concept_path = (String) ctx.lookup("java:global/fence_harmonized_consent_group_concept_path");
if (fence_harmonized_consent_group_concept_path == null) {
logger.error("checkIDPProvider() Empty harmonized consent group concept path from standalone.xml. Using default!");
fence_harmonized_consent_group_concept_path = "\\\\_Consents\\\\Short Study Accession with Consent code\\\\";
}

fence_topmed_consent_group_concept_path = (String) ctx.lookup("java:global/fence_topmed_consent_group_concept_path");
if (fence_topmed_consent_group_concept_path == null) {
logger.error("checkIDPProvider() Empty topmed consent group concept path from standalone.xml. Using default!");
fence_topmed_consent_group_concept_path = "\\\\_Consents\\\\Short Study Accession with Consent code\\\\";
}

fence_standard_access_rules = (String) ctx.lookup("java:global/fence_standard_access_rules");
if (fence_standard_access_rules.isEmpty()) {
logger.error("checkIDPProvider() Missing Standard Access Rules in standalone.xml. Using defaults.");
fence_standard_access_rules = "GATE_ONLY_INFO,GATE_ONLY_QUERY,GATE_ONLY_SEARCH,GATE_FENCE_CONSENT_REQUIRED";
}

fence_allowed_query_types = (String) ctx.lookup("java:global/fence_allowed_query_types");
if (fence_allowed_query_types.isEmpty()) {
logger.error("checkIDPProvider() Missing Allowed query types from standalone.xml. Using defaults.");
fence_allowed_query_types = "COUNT,CROSS_COUNT";
}

getFenceParentConsentGroupConceptPath(ctx);
getFenceHarmonizaedGroupConsentPath(ctx);
getFenceTopmedConsentGroupPath(ctx);
getFenceStandardAccessRules(ctx);
getFenceAllowedQueryTypes(ctx);
getFenceHarmonizedConceptPath(ctx);

fence_harmonized_concept_path = (String) ctx.lookup("java:global/fence_harmonized_concept_path");
if (fence_harmonized_concept_path.isEmpty()) {
logger.error("checkIDPProvider() Empty harmonized concept path. Not in use.");
fence_harmonized_concept_path = "";
}
logger.debug("checkIDPProvider() idp provider FENCE is configured");

// Upsert FENCE connection
Expand Down Expand Up @@ -263,6 +235,13 @@ public void checkIDPProvider(Context ctx) {
connectionId = (String) ctx.lookup("java:global/connection_id");
clientId = (String) ctx.lookup("java:global/client_id");

getFenceParentConsentGroupConceptPath(ctx);
getFenceHarmonizaedGroupConsentPath(ctx);
getFenceTopmedConsentGroupPath(ctx);
getFenceStandardAccessRules(ctx);
getFenceAllowedQueryTypes(ctx);
getFenceHarmonizedConceptPath(ctx);

logger.debug("checkIDPProvider() idp provider OKTA is configured");
} catch (Exception ex) {
logger.error("checkIDPProvider() " + ex.getMessage());
Expand All @@ -276,6 +255,54 @@ public void checkIDPProvider(Context ctx) {
logger.debug("checkIDPProvider() finished");
}

private void getFenceTopmedConsentGroupPath(Context ctx) throws NamingException {
fence_topmed_consent_group_concept_path = (String) ctx.lookup("java:global/fence_topmed_consent_group_concept_path");
if (StringUtils.isBlank(fence_topmed_consent_group_concept_path)) {
logger.error("checkIDPProvider() Empty topmed consent group concept path from standalone.xml. Using default!");
fence_topmed_consent_group_concept_path = "\\\\_Consents\\\\Short Study Accession with Consent code\\\\";
}
}

private void getFenceHarmonizaedGroupConsentPath(Context ctx) throws NamingException {
fence_harmonized_consent_group_concept_path = (String) ctx.lookup("java:global/fence_harmonized_consent_group_concept_path");
if (StringUtils.isBlank(fence_harmonized_consent_group_concept_path)) {
logger.error("checkIDPProvider() Empty harmonized consent group concept path from standalone.xml. Using default!");
fence_harmonized_consent_group_concept_path = "\\\\_Consents\\\\Short Study Accession with Consent code\\\\";
}
}

private void getFenceStandardAccessRules(Context ctx) throws NamingException {
fence_standard_access_rules = (String) ctx.lookup("java:global/fence_standard_access_rules");
if (StringUtils.isBlank(fence_standard_access_rules)) {
logger.error("checkIDPProvider() Missing Standard Access Rules in standalone.xml. Using defaults.");
fence_standard_access_rules = "GATE_ONLY_INFO,GATE_ONLY_QUERY,GATE_ONLY_SEARCH,GATE_FENCE_CONSENT_REQUIRED";
}
}

private void getFenceHarmonizedConceptPath(Context ctx) throws NamingException {
fence_harmonized_concept_path = (String) ctx.lookup("java:global/fence_harmonized_concept_path");
if (StringUtils.isBlank(fence_harmonized_concept_path)) {
logger.error("checkIDPProvider() Empty harmonized concept path. Not in use.");
fence_harmonized_concept_path = "";
}
}

private void getFenceParentConsentGroupConceptPath(Context ctx) throws NamingException {
fence_parent_consent_group_concept_path = (String) ctx.lookup("java:global/fence_parent_consent_group_concept_path");
if (StringUtils.isBlank(fence_parent_consent_group_concept_path)) {
logger.error("checkIDPProvider() Empty parent consent group concept path from standalone.xml. Using default!");
fence_parent_consent_group_concept_path = "\\\\_Consents\\\\Short Study Accession with Consent code\\\\";
}
}

private void getFenceAllowedQueryTypes(Context ctx) throws NamingException {
fence_allowed_query_types = (String) ctx.lookup("java:global/fence_allowed_query_types");
if (StringUtils.isBlank(fence_allowed_query_types)) {
logger.error("checkIDPProvider() Missing Allowed query types from standalone.xml. Using defaults.");
fence_allowed_query_types = "COUNT,CROSS_COUNT";
}
}

private void initializeTokenExpirationTime(Context ctx) {
try {
tokenExpirationTime = Long.parseLong((String) ctx.lookup("java:global/tokenExpirationTime"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package edu.harvard.hms.dbmi.avillach.auth.service.auth;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import edu.harvard.dbmi.avillach.util.HttpClientUtil;
Expand Down

0 comments on commit 6d4a27b

Please sign in to comment.