diff --git a/api/pom.xml b/api/pom.xml index 3e03fd4e056..4370125b65e 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -21,7 +21,7 @@ com.okta.sdk okta-sdk-root - 14.0.1-SNAPSHOT + 14.1.0-SNAPSHOT okta-sdk-api diff --git a/api/src/main/java/com/okta/sdk/resource/user/UserBuilder.java b/api/src/main/java/com/okta/sdk/resource/user/UserBuilder.java index 57e0493716d..342bba4b9ce 100644 --- a/api/src/main/java/com/okta/sdk/resource/user/UserBuilder.java +++ b/api/src/main/java/com/okta/sdk/resource/user/UserBuilder.java @@ -121,6 +121,8 @@ default UserBuilder setGroups(String... groupIds) { UserBuilder setNextLogin(UserNextLogin nextLogin); + UserBuilder setBcryptPasswordHash(String value); + UserBuilder setBcryptPasswordHash(String value, String salt, int workFactor); UserBuilder setSha256PasswordHash(String value, String salt, String saltOrder); diff --git a/coverage/pom.xml b/coverage/pom.xml index fc1af159cda..b708130536a 100644 --- a/coverage/pom.xml +++ b/coverage/pom.xml @@ -21,7 +21,7 @@ com.okta.sdk okta-sdk-root - 14.0.1-SNAPSHOT + 14.1.0-SNAPSHOT okta-sdk-coverage diff --git a/examples/pom.xml b/examples/pom.xml index 49861f565da..75b86996c22 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -21,7 +21,7 @@ com.okta.sdk okta-sdk-root - 14.0.1-SNAPSHOT + 14.1.0-SNAPSHOT okta-sdk-examples diff --git a/examples/quickstart/pom.xml b/examples/quickstart/pom.xml index e06abb30c6e..8c3e025824c 100644 --- a/examples/quickstart/pom.xml +++ b/examples/quickstart/pom.xml @@ -20,7 +20,7 @@ com.okta.sdk okta-sdk-examples - 14.0.1-SNAPSHOT + 14.1.0-SNAPSHOT ../pom.xml diff --git a/impl/pom.xml b/impl/pom.xml index 8cde6bc2888..5c4c3a98c35 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -21,7 +21,7 @@ com.okta.sdk okta-sdk-root - 14.0.1-SNAPSHOT + 14.1.0-SNAPSHOT okta-sdk-impl diff --git a/impl/src/main/java/com/okta/sdk/impl/resource/DefaultUserBuilder.java b/impl/src/main/java/com/okta/sdk/impl/resource/DefaultUserBuilder.java index 29482690777..49161012bd7 100644 --- a/impl/src/main/java/com/okta/sdk/impl/resource/DefaultUserBuilder.java +++ b/impl/src/main/java/com/okta/sdk/impl/resource/DefaultUserBuilder.java @@ -15,6 +15,7 @@ */ package com.okta.sdk.impl.resource; +import com.okta.commons.lang.Assert; import com.okta.commons.lang.Collections; import com.okta.commons.lang.Strings; import com.okta.sdk.resource.user.UserBuilder; @@ -428,6 +429,17 @@ private UserCredentials createCredentialsIfNeeded(CreateUserRequest createUserRe return createUserRequest.getCredentials(); } + public UserBuilder setBcryptPasswordHash(String value) { + Assert.notNull(value); + String[] tokenizedStr = value.split("\\$"); + Assert.isTrue(tokenizedStr.length == 4); + + int work = Integer.parseInt(tokenizedStr[2]); + String salt = tokenizedStr[3].substring(0, 22); + String hash = tokenizedStr[3].substring(22); + return setBcryptPasswordHash(hash, salt, work); + } + public UserBuilder setBcryptPasswordHash(String value, String salt, int workFactor) { passwordHashProperties = new HashMap<>(); passwordHashProperties.put("algorithm", "BCRYPT"); diff --git a/impl/src/test/groovy/com/okta/sdk/impl/resource/DefaultUserBuilderTest.groovy b/impl/src/test/groovy/com/okta/sdk/impl/resource/DefaultUserBuilderTest.groovy new file mode 100644 index 00000000000..873fefdb8af --- /dev/null +++ b/impl/src/test/groovy/com/okta/sdk/impl/resource/DefaultUserBuilderTest.groovy @@ -0,0 +1,39 @@ +/* + * Copyright 2023-Present Okta, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.okta.sdk.impl.resource + +import org.testng.annotations.Test + +import static org.testng.Assert.assertEquals + +/** + * @since 14.1.0 + */ +class DefaultUserBuilderTest { + + var userBuilder = new DefaultUserBuilder() + + @Test + void testSetBcryptPasswordHash() { + userBuilder.setBcryptPasswordHash("\$2a\$10\$Ro0CUfOqk6cXEKf3dyaM7OhSCvnwM9s4wIX9JeLapehKK5YdLxKcm") + + assertEquals(userBuilder.passwordHashProperties.size(), 4) + assertEquals(userBuilder.passwordHashProperties.salt, "Ro0CUfOqk6cXEKf3dyaM7O") + assertEquals(userBuilder.passwordHashProperties.workFactor, 10) + assertEquals(userBuilder.passwordHashProperties.value, "hSCvnwM9s4wIX9JeLapehKK5YdLxKcm") + assertEquals(userBuilder.passwordHashProperties.algorithm, "BCRYPT") + } +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index fe5e1418b8b..255ff9f9846 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -20,7 +20,7 @@ com.okta.sdk okta-sdk-root - 14.0.1-SNAPSHOT + 14.1.0-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index fc98ea7ea63..3b7fb5d97dc 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ com.okta.sdk okta-sdk-root - 14.0.1-SNAPSHOT + 14.1.0-SNAPSHOT pom Okta Java SDK @@ -68,12 +68,12 @@ com.okta.sdk okta-sdk-api - 14.0.1-SNAPSHOT + 14.1.0-SNAPSHOT com.okta.sdk okta-sdk-impl - 14.0.1-SNAPSHOT + 14.1.0-SNAPSHOT @@ -103,14 +103,14 @@ com.okta.sdk okta-sdk-integration-tests - 14.0.1-SNAPSHOT + 14.1.0-SNAPSHOT com.okta.sdk okta-sdk-examples-quickstart - 14.0.1-SNAPSHOT + 14.1.0-SNAPSHOT