forked from loafle/openapi-generator-original
Support for Secure SPNEGO kerberos negotiation
Ability to integrate with a SPNEGO-protected REST API with KerberosV5 ticket preemptive authentication.
This commit is contained in:
@@ -12,6 +12,9 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
protected String artifactId = "swagger-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String sourceFolder = "src/main/java";
|
||||
protected String authScheme = "";
|
||||
protected boolean authPreemptive = false;
|
||||
protected boolean asyncHttpClient = !authScheme.isEmpty();
|
||||
|
||||
public String getName() {
|
||||
return "scala";
|
||||
@@ -43,7 +46,9 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
additionalProperties.put("groupId", groupId);
|
||||
additionalProperties.put("artifactId", artifactId);
|
||||
additionalProperties.put("artifactVersion", artifactVersion);
|
||||
additionalProperties.put("asyncHttpClient", false);
|
||||
additionalProperties.put("asyncHttpClient", asyncHttpClient);
|
||||
additionalProperties.put("authScheme", authScheme);
|
||||
additionalProperties.put("authPreemptive", authPreemptive);
|
||||
|
||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
supportingFiles.add(new SupportingFile("apiInvoker.mustache",
|
||||
|
||||
@@ -38,7 +38,9 @@ object ScalaJsonUtil {
|
||||
class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
||||
httpHeaders: HashMap[String, String] = HashMap(),
|
||||
hostMap: HashMap[String, Client] = HashMap(),
|
||||
asyncHttpClient: Boolean = false) {
|
||||
asyncHttpClient: Boolean = false,
|
||||
authScheme: String = "",
|
||||
authPreemptive: Boolean = false) {
|
||||
|
||||
var defaultHeaders: HashMap[String, String] = httpHeaders
|
||||
|
||||
@@ -167,6 +169,12 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
||||
import org.sonatype.spice.jersey.client.ahc.AhcHttpClient
|
||||
|
||||
val config: DefaultAhcConfig = new DefaultAhcConfig()
|
||||
if (!authScheme.isEmpty) {
|
||||
val authSchemeEnum = Realm.AuthScheme.valueOf(authScheme)
|
||||
config.getAsyncHttpClientConfigBuilder
|
||||
.setRealm(new Realm.RealmBuilder().setScheme(authSchemeEnum)
|
||||
.setUsePreemptiveAuth(authPreemptive).build)
|
||||
}
|
||||
AhcHttpClient.create(config)
|
||||
}
|
||||
case _ => Client.create()
|
||||
@@ -176,7 +184,9 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
||||
object ApiInvoker extends ApiInvoker(mapper = ScalaJsonUtil.getJsonMapper,
|
||||
httpHeaders = HashMap(),
|
||||
hostMap = HashMap(),
|
||||
asyncHttpClient = {{asyncHttpClient}})
|
||||
asyncHttpClient = {{asyncHttpClient}},
|
||||
authScheme = {{authScheme}},
|
||||
authPreemptive = {{authPreemptive}})
|
||||
|
||||
class ApiException(val code: Int, msg: String) extends RuntimeException(msg)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user