Java Code Examples for org.wso2.carbon.registry.core.config.RegistryContext#getBaseInstance()
The following examples show how to use
org.wso2.carbon.registry.core.config.RegistryContext#getBaseInstance() .
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 |
/** * 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 |
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: CarbonBasedTestListener.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
/** * Creates the regostry service if not available. * * @param realClass * @return * @throws RegistryException */ private RegistryService createRegistryService(Class realClass, int tenantID, String tenantDomain) throws RegistryException { if (registryService != null) { return registryService; } try { PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantID); RegistryContext registryContext = RegistryContext.getBaseInstance(IdentityTenantUtil.getRealmService()); DataSource dataSource = MockInitialContextFactory .initializeDatasource(REG_DB_JNDI_NAME, realClass, new String[]{REG_DB_SQL_FILE}); registryContext.setDataAccessManager(new JDBCDataAccessManager(dataSource)); registryService = new EmbeddedRegistryService(registryContext); OSGiDataHolder.getInstance().setRegistryService(registryService); CarbonCoreDataHolder.getInstance().setRegistryService(registryService); PrivilegedCarbonContext.getThreadLocalCarbonContext() .setRegistry(RegistryType.USER_GOVERNANCE, registryService.getRegistry()); return registryService; } catch (TestCreationException e) { log.error("Could not load registry data", e); throw new RegistryException("Could not load registry data", e); } }
Example 4
Source File: Utils.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
/** * 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 5
Source File: TestUtils.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
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 6
Source File: DeviceManagementProviderServiceTest.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
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: BaseDeviceManagementTest.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
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: NotificationManagementServiceImplTests.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
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 9
Source File: BaseAPIPublisherTest.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
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 10
Source File: BasePolicyManagementDAOTest.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
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 11
Source File: BaseJWTClientManagerExtTest.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
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(); }