forked from loafle/openapi-generator-original
Add java8 option 2.3.0 (#5955)
* 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. * Closes #5954 built and ran tests/samples
This commit is contained in:
committed by
wing328
parent
fd44d01d9c
commit
40369bb819
@@ -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}}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +130,8 @@ dependencies {
|
||||
{{#threetenbp}}
|
||||
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version",
|
||||
{{/threetenbp}}
|
||||
{{^java8}}
|
||||
compile "com.brsanthu:migbase64:2.2"
|
||||
{{/java8}}
|
||||
testCompile "junit:junit:$junit_version"
|
||||
}
|
||||
|
||||
@@ -136,6 +136,8 @@ dependencies {
|
||||
{{#threetenbp}}
|
||||
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version",
|
||||
{{/threetenbp}}
|
||||
{{^java8}}
|
||||
compile "com.brsanthu:migbase64:2.2"
|
||||
{{/java8}}
|
||||
testCompile "junit:junit:$junit_version"
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@ lazy val root = (project in file(".")).
|
||||
{{#threetenbp}}
|
||||
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.6.4" % "compile",
|
||||
{{/threetenbp}}
|
||||
{{^java8}}
|
||||
"com.brsanthu" % "migbase64" % "2.2",
|
||||
{{/java8}}
|
||||
{{#supportJava6}}
|
||||
"org.apache.commons" % "commons-lang3" % "3.6",
|
||||
"commons-io" % "commons-io" % "2.5",
|
||||
|
||||
@@ -244,12 +244,14 @@
|
||||
</dependency>
|
||||
{{/threetenbp}}
|
||||
|
||||
{{^java8}}
|
||||
<!-- Base64 encoding that works in both JVM and Android -->
|
||||
<dependency>
|
||||
<groupId>com.brsanthu</groupId>
|
||||
<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>
|
||||
|
||||
@@ -245,12 +245,14 @@
|
||||
</dependency>
|
||||
{{/threetenbp}}
|
||||
|
||||
{{^java8}}
|
||||
<!-- Base64 encoding that works in both JVM and Android -->
|
||||
<dependency>
|
||||
<groupId>com.brsanthu</groupId>
|
||||
<artifactId>migbase64</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
{{/java8}}
|
||||
|
||||
{{#supportJava6}}
|
||||
<dependency>
|
||||
|
||||
Reference in New Issue
Block a user