Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
software.amazon.awssdk.services.cognitoidentityprovider.model.AdminRespondToAuthChallengeResponse Maven / Gradle / Ivy
/*
* Copyright 2014-2019 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 software.amazon.awssdk.services.cognitoidentityprovider.model;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Responds to the authentication challenge, as an administrator.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class AdminRespondToAuthChallengeResponse extends CognitoIdentityProviderResponse implements
ToCopyableBuilder {
private static final SdkField CHALLENGE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(AdminRespondToAuthChallengeResponse::challengeNameAsString)).setter(setter(Builder::challengeName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ChallengeName").build()).build();
private static final SdkField SESSION_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(AdminRespondToAuthChallengeResponse::session)).setter(setter(Builder::session))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Session").build()).build();
private static final SdkField> CHALLENGE_PARAMETERS_FIELD = SdkField
.> builder(MarshallingType.MAP)
.getter(getter(AdminRespondToAuthChallengeResponse::challengeParameters))
.setter(setter(Builder::challengeParameters))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ChallengeParameters").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final SdkField AUTHENTICATION_RESULT_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.getter(getter(AdminRespondToAuthChallengeResponse::authenticationResult))
.setter(setter(Builder::authenticationResult)).constructor(AuthenticationResultType::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AuthenticationResult").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CHALLENGE_NAME_FIELD,
SESSION_FIELD, CHALLENGE_PARAMETERS_FIELD, AUTHENTICATION_RESULT_FIELD));
private final String challengeName;
private final String session;
private final Map challengeParameters;
private final AuthenticationResultType authenticationResult;
private AdminRespondToAuthChallengeResponse(BuilderImpl builder) {
super(builder);
this.challengeName = builder.challengeName;
this.session = builder.session;
this.challengeParameters = builder.challengeParameters;
this.authenticationResult = builder.authenticationResult;
}
/**
*
* The name of the challenge. For more information, see .
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #challengeName}
* will return {@link ChallengeNameType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #challengeNameAsString}.
*
*
* @return The name of the challenge. For more information, see .
* @see ChallengeNameType
*/
public ChallengeNameType challengeName() {
return ChallengeNameType.fromValue(challengeName);
}
/**
*
* The name of the challenge. For more information, see .
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #challengeName}
* will return {@link ChallengeNameType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #challengeNameAsString}.
*
*
* @return The name of the challenge. For more information, see .
* @see ChallengeNameType
*/
public String challengeNameAsString() {
return challengeName;
}
/**
*
* The session which should be passed both ways in challenge-response calls to the service. If the or API call
* determines that the caller needs to go through another challenge, they return a session with other challenge
* parameters. This session should be passed as it is to the next RespondToAuthChallenge
API call.
*
*
* @return The session which should be passed both ways in challenge-response calls to the service. If the or API
* call determines that the caller needs to go through another challenge, they return a session with other
* challenge parameters. This session should be passed as it is to the next
* RespondToAuthChallenge
API call.
*/
public String session() {
return session;
}
/**
*
* The challenge parameters. For more information, see .
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return The challenge parameters. For more information, see .
*/
public Map challengeParameters() {
return challengeParameters;
}
/**
*
* The result returned by the server in response to the authentication request.
*
*
* @return The result returned by the server in response to the authentication request.
*/
public AuthenticationResultType authenticationResult() {
return authenticationResult;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(challengeNameAsString());
hashCode = 31 * hashCode + Objects.hashCode(session());
hashCode = 31 * hashCode + Objects.hashCode(challengeParameters());
hashCode = 31 * hashCode + Objects.hashCode(authenticationResult());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof AdminRespondToAuthChallengeResponse)) {
return false;
}
AdminRespondToAuthChallengeResponse other = (AdminRespondToAuthChallengeResponse) obj;
return Objects.equals(challengeNameAsString(), other.challengeNameAsString())
&& Objects.equals(session(), other.session())
&& Objects.equals(challengeParameters(), other.challengeParameters())
&& Objects.equals(authenticationResult(), other.authenticationResult());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public String toString() {
return ToString.builder("AdminRespondToAuthChallengeResponse").add("ChallengeName", challengeNameAsString())
.add("Session", session()).add("ChallengeParameters", challengeParameters())
.add("AuthenticationResult", authenticationResult()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ChallengeName":
return Optional.ofNullable(clazz.cast(challengeNameAsString()));
case "Session":
return Optional.ofNullable(clazz.cast(session()));
case "ChallengeParameters":
return Optional.ofNullable(clazz.cast(challengeParameters()));
case "AuthenticationResult":
return Optional.ofNullable(clazz.cast(authenticationResult()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function getter(Function g) {
return obj -> g.apply((AdminRespondToAuthChallengeResponse) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends CognitoIdentityProviderResponse.Builder, SdkPojo,
CopyableBuilder {
/**
*
* The name of the challenge. For more information, see .
*
*
* @param challengeName
* The name of the challenge. For more information, see .
* @see ChallengeNameType
* @return Returns a reference to this object so that method calls can be chained together.
* @see ChallengeNameType
*/
Builder challengeName(String challengeName);
/**
*
* The name of the challenge. For more information, see .
*
*
* @param challengeName
* The name of the challenge. For more information, see .
* @see ChallengeNameType
* @return Returns a reference to this object so that method calls can be chained together.
* @see ChallengeNameType
*/
Builder challengeName(ChallengeNameType challengeName);
/**
*
* The session which should be passed both ways in challenge-response calls to the service. If the or API call
* determines that the caller needs to go through another challenge, they return a session with other challenge
* parameters. This session should be passed as it is to the next RespondToAuthChallenge
API call.
*
*
* @param session
* The session which should be passed both ways in challenge-response calls to the service. If the or API
* call determines that the caller needs to go through another challenge, they return a session with
* other challenge parameters. This session should be passed as it is to the next
* RespondToAuthChallenge
API call.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder session(String session);
/**
*
* The challenge parameters. For more information, see .
*
*
* @param challengeParameters
* The challenge parameters. For more information, see .
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder challengeParameters(Map challengeParameters);
/**
*
* The result returned by the server in response to the authentication request.
*
*
* @param authenticationResult
* The result returned by the server in response to the authentication request.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder authenticationResult(AuthenticationResultType authenticationResult);
/**
*
* The result returned by the server in response to the authentication request.
*
* This is a convenience that creates an instance of the {@link AuthenticationResultType.Builder} avoiding the
* need to create one manually via {@link AuthenticationResultType#builder()}.
*
* When the {@link Consumer} completes, {@link AuthenticationResultType.Builder#build()} is called immediately
* and its result is passed to {@link #authenticationResult(AuthenticationResultType)}.
*
* @param authenticationResult
* a consumer that will call methods on {@link AuthenticationResultType.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #authenticationResult(AuthenticationResultType)
*/
default Builder authenticationResult(Consumer authenticationResult) {
return authenticationResult(AuthenticationResultType.builder().applyMutation(authenticationResult).build());
}
}
static final class BuilderImpl extends CognitoIdentityProviderResponse.BuilderImpl implements Builder {
private String challengeName;
private String session;
private Map challengeParameters = DefaultSdkAutoConstructMap.getInstance();
private AuthenticationResultType authenticationResult;
private BuilderImpl() {
}
private BuilderImpl(AdminRespondToAuthChallengeResponse model) {
super(model);
challengeName(model.challengeName);
session(model.session);
challengeParameters(model.challengeParameters);
authenticationResult(model.authenticationResult);
}
public final String getChallengeNameAsString() {
return challengeName;
}
@Override
public final Builder challengeName(String challengeName) {
this.challengeName = challengeName;
return this;
}
@Override
public final Builder challengeName(ChallengeNameType challengeName) {
this.challengeName(challengeName == null ? null : challengeName.toString());
return this;
}
public final void setChallengeName(String challengeName) {
this.challengeName = challengeName;
}
public final String getSession() {
return session;
}
@Override
public final Builder session(String session) {
this.session = session;
return this;
}
public final void setSession(String session) {
this.session = session;
}
public final Map getChallengeParameters() {
return challengeParameters;
}
@Override
public final Builder challengeParameters(Map challengeParameters) {
this.challengeParameters = ChallengeParametersTypeCopier.copy(challengeParameters);
return this;
}
public final void setChallengeParameters(Map challengeParameters) {
this.challengeParameters = ChallengeParametersTypeCopier.copy(challengeParameters);
}
public final AuthenticationResultType.Builder getAuthenticationResult() {
return authenticationResult != null ? authenticationResult.toBuilder() : null;
}
@Override
public final Builder authenticationResult(AuthenticationResultType authenticationResult) {
this.authenticationResult = authenticationResult;
return this;
}
public final void setAuthenticationResult(AuthenticationResultType.BuilderImpl authenticationResult) {
this.authenticationResult = authenticationResult != null ? authenticationResult.build() : null;
}
@Override
public AdminRespondToAuthChallengeResponse build() {
return new AdminRespondToAuthChallengeResponse(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}