Skip to content

Instantly share code, notes, and snippets.

@ehdez73
ehdez73 / DemoApplication.java
Last active March 8, 2024 19:54
Create Beans programatically with Spring Boot
package com.example;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@ehdez73
ehdez73 / CertTest.java
Created March 11, 2014 06:59
Test host certificate
import java.io.IOException;
import java.net.UnknownHostException;
import java.security.cert.Certificate;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
public class CertTest {
public static void main(String[] args) throws UnknownHostException, IOException {
@ehdez73
ehdez73 / Application.java
Last active August 29, 2015 13:57
SSL with RestTemplate to external Host
import org.springframework.web.client.RestTemplate;
public class Application {
static {
System.setProperty("javax.net.ssl.trustStore", "/opt/cert/trustStore");
System.setProperty("javax.net.ssl.trustStorePassword", "s3cret");
}
public static void main(String[] args) throws Exception {
@ehdez73
ehdez73 / Application.java
Last active August 29, 2015 13:57
SSL with RestTemplate to localhost
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
import org.springframework.web.client.RestTemplate;
public class Application {
static {
System.setProperty("javax.net.ssl.trustStore", "/opt/cert/trustStore");