Created
January 29, 2020 00:09
-
-
Save plavjanik/8712cd084ee5e4a3d2f181c76162dbf2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * This program and the accompanying materials are made available under the terms of the | |
| * Eclipse Public License v2.0 which accompanies this distribution, and is available at | |
| * https://www.eclipse.org/legal/epl-v20.html | |
| * | |
| * SPDX-License-Identifier: EPL-2.0 | |
| * | |
| * Copyright Contributors to the Zowe Project. | |
| */ | |
| package com.ca.mfaas.gateway.zosmf; | |
| import java.io.File; | |
| import java.io.IOException; | |
| import com.ca.mfaas.security.HttpsConfig; | |
| import com.ca.mfaas.security.HttpsFactory; | |
| import org.apache.http.HttpResponse; | |
| import org.apache.http.client.methods.HttpGet; | |
| import org.apache.http.impl.client.CloseableHttpClient; | |
| import lombok.extern.slf4j.Slf4j; | |
| @Slf4j | |
| public class ZosmfHttpsTest { | |
| public static void main(String[] args) throws IOException { | |
| log.debug("Cwd: {}", System.getProperty("user.dir")); | |
| ///Users/plape03/workspace/github.gwd.broadcom.net/MFD/ca-api-layer/keystore/ca3x/ | |
| String keyStorePath = "apiml.keystore.p12"; | |
| System.setProperty("javax.net.ssl.keyStore", keyStorePath); | |
| System.setProperty("javax.net.ssl.keyStorePassword", "password"); | |
| System.setProperty("javax.net.ssl.keyStoreType", "PKCS12"); | |
| HttpsConfig httpsConfig = HttpsConfig.builder() | |
| // .keyStore(new File("apiml.truststore.p12").getCanonicalPath()) | |
| // .keyStorePassword("password").keyPassword("password") | |
| .trustStore(new File("apiml.truststore.p12").getCanonicalPath()) | |
| .trustStorePassword("password").protocol("TLSv1.2").build(); | |
| HttpsFactory httpsFactory = new HttpsFactory(httpsConfig); | |
| CloseableHttpClient secureHttpClient = httpsFactory.createSecureHttpClient(); | |
| HttpGet request = new HttpGet("https://ca32.lvn.broadcom.net:1443/zosmf/info"); | |
| request.setHeader("Authorization", "Basic eHVzZXI6d3JvbmcK"); | |
| request.setHeader("X-CSRF-ZOSMF-HEADER", ""); | |
| HttpResponse response = secureHttpClient.execute(request); | |
| System.out.println(response.getHeaders("Set-Cookie").length); | |
| System.out.println(response.getStatusLine()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment