forked from loafle/openapi-generator-original
[Java] Add custom SSL KeyManagers for okhttp-gson Java clients (#5629)
* Add the ability to set SSL KeyManagers for okhttp-gson Java clients * Update generated code. * Update security model files.
This commit is contained in:
@@ -116,6 +116,7 @@ public class ApiClient {
|
|||||||
|
|
||||||
private InputStream sslCaCert;
|
private InputStream sslCaCert;
|
||||||
private boolean verifyingSsl;
|
private boolean verifyingSsl;
|
||||||
|
private KeyManager[] keyManagers;
|
||||||
|
|
||||||
private OkHttpClient httpClient;
|
private OkHttpClient httpClient;
|
||||||
private JSON json;
|
private JSON json;
|
||||||
@@ -267,6 +268,23 @@ public class ApiClient {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public KeyManager[] getKeyManagers() {
|
||||||
|
return keyManagers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure client keys to use for authorization in an SSL session.
|
||||||
|
* Use null to reset to default.
|
||||||
|
*
|
||||||
|
* @param managers The KeyManagers to use
|
||||||
|
* @return ApiClient
|
||||||
|
*/
|
||||||
|
public ApiClient setKeyManagers(KeyManager[] managers) {
|
||||||
|
this.keyManagers = managers;
|
||||||
|
applySslSettings();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DateFormat getDateFormat() {
|
public DateFormat getDateFormat() {
|
||||||
return dateFormat;
|
return dateFormat;
|
||||||
}
|
}
|
||||||
@@ -1256,7 +1274,6 @@ public class ApiClient {
|
|||||||
*/
|
*/
|
||||||
private void applySslSettings() {
|
private void applySslSettings() {
|
||||||
try {
|
try {
|
||||||
KeyManager[] keyManagers = null;
|
|
||||||
TrustManager[] trustManagers = null;
|
TrustManager[] trustManagers = null;
|
||||||
HostnameVerifier hostnameVerifier = null;
|
HostnameVerifier hostnameVerifier = null;
|
||||||
if (!verifyingSsl) {
|
if (!verifyingSsl) {
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ public class ApiClient {
|
|||||||
|
|
||||||
private InputStream sslCaCert;
|
private InputStream sslCaCert;
|
||||||
private boolean verifyingSsl;
|
private boolean verifyingSsl;
|
||||||
|
private KeyManager[] keyManagers;
|
||||||
|
|
||||||
private OkHttpClient httpClient;
|
private OkHttpClient httpClient;
|
||||||
private JSON json;
|
private JSON json;
|
||||||
@@ -273,6 +274,23 @@ public class ApiClient {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public KeyManager[] getKeyManagers() {
|
||||||
|
return keyManagers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure client keys to use for authorization in an SSL session.
|
||||||
|
* Use null to reset to default.
|
||||||
|
*
|
||||||
|
* @param managers The KeyManagers to use
|
||||||
|
* @return ApiClient
|
||||||
|
*/
|
||||||
|
public ApiClient setKeyManagers(KeyManager[] managers) {
|
||||||
|
this.keyManagers = managers;
|
||||||
|
applySslSettings();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DateFormat getDateFormat() {
|
public DateFormat getDateFormat() {
|
||||||
return dateFormat;
|
return dateFormat;
|
||||||
}
|
}
|
||||||
@@ -1262,7 +1280,6 @@ public class ApiClient {
|
|||||||
*/
|
*/
|
||||||
private void applySslSettings() {
|
private void applySslSettings() {
|
||||||
try {
|
try {
|
||||||
KeyManager[] keyManagers = null;
|
|
||||||
TrustManager[] trustManagers = null;
|
TrustManager[] trustManagers = null;
|
||||||
HostnameVerifier hostnameVerifier = null;
|
HostnameVerifier hostnameVerifier = null;
|
||||||
if (!verifyingSsl) {
|
if (!verifyingSsl) {
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ public class ApiClient {
|
|||||||
|
|
||||||
private InputStream sslCaCert;
|
private InputStream sslCaCert;
|
||||||
private boolean verifyingSsl;
|
private boolean verifyingSsl;
|
||||||
|
private KeyManager[] keyManagers;
|
||||||
|
|
||||||
private OkHttpClient httpClient;
|
private OkHttpClient httpClient;
|
||||||
private JSON json;
|
private JSON json;
|
||||||
@@ -274,6 +275,23 @@ public class ApiClient {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public KeyManager[] getKeyManagers() {
|
||||||
|
return keyManagers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure client keys to use for authorization in an SSL session.
|
||||||
|
* Use null to reset to default.
|
||||||
|
*
|
||||||
|
* @param managers The KeyManagers to use
|
||||||
|
* @return ApiClient
|
||||||
|
*/
|
||||||
|
public ApiClient setKeyManagers(KeyManager[] managers) {
|
||||||
|
this.keyManagers = managers;
|
||||||
|
applySslSettings();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DateFormat getDateFormat() {
|
public DateFormat getDateFormat() {
|
||||||
return dateFormat;
|
return dateFormat;
|
||||||
}
|
}
|
||||||
@@ -1263,7 +1281,6 @@ public class ApiClient {
|
|||||||
*/
|
*/
|
||||||
private void applySslSettings() {
|
private void applySslSettings() {
|
||||||
try {
|
try {
|
||||||
KeyManager[] keyManagers = null;
|
|
||||||
TrustManager[] trustManagers = null;
|
TrustManager[] trustManagers = null;
|
||||||
HostnameVerifier hostnameVerifier = null;
|
HostnameVerifier hostnameVerifier = null;
|
||||||
if (!verifyingSsl) {
|
if (!verifyingSsl) {
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ public class ApiClient {
|
|||||||
|
|
||||||
private InputStream sslCaCert;
|
private InputStream sslCaCert;
|
||||||
private boolean verifyingSsl;
|
private boolean verifyingSsl;
|
||||||
|
private KeyManager[] keyManagers;
|
||||||
|
|
||||||
private OkHttpClient httpClient;
|
private OkHttpClient httpClient;
|
||||||
private JSON json;
|
private JSON json;
|
||||||
@@ -274,6 +275,23 @@ public class ApiClient {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public KeyManager[] getKeyManagers() {
|
||||||
|
return keyManagers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure client keys to use for authorization in an SSL session.
|
||||||
|
* Use null to reset to default.
|
||||||
|
*
|
||||||
|
* @param managers The KeyManagers to use
|
||||||
|
* @return ApiClient
|
||||||
|
*/
|
||||||
|
public ApiClient setKeyManagers(KeyManager[] managers) {
|
||||||
|
this.keyManagers = managers;
|
||||||
|
applySslSettings();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DateFormat getDateFormat() {
|
public DateFormat getDateFormat() {
|
||||||
return dateFormat;
|
return dateFormat;
|
||||||
}
|
}
|
||||||
@@ -1263,7 +1281,6 @@ public class ApiClient {
|
|||||||
*/
|
*/
|
||||||
private void applySslSettings() {
|
private void applySslSettings() {
|
||||||
try {
|
try {
|
||||||
KeyManager[] keyManagers = null;
|
|
||||||
TrustManager[] trustManagers = null;
|
TrustManager[] trustManagers = null;
|
||||||
HostnameVerifier hostnameVerifier = null;
|
HostnameVerifier hostnameVerifier = null;
|
||||||
if (!verifyingSsl) {
|
if (!verifyingSsl) {
|
||||||
|
|||||||
Reference in New Issue
Block a user