Java Code Examples for org.wso2.carbon.registry.core.config.RegistryContext#getEmbeddedRegistryService()

The following examples show how to use org.wso2.carbon.registry.core.config.RegistryContext#getEmbeddedRegistryService() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseWebAppAuthenticatorFrameworkTest.java    From carbon-device-mgt with Apache License 2.0 6 votes vote down vote up
/**
 * To get the registry service.
 * @return RegistryService
 * @throws RegistryException Registry Exception
 */
private  RegistryService getRegistryService() throws RegistryException, UserStoreException {
    RealmService realmService = new InMemoryRealmService();
    AuthenticatorFrameworkDataHolder.getInstance().setRealmService(realmService);
    UserStoreManager userStoreManager = AuthenticatorFrameworkDataHolder.getInstance().getRealmService()
            .getTenantUserRealm(MultitenantConstants.SUPER_TENANT_ID).getUserStoreManager();
    Permission adminPermission = new Permission(PermissionUtils.ADMIN_PERMISSION_REGISTRY_PATH,
            CarbonConstants.UI_PERMISSION_ACTION);
    userStoreManager.addRole(ADMIN_ROLE + "t", new String[] { ADMIN_USER }, new Permission[] { adminPermission });
    RegistryDataHolder.getInstance().setRealmService(realmService);
    DeviceManagementDataHolder.getInstance().setRealmService(realmService);
    InputStream is = BaseWebAppAuthenticatorFrameworkTest.class.getClassLoader()
            .getResourceAsStream("carbon-home/repository/conf/registry.xml");
    RegistryContext context = RegistryContext.getBaseInstance(is, realmService);
    context.setSetup(true);
    return context.getEmbeddedRegistryService();
}
 
Example 2
Source File: DeviceAccessAuthorizationServiceTest.java    From carbon-device-mgt with Apache License 2.0 6 votes vote down vote up
private RegistryService getRegistryService() throws RegistryException, UserStoreException {
    RealmService realmService = new InMemoryRealmService();
    PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(ADMIN_USER);
    BasicDataSource dataSource = new BasicDataSource();
    String connectionUrl = "jdbc:h2:./target/databasetest/CARBON_TEST";
    dataSource.setUrl(connectionUrl);
    dataSource.setDriverClassName(DRIVER_CLASS_NAME);
    JDBCTenantManager jdbcTenantManager = new JDBCTenantManager(dataSource,
            MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    realmService.setTenantManager(jdbcTenantManager);
    RegistryDataHolder.getInstance().setRealmService(realmService);
    DeviceManagementDataHolder.getInstance().setRealmService(realmService);
    InputStream is = this.getClass().getClassLoader().getResourceAsStream("carbon-home/repository/conf/registry.xml");
    RegistryContext context = RegistryContext.getBaseInstance(is, realmService);
    context.setSetup(true);
    return context.getEmbeddedRegistryService();
}
 
Example 3
Source File: Utils.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
/**
 * To get the registry service.
 * @return RegistryService
 * @throws RegistryException Registry Exception
 */
public static RegistryService getRegistryService() throws RegistryException {
    RealmService realmService = new InMemoryRealmService();
    RegistryDataHolder.getInstance().setRealmService(realmService);
    DeviceManagementDataHolder.getInstance().setRealmService(realmService);
    InputStream is = Utils.class.getClassLoader().getResourceAsStream("carbon-home/repository/conf/registry.xml");
    RegistryContext context = RegistryContext.getBaseInstance(is, realmService);
    context.setSetup(true);
    return context.getEmbeddedRegistryService();
}
 
Example 4
Source File: TestUtils.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
public static RegistryService getRegistryService(Class clazz) throws RegistryException {
    RealmService realmService = new InMemoryRealmService();
    RegistryDataHolder.getInstance().setRealmService(realmService);
    DeviceManagementDataHolder.getInstance().setRealmService(realmService);
    InputStream is = clazz.getClassLoader().getResourceAsStream("carbon-home/repository/conf/registry.xml");
    RegistryContext context = RegistryContext.getBaseInstance(is, realmService);
    context.setSetup(true);
    return context.getEmbeddedRegistryService();
}
 
Example 5
Source File: DeviceManagementProviderServiceTest.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
private RegistryService getRegistryService() throws RegistryException {
    RealmService realmService = new InMemoryRealmService();
    RegistryDataHolder.getInstance().setRealmService(realmService);
    DeviceManagementDataHolder.getInstance().setRealmService(realmService);
    InputStream is = this.getClass().getClassLoader().getResourceAsStream("carbon-home/repository/conf/registry.xml");
    RegistryContext context = RegistryContext.getBaseInstance(is, realmService);
    context.setSetup(true);
    return context.getEmbeddedRegistryService();
}
 
Example 6
Source File: BaseDeviceManagementTest.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
private RegistryService getRegistryService() throws RegistryException {
    RealmService realmService = new InMemoryRealmService();
    RegistryDataHolder.getInstance().setRealmService(realmService);
    DeviceManagementDataHolder.getInstance().setRealmService(realmService);
    InputStream is = this.getClass().getClassLoader().getResourceAsStream("carbon-home/repository/conf/registry.xml");
    RegistryContext context = RegistryContext.getBaseInstance(is, realmService);
    context.setSetup(true);
    return context.getEmbeddedRegistryService();
}
 
Example 7
Source File: NotificationManagementServiceImplTests.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
private RegistryService getRegistryService() throws RegistryException {
    RealmService realmService = new InMemoryRealmService();
    RegistryDataHolder.getInstance().setRealmService(realmService);
    DeviceManagementDataHolder.getInstance().setRealmService(realmService);
    InputStream is = this.getClass().getClassLoader().getResourceAsStream("carbon-home/repository/conf/registry.xml");
    RegistryContext context = RegistryContext.getBaseInstance(is, realmService);
    context.setSetup(true);
    return context.getEmbeddedRegistryService();
}
 
Example 8
Source File: BaseAPIPublisherTest.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
private RegistryService getRegistryService() throws RegistryException, UserStoreException {
    RealmService realmService = new InMemoryRealmService();
    APIPublisherDataHolder.getInstance().setRealmService(realmService);
    RegistryDataHolder.getInstance().setRealmService(realmService);
    JWTClientExtensionDataHolder.getInstance().setRealmService(realmService);
    InputStream is = this.getClass().getClassLoader().getResourceAsStream("carbon-home/repository/" +
            "conf/registry.xml");
    RegistryContext context = RegistryContext.getBaseInstance(is, realmService);
    context.setSetup(true);
    return context.getEmbeddedRegistryService();
}
 
Example 9
Source File: BasePolicyManagementDAOTest.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
protected RegistryService getRegistryService() throws RegistryException {
    RealmService realmService = new InMemoryRealmService();
    RegistryDataHolder.getInstance().setRealmService(realmService);
    DeviceManagementDataHolder.getInstance().setRealmService(realmService);
    InputStream is = this.getClass().getClassLoader().getResourceAsStream(
            "carbon-home/repository/conf/registry.xml");
    RegistryContext context = RegistryContext.getBaseInstance(is, realmService);
    context.setSetup(true);
    return context.getEmbeddedRegistryService();
}
 
Example 10
Source File: BaseJWTClientManagerExtTest.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
private RegistryService getRegistryService() throws RegistryException {
    RealmService realmService = new InMemoryRealmService();
    RegistryDataHolder.getInstance().setRealmService(realmService);
    JWTClientExtensionDataHolder.getInstance().setRealmService(realmService);
    InputStream is = this.getClass().getClassLoader().getResourceAsStream("carbon-home/repository/conf/registry.xml");
    RegistryContext context = RegistryContext.getBaseInstance(is, realmService);
    context.setSetup(true);
    return context.getEmbeddedRegistryService();
}