/** * If the endpoint properties includes a read timeout override, then * set it here. * @param connection */ private void setReadTimeout(HttpURLConnection connection) { try { Map<String, String> endpointProperties = this.api.getEndpointProperties(); if (endpointProperties.containsKey("timeouts.read")) { //$NON-NLS-1$ int connectTimeoutMs = new Integer(endpointProperties.get("timeouts.read")); //$NON-NLS-1$ connection.setReadTimeout(connectTimeoutMs); } } catch (Throwable t) { } }
/** * If the endpoint properties includes a connect timeout override, then * set it here. * @param connection */ private void setConnectTimeout(HttpURLConnection connection) { try { Map<String, String> endpointProperties = this.api.getEndpointProperties(); if (endpointProperties.containsKey("timeouts.connect")) { //$NON-NLS-1$ int connectTimeoutMs = new Integer(endpointProperties.get("timeouts.connect")); //$NON-NLS-1$ connection.setConnectTimeout(connectTimeoutMs); } } catch (Throwable t) { } }
/** * If the endpoint properties includes a connect timeout override, then * set it here. * @param connection */ private void setConnectTimeout(HttpURLConnection connection) { try { Map<String, String> endpointProperties = this.api.getEndpointProperties(); if (endpointProperties.containsKey("timeouts.connect")) { //$NON-NLS-1$ int connectTimeoutMs = new Integer(endpointProperties.get("timeouts.connect")); //$NON-NLS-1$ connection.setConnectTimeout(connectTimeoutMs); } } catch (Throwable t) { } }
/** * If the endpoint properties includes a read timeout override, then * set it here. * @param connection */ private void setReadTimeout(HttpURLConnection connection) { try { Map<String, String> endpointProperties = this.api.getEndpointProperties(); if (endpointProperties.containsKey("timeouts.read")) { //$NON-NLS-1$ int connectTimeoutMs = new Integer(endpointProperties.get("timeouts.read")); //$NON-NLS-1$ connection.setReadTimeout(connectTimeoutMs); } } catch (Throwable t) { } }
/** * Parse API endpoint properties to retrieve enum value (if any) * * @param api the API * @return the required auth type */ public static RequiredAuthType parseType(Api api) { return RequiredAuthType.fromValue(api.getEndpointProperties().get( RequiredAuthType.ENDPOINT_AUTHORIZATION_TYPE)); } }
/** * Parse API endpoint properties to retrieve enum value (if any) * * @param api the API * @return the required auth type */ public static RequiredAuthType parseType(Api api) { return RequiredAuthType.fromValue(api.getEndpointProperties().get( RequiredAuthType.ENDPOINT_AUTHORIZATION_TYPE)); } }
/** * If the endpoint properties includes a read timeout override, then * set it here. * @param connection */ private void setAttributesFromApiEndpointProperties(Api api, ApimanHttpConnectorOptions options) { try { Map<String, String> endpointProperties = api.getEndpointProperties(); if (endpointProperties.containsKey("timeouts.read")) { //$NON-NLS-1$ int connectTimeoutMs = Integer.parseInt(endpointProperties.get("timeouts.read")); //$NON-NLS-1$ options.setRequestTimeout(connectTimeoutMs); } if (endpointProperties.containsKey("timeouts.connect")) { //$NON-NLS-1$ int connectTimeoutMs = Integer.parseInt(endpointProperties.get("timeouts.connect")); //$NON-NLS-1$ options.setConnectionTimeout(connectTimeoutMs); } } catch (NumberFormatException e) { throw new RuntimeException(e); } }
/** * Response API property replacements */ protected void resolvePropertyReplacements(Api api) { if (api == null) { return; } String endpoint = api.getEndpoint(); endpoint = resolveProperties(endpoint); api.setEndpoint(endpoint); Map<String, String> properties = api.getEndpointProperties(); for (Entry<String, String> entry : properties.entrySet()) { String value = entry.getValue(); value = resolveProperties(value); entry.setValue(value); } resolvePropertyReplacements(api.getApiPolicies()); }
/** * Response API property replacements */ protected void resolvePropertyReplacements(Api api) { if (api == null) { return; } String endpoint = api.getEndpoint(); endpoint = resolveProperties(endpoint); api.setEndpoint(endpoint); Map<String, String> properties = api.getEndpointProperties(); for (Entry<String, String> entry : properties.entrySet()) { String value = entry.getValue(); value = resolveProperties(value); entry.setValue(value); } resolvePropertyReplacements(api.getApiPolicies()); }
@Override public void handle(IAsyncResult<Api> result) { if (result.isSuccess()) { Api api = result.getResult(); if (api != null) { List<Policy> policies = api.getApiPolicies(); decryptPolicies(organizationId, apiId, apiVersion, EntityType.Api, policies); decryptEndpointProperties(organizationId, apiId, apiVersion, EntityType.Api, api.getEndpointProperties()); } } handler.handle(result); } });
BasicAuthOptions options = new BasicAuthOptions(api.getEndpointProperties()); if (options.getUsername() != null && options.getPassword() != null) { if (options.isRequireSSL() && !isSsl) {
@Override public void handle(IAsyncResult<Api> result) { if (result.isSuccess()) { Api api = result.getResult(); if (api != null) { List<Policy> policies = api.getApiPolicies(); decryptPolicies(organizationId, apiId, apiVersion, EntityType.Api, policies); decryptEndpointProperties(organizationId, apiId, apiVersion, EntityType.Api, api.getEndpointProperties()); } } handler.handle(result); } });
BasicAuthOptions options = new BasicAuthOptions(api.getEndpointProperties()); if (options.getUsername() != null && options.getPassword() != null) { if (options.isRequireSSL() && !isSsl) {
private void verifyConnection() { switch (options.getRequiredAuthType()) { case BASIC: basicOptions = new BasicAuthOptions(api.getEndpointProperties()); if (!options.isSsl() && basicOptions.isRequireSSL()) throw new ConnectorException("Endpoint security requested (BASIC auth) but endpoint is not secure (SSL)."); break; case MTLS: if (!options.isSsl()) throw new ConnectorException("Mutual TLS specified, but endpoint is not HTTPS."); break; case DEFAULT: break; } }
/** * @see io.apiman.gateway.engine.IRegistry#publishApi(io.apiman.gateway.engine.beans.Api, io.apiman.gateway.engine.async.IAsyncResultHandler) */ @Override public void publishApi(Api api, IAsyncResultHandler<Void> handler) { List<Policy> policies = api.getApiPolicies(); encryptPolicies(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, policies); encryptEndpointProperties(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, api.getEndpointProperties()); delegate.publishApi(api, handler); decryptPolicies(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, policies); decryptEndpointProperties(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, api.getEndpointProperties()); }
/** * @see io.apiman.gateway.engine.IRegistry#publishApi(io.apiman.gateway.engine.beans.Api, io.apiman.gateway.engine.async.IAsyncResultHandler) */ @Override public void publishApi(Api api, IAsyncResultHandler<Void> handler) { List<Policy> policies = api.getApiPolicies(); encryptPolicies(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, policies); encryptEndpointProperties(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, api.getEndpointProperties()); delegate.publishApi(api, handler); decryptPolicies(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, policies); decryptEndpointProperties(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, api.getEndpointProperties()); }
@Override public void handle(IAsyncResult<ApiContract> result) { if (result.isSuccess()) { ApiContract contract = result.getResult(); List<Policy> policies = contract.getPolicies(); decryptPolicies(contract.getClient().getOrganizationId(), contract.getClient().getClientId(), contract.getClient().getVersion(), EntityType.ClientApp, policies); Api api = contract.getApi(); if (api != null) { List<Policy> apiPolicies = api.getApiPolicies(); decryptPolicies(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, apiPolicies); decryptEndpointProperties(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, api.getEndpointProperties()); } } handler.handle(result); } });
@Override public void handle(IAsyncResult<ApiContract> result) { if (result.isSuccess()) { ApiContract contract = result.getResult(); List<Policy> policies = contract.getPolicies(); decryptPolicies(contract.getClient().getOrganizationId(), contract.getClient().getClientId(), contract.getClient().getVersion(), EntityType.ClientApp, policies); Api api = contract.getApi(); if (api != null) { List<Policy> apiPolicies = api.getApiPolicies(); decryptPolicies(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, apiPolicies); decryptEndpointProperties(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, api.getEndpointProperties()); } } handler.handle(result); } });