]> git.basschouten.com Git - openhab-addons.git/blob
c904e9a12104e9d460a15b913f8024721249931b
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.windcentrale.internal.dto;
14
15 import java.util.Map;
16 import java.util.Objects;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19
20 /**
21  * The {@link ChallengeResponse} is the response of Cognito when starting user SRP authentication with a
22  * {@link InitiateAuthRequest}. It is answered using a {@link RespondToAuthChallengeRequest}.
23  *
24  * @author Wouter Born - Initial contribution
25  */
26 @NonNullByDefault
27 public class ChallengeResponse {
28
29     public String challengeName = "";
30     public Map<String, String> challengeParameters = Map.of();
31
32     private String getChallengeParameter(String key) {
33         return Objects.requireNonNullElse(challengeParameters.get(key), "");
34     }
35
36     public String getSalt() {
37         return getChallengeParameter("SALT");
38     }
39
40     public String getSecretBlock() {
41         return getChallengeParameter("SECRET_BLOCK");
42     }
43
44     public String getSrpB() {
45         return getChallengeParameter("SRP_B");
46     }
47
48     public String getUsername() {
49         return getChallengeParameter("USERNAME");
50     }
51
52     public String getUserIdForSrp() {
53         return getChallengeParameter("USER_ID_FOR_SRP");
54     }
55 }