use of org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException in project devspaces-images by redhat-developer.
the class PassThroughProxyProvisioner method constructSignatureKeyPair.
/**
* Constructs a key pair to satisfy JWT proxy which needs a key pair in its configuration. In case
* of pass-through proxy, this key pair is unused so we just generate a random one.
*
* @return a random key pair
* @throws InternalInfrastructureException if RSA is not available as a key pair generator. This
* should not happen.
*/
private static KeyPair constructSignatureKeyPair() throws InternalInfrastructureException {
try {
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(512);
return kpg.generateKeyPair();
} catch (NoSuchAlgorithmException e) {
throw new InternalInfrastructureException("Could not generate a fake key pair to support JWT proxy in single-user mode.");
}
}
use of org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException in project devspaces-images by redhat-developer.
the class StartSynchronizerTest method shouldWrapExceptionIntoInternalExcWhenItIsCompletedWithNonInfraException.
@Test
public void shouldWrapExceptionIntoInternalExcWhenItIsCompletedWithNonInfraException() {
// given
RuntimeException toThrow = new RuntimeException("test exception");
startSynchronizer.completeExceptionally(toThrow);
// when
InfrastructureException startFailure = startSynchronizer.getStartFailureNow();
// then
assertTrue(startFailure instanceof InternalInfrastructureException);
assertEquals(startFailure.getCause(), toThrow);
}
use of org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException in project devspaces-images by redhat-developer.
the class TerminalServerLivenessProbeConfigFactory method get.
@Override
public HttpProbeConfig get(String userId, String workspaceId, Server server) throws InternalInfrastructureException {
URI uri;
try {
uri = new URI(server.getUrl());
} catch (URISyntaxException e) {
throw new InternalInfrastructureException("Terminal agent server liveness probe url is invalid. Error: " + e.getMessage());
}
String protocol;
if ("wss".equals(uri.getScheme())) {
protocol = "https";
} else {
protocol = "http";
}
int port;
if (uri.getPort() == -1) {
if ("http".equals(protocol)) {
port = 80;
} else {
port = 443;
}
} else {
port = uri.getPort();
}
String path = uri.getPath().replaceFirst("/pty$", "/liveness");
return new HttpProbeConfig(port, uri.getHost(), protocol, path, null, successThreshold, 3, 120, 10, 10);
}
use of org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException in project devspaces-images by redhat-developer.
the class WsAgentServerLivenessProbeConfigFactory method get.
@Override
public HttpProbeConfig get(String userId, String workspaceId, Server server) throws InternalInfrastructureException {
try {
// add check path
URI uri = UriBuilder.fromUri(server.getUrl()).path("/liveness").build();
int port;
if (uri.getPort() == -1) {
if ("http".equals(uri.getScheme())) {
port = 80;
} else {
port = 443;
}
} else {
port = uri.getPort();
}
return new HttpProbeConfig(port, uri.getHost(), uri.getScheme(), uri.getPath(), singletonMap(HttpHeaders.AUTHORIZATION, "Bearer " + machineTokenProvider.getToken(userId, workspaceId)), successThreshold, 3, 120, 10, 10);
} catch (MachineTokenException e) {
throw new InternalInfrastructureException("Failed to retrieve workspace token for ws-agent server liveness probe. Error: " + e.getMessage());
} catch (UriBuilderException e) {
throw new InternalInfrastructureException("Wsagent server liveness probe url is invalid. Error: " + e.getMessage());
}
}
use of org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException in project che-server by eclipse-che.
the class JwtProxyConfigBuilder method build.
public String build() throws InternalInfrastructureException {
List<VerifierProxyConfig> proxyConfigs = new ArrayList<>();
Config config = new Config().withJWTProxy(new JWTProxy().withSignerProxy(new SignerProxyConfig().withEnabled(false)).withVerifiedProxyConfigs(proxyConfigs));
for (VerifierProxy verifierProxy : verifierProxies) {
VerifierConfig verifierConfig = new VerifierConfig().withAudience(workspaceId).withUpstream(verifierProxy.upstream).withMaxSkew("1m").withMaxTtl(ttl).withKeyServer(new RegistrableComponentConfig().withType("preshared").withOptions(ImmutableMap.of("issuer", issuer, "key_id", workspaceId, "public_key_path", JWT_PROXY_CONFIG_FOLDER + '/' + JWT_PROXY_PUBLIC_KEY_FILE))).withCookiesEnabled(verifierProxy.cookiesAuthEnabled).withCookiePath(ensureStartsWithSlash(verifierProxy.cookiePath)).withClaimsVerifier(Collections.singleton(new RegistrableComponentConfig().withType("static").withOptions(ImmutableMap.of("iss", issuer)))).withNonceStorage(new RegistrableComponentConfig().withType("void"));
if (!verifierProxy.excludes.isEmpty()) {
verifierConfig.setExcludes(verifierProxy.excludes);
}
if (verifierProxy.cookiesAuthEnabled && authPageUrl != null) {
verifierConfig.setAuthUrl(authPageUrl.toString());
}
if (verifierProxy.publicBasePath != null) {
verifierConfig.setPublicBasePath(verifierProxy.publicBasePath);
}
VerifierProxyConfig proxyConfig = new VerifierProxyConfig().withListenAddr(":" + verifierProxy.listenPort).withVerifierConfig(verifierConfig);
proxyConfigs.add(proxyConfig);
}
try {
return YAML_PARSER.writeValueAsString(config);
} catch (JsonProcessingException e) {
throw new InternalInfrastructureException("Error during creation of JWTProxy config YAML: " + e.getMessage(), e);
}
}
Aggregations