diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/JdbcDataSource.java b/core/src/main/java/org/mskcc/cbio/portal/dao/JdbcDataSource.java index 00bcb76b7cb..4746ff947a7 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/dao/JdbcDataSource.java +++ b/core/src/main/java/org/mskcc/cbio/portal/dao/JdbcDataSource.java @@ -4,11 +4,15 @@ import org.mskcc.cbio.portal.util.DatabaseProperties; import org.apache.commons.lang3.StringUtils; import org.springframework.util.Assert; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Data source that self-initializes based on cBioPortal configuration. */ public class JdbcDataSource extends BasicDataSource { + + private static final Logger LOG = LoggerFactory.getLogger(JdbcDataSource.class); public JdbcDataSource () { DatabaseProperties dbProperties = DatabaseProperties.getInstance(); @@ -20,17 +24,17 @@ public JdbcDataSource () { String database = dbProperties.getDbName(); String enablePooling = (!StringUtils.isBlank(dbProperties.getDbEnablePooling())) ? dbProperties.getDbEnablePooling(): "false"; String connectionURL = dbProperties.getConnectionURL(); - - Assert.isTrue( - !defined(host) && !defined(database) && !defined(dbProperties.getDbUseSSL()), - "\n----------------------------------------------------------------------------------------------------------------" + - "-- Connection error:\n" + - "-- You try to connect to the database using the deprecated 'db.host', 'db.portal_db_name' and 'db.use_ssl' properties.\n" + - "-- Please remove these properties and use the 'db.connection_string' property instead. See https://docs.cbioportal.org/deployment/customization/portal.properties-reference/\n" + - "-- for assistance on building a valid connection string.\n" + - "----------------------------------------------------------------------------------------------------------------\n" - ); - + + if (defined(host) || defined(database) || defined(dbProperties.getDbUseSSL())) { + LOG.warn("\n----------------------------------------------------------------------------------------------------------------" + + "-- Connection error:\n" + + "-- You try to connect to the database using the deprecated 'db.host', 'db.portal_db_name' and 'db.use_ssl' properties.\n" + + "-- Please remove these properties and use the 'db.connection_string' property instead. See https://docs.cbioportal.org/deployment/customization/portal.properties-reference/\n" + + "-- for assistance on building a valid connection string.\n" + + "----------------------------------------------------------------------------------------------------------------\n" + ); + } + Assert.hasText(userName, errorMessage("username", "db.user")); Assert.hasText(password, errorMessage("password", "db.password")); Assert.hasText(mysqlDriverClassName, errorMessage("driver class name", "db.driver")); @@ -53,11 +57,11 @@ public JdbcDataSource () { this.setValidationQuery("SELECT 1"); this.setJmxName("org.cbioportal:DataSource=" + database); } - + private String errorMessage(String displayName, String propertyName) { return String.format("No %s provided for database connection. Please set '%s' in portal.properties.", displayName, propertyName); } - + private boolean defined(String property) { return property != null && !property.isEmpty(); } diff --git a/security/security-spring/src/main/java/org/cbioportal/security/spring/authentication/token/config/DataAccessTokenConfig.java b/security/security-spring/src/main/java/org/cbioportal/security/spring/authentication/token/config/DataAccessTokenConfig.java index 404777b4a8a..e984a261276 100644 --- a/security/security-spring/src/main/java/org/cbioportal/security/spring/authentication/token/config/DataAccessTokenConfig.java +++ b/security/security-spring/src/main/java/org/cbioportal/security/spring/authentication/token/config/DataAccessTokenConfig.java @@ -48,7 +48,7 @@ public OAuth2DataAccessTokenServiceImpl oauth2DataAccessTokenService() { } @Bean("dataAccessTokenService") - @ConditionalOnProperty(name = "dat.method", havingValue = "none") + @ConditionalOnProperty(name = "dat.method", havingValue = "none", matchIfMissing = true) public UnauthDataAccessTokenServiceImpl unauthDataAccessTokenService() { return new UnauthDataAccessTokenServiceImpl(); } @@ -65,4 +65,4 @@ public JwtDataAccessTokenServiceImpl jwtDataAccessTokenService() { return new JwtDataAccessTokenServiceImpl(); } -} \ No newline at end of file +}