Skip to content

Commit

Permalink
Change the keystore data storage type config to use registry keystore…
Browse files Browse the repository at this point in the history
… data persistence manager
  • Loading branch information
UdeshAthukorala committed Dec 20, 2024
1 parent 17867c4 commit 705129b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.keystore.persistence.impl.JDBCKeyStorePersistenceManager;
import org.wso2.carbon.keystore.persistence.impl.RegistryKeyStorePersistenceManager;
import org.wso2.carbon.utils.CarbonUtils;

Expand All @@ -43,7 +42,7 @@ private KeyStorePersistenceManagerFactory() {

public static KeyStorePersistenceManager getKeyStorePersistenceManager() {

KeyStorePersistenceManager defaultKeyStorePersistenceManager = new JDBCKeyStorePersistenceManager();
KeyStorePersistenceManager defaultKeyStorePersistenceManager = new RegistryKeyStorePersistenceManager();
if (StringUtils.isNotBlank(KEYSTORE_STORAGE_TYPE)) {
if (LOG.isDebugEnabled()) {
LOG.debug("KeyStore storage type is set to: " + KEYSTORE_STORAGE_TYPE);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wso2.carbon.utils.internal;

import org.apache.commons.lang3.StringUtils;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
Expand All @@ -25,6 +26,10 @@ protected void activate(ComponentContext ctx) {
ctx.getBundleContext().registerService(GhostMetaArtifactsLoader.class.getName(), serviceMetaArtifactsLoader, null);
// Read and set diagnostic logs config.
CarbonUtils.setDiagnosticLogMode(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
DataSource dataSource = getKeyStoreDataSource();
if (dataSource == null) {
throw new RuntimeException("Data source is not available for KeyStore Data Persistence Manager.");
}
CarbonUtilsDataHolder.getInstance().setDataSource(getKeyStoreDataSource());
}

Expand All @@ -42,7 +47,7 @@ private static synchronized DataSource getKeyStoreDataSource() {

String dataSourceName = CarbonUtils.getServerConfiguration().getFirstProperty(
"KeyStoreDataPersistenceManager.DataSourceName");
if (dataSourceName != null) {
if (StringUtils.isNotBlank(dataSourceName)) {
try {
return InitialContext.doLookup(dataSourceName);
} catch (NamingException e) {
Expand Down
2 changes: 1 addition & 1 deletion distribution/kernel/carbon-home/repository/conf/carbon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@

<KeyStoreDataPersistenceManager>
<!-- Keystore data storage type-->
<DataStorageType>database</DataStorageType>
<DataStorageType>registry</DataStorageType>
<!-- Include a data source name from the set of data sources defined in master-datasources.xml -->
<DataSourceName>jdbc/SHARED_DB</DataSourceName>
</KeyStoreDataPersistenceManager>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,6 @@
"database.registry_db.pool_options.validationInterval" : "30000",
"database.registry_db.pool_options.defaultAutoCommit" : "true",
"admin_console.resolve_absolute_urls.enable": true,
"data_storage_type.keystores": "database",
"data_storage_type.keystores": "registry",
"keystore.datasource": "jdbc/SHARED_DB"
}

0 comments on commit 705129b

Please sign in to comment.