Search in sources :

Example 6 with SignatureKeyPairImpl

use of org.eclipse.che.multiuser.machine.authentication.server.signature.model.impl.SignatureKeyPairImpl in project devspaces-images by redhat-developer.

the class SignatureKeyManagerTest method shouldThrowsExceptionWhenAlgorithmIsNotSupported.

@Test(expectedExceptions = SignatureKeyManagerException.class)
public void shouldThrowsExceptionWhenAlgorithmIsNotSupported() throws Exception {
    final SignatureKeyImpl publicKey = new SignatureKeyImpl(new byte[] {}, "ECDH", "PKCS#15");
    final SignatureKeyImpl privateKey = new SignatureKeyImpl(new byte[] {}, "ECDH", "PKCS#3");
    final SignatureKeyPairImpl kp = new SignatureKeyPairImpl("id_" + 1, publicKey, privateKey);
    doReturn(kp).when(signatureKeyDao).get(anyString());
    signatureKeyManager.getOrCreateKeyPair("ws1");
    verify(signatureKeyDao).get(anyString());
}
Also used : SignatureKeyImpl(org.eclipse.che.multiuser.machine.authentication.server.signature.model.impl.SignatureKeyImpl) SignatureKeyPairImpl(org.eclipse.che.multiuser.machine.authentication.server.signature.model.impl.SignatureKeyPairImpl) Test(org.testng.annotations.Test)

Example 7 with SignatureKeyPairImpl

use of org.eclipse.che.multiuser.machine.authentication.server.signature.model.impl.SignatureKeyPairImpl in project devspaces-images by redhat-developer.

the class SignatureKeyTckModule method configure.

@Override
protected void configure() {
    H2DBTestServer server = H2DBTestServer.startDefault();
    install(new PersistTestModuleBuilder().setDriver("org.h2.Driver").runningOn(server).addEntityClasses(AccountImpl.class, UserImpl.class, SignatureKeyImpl.class, SignatureKeyPairImpl.class, WorkspaceImpl.class, WorkspaceConfigImpl.class, ProjectConfigImpl.class, EnvironmentImpl.class, MachineConfigImpl.class, SourceStorageImpl.class, ServerConfigImpl.class, CommandImpl.class, RecipeImpl.class, VolumeImpl.class, // devfile
    ActionImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl.class, ComponentImpl.class, DevfileImpl.class, EndpointImpl.class, EntrypointImpl.class, EnvImpl.class, ProjectImpl.class, SourceImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class).addEntityClass("org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute").addClass(SerializableConverter.class).setExceptionHandler(H2ExceptionHandler.class).build());
    bind(DBInitializer.class).asEagerSingleton();
    bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
    bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
    bind(SignatureKeyDao.class).to(JpaSignatureKeyDao.class);
    bind(new TypeLiteral<TckRepository<SignatureKeyPairImpl>>() {
    }).toInstance(new JpaTckRepository<>(SignatureKeyPairImpl.class));
    bind(new TypeLiteral<TckRepository<AccountImpl>>() {
    }).toInstance(new JpaTckRepository<>(AccountImpl.class));
    bind(new TypeLiteral<TckRepository<WorkspaceImpl>>() {
    }).toInstance(new WorkspaceRepository());
}
Also used : TckResourcesCleaner(org.eclipse.che.commons.test.tck.TckResourcesCleaner) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) AccountImpl(org.eclipse.che.account.spi.AccountImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) H2JpaCleaner(org.eclipse.che.commons.test.db.H2JpaCleaner) SignatureKeyDao(org.eclipse.che.multiuser.machine.authentication.server.signature.spi.SignatureKeyDao) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) TypeLiteral(com.google.inject.TypeLiteral) DBInitializer(org.eclipse.che.core.db.DBInitializer) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) SignatureKeyImpl(org.eclipse.che.multiuser.machine.authentication.server.signature.model.impl.SignatureKeyImpl) CommandImpl(org.eclipse.che.api.workspace.server.model.impl.CommandImpl) EntrypointImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl) H2DBTestServer(org.eclipse.che.commons.test.db.H2DBTestServer) ProjectImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl) EndpointImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl) EnvImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl) SignatureKeyPairImpl(org.eclipse.che.multiuser.machine.authentication.server.signature.model.impl.SignatureKeyPairImpl) SourceStorageImpl(org.eclipse.che.api.workspace.server.model.impl.SourceStorageImpl) PersistTestModuleBuilder(org.eclipse.che.commons.test.db.PersistTestModuleBuilder) SerializableConverter(org.eclipse.che.api.workspace.server.devfile.SerializableConverter) MachineConfigImpl(org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl) SourceImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl) RecipeImpl(org.eclipse.che.api.workspace.server.model.impl.RecipeImpl) VolumeImpl(org.eclipse.che.api.workspace.server.model.impl.VolumeImpl) ActionImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl) ProjectConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl)

Example 8 with SignatureKeyPairImpl

use of org.eclipse.che.multiuser.machine.authentication.server.signature.model.impl.SignatureKeyPairImpl in project devspaces-images by redhat-developer.

the class SignatureKeyDaoTest method throwsConflictExceptionWhenCreatingSignatureKeyPair.

@Test(expectedExceptions = ConflictException.class)
public void throwsConflictExceptionWhenCreatingSignatureKeyPair() throws Exception {
    final SignatureKeyPairImpl signKeyPair = newKeyPair(storedKeyPairs[0].getWorkspaceId());
    dao.create(signKeyPair);
}
Also used : SignatureKeyPairImpl(org.eclipse.che.multiuser.machine.authentication.server.signature.model.impl.SignatureKeyPairImpl) Test(org.testng.annotations.Test)

Example 9 with SignatureKeyPairImpl

use of org.eclipse.che.multiuser.machine.authentication.server.signature.model.impl.SignatureKeyPairImpl in project devspaces-images by redhat-developer.

the class SignatureKeyDaoTest method testGetsAllKeys.

@Test
public void testGetsAllKeys() throws Exception {
    List<SignatureKeyPairImpl> foundKeys = new ArrayList<>();
    for (SignatureKeyPairImpl expected : storedKeyPairs) {
        foundKeys.add(dao.get(expected.getWorkspaceId()));
    }
    assertEquals(new HashSet<>(foundKeys), new HashSet<>(asList(storedKeyPairs)));
    assertEquals(foundKeys.size(), COUNT_KEY_PAIRS);
}
Also used : ArrayList(java.util.ArrayList) SignatureKeyPairImpl(org.eclipse.che.multiuser.machine.authentication.server.signature.model.impl.SignatureKeyPairImpl) Test(org.testng.annotations.Test)

Example 10 with SignatureKeyPairImpl

use of org.eclipse.che.multiuser.machine.authentication.server.signature.model.impl.SignatureKeyPairImpl in project devspaces-images by redhat-developer.

the class JpaSignatureKeyDao method doRemove.

@Transactional
protected void doRemove(String workspaceId) {
    final EntityManager manager = managerProvider.get();
    final SignatureKeyPairImpl keyPair = manager.find(SignatureKeyPairImpl.class, workspaceId);
    if (keyPair != null) {
        manager.remove(keyPair);
        manager.flush();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) SignatureKeyPairImpl(org.eclipse.che.multiuser.machine.authentication.server.signature.model.impl.SignatureKeyPairImpl) Transactional(com.google.inject.persist.Transactional)

Aggregations

SignatureKeyPairImpl (org.eclipse.che.multiuser.machine.authentication.server.signature.model.impl.SignatureKeyPairImpl)28 Test (org.testng.annotations.Test)12 AccountImpl (org.eclipse.che.account.spi.AccountImpl)10 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)10 TypeLiteral (com.google.inject.TypeLiteral)8 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)8 TckResourcesCleaner (org.eclipse.che.commons.test.tck.TckResourcesCleaner)8 DBInitializer (org.eclipse.che.core.db.DBInitializer)8 SchemaInitializer (org.eclipse.che.core.db.schema.SchemaInitializer)8 FlywaySchemaInitializer (org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer)8 SignatureKeyDao (org.eclipse.che.multiuser.machine.authentication.server.signature.spi.SignatureKeyDao)8 KeyPair (java.security.KeyPair)6 UserDevfileImpl (org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl)5 JpaSignatureKeyDao (org.eclipse.che.multiuser.machine.authentication.server.signature.jpa.JpaSignatureKeyDao)5 SHA512PasswordEncryptor (org.eclipse.che.security.SHA512PasswordEncryptor)5 JpaPersistModule (com.google.inject.persist.jpa.JpaPersistModule)4 KeyPairGenerator (java.security.KeyPairGenerator)4 HashMap (java.util.HashMap)4 SystemPermissionsImpl (org.eclipse.che.multiuser.api.permission.server.model.impl.SystemPermissionsImpl)4 SystemPermissionsDaoTest (org.eclipse.che.multiuser.api.permission.server.spi.tck.SystemPermissionsDaoTest)4