forked from loafle/openapi-generator-original
Support a true "java8" option (#5864)
* Closes #5863 The "dateLibrary" option for java, sadly, sets a mustache value "java8". This change updates this so that "java" in the mustache libraries means what it should mean - use all java8 classes. In this case, there's no need for the third party Base64 library as java8's JDK has this built in. In my view, the "dateLibrary" should be deprecated but that should be a separate PR. * updated samples * fixed tests for new CLI java8 * regenerated samples after master merge * oops - left in an end tag after master merge * rerun checks * rerun checks
This commit is contained in:
committed by
wing328
parent
a64c7d7986
commit
b2efb70410
@@ -4,12 +4,20 @@ package {{invokerPackage}}.auth;
|
||||
|
||||
import {{invokerPackage}}.Pair;
|
||||
|
||||
{{^java8}}
|
||||
import com.migcomponents.migbase64.Base64;
|
||||
{{/java8}}
|
||||
{{#java8}}
|
||||
import java.util.Base64;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
{{/java8}}
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{^java8}}
|
||||
import java.io.UnsupportedEncodingException;
|
||||
{{/java8}}
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class HttpBasicAuth implements Authentication {
|
||||
@@ -38,10 +46,15 @@ public class HttpBasicAuth implements Authentication {
|
||||
return;
|
||||
}
|
||||
String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
|
||||
{{^java8}}
|
||||
try {
|
||||
headerParams.put("Authorization", "Basic " + Base64.encodeToString(str.getBytes("UTF-8"), false));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
{{/java8}}
|
||||
{{#java8}}
|
||||
headerParams.put("Authorization", "Basic " + Base64.getEncoder().encodeToString(str.getBytes(StandardCharsets.UTF_8)));
|
||||
{{/java8}}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ dependencies {
|
||||
{{^java8}}
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
||||
compile "joda-time:joda-time:$jodatime_version"
|
||||
{{/java8}}
|
||||
compile "com.brsanthu:migbase64:2.2"
|
||||
{{/java8}}
|
||||
testCompile "junit:junit:$junit_version"
|
||||
}
|
||||
|
||||
@@ -132,11 +132,11 @@ dependencies {
|
||||
{{^java8}}
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
||||
compile "joda-time:joda-time:$jodatime_version"
|
||||
compile "com.brsanthu:migbase64:2.2"
|
||||
{{/java8}}
|
||||
{{#supportJava6}}
|
||||
compile "commons-io:commons-io:$commons_io_version"
|
||||
compile "org.apache.commons:commons-lang3:$commons_lang3_version"
|
||||
{{/supportJava6}}
|
||||
compile "com.brsanthu:migbase64:2.2"
|
||||
testCompile "junit:junit:$junit_version"
|
||||
}
|
||||
|
||||
@@ -240,7 +240,6 @@
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>${jodatime-version}</version>
|
||||
</dependency>
|
||||
{{/java8}}
|
||||
|
||||
<!-- Base64 encoding that works in both JVM and Android -->
|
||||
<dependency>
|
||||
@@ -248,6 +247,8 @@
|
||||
<artifactId>migbase64</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
{{/java8}}
|
||||
|
||||
{{#supportJava6}}
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
|
||||
@@ -132,11 +132,11 @@ dependencies {
|
||||
{{^java8}}
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
||||
compile "joda-time:joda-time:$jodatime_version"
|
||||
compile "com.brsanthu:migbase64:2.2"
|
||||
{{/java8}}
|
||||
{{#supportJava6}}
|
||||
compile "commons-io:commons-io:$commons_io_version"
|
||||
compile "org.apache.commons:commons-lang3:$commons_lang3_version"
|
||||
{{/supportJava6}}
|
||||
compile "com.brsanthu:migbase64:2.2"
|
||||
testCompile "junit:junit:$junit_version"
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ lazy val root = (project in file(".")).
|
||||
{{^java8}}
|
||||
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.7.5",
|
||||
"joda-time" % "joda-time" % "2.9.4",
|
||||
{{/java8}}
|
||||
"com.brsanthu" % "migbase64" % "2.2",
|
||||
{{/java8}}
|
||||
{{#supportJava6}}
|
||||
"org.apache.commons" % "commons-lang3" % "3.5",
|
||||
"commons-io" % "commons-io" % "2.5",
|
||||
|
||||
@@ -168,7 +168,6 @@
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>${jodatime-version}</version>
|
||||
</dependency>
|
||||
{{/java8}}
|
||||
|
||||
<!-- Base64 encoding that works in both JVM and Android -->
|
||||
<dependency>
|
||||
@@ -176,6 +175,8 @@
|
||||
<artifactId>migbase64</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
{{/java8}}
|
||||
|
||||
{{#supportJava6}}
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
|
||||
@@ -241,7 +241,6 @@
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>${jodatime-version}</version>
|
||||
</dependency>
|
||||
{{/java8}}
|
||||
|
||||
<!-- Base64 encoding that works in both JVM and Android -->
|
||||
<dependency>
|
||||
@@ -249,6 +248,7 @@
|
||||
<artifactId>migbase64</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
{{/java8}}
|
||||
|
||||
{{#supportJava6}}
|
||||
<dependency>
|
||||
|
||||
Reference in New Issue
Block a user