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());
}
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());
}
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);
}
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);
}
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();
}
}
Aggregations