-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1182 from adorsys/847-otppolicyalgorithm-ignored
fix otpPolicyAlgorithm ignored during import
- Loading branch information
Showing
7 changed files
with
128 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/de/adorsys/keycloak/config/repository/OtpPolicyRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/*- | ||
* ---license-start | ||
* keycloak-config-cli | ||
* --- | ||
* Copyright (C) 2017 - 2021 adorsys GmbH & Co. KG @ https://adorsys.com | ||
* --- | ||
* 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. | ||
* ---license-end | ||
*/ | ||
|
||
package de.adorsys.keycloak.config.repository; | ||
|
||
import org.keycloak.representations.idm.RealmRepresentation; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class OtpPolicyRepository { | ||
private final RealmRepository realmRepository; | ||
|
||
@Autowired | ||
public OtpPolicyRepository(RealmRepository realmRepository) { | ||
this.realmRepository = realmRepository; | ||
} | ||
|
||
public void updateOtpPolicy(String realmName, RealmRepresentation newRealmRepresentation) { | ||
RealmRepresentation existingRealm = realmRepository.get(realmName); | ||
|
||
existingRealm.setOtpPolicyAlgorithm(newRealmRepresentation.getOtpPolicyAlgorithm()); | ||
|
||
|
||
realmRepository.update(existingRealm); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/de/adorsys/keycloak/config/service/OtpPolicyImportService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/*- | ||
* ---license-start | ||
* keycloak-config-cli | ||
* --- | ||
* Copyright (C) 2017 - 2021 adorsys GmbH & Co. KG @ https://adorsys.com | ||
* --- | ||
* 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. | ||
* ---license-end | ||
*/ | ||
|
||
package de.adorsys.keycloak.config.service; | ||
|
||
import de.adorsys.keycloak.config.repository.OtpPolicyRepository; | ||
import org.keycloak.representations.idm.RealmRepresentation; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class OtpPolicyImportService { | ||
private final OtpPolicyRepository otpPolicyRepository; | ||
|
||
@Autowired | ||
public OtpPolicyImportService(OtpPolicyRepository otpPolicyRepository) { | ||
this.otpPolicyRepository = otpPolicyRepository; | ||
} | ||
|
||
public void updateOtpPolicy(String realmName, RealmRepresentation realmRepresentation) { | ||
if (realmRepresentation.getOtpPolicyAlgorithm() != null) { | ||
otpPolicyRepository.updateOtpPolicy(realmName, realmRepresentation); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...sources/import-files/simple-realm/08.5_update_simple-realm_with_otp-policy-algorithm.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"realm": "realmWithOtpPolicy", | ||
"otpPolicyAlgorithm": "HmacSHA1" | ||
} |
4 changes: 4 additions & 0 deletions
4
...ces/import-files/simple-realm/08.6_update_simple-realm_with_new_otp-policy-algorithm.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"realm": "realmWithOtpPolicy", | ||
"otpPolicyAlgorithm": "HmacSHA512" | ||
} |