use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project che-server by eclipse-che.
the class MultiuserPostgresqlTckModule method configure.
@Override
protected void configure() {
final Map<String, String> properties = new HashMap<>();
properties.put(TRANSACTION_TYPE, PersistenceUnitTransactionType.RESOURCE_LOCAL.name());
final String dbUrl = System.getProperty("jdbc.url");
final String dbUser = System.getProperty("jdbc.user");
final String dbPassword = System.getProperty("jdbc.password");
waitConnectionIsEstablished(dbUrl, dbUser, dbPassword);
properties.put(JDBC_URL, dbUrl);
properties.put(JDBC_USER, dbUser);
properties.put(JDBC_PASSWORD, dbPassword);
properties.put(JDBC_DRIVER, System.getProperty("jdbc.driver"));
JpaPersistModule main = new JpaPersistModule("main");
main.properties(properties);
install(main);
final PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setUser(dbUser);
dataSource.setPassword(dbPassword);
dataSource.setUrl(dbUrl);
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(dataSource, "che-schema"));
bind(DBInitializer.class).asEagerSingleton();
bind(TckResourcesCleaner.class).to(JpaCleaner.class);
// repositories
// api-account
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
// api-user
bind(new TypeLiteral<TckRepository<UserImpl>>() {
}).to(UserJpaTckRepository.class);
// api-workspace
bind(new TypeLiteral<TckRepository<WorkspaceImpl>>() {
}).toInstance(new JpaTckRepository<>(WorkspaceImpl.class));
bind(new TypeLiteral<TckRepository<WorkerImpl>>() {
}).toInstance(new JpaTckRepository<>(WorkerImpl.class));
// api permission
bind(new TypeLiteral<TckRepository<SystemPermissionsImpl>>() {
}).toInstance(new JpaTckRepository<>(SystemPermissionsImpl.class));
bind(new TypeLiteral<PermissionsDao<SystemPermissionsImpl>>() {
}).to(JpaSystemPermissionsDao.class);
bind(new TypeLiteral<AbstractPermissionsDomain<WorkerImpl>>() {
}).to(WorkerDaoTest.TestDomain.class);
bind(new TypeLiteral<AbstractPermissionsDomain<SystemPermissionsImpl>>() {
}).to(SystemPermissionsDaoTest.TestDomain.class);
// api-organization
bind(new TypeLiteral<TckRepository<OrganizationImpl>>() {
}).to(JpaOrganizationImplTckRepository.class);
bind(new TypeLiteral<TckRepository<MemberImpl>>() {
}).toInstance(new JpaTckRepository<>(MemberImpl.class));
bind(new TypeLiteral<TckRepository<OrganizationDistributedResourcesImpl>>() {
}).toInstance(new JpaTckRepository<>(OrganizationDistributedResourcesImpl.class));
// api-resource
bind(new TypeLiteral<TckRepository<FreeResourcesLimitImpl>>() {
}).toInstance(new JpaTckRepository<>(FreeResourcesLimitImpl.class));
// machine token keys
bind(new TypeLiteral<TckRepository<SignatureKeyPairImpl>>() {
}).toInstance(new JpaTckRepository<>(SignatureKeyPairImpl.class));
bind(new TypeLiteral<TckRepository<UserDevfileImpl>>() {
}).toInstance(new JpaTckRepository<>(UserDevfileImpl.class));
// dao
bind(OrganizationDao.class).to(JpaOrganizationDao.class);
bind(OrganizationDistributedResourcesDao.class).to(JpaOrganizationDistributedResourcesDao.class);
bind(FreeResourcesLimitDao.class).to(JpaFreeResourcesLimitDao.class);
bind(WorkerDao.class).to(JpaWorkerDao.class);
bind(MemberDao.class).to(JpaMemberDao.class);
bind(SignatureKeyDao.class).to(JpaSignatureKeyDao.class);
bind(new TypeLiteral<PermissionsDao<MemberImpl>>() {
}).to(JpaMemberDao.class);
bind(new TypeLiteral<AbstractPermissionsDomain<MemberImpl>>() {
}).to(OrganizationDomain.class);
bind(UserDevfilePermissionDao.class).to(JpaUserDevfilePermissionDao.class);
bind(new TypeLiteral<AbstractPermissionsDomain<UserDevfilePermissionImpl>>() {
}).to(UserDevfileDomain.class);
bind(new TypeLiteral<TckRepository<UserDevfilePermission>>() {
}).toInstance(new JpaTckRepository<>(UserDevfilePermission.class));
// SHA-512 ecnryptor is faster than PBKDF2 so it is better for testing
bind(PasswordEncryptor.class).to(SHA512PasswordEncryptor.class).in(Singleton.class);
// Creates empty multibinder to avoid error during container starting
Multibinder.newSetBinder(binder(), String.class, Names.named(SystemDomain.SYSTEM_DOMAIN_ACTIONS));
}
use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project devspaces-images by redhat-developer.
the class JpaEntitiesCascadeRemovalTest method createTestData.
private void createTestData() throws NotFoundException, ConflictException, ServerException, NoSuchAlgorithmException {
userDao.create(user = createUser("bobby"));
accountDao.create(account = createAccount("bobby"));
// test permissions users
userDao.create(user2 = createUser("worker"));
userDao.create(user3 = createUser("stacker"));
profileDao.create(profile = createProfile(user.getId()));
preferenceDao.setPreferences(user.getId(), preferences = createPreferences());
workspaceDao.create(workspace1 = createWorkspace("workspace1", account));
workspaceDao.create(workspace2 = createWorkspace("workspace2", account));
workspaceDao.create(workspace3 = createWorkspace("workspace3", account));
sshDao.create(sshPair1 = createSshPair(user.getId(), "service", "name1"));
sshDao.create(sshPair2 = createSshPair(user.getId(), "service", "name2"));
factoryDao.create(factory1 = createFactory("factory1", user.getId()));
factoryDao.create(factory2 = createFactory("factory2", user.getId()));
workerDao.store(createWorker(user2.getId(), workspace3.getId()));
signatureKeyDao.create(createSignatureKeyPair(workspace1.getId()));
signatureKeyDao.create(createSignatureKeyPair(workspace2.getId()));
// creator will have all permissions for newly created organization
prepareCreator(user.getId());
organization = organizationManager.create(new OrganizationImpl(null, "testOrg", null));
organizationalAccount = accountDao.getById(organization.getId());
workspaceDao.create(workspace4 = createWorkspace("workspace4", organizationalAccount));
organization2 = organizationManager.create(new OrganizationImpl(null, "anotherOrg", null));
prepareCreator(user2.getId());
childOrganization = organizationManager.create(new OrganizationImpl(null, "childTestOrg", organization.getId()));
memberDao.store(new MemberImpl(user2.getId(), organization2.getId(), singletonList(SET_PERMISSIONS)));
memberDao.store(new MemberImpl(user3.getId(), organization2.getId(), singletonList(SET_PERMISSIONS)));
freeResourcesLimitDao.store(freeResourcesLimit = createFreeResourcesLimit(account.getId()));
freeResourcesLimitDao.store(freeResourcesLimit2 = createFreeResourcesLimit(organization.getId()));
organizationResourcesDistributor.capResources(childOrganization.getId(), singletonList(new ResourceImpl(RamResourceType.ID, 1024, RamResourceType.UNIT)));
userDevfileDao.create(devfile = TestObjectsFactory.createUserDevfile("id-dev1", "devfile1", account));
userDevfilePermissionDao.store(devfilePermission = new UserDevfilePermissionImpl(devfile.getId(), user2.getId(), ImmutableList.of(READ, DELETE, UPDATE)));
}
use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project devspaces-images by redhat-developer.
the class MultiuserMySqlTckModule method configure.
@Override
protected void configure() {
final Map<String, String> properties = new HashMap<>();
properties.put(TRANSACTION_TYPE, PersistenceUnitTransactionType.RESOURCE_LOCAL.name());
final String dbUrl = System.getProperty("jdbc.url");
final String dbUser = System.getProperty("jdbc.user");
final String dbPassword = System.getProperty("jdbc.password");
waitConnectionIsEstablished(dbUrl, dbUser, dbPassword);
properties.put(JDBC_URL, dbUrl);
properties.put(JDBC_USER, dbUser);
properties.put(JDBC_PASSWORD, dbPassword);
properties.put(JDBC_DRIVER, System.getProperty("jdbc.driver"));
JpaPersistModule main = new JpaPersistModule("main");
main.properties(properties);
install(main);
final com.mysql.cj.jdbc.MysqlDataSource dataSource = new com.mysql.cj.jdbc.MysqlDataSource();
dataSource.setUser(dbUser);
dataSource.setPassword(dbPassword);
dataSource.setUrl(dbUrl);
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(dataSource, "che-schema"));
bind(DBInitializer.class).asEagerSingleton();
bind(TckResourcesCleaner.class).to(JpaCleaner.class);
// repositories
// api-account
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
// api-user
bind(new TypeLiteral<TckRepository<UserImpl>>() {
}).to(UserJpaTckRepository.class);
// api-workspace
bind(new TypeLiteral<TckRepository<WorkspaceImpl>>() {
}).toInstance(new JpaTckRepository<>(WorkspaceImpl.class));
bind(new TypeLiteral<TckRepository<WorkerImpl>>() {
}).toInstance(new JpaTckRepository<>(WorkerImpl.class));
// api permission
bind(new TypeLiteral<TckRepository<SystemPermissionsImpl>>() {
}).toInstance(new JpaTckRepository<>(SystemPermissionsImpl.class));
bind(new TypeLiteral<PermissionsDao<SystemPermissionsImpl>>() {
}).to(JpaSystemPermissionsDao.class);
bind(new TypeLiteral<AbstractPermissionsDomain<WorkerImpl>>() {
}).to(WorkerDaoTest.TestDomain.class);
bind(new TypeLiteral<AbstractPermissionsDomain<SystemPermissionsImpl>>() {
}).to(SystemPermissionsDaoTest.TestDomain.class);
// api-organization
bind(new TypeLiteral<TckRepository<OrganizationImpl>>() {
}).to(JpaOrganizationImplTckRepository.class);
bind(new TypeLiteral<TckRepository<MemberImpl>>() {
}).toInstance(new JpaTckRepository<>(MemberImpl.class));
bind(new TypeLiteral<TckRepository<OrganizationDistributedResourcesImpl>>() {
}).toInstance(new JpaTckRepository<>(OrganizationDistributedResourcesImpl.class));
// api-resource
bind(new TypeLiteral<TckRepository<FreeResourcesLimitImpl>>() {
}).toInstance(new JpaTckRepository<>(FreeResourcesLimitImpl.class));
// machine token keys
bind(new TypeLiteral<TckRepository<SignatureKeyPairImpl>>() {
}).toInstance(new JpaTckRepository<>(SignatureKeyPairImpl.class));
bind(new TypeLiteral<TckRepository<UserDevfileImpl>>() {
}).toInstance(new JpaTckRepository<>(UserDevfileImpl.class));
// dao
bind(OrganizationDao.class).to(JpaOrganizationDao.class);
bind(OrganizationDistributedResourcesDao.class).to(JpaOrganizationDistributedResourcesDao.class);
bind(FreeResourcesLimitDao.class).to(JpaFreeResourcesLimitDao.class);
bind(WorkerDao.class).to(JpaWorkerDao.class);
bind(MemberDao.class).to(JpaMemberDao.class);
bind(SignatureKeyDao.class).to(JpaSignatureKeyDao.class);
bind(new TypeLiteral<PermissionsDao<MemberImpl>>() {
}).to(JpaMemberDao.class);
bind(new TypeLiteral<AbstractPermissionsDomain<MemberImpl>>() {
}).to(OrganizationDomain.class);
bind(UserDevfilePermissionDao.class).to(JpaUserDevfilePermissionDao.class);
bind(new TypeLiteral<AbstractPermissionsDomain<UserDevfilePermissionImpl>>() {
}).to(UserDevfileDomain.class);
bind(new TypeLiteral<TckRepository<UserDevfilePermission>>() {
}).toInstance(new JpaTckRepository<>(UserDevfilePermission.class));
// SHA-512 ecnryptor is faster than PBKDF2 so it is better for testing
bind(PasswordEncryptor.class).to(SHA512PasswordEncryptor.class).in(Singleton.class);
// Creates empty multibinder to avoid error during container starting
Multibinder.newSetBinder(binder(), String.class, Names.named(SystemDomain.SYSTEM_DOMAIN_ACTIONS));
}
use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project devspaces-images by redhat-developer.
the class MultiuserPostgresqlTckModule method configure.
@Override
protected void configure() {
final Map<String, String> properties = new HashMap<>();
properties.put(TRANSACTION_TYPE, PersistenceUnitTransactionType.RESOURCE_LOCAL.name());
final String dbUrl = System.getProperty("jdbc.url");
final String dbUser = System.getProperty("jdbc.user");
final String dbPassword = System.getProperty("jdbc.password");
waitConnectionIsEstablished(dbUrl, dbUser, dbPassword);
properties.put(JDBC_URL, dbUrl);
properties.put(JDBC_USER, dbUser);
properties.put(JDBC_PASSWORD, dbPassword);
properties.put(JDBC_DRIVER, System.getProperty("jdbc.driver"));
JpaPersistModule main = new JpaPersistModule("main");
main.properties(properties);
install(main);
final PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setUser(dbUser);
dataSource.setPassword(dbPassword);
dataSource.setUrl(dbUrl);
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(dataSource, "che-schema"));
bind(DBInitializer.class).asEagerSingleton();
bind(TckResourcesCleaner.class).to(JpaCleaner.class);
// repositories
// api-account
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
// api-user
bind(new TypeLiteral<TckRepository<UserImpl>>() {
}).to(UserJpaTckRepository.class);
// api-workspace
bind(new TypeLiteral<TckRepository<WorkspaceImpl>>() {
}).toInstance(new JpaTckRepository<>(WorkspaceImpl.class));
bind(new TypeLiteral<TckRepository<WorkerImpl>>() {
}).toInstance(new JpaTckRepository<>(WorkerImpl.class));
// api permission
bind(new TypeLiteral<TckRepository<SystemPermissionsImpl>>() {
}).toInstance(new JpaTckRepository<>(SystemPermissionsImpl.class));
bind(new TypeLiteral<PermissionsDao<SystemPermissionsImpl>>() {
}).to(JpaSystemPermissionsDao.class);
bind(new TypeLiteral<AbstractPermissionsDomain<WorkerImpl>>() {
}).to(WorkerDaoTest.TestDomain.class);
bind(new TypeLiteral<AbstractPermissionsDomain<SystemPermissionsImpl>>() {
}).to(SystemPermissionsDaoTest.TestDomain.class);
// api-organization
bind(new TypeLiteral<TckRepository<OrganizationImpl>>() {
}).to(JpaOrganizationImplTckRepository.class);
bind(new TypeLiteral<TckRepository<MemberImpl>>() {
}).toInstance(new JpaTckRepository<>(MemberImpl.class));
bind(new TypeLiteral<TckRepository<OrganizationDistributedResourcesImpl>>() {
}).toInstance(new JpaTckRepository<>(OrganizationDistributedResourcesImpl.class));
// api-resource
bind(new TypeLiteral<TckRepository<FreeResourcesLimitImpl>>() {
}).toInstance(new JpaTckRepository<>(FreeResourcesLimitImpl.class));
// machine token keys
bind(new TypeLiteral<TckRepository<SignatureKeyPairImpl>>() {
}).toInstance(new JpaTckRepository<>(SignatureKeyPairImpl.class));
bind(new TypeLiteral<TckRepository<UserDevfileImpl>>() {
}).toInstance(new JpaTckRepository<>(UserDevfileImpl.class));
// dao
bind(OrganizationDao.class).to(JpaOrganizationDao.class);
bind(OrganizationDistributedResourcesDao.class).to(JpaOrganizationDistributedResourcesDao.class);
bind(FreeResourcesLimitDao.class).to(JpaFreeResourcesLimitDao.class);
bind(WorkerDao.class).to(JpaWorkerDao.class);
bind(MemberDao.class).to(JpaMemberDao.class);
bind(SignatureKeyDao.class).to(JpaSignatureKeyDao.class);
bind(new TypeLiteral<PermissionsDao<MemberImpl>>() {
}).to(JpaMemberDao.class);
bind(new TypeLiteral<AbstractPermissionsDomain<MemberImpl>>() {
}).to(OrganizationDomain.class);
bind(UserDevfilePermissionDao.class).to(JpaUserDevfilePermissionDao.class);
bind(new TypeLiteral<AbstractPermissionsDomain<UserDevfilePermissionImpl>>() {
}).to(UserDevfileDomain.class);
bind(new TypeLiteral<TckRepository<UserDevfilePermission>>() {
}).toInstance(new JpaTckRepository<>(UserDevfilePermission.class));
// SHA-512 ecnryptor is faster than PBKDF2 so it is better for testing
bind(PasswordEncryptor.class).to(SHA512PasswordEncryptor.class).in(Singleton.class);
// Creates empty multibinder to avoid error during container starting
Multibinder.newSetBinder(binder(), String.class, Names.named(SystemDomain.SYSTEM_DOMAIN_ACTIONS));
}
use of org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl in project devspaces-images by redhat-developer.
the class MultiuserJpaUserDevfileDaoTest method setupEntities.
@BeforeClass
public void setupEntities() throws Exception {
permissions = ImmutableList.of(new UserDevfilePermissionImpl("devfile_id1", "user1", Arrays.asList(READ, DELETE, UPDATE)), new UserDevfilePermissionImpl("devfile_id2", "user1", Arrays.asList(READ, UPDATE)), new UserDevfilePermissionImpl("devfile_id3", "user1", Arrays.asList(DELETE, UPDATE)), new UserDevfilePermissionImpl("devfile_id1", "user2", Arrays.asList(READ, DELETE, UPDATE)));
users = ImmutableList.of(new UserImpl("user1", "user1@com.com", "usr1"), new UserImpl("user2", "user2@com.com", "usr2"));
accounts = ImmutableList.of(new AccountImpl("acc-1", NameGenerator.generate("account", 6), "user"), new AccountImpl("acc-2", NameGenerator.generate("account", 6), "user"));
userDevfiles = ImmutableList.of(createUserDevfile("devfile_id1", accounts.get(0), generate("name", 6)), createUserDevfile("devfile_id2", accounts.get(0), generate("name", 6)), createUserDevfile("devfile_id3", accounts.get(0), generate("name", 6)));
Injector injector = Guice.createInjector(new UserDevfileTckModule());
manager = injector.getInstance(EntityManager.class);
dao = injector.getInstance(MultiuserJpaUserDevfileDao.class);
tckResourcesCleaner = injector.getInstance(TckResourcesCleaner.class);
}
Aggregations