Skip to content

Commit

Permalink
Introduce KeyStoreDAO and database based keystore persistence manager…
Browse files Browse the repository at this point in the history
… implementation
  • Loading branch information
UdeshAthukorala committed Dec 4, 2024
1 parent d61106f commit b7ac1d7
Show file tree
Hide file tree
Showing 24 changed files with 3,441 additions and 13 deletions.
7 changes: 7 additions & 0 deletions core/org.wso2.carbon.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.metatype.annotations</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.utils</groupId>
<artifactId>org.wso2.carbon.database.utils</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
Expand Down Expand Up @@ -238,12 +243,14 @@
org.apache.axiom.*; version="${imp.pkg.version.axiom}",
org.apache.neethi.*; version="${neethi.osgi.version.range}",
javax.xml.namespace; version=0.0.0,
javax.sql.*,
javax.servlet; version="${imp.pkg.version.javax.servlet}",
javax.servlet.http; version="${imp.pkg.version.javax.servlet}",
javax.xml.stream.*; version=1.0.1,
org.wso2.carbon.registry.core.service,
org.wso2.carbon.user.core.*; version=0.0.0,
org.bouncycastle.*; version="${imp.pkg.version.bcp}",
org.wso2.carbon.database.utils.jdbc.*;version="${org.wso2.carbon.database.utils.version.range}",
*;resolution:=optional
</Import-Package>
<Embed-Dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,20 @@
import org.osgi.framework.BundleContext;
import org.osgi.service.http.HttpService;
import org.wso2.carbon.base.api.ServerConfigurationService;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.core.clustering.api.CoordinatedActivity;
import org.wso2.carbon.crypto.api.CryptoService;
import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.registry.core.service.TenantRegistryLoader;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.user.core.util.DatabaseUtil;

import org.wso2.carbon.core.clustering.api.CoordinatedActivity;
import java.util.ArrayList;
import java.util.List;

import javax.sql.DataSource;

/**
* This singleton data holder contains all the data required by the Carbon core OSGi bundle
*/
Expand All @@ -49,6 +54,7 @@ public class CarbonCoreDataHolder {

private List<CoordinatedActivity> coordinatedActivities = new ArrayList<CoordinatedActivity>() ;
private CryptoService cryptoService;
private DataSource dataSource;

public static CarbonCoreDataHolder getInstance() {
return instance;
Expand Down Expand Up @@ -166,4 +172,19 @@ public CryptoService getCryptoService() {

return cryptoService;
}

public DataSource getDataSource() {

return dataSource;
}

public void initDataSource() {

try {
this.dataSource = DatabaseUtil.getRealmDataSource(CarbonContext.getThreadLocalCarbonContext().
getUserRealm().getRealmConfiguration());
} catch (UserStoreException e) {
log.error("Error while retrieving user management data source.", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ protected void activate(ComponentContext ctxt) {

carbonServerManager = new CarbonServerManager();
carbonServerManager.start(ctxt.getBundleContext());
CarbonCoreDataHolder.getInstance().initDataSource();
} catch (Throwable e) {
log.error("Failed to activate Carbon Core bundle ", e);
}
Expand Down
Loading

0 comments on commit b7ac1d7

Please sign in to comment.