From 0d0b227003a8deb88a87e871a4e3882a08d3f1ad Mon Sep 17 00:00:00 2001 From: Maksim Ustinov Date: Thu, 3 Feb 2022 00:53:34 +0000 Subject: [PATCH] Adding JVM overloading for `generatePassword` (#218) Bumping Java SDK version to 16.2.8 --- sdk/java/core/build.gradle.kts | 2 +- .../com/keepersecurity/secretsManager/core/CryptoUtils.kt | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sdk/java/core/build.gradle.kts b/sdk/java/core/build.gradle.kts index db0883d7..66626392 100644 --- a/sdk/java/core/build.gradle.kts +++ b/sdk/java/core/build.gradle.kts @@ -6,7 +6,7 @@ import java.util.* group = "com.keepersecurity.secrets-manager" // During publishing, If version ends with '-SNAPSHOT' then it will be published to Maven snapshot repository -version = "16.2.7" +version = "16.2.8" plugins { `java-library` diff --git a/sdk/java/core/src/main/kotlin/com/keepersecurity/secretsManager/core/CryptoUtils.kt b/sdk/java/core/src/main/kotlin/com/keepersecurity/secretsManager/core/CryptoUtils.kt index 78af2d4f..f2ee69fe 100644 --- a/sdk/java/core/src/main/kotlin/com/keepersecurity/secretsManager/core/CryptoUtils.kt +++ b/sdk/java/core/src/main/kotlin/com/keepersecurity/secretsManager/core/CryptoUtils.kt @@ -260,12 +260,10 @@ const val AsciiUppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" const val AsciiDigits = "0123456789" const val AsciiSpecialCharacters = "\"!@#$%()+;<>=?[]{}^.," -internal fun randomSample(sampleLength: Int=0, sampleString: String=""): String -{ +internal fun randomSample(sampleLength: Int=0, sampleString: String=""): String { var result = "" val sampleLen = if (sampleLength < 0) 0 else sampleLength - if (sampleLen > 0 && sampleString.isNotEmpty()) - { + if (sampleLen > 0 && sampleString.isNotEmpty()) { val secureRandom = SecureRandom.getInstanceStrong() val bytes = CharArray(sampleLen) result = (bytes.indices) @@ -277,6 +275,7 @@ internal fun randomSample(sampleLength: Int=0, sampleString: String=""): String return result } +@JvmOverloads fun generatePassword( length: Int = 64, lowercase: Int = 0,