|
| 1 | +/* |
| 2 | + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with |
| 5 | + * the License. A copy of the License is located at |
| 6 | + * |
| 7 | + * http://aws.amazon.com/apache2.0 |
| 8 | + * |
| 9 | + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
| 10 | + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions |
| 11 | + * and limitations under the License. |
| 12 | + */ |
| 13 | +package com.amazonaws.services.lambda.runtime.events; |
| 14 | + |
| 15 | +import lombok.*; |
| 16 | + |
| 17 | +import java.util.Map; |
| 18 | + |
| 19 | +/** |
| 20 | + * Represent the class for the Cognito User Pool Create Auth Challenge Lambda Trigger |
| 21 | + * |
| 22 | + * See <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-create-auth-challenge.html">Create Auth Challenge Lambda Trigger</a> |
| 23 | + * |
| 24 | + * @author jvdl <[email protected]> |
| 25 | + */ |
| 26 | +@Data |
| 27 | +@EqualsAndHashCode(callSuper = true) |
| 28 | +@NoArgsConstructor |
| 29 | +public class CognitoUserPoolCreateAuthChallengeEvent extends CognitoUserPoolEvent { |
| 30 | + |
| 31 | + /** |
| 32 | + * The request from the Amazon Cognito service. |
| 33 | + */ |
| 34 | + private Request request; |
| 35 | + |
| 36 | + /** |
| 37 | + * The response from your Lambda trigger. |
| 38 | + */ |
| 39 | + private Response response; |
| 40 | + |
| 41 | + @Builder(setterPrefix = "with") |
| 42 | + public CognitoUserPoolCreateAuthChallengeEvent( |
| 43 | + String version, |
| 44 | + String triggerSource, |
| 45 | + String region, |
| 46 | + String userPoolId, |
| 47 | + String userName, |
| 48 | + CallerContext callerContext, |
| 49 | + Request request, |
| 50 | + Response response) { |
| 51 | + super(version, triggerSource, region, userPoolId, userName, callerContext); |
| 52 | + this.request = request; |
| 53 | + this.response = response; |
| 54 | + } |
| 55 | + |
| 56 | + @Data |
| 57 | + @EqualsAndHashCode(callSuper = true) |
| 58 | + @NoArgsConstructor |
| 59 | + public static class Request extends CognitoUserPoolEvent.Request { |
| 60 | + /** |
| 61 | + * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the create auth challenge trigger. |
| 62 | + */ |
| 63 | + private Map<String, String> clientMetadata; |
| 64 | + /** |
| 65 | + * The name of the new challenge. |
| 66 | + */ |
| 67 | + private String challengeName; |
| 68 | + private ChallengeResult[] session; |
| 69 | + /** |
| 70 | + * This boolean is populated when PreventUserExistenceErrors is set to ENABLED for your User Pool client. |
| 71 | + */ |
| 72 | + private boolean userNotFound; |
| 73 | + |
| 74 | + @Builder(setterPrefix = "with") |
| 75 | + public Request(Map<String, String> userAttributes, Map<String, String> clientMetadata, String challengeName, ChallengeResult[] session, boolean userNotFound) { |
| 76 | + super(userAttributes); |
| 77 | + this.clientMetadata = clientMetadata; |
| 78 | + this.session = session; |
| 79 | + this.userNotFound = userNotFound; |
| 80 | + this.challengeName = challengeName; |
| 81 | + } |
| 82 | + } |
| 83 | + |
| 84 | + @AllArgsConstructor |
| 85 | + @Builder(setterPrefix = "with") |
| 86 | + @Data |
| 87 | + @NoArgsConstructor |
| 88 | + public static class ChallengeResult { |
| 89 | + /** |
| 90 | + * The challenge type. One of: "CUSTOM_CHALLENGE", "PASSWORD_VERIFIER", "SMS_MFA", "DEVICE_SRP_AUTH", "DEVICE_PASSWORD_VERIFIER", or "ADMIN_NO_SRP_AUTH". |
| 91 | + */ |
| 92 | + private String challengeName; |
| 93 | + /** |
| 94 | + * Set to true if the user successfully completed the challenge, or false otherwise. |
| 95 | + */ |
| 96 | + private boolean challengeResult; |
| 97 | + /** |
| 98 | + * Your name for the custom challenge. Used only if challengeName is CUSTOM_CHALLENGE. |
| 99 | + */ |
| 100 | + private String challengeMetadata; |
| 101 | + } |
| 102 | + |
| 103 | + @AllArgsConstructor |
| 104 | + @Builder(setterPrefix = "with") |
| 105 | + @Data |
| 106 | + @NoArgsConstructor |
| 107 | + public static class Response { |
| 108 | + /** |
| 109 | + * One or more key-value pairs for the client app to use in the challenge to be presented to the user. |
| 110 | + * Contains the question that is presented to the user. |
| 111 | + */ |
| 112 | + private Map<String, String> publicChallengeParameters; |
| 113 | + /** |
| 114 | + * Contains the valid answers for the question in publicChallengeParameters |
| 115 | + */ |
| 116 | + private Map<String, String> privateChallengeParameters; |
| 117 | + /** |
| 118 | + * Your name for the custom challenge, if this is a custom challenge. |
| 119 | + */ |
| 120 | + private String challengeMetadata; |
| 121 | + } |
| 122 | +} |
0 commit comments