]> git.basschouten.com Git - openhab-addons.git/blob
e39ee10dd7e75fb8983e7c95b89caa0e0ef2e082
[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.TreeMap;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19
20 /**
21  * The {@link InitiateAuthRequest} can be used to start a Cognito user SRP authentication challenge or to refresh
22  * expired tokens using a refresh token.
23  *
24  * When starting user SRP authentication Cognito will respond with a {@link ChallengeResponse}.
25  * When refreshing expired tokens Cognito grants the new tokens in a {@link AuthenticationResultResponse}.
26  *
27  * @author Wouter Born - Initial contribution
28  */
29 @NonNullByDefault
30 public class InitiateAuthRequest {
31
32     public String authFlow = "";
33
34     public String clientId = "";
35
36     public Map<String, String> authParameters = new TreeMap<>();
37
38     InitiateAuthRequest(String authFlow, String clientId, Map<String, String> authParameters) {
39         this.authFlow = authFlow;
40         this.clientId = clientId;
41         this.authParameters.putAll(authParameters);
42     }
43
44     public static InitiateAuthRequest userSrpAuth(String clientId, String username, String srpA) {
45         return new InitiateAuthRequest("USER_SRP_AUTH", clientId, Map.of("USERNAME", username, "SRP_A", srpA));
46     }
47
48     public static InitiateAuthRequest refreshTokenAuth(String clientId, String refreshToken) {
49         return new InitiateAuthRequest("REFRESH_TOKEN_AUTH", clientId, Map.of("REFRESH_TOKEN", refreshToken));
50     }
51 }