diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolCreateAuthChallengeEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolCreateAuthChallengeEvent.java new file mode 100644 index 00000000..6739d27f --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolCreateAuthChallengeEvent.java @@ -0,0 +1,122 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.amazonaws.services.lambda.runtime.events; + +import lombok.*; + +import java.util.Map; + +/** + * Represent the class for the Cognito User Pool Create Auth Challenge Lambda Trigger + * + * See Create Auth Challenge Lambda Trigger + * + * @author jvdl + */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class CognitoUserPoolCreateAuthChallengeEvent extends CognitoUserPoolEvent { + + /** + * The request from the Amazon Cognito service. + */ + private Request request; + + /** + * The response from your Lambda trigger. + */ + private Response response; + + @Builder(setterPrefix = "with") + public CognitoUserPoolCreateAuthChallengeEvent( + String version, + String triggerSource, + String region, + String userPoolId, + String userName, + CallerContext callerContext, + Request request, + Response response) { + super(version, triggerSource, region, userPoolId, userName, callerContext); + this.request = request; + this.response = response; + } + + @Data + @EqualsAndHashCode(callSuper = true) + @NoArgsConstructor + public static class Request extends CognitoUserPoolEvent.Request { + /** + * 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. + */ + private Map clientMetadata; + /** + * The name of the new challenge. + */ + private String challengeName; + private ChallengeResult[] session; + /** + * This boolean is populated when PreventUserExistenceErrors is set to ENABLED for your User Pool client. + */ + private boolean userNotFound; + + @Builder(setterPrefix = "with") + public Request(Map userAttributes, Map clientMetadata, String challengeName, ChallengeResult[] session, boolean userNotFound) { + super(userAttributes); + this.clientMetadata = clientMetadata; + this.session = session; + this.userNotFound = userNotFound; + this.challengeName = challengeName; + } + } + + @AllArgsConstructor + @Builder(setterPrefix = "with") + @Data + @NoArgsConstructor + public static class ChallengeResult { + /** + * The challenge type. One of: "CUSTOM_CHALLENGE", "PASSWORD_VERIFIER", "SMS_MFA", "DEVICE_SRP_AUTH", "DEVICE_PASSWORD_VERIFIER", or "ADMIN_NO_SRP_AUTH". + */ + private String challengeName; + /** + * Set to true if the user successfully completed the challenge, or false otherwise. + */ + private boolean challengeResult; + /** + * Your name for the custom challenge. Used only if challengeName is CUSTOM_CHALLENGE. + */ + private String challengeMetadata; + } + + @AllArgsConstructor + @Builder(setterPrefix = "with") + @Data + @NoArgsConstructor + public static class Response { + /** + * One or more key-value pairs for the client app to use in the challenge to be presented to the user. + * Contains the question that is presented to the user. + */ + private Map publicChallengeParameters; + /** + * Contains the valid answers for the question in publicChallengeParameters + */ + private Map privateChallengeParameters; + /** + * Your name for the custom challenge, if this is a custom challenge. + */ + private String challengeMetadata; + } +} diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolCustomMessageEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolCustomMessageEvent.java new file mode 100644 index 00000000..f8642c75 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolCustomMessageEvent.java @@ -0,0 +1,99 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.amazonaws.services.lambda.runtime.events; + +import lombok.*; + +import java.util.Map; + +/** + * Represent the class for the Cognito User Pool Custom Message Lambda Trigger + * + * See Custom Message Lambda Trigger + * + * @author jvdl + */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class CognitoUserPoolCustomMessageEvent extends CognitoUserPoolEvent { + /** + * The request from the Amazon Cognito service. + */ + private Request request; + + /** + * The response from your Lambda trigger. + */ + private Response response; + + @Builder(setterPrefix = "with") + public CognitoUserPoolCustomMessageEvent( + String version, + String triggerSource, + String region, + String userPoolId, + String userName, + CallerContext callerContext, + Request request, + Response response) { + super(version, triggerSource, region, userPoolId, userName, callerContext); + this.request = request; + this.response = response; + } + + @Data + @EqualsAndHashCode(callSuper = true) + @NoArgsConstructor + public static class Request extends CognitoUserPoolEvent.Request { + /** + * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the custom message trigger. + */ + private Map clientMetadata; + /** + * A string for you to use as the placeholder for the verification code in the custom message. + */ + private String codeParameter; + /** + * The username parameter. It is a required request parameter for the admin create user flow. + */ + private String usernameParameter; + + @Builder(setterPrefix = "with") + public Request(Map userAttributes, Map clientMetadata, String codeParameter, String usernameParameter) { + super(userAttributes); + this.clientMetadata = clientMetadata; + this.codeParameter = codeParameter; + this.usernameParameter = usernameParameter; + } + } + + @Data + @AllArgsConstructor + @Builder(setterPrefix = "with") + @NoArgsConstructor + public static class Response { + /** + * The custom SMS message to be sent to your users. Must include the codeParameter value received in the request. + */ + private String smsMessage; + /** + * The custom email message to be sent to your users. Must include the codeParameter value received in the request. + */ + private String emailMessage; + /** + * The subject line for the custom message. + */ + private String emailSubject; + } +} diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolDefineAuthChallengeEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolDefineAuthChallengeEvent.java new file mode 100644 index 00000000..33fcf53a --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolDefineAuthChallengeEvent.java @@ -0,0 +1,121 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.amazonaws.services.lambda.runtime.events; + +import lombok.*; + +import java.util.Map; + +/** + * Represent the class for the Cognito User Pool Define Auth Challenge Lambda Trigger + * + * See Define Auth Challenge Lambda Trigger + * + * @author jvdl + */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class CognitoUserPoolDefineAuthChallengeEvent extends CognitoUserPoolEvent { + + /** + * The request from the Amazon Cognito service. + */ + private Request request; + + /** + * The response from your Lambda trigger. + */ + private Response response; + + @Builder(setterPrefix = "with") + public CognitoUserPoolDefineAuthChallengeEvent( + String version, + String triggerSource, + String region, + String userPoolId, + String userName, + CallerContext callerContext, + Request request, + Response response) { + super(version, triggerSource, region, userPoolId, userName, callerContext); + this.request = request; + this.response = response; + } + + @Data + @EqualsAndHashCode(callSuper = true) + @NoArgsConstructor + public static class Request extends CognitoUserPoolEvent.Request { + /** + * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the define auth challenge trigger. + */ + private Map clientMetadata; + + private ChallengeResult[] session; + + /** + * A Boolean that is populated when PreventUserExistenceErrors is set to ENABLED for your user pool client. + * A value of true means that the user id (user name, email address, etc.) did not match any existing users. + */ + private boolean userNotFound; + + @Builder(setterPrefix = "with") + public Request(Map userAttributes, Map clientMetadata, ChallengeResult[] session, boolean userNotFound) { + super(userAttributes); + this.clientMetadata = clientMetadata; + this.session = session; + this.userNotFound = userNotFound; + } + } + + @Data + @AllArgsConstructor + @Builder(setterPrefix = "with") + @NoArgsConstructor + public static class ChallengeResult { + /** + * The challenge type. One of: CUSTOM_CHALLENGE, SRP_A, PASSWORD_VERIFIER, SMS_MFA, DEVICE_SRP_AUTH, DEVICE_PASSWORD_VERIFIER, or ADMIN_NO_SRP_AUTH. + */ + private String challengeName; + /** + * Set to true if the user successfully completed the challenge, or false otherwise. + */ + private boolean challengeResult; + /** + * Your name for the custom challenge. Used only if challengeName is CUSTOM_CHALLENGE. + */ + private String challengeMetadata; + } + + @Data + @AllArgsConstructor + @Builder(setterPrefix = "with") + @NoArgsConstructor + public static class Response { + /** + * Name of the next challenge, if you want to present a new challenge to your user. + */ + private String challengeName; + + /** + * Set to true if you determine that the user has been sufficiently authenticated by completing the challenges, or false otherwise. + */ + private boolean issueTokens; + + /** + * Set to true if you want to terminate the current authentication process, or false otherwise. + */ + private boolean failAuthentication; + } +} diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolEvent.java new file mode 100644 index 00000000..17c4b409 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolEvent.java @@ -0,0 +1,89 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.amazonaws.services.lambda.runtime.events; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +/** + * Represent the base class for all Cognito User Pool Events + * + * See Customizing User Pool Workflows with Lambda Triggers + * + * @author jvdl + */ +@AllArgsConstructor +@Data +@NoArgsConstructor +public abstract class CognitoUserPoolEvent { + + /** + * The version number of your Lambda function. + */ + private String version; + + /** + * The name of the event that triggered the Lambda function. + */ + private String triggerSource; + + /** + * The AWS Region. + */ + private String region; + + /** + * The user pool ID for the user pool. + */ + private String userPoolId; + + /** + * The username of the current user. + */ + private String userName; + + /** + * The caller context. + */ + private CallerContext callerContext; + + @AllArgsConstructor + @Data + @NoArgsConstructor + public static abstract class Request { + /** + * One or more pairs of user attribute names and values. + */ + private Map userAttributes; + } + + @AllArgsConstructor + @Builder(setterPrefix = "with") + @Data + @NoArgsConstructor + public static class CallerContext { + /** + * The AWS SDK version number. + */ + private String awsSdkVersion; + + /** + * The ID of the client associated with the user pool. + */ + private String clientId; + } +} diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolMigrateUserEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolMigrateUserEvent.java new file mode 100644 index 00000000..ee47c360 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolMigrateUserEvent.java @@ -0,0 +1,119 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.amazonaws.services.lambda.runtime.events; + +import lombok.*; + +import java.util.Map; + +/** + * Represent the class for the Cognito User Pool Migrate User Lambda Trigger + * + * See Migrate User Lambda Trigger + * + * @author jvdl + */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class CognitoUserPoolMigrateUserEvent extends CognitoUserPoolEvent { + /** + * The request from the Amazon Cognito service. + */ + private Request request; + + /** + * The response from your Lambda trigger. + */ + private Response response; + + @Builder(setterPrefix = "with") + public CognitoUserPoolMigrateUserEvent( + String version, + String triggerSource, + String region, + String userPoolId, + String userName, + CallerContext callerContext, + Request request, + Response response) { + super(version, triggerSource, region, userPoolId, userName, callerContext); + this.request = request; + this.response = response; + } + + @Data + @EqualsAndHashCode(callSuper = true) + @NoArgsConstructor + public static class Request extends CognitoUserPoolEvent.Request { + /** + * The username entered by the user. + */ + private String userName; + /** + * The password entered by the user for sign-in. It is not set in the forgot-password flow. + */ + private String password; + /** + * One or more key-value pairs containing the validation data in the user's sign-in request. + */ + private Map validationData; + /** + * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the migrate user trigger. + */ + private Map clientMetadata; + + @Builder(setterPrefix = "with") + public Request(Map userAttributes, Map validationData, Map clientMetadata, String userName, String password) { + super(userAttributes); + this.validationData = validationData; + this.clientMetadata = clientMetadata; + this.userName = userName; + this.password = password; + } + } + + @AllArgsConstructor + @Builder(setterPrefix = "with") + @Data + @NoArgsConstructor + public static class Response { + + /** + * It must contain one or more name-value pairs representing user attributes to be stored in the user profile in your user pool. + */ + private Map userAttributes; + + /** + * During sign-in, this attribute can be set to CONFIRMED, or not set, to auto-confirm your users and allow them to sign-in with their previous passwords. + */ + private String finalUserStatus; + + /** + * This attribute can be set to "SUPPRESS" to suppress the welcome message usually sent by Amazon Cognito to new users. + * If this attribute is not returned, the welcome message will be sent. + */ + private String messageAction; + + /** + * This attribute can be set to "EMAIL" to send the welcome message by email, or "SMS" to send the welcome message by SMS. + * If this attribute is not returned, the welcome message will be sent by SMS. + */ + private String[] desiredDeliveryMediums; + + /** + * If this parameter is set to "true" and the phone number or email address specified in the UserAttributes parameter already exists as an alias with a different user, the API call will migrate the alias from the previous user to the newly created user. + */ + private boolean forceAliasCreation; + } +} diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPostAuthenticationEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPostAuthenticationEvent.java new file mode 100644 index 00000000..5d2f5089 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPostAuthenticationEvent.java @@ -0,0 +1,73 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.amazonaws.services.lambda.runtime.events; + +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.util.Map; + +/** + * Represent the class for the Cognito User Pool Post Authentication Lambda Trigger + * + * See Post Authentication Lambda Trigger + * + * @author jvdl + */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class CognitoUserPoolPostAuthenticationEvent extends CognitoUserPoolEvent { + + /** + * The request from the Amazon Cognito service. + */ + private Request request; + + @Builder(setterPrefix = "with") + public CognitoUserPoolPostAuthenticationEvent( + String version, + String triggerSource, + String region, + String userPoolId, + String userName, + CallerContext callerContext, + Request request) { + super(version, triggerSource, region, userPoolId, userName, callerContext); + this.request = request; + } + + @Data + @EqualsAndHashCode(callSuper = true) + @NoArgsConstructor + public static class Request extends CognitoUserPoolEvent.Request { + /** + * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the post authentication trigger. + */ + private Map clientMetadata; + + /** + * This flag indicates if the user has signed in on a new device. + */ + private boolean newDeviceUsed; + + @Builder(setterPrefix = "with") + public Request(Map userAttributes, Map clientMetadata, boolean newDeviceUsed) { + super(userAttributes); + this.clientMetadata = clientMetadata; + this.newDeviceUsed = newDeviceUsed; + } + } +} diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPostConfirmationEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPostConfirmationEvent.java new file mode 100644 index 00000000..340b2a88 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPostConfirmationEvent.java @@ -0,0 +1,67 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.amazonaws.services.lambda.runtime.events; + +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.util.Map; + +/** + * Represent the class for the Cognito User Pool Post Confirmation Lambda Trigger + * + * See Post Confirmation Lambda Trigger + * + * @author jvdl + */ +@EqualsAndHashCode(callSuper = true) +@Data +@NoArgsConstructor +public class CognitoUserPoolPostConfirmationEvent extends CognitoUserPoolEvent { + + /** + * The request from the Amazon Cognito service. + */ + private Request request; + + @Builder(setterPrefix = "with") + public CognitoUserPoolPostConfirmationEvent( + String version, + String triggerSource, + String region, + String userPoolId, + String userName, + CallerContext callerContext, + Request request) { + super(version, triggerSource, region, userPoolId, userName, callerContext); + this.request = request; + } + + @Data + @EqualsAndHashCode(callSuper = true) + @NoArgsConstructor + public static class Request extends CognitoUserPoolEvent.Request { + /** + * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the post confirmation trigger. + */ + private Map clientMetadata; + + @Builder(setterPrefix = "with") + public Request(Map userAttributes, Map clientMetadata) { + super(userAttributes); + this.clientMetadata = clientMetadata; + } + } +} diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreAuthenticationEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreAuthenticationEvent.java new file mode 100644 index 00000000..26f45bb9 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreAuthenticationEvent.java @@ -0,0 +1,74 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.amazonaws.services.lambda.runtime.events; + +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.util.Map; + +/** + * Represent the class for the Cognito User Pool Pre Authentication Lambda Trigger + * + * See Pre Authentication Lambda Trigger + * + * @author jvdl + */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class CognitoUserPoolPreAuthenticationEvent extends CognitoUserPoolEvent { + + /** + * The request from the Amazon Cognito service. + */ + private Request request; + + @Builder(setterPrefix = "with") + public CognitoUserPoolPreAuthenticationEvent( + String version, + String triggerSource, + String region, + String userPoolId, + String userName, + CallerContext callerContext, + Request request) { + super(version, triggerSource, region, userPoolId, userName, callerContext); + this.request = request; + } + + @Data + @EqualsAndHashCode(callSuper = true) + @NoArgsConstructor + public static class Request extends CognitoUserPoolEvent.Request { + /** + * One or more name-value pairs containing the validation data in the request to register a user. + * The validation data is set and then passed from the client in the request to register a user. + */ + private Map validationData; + + /** + * This boolean is populated when PreventUserExistenceErrors is set to ENABLED for your User Pool client. + */ + private boolean userNotFound; + + @Builder(setterPrefix = "with") + public Request(Map userAttributes, Map validationData, boolean userNotFound) { + super(userAttributes); + this.validationData = validationData; + this.userNotFound = userNotFound; + } + } +} diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreSignUpEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreSignUpEvent.java new file mode 100644 index 00000000..2a7f0e3f --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreSignUpEvent.java @@ -0,0 +1,102 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.amazonaws.services.lambda.runtime.events; + +import lombok.*; + +import java.util.Map; + +/** + * Represent the class for the Cognito User Pool Pre Sign-up Lambda Trigger + * + * See Pre Sign-up Lambda Trigger + * + * @author jvdl + */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class CognitoUserPoolPreSignUpEvent extends CognitoUserPoolEvent { + + /** + * The request from the Amazon Cognito service. + */ + private Request request; + + /** + * The response from your Lambda trigger. + */ + private Response response; + + @Builder(setterPrefix = "with") + public CognitoUserPoolPreSignUpEvent( + String version, + String triggerSource, + String region, + String userPoolId, + String userName, + CallerContext callerContext, + Request request, + Response response) { + super(version, triggerSource, region, userPoolId, userName, callerContext); + this.request = request; + this.response = response; + } + + @Data + @EqualsAndHashCode(callSuper = true) + @NoArgsConstructor + public static class Request extends CognitoUserPoolEvent.Request { + /** + * One or more name-value pairs containing the validation data in the request to register a user. + * The validation data is set and then passed from the client in the request to register a user. + */ + private Map validationData; + + /** + * One or more key-value pairs that you can provide as custom input + * to the Lambda function that you specify for the pre sign-up trigger. + */ + private Map clientMetadata; + + @Builder(setterPrefix = "with") + public Request(Map userAttributes, Map validationData, Map clientMetadata) { + super(userAttributes); + this.validationData = validationData; + this.clientMetadata = clientMetadata; + } + } + + @AllArgsConstructor + @Builder(setterPrefix = "with") + @Data + @NoArgsConstructor + public static class Response { + /** + * Set to true to auto-confirm the user, or false otherwise. + */ + private boolean autoConfirmUser; + + /** + * Set to true to set as verified the phone number of a user who is signing up, or false otherwise. + * If autoVerifyPhone is set to true, the phone_number attribute must have a valid, non-null value. + */ + private boolean autoVerifyPhone; + + /** + * Set to true to set as verified the email of a user who is signing up, or false otherwise. + * If autoVerifyEmail is set to true, the email attribute must have a valid, non-null value. + */ + private boolean autoVerifyEmail; + } +} diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreTokenGenerationEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreTokenGenerationEvent.java new file mode 100644 index 00000000..db73bbd9 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreTokenGenerationEvent.java @@ -0,0 +1,123 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.amazonaws.services.lambda.runtime.events; + +import lombok.*; + +import java.util.Map; + +/** + * Represent the class for the Cognito User Pool Pre Token Generation Lambda Trigger + * + * See Pre Token Generation Lambda Trigger + * + * @author jvdl + */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class CognitoUserPoolPreTokenGenerationEvent extends CognitoUserPoolEvent { + /** + * The request from the Amazon Cognito service. + */ + private Request request; + + /** + * The response from your Lambda trigger. + */ + private Response response; + + @Builder(setterPrefix = "with") + public CognitoUserPoolPreTokenGenerationEvent( + String version, + String triggerSource, + String region, + String userPoolId, + String userName, + CallerContext callerContext, + Request request, + Response response) { + super(version, triggerSource, region, userPoolId, userName, callerContext); + this.request = request; + this.response = response; + } + + @Data + @EqualsAndHashCode(callSuper = true) + @NoArgsConstructor + public static class Request extends CognitoUserPoolEvent.Request { + /** + * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the pre token generation trigger. + */ + private Map clientMetadata; + + /** + * The input object containing the current group configuration. + */ + private GroupConfiguration groupConfiguration; + + @Builder(setterPrefix = "with") + public Request(Map userAttributes, Map clientMetadata, GroupConfiguration groupConfiguration) { + super(userAttributes); + this.clientMetadata = clientMetadata; + this.groupConfiguration = groupConfiguration; + } + } + + @Data + @AllArgsConstructor + @Builder(setterPrefix = "with") + @NoArgsConstructor + public static class GroupConfiguration { + /** + * A list of the group names that are associated with the user that the identity token is issued for. + */ + private String[] groupsToOverride; + /** + * A list of the current IAM roles associated with these groups. + */ + private String[] iamRolesToOverride; + /** + * Indicates the preferred IAM role. + */ + private String preferredRole; + } + + @Data + @AllArgsConstructor + @Builder(setterPrefix = "with") + @NoArgsConstructor + public static class Response { + private ClaimsOverrideDetails claimsOverrideDetails; + } + + @Data + @AllArgsConstructor + @Builder(setterPrefix = "with") + @NoArgsConstructor + public static class ClaimsOverrideDetails { + /** + * A map of one or more key-value pairs of claims to add or override. + * For group related claims, use groupOverrideDetails instead. + */ + private Map claimsToAddOrOverride; + /** + * A list that contains claims to be suppressed from the identity token. + */ + private String[] claimsToSuppress; + /** + * The output object containing the current group configuration. + */ + private GroupConfiguration groupOverrideDetails; + } +} diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolVerifyAuthChallengeResponseEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolVerifyAuthChallengeResponseEvent.java new file mode 100644 index 00000000..1289c07b --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolVerifyAuthChallengeResponseEvent.java @@ -0,0 +1,100 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.amazonaws.services.lambda.runtime.events; + +import lombok.*; + +import java.util.Map; + +/** + * Represent the class for the Cognito User Pool Verify Auth Challenge Response Lambda Trigger + * + * See Verify Auth Challenge Response Lambda Trigger + * + * @author jvdl + */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class CognitoUserPoolVerifyAuthChallengeResponseEvent extends CognitoUserPoolEvent { + /** + * The request from the Amazon Cognito service. + */ + private Request request; + + /** + * The response from your Lambda trigger. + */ + private Response response; + + @Builder(setterPrefix = "with") + public CognitoUserPoolVerifyAuthChallengeResponseEvent( + String version, + String triggerSource, + String region, + String userPoolId, + String userName, + CallerContext callerContext, + Request request, + Response response) { + super(version, triggerSource, region, userPoolId, userName, callerContext); + this.request = request; + this.response = response; + } + + @Data + @EqualsAndHashCode(callSuper = true) + @NoArgsConstructor + public static class Request extends CognitoUserPoolEvent.Request { + /** + * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the verify auth challenge trigger. + */ + private Map clientMetadata; + /** + * This parameter comes from the Create Auth Challenge trigger, and is compared against a user’s challengeAnswer to determine whether the user passed the challenge. + */ + private Map privateChallengeParameters; + /** + * The answer from the user's response to the challenge. + */ + private Map challengeAnswer; + /** + * This boolean is populated when PreventUserExistenceErrors is set to ENABLED for your User Pool client + */ + private boolean userNotFound; + + @Builder(setterPrefix = "with") + public Request(Map userAttributes, + Map clientMetadata, + Map challengeAnswer, + Map privateChallengeParameters, + boolean userNotFound) { + super(userAttributes); + this.clientMetadata = clientMetadata; + this.userNotFound = userNotFound; + this.challengeAnswer = challengeAnswer; + this.privateChallengeParameters = privateChallengeParameters; + } + } + + @AllArgsConstructor + @Builder(setterPrefix = "with") + @Data + @NoArgsConstructor + public static class Response { + /** + * Set to true if the user has successfully completed the challenge, or false otherwise. + */ + private boolean answerCorrect; + } +}