Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy endpoints for HTTP Connector Connection during Local Entry Deployer #2262

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,103 @@ public enum ENDPOINT_TIMEOUT_TYPE { ENDPOINT_TIMEOUT, GLOBAL_TIMEOUT, HTTP_CONNE

public static final String ANALYTICS_METADATA = "ANALYTICS_METADATA";

// Constants for the HTTP Connection
public static final String ENDPOINT_IDENTIFIER = "_INTERNAL_ENDPOINT_REFERENCE";
public static final String BASIC_AUTH = "Basic Auth";
public static final String OAUTH = "OAuth";
public static final String OAUTH_GRANT_TYPE_AUTHORIZATION_CODE = "Authorization Code";
public static final String OAUTH_GRANT_TYPE_CLIENT_CREDENTIALS = "Client Credentials";
public static final String OAUTH_GRANT_TYPE_PASSWORD = "Password";

public static final String NAME = "name";
public static final String BASE_URL = "baseUrl";
public static final String CONNECTION_TYPE = "connectionType";
public static final String CERTIFICATE_TYPE = "certificateType";
public static final String AUTH_TYPE = "authType";
public static final String OAUTH_AUTHORIZATION_MODE = "oauthAuthorizationMode";
public static final String OAUTH_GRANT_TYPE = "oauthGrantType";
public static final String BASIC_CREDENTIALS_USERNAME = "basicCredentialsUsername";
public static final String BASIC_CREDENTIALS_PASSWORD = "basicCredentialsPassword";
public static final String OAUTH_PASSWORD_GRANT_USERNAME = "oauthPasswordUsername";
public static final String OAUTH_PASSWORD_GRANT_PASSWORD = "oauthPasswordPassword";
public static final String OAUTH_PASSWORD_GRANT_CLIENT_ID = "oauthPasswordClientId";
public static final String OAUTH_PASSWORD_GRANT_CLIENT_SECRET = "oauthPasswordClientSecret";
public static final String OAUTH_PASSWORD_GRANT_TOKEN_URL = "oauthPasswordTokenUrl";
public static final String OAUTH_PASSWORD_GRANT_ADDITIONAL_PROPERTIES = "oauthPasswordAdditionalProperties";

public static final String OAUTH_CLIENT_CREDENTIALS_GRANT_CLIENT_ID = "oauthClientClientId";
public static final String OAUTH_CLIENT_CREDENTIALS_GRANT_CLIENT_SECRET = "oauthClientClientSecret";
public static final String OAUTH_CLIENT_CREDENTIALS_GRANT_TOKEN_URL = "oauthClientTokenUrl";
public static final String OAUTH_CLIENT_CREDENTIALS_GRANT_ADDITIONAL_PROPERTIES = "oauthClientAdditionalProperties";

public static final String OAUTH_AUTHORIZATION_GRANT_CLIENT_SECRET = "oauthAuthorizationClientSecret";
public static final String OAUTH_AUTHORIZATION_GRANT_CLIENT_ID = "oauthAuthorizationClientId";
public static final String OAUTH_AUTHORIZATION_GRANT_TOKEN_URL = "oauthAuthorizationTokenUrl";
public static final String OAUTH_AUTHORIZATION_GRANT_REFRESH_TOKEN = "oauthAuthorizationRefreshToken";
public static final String OAUTH_AUTHORIZATION_GRANT_ADDITIONAL_PROPERTIES = "oauthAuthorizationAdditionalProperties";

public static final String OAUTH_CLIENT_ID = "oauthClientId";
public static final String TIMEOUT_DURATION = "timeoutDuration";
public static final String TIMEOUT_ACTION = "timeoutAction";
public static final String SUSPEND_ERROR_CODES = "suspendErrorCodes";
public static final String SUSPEND_INITIAL_DURATION = "suspendInitialDuration";
public static final String SUSPEND_MAXIMUM_DURATION = "suspendMaximumDuration";
public static final String SUSPEND_PROGRESSION_FACTOR = "suspendProgressionFactor";
public static final String RETRY_ERROR_CODES = "retryErrorCodes";
public static final String RETRY_COUNT = "retryCount";
public static final String RETRY_DELAY = "retryDelay";

public static final String TRACE = "trace";
public static final String STATISTICS = "statistics";
public static final String MISCELLANEOUS_DESCRIPTION = "miscellaneousDescription";
public static final String MISCELLANEOUS_PROPERTIES = "miscellaneousProperties";
public static final String QUALITY_OF_SERVICE_ADDRESS_OPTION = "qualityServiceAddressOption";
public static final String QUALITY_OF_SERVICE_ADDRESS_VERSION = "qualityServiceAddressVersion";
public static final String QUALITY_OF_SERVICE_ADDRESS_SEPARATE_LISTENER = "qualityServiceAddressSeparateListener";

public static final String QUALITY_OF_SERVICE_SECURITY_OPTION = "qualityServiceSecurityOption";
public static final String QUALITY_OF_SERVICE_SECURITY_INBOUND_OUTBOUND_POLICY_OPTION = "qualityServiceSecurityInboundOutboundPolicyOption";
public static final String QUALITY_OF_SERVICE_SECURITY_INBOUND_POLICY_KEY = "qualityServiceSecurityInboundPolicyKey";
public static final String QUALITY_OF_SERVICE_SECURITY_OUTBOUND_POLICY_KEY = "qualityServiceSecurityOutboundPolicyKey";
public static final String QUALITY_OF_SERVICE_SECURITY_POLICY_KEY = "qualityServiceSecurityPolicyKey";

public static final String ENDPOINT = "endpoint";
public static final String HTTP = "http";
public static final String ENABLE = "enable";
public static final String URI_TEMPLATE = "uri-template";
public static final String ENABLE_ADDRESSING = "enableAddressing";
public static final String ENABLE_SECURITY = "enableSec";
public static final String SEPARATE_LISTENER = "separateListener";
public static final String VERSION = "version";
public static final String POLICY = "policy";
public static final String INBOUND_POLICY = "inboundPolicy";
public static final String OUTBOUND_POLICY = "outboundPolicy";
public static final String TIMEOUT = "timeout";
public static final String DURATION = "duration";
public static final String RESPONSE_ACTION = "responseAction";
public static final String NEVER = "never";
public static final String SUSPEND_ON_FAILURE = "suspendOnFailure";
public static final String ERROR_CODES = "errorCodes";
public static final String INITIAL_DURATION = "initialDuration";
public static final String MAXIMUM_DURATION = "maximumDuration";
public static final String PROGRESSION_FACTOR = "progressionFactor";
public static final String MARK_FOR_SUSPENSION = "markForSuspension";
public static final String RETRIES_BEFORE_SUSPENSION = "retriesBeforeSuspension";
public static final String AUTHENTICATION = "authentication";
public static final String DESCRIPTION = "description";
public static final String AUTHORIZATION_CODE = "authorizationCode";
public static final String PASSWORD_CREDENTIALS = "passwordCredentials";
public static final String CLIENT_CREDENTIALS = "clientCredentials";
public static final String TOKEN_URL = "tokenUrl";
public static final String CLIENT_ID = "clientId";
public static final String CLIENT_SECRET = "clientSecret";
public static final String USERNAME = "username";
public static final String PASSWORD = "password";
public static final String REFRESH_TOKEN = "refreshToken";
public static final String AUTH_MODE = "authMode";
public static final String REQUEST_PARAMETERS = "requestParameters";
public static final String BASIC_AUTH_TAG = "basicAuth";
public static final String OAUTH_TAG = "oauth";
public static final String SCATTER_MESSAGES = "SCATTER_MESSAGES";
public static final String CONTINUE_FLOW_TRIGGERED_FROM_MEDIATOR_WORKER = "CONTINUE_FLOW_TRIGGERED_FROM_MEDIATOR_WORKER";
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@
import org.apache.synapse.config.xml.EntryFactory;
import org.apache.synapse.config.xml.EntrySerializer;
import org.apache.synapse.config.xml.MultiXMLConfigurationBuilder;
import org.apache.synapse.config.xml.endpoints.EndpointFactory;
import org.apache.synapse.endpoints.Endpoint;
import org.apache.synapse.transport.dynamicconfigurations.KeyStoreReloaderHolder;
import org.apache.synapse.transport.nhttp.config.SslSenderTrustStoreHolder;
import org.apache.synapse.util.HTTPConnectionUtils;

import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -89,6 +92,7 @@ public String deploySynapseArtifact(OMElement artifactConfig, String fileName,
log.info("LocalEntry named '" + e.getKey()
+ "' has been deployed from file : " + fileName);
handleSSLSenderCertificates(artifactConfig);
deployEndpointsForHTTPConnection(artifactConfig, fileName, properties);
return e.getKey();
} else {
handleSynapseArtifactDeploymentError("LocalEntry Deployment Failed. The artifact " +
Expand All @@ -102,6 +106,50 @@ public String deploySynapseArtifact(OMElement artifactConfig, String fileName,
return null;
}

private void deployEndpointsForHTTPConnection(OMElement artifactConfig, String fileName, Properties properties) {

OMElement httpInitElement =
artifactConfig.getFirstChildWithName(
new QName(SynapseConstants.SYNAPSE_NAMESPACE, HTTP_CONNECTION_IDENTIFIER));
if (httpInitElement != null) {
OMElement generatedEndpointElement = HTTPConnectionUtils.generateHTTPEndpointOMElement(httpInitElement);
deployHTTPEndpointForElement(generatedEndpointElement, fileName, properties);
}
}

private void deployHTTPEndpointForElement(OMElement documentElement, String fileName, Properties properties) {

try {
Endpoint ep = EndpointFactory.getEndpointFromElement(documentElement, false, properties);

//Set the car name
ep.setArtifactContainerName(customLogContent);
if (ep != null) {
ep.setFileName((new File(fileName)).getName());
if (log.isDebugEnabled()) {
log.debug("Endpoint named '" + ep.getName()
+ "' has been built from the http connection file " + fileName);
}
ep.init(getSynapseEnvironment());
if (log.isDebugEnabled()) {
log.debug("Initialized the endpoint : " + ep.getName());
}
getSynapseConfiguration().addEndpoint(ep.getName(), ep);
if (log.isDebugEnabled()) {
log.debug("Endpoint Deployment from the http connection file : " + fileName + " : Completed");
}
log.info("Endpoint named '" + ep.getName()
+ "' has been deployed from the http connection file : " + fileName);
} else {
handleSynapseArtifactDeploymentError("Endpoint Deployment Failed. The artifact " +
"described in the http connection file " + fileName + " has filed to describe an Endpoint");
}
} catch (Exception e) {
handleSynapseArtifactDeploymentError("Endpoint Deployment from the http connection file : "
+ fileName + " : Failed.", e);
}
}

private void handleSSLSenderCertificates(OMElement element) throws DeploymentException {

OMElement httpInitElement =
Expand Down
Loading
Loading