DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Basic Camel and HTTPS

In this very quick tutorial, Red Hat developer, and MVB, Mary Cochran shows you how to set up and hit basic HTTPS endpoints with Camel.

Mary Cochran user avatar by
Mary Cochran
·
Mar. 19, 17 · Tutorial
Like (1)
Save
Tweet
Share
8.05K Views

Join the DZone community and get the full member experience.

Join For Free

Ever wonder how you can set up and hit a basic HTTPS endpoint with Camel? These directions are sure to help!

First, configure your RouteBuilder. This RouteBuilder calls for two methods. Those will be defined down below. It then polls a jetty HTTPS endpoint. When the jetty endpoint gets a hit, it sends a request to HTTPS endpoint deployed elsewhere.

public class MyRouteBuilder extends RouteBuilder{
	public void configure() {
		configureJetty();
		configureHttp4();
		from("jetty:https://0.0.0.0:8080/sample/?matchOnUriPrefix=true")
			.to("https4://example.com:8081/?q=ssl&bridgeEndpoint=true&throwExceptionOnFailure=false");
	}
}

Next, we need to define the SSL configuration for the jetty endpoint.

private void configureJetty() {
	KeyStoreParameters ksp = new KeyStoreParameters();
	ksp.setResource("\Projects\example\myJks.jks");
	ksp.setPassword("password");
	KeyManagersParameters kmp = new KeyManagersParameters();
	kmp.setKeyStore(ksp); kmp.setKeyPassword("keyPassword");
	SSLContextParameters scp = new SSLContextParameters();
	scp.setKeyManagers(kmp);
	JettyHttpComponent jettyComponent = getContext().getComponent("jetty", JettyHttpComponent.class);
	jettyComponent.setSslContextParameters(scp);
}

Finally, we need to define the SSL configuration to send to the HTTPS endpoint.

private void configureHttp4() {
	KeyStoreParameters ksp = new KeyStoreParameters();
	ksp.setResource("\Projects\example\exampleCa.jks");
	ksp.setPassword("password");
	TrustManagersParameters tmp = new TrustManagersParameters();
	tmp.setKeyStore(ksp);
	SSLContextParameters scp = new SSLContextParameters();
	scp.setTrustManagers(tmp);
	HttpComponent httpComponent = getContext().getComponent("https4", HttpComponent.class);
	httpComponent.setSslContextParameters(scp);
}

Red Hat Software Collections are available for download, you can read more at Red Hat Software Collections.

HTTPS

Published at DZone with permission of Mary Cochran, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Unleashing the Power of JavaScript Modules: A Beginner’s Guide
  • Using QuestDB to Collect Infrastructure Metrics
  • Core Machine Learning Metrics
  • A Beginner's Guide to Back-End Development

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: