All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.iam.model.PasswordPolicy 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.iam.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
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.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Contains information about the account password policy. *

*

* This data type is used as a response element in the GetAccountPasswordPolicy operation. *

*/ @Generated("software.amazon.awssdk:codegen") public final class PasswordPolicy implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField MINIMUM_PASSWORD_LENGTH_FIELD = SdkField. builder(MarshallingType.INTEGER) .getter(getter(PasswordPolicy::minimumPasswordLength)).setter(setter(Builder::minimumPasswordLength)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MinimumPasswordLength").build()) .build(); private static final SdkField REQUIRE_SYMBOLS_FIELD = SdkField. builder(MarshallingType.BOOLEAN) .getter(getter(PasswordPolicy::requireSymbols)).setter(setter(Builder::requireSymbols)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RequireSymbols").build()).build(); private static final SdkField REQUIRE_NUMBERS_FIELD = SdkField. builder(MarshallingType.BOOLEAN) .getter(getter(PasswordPolicy::requireNumbers)).setter(setter(Builder::requireNumbers)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RequireNumbers").build()).build(); private static final SdkField REQUIRE_UPPERCASE_CHARACTERS_FIELD = SdkField . builder(MarshallingType.BOOLEAN) .getter(getter(PasswordPolicy::requireUppercaseCharacters)) .setter(setter(Builder::requireUppercaseCharacters)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RequireUppercaseCharacters").build()) .build(); private static final SdkField REQUIRE_LOWERCASE_CHARACTERS_FIELD = SdkField . builder(MarshallingType.BOOLEAN) .getter(getter(PasswordPolicy::requireLowercaseCharacters)) .setter(setter(Builder::requireLowercaseCharacters)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RequireLowercaseCharacters").build()) .build(); private static final SdkField ALLOW_USERS_TO_CHANGE_PASSWORD_FIELD = SdkField . builder(MarshallingType.BOOLEAN) .getter(getter(PasswordPolicy::allowUsersToChangePassword)) .setter(setter(Builder::allowUsersToChangePassword)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AllowUsersToChangePassword").build()) .build(); private static final SdkField EXPIRE_PASSWORDS_FIELD = SdkField. builder(MarshallingType.BOOLEAN) .getter(getter(PasswordPolicy::expirePasswords)).setter(setter(Builder::expirePasswords)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExpirePasswords").build()).build(); private static final SdkField MAX_PASSWORD_AGE_FIELD = SdkField. builder(MarshallingType.INTEGER) .getter(getter(PasswordPolicy::maxPasswordAge)).setter(setter(Builder::maxPasswordAge)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MaxPasswordAge").build()).build(); private static final SdkField PASSWORD_REUSE_PREVENTION_FIELD = SdkField. builder(MarshallingType.INTEGER) .getter(getter(PasswordPolicy::passwordReusePrevention)).setter(setter(Builder::passwordReusePrevention)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PasswordReusePrevention").build()) .build(); private static final SdkField HARD_EXPIRY_FIELD = SdkField. builder(MarshallingType.BOOLEAN) .getter(getter(PasswordPolicy::hardExpiry)).setter(setter(Builder::hardExpiry)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HardExpiry").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(MINIMUM_PASSWORD_LENGTH_FIELD, REQUIRE_SYMBOLS_FIELD, REQUIRE_NUMBERS_FIELD, REQUIRE_UPPERCASE_CHARACTERS_FIELD, REQUIRE_LOWERCASE_CHARACTERS_FIELD, ALLOW_USERS_TO_CHANGE_PASSWORD_FIELD, EXPIRE_PASSWORDS_FIELD, MAX_PASSWORD_AGE_FIELD, PASSWORD_REUSE_PREVENTION_FIELD, HARD_EXPIRY_FIELD)); private static final long serialVersionUID = 1L; private final Integer minimumPasswordLength; private final Boolean requireSymbols; private final Boolean requireNumbers; private final Boolean requireUppercaseCharacters; private final Boolean requireLowercaseCharacters; private final Boolean allowUsersToChangePassword; private final Boolean expirePasswords; private final Integer maxPasswordAge; private final Integer passwordReusePrevention; private final Boolean hardExpiry; private PasswordPolicy(BuilderImpl builder) { this.minimumPasswordLength = builder.minimumPasswordLength; this.requireSymbols = builder.requireSymbols; this.requireNumbers = builder.requireNumbers; this.requireUppercaseCharacters = builder.requireUppercaseCharacters; this.requireLowercaseCharacters = builder.requireLowercaseCharacters; this.allowUsersToChangePassword = builder.allowUsersToChangePassword; this.expirePasswords = builder.expirePasswords; this.maxPasswordAge = builder.maxPasswordAge; this.passwordReusePrevention = builder.passwordReusePrevention; this.hardExpiry = builder.hardExpiry; } /** *

* Minimum length to require for IAM user passwords. *

* * @return Minimum length to require for IAM user passwords. */ public Integer minimumPasswordLength() { return minimumPasswordLength; } /** *

* Specifies whether to require symbols for IAM user passwords. *

* * @return Specifies whether to require symbols for IAM user passwords. */ public Boolean requireSymbols() { return requireSymbols; } /** *

* Specifies whether to require numbers for IAM user passwords. *

* * @return Specifies whether to require numbers for IAM user passwords. */ public Boolean requireNumbers() { return requireNumbers; } /** *

* Specifies whether to require uppercase characters for IAM user passwords. *

* * @return Specifies whether to require uppercase characters for IAM user passwords. */ public Boolean requireUppercaseCharacters() { return requireUppercaseCharacters; } /** *

* Specifies whether to require lowercase characters for IAM user passwords. *

* * @return Specifies whether to require lowercase characters for IAM user passwords. */ public Boolean requireLowercaseCharacters() { return requireLowercaseCharacters; } /** *

* Specifies whether IAM users are allowed to change their own password. *

* * @return Specifies whether IAM users are allowed to change their own password. */ public Boolean allowUsersToChangePassword() { return allowUsersToChangePassword; } /** *

* Indicates whether passwords in the account expire. Returns true if MaxPasswordAge contains a value * greater than 0. Returns false if MaxPasswordAge is 0 or not present. *

* * @return Indicates whether passwords in the account expire. Returns true if MaxPasswordAge contains a * value greater than 0. Returns false if MaxPasswordAge is 0 or not present. */ public Boolean expirePasswords() { return expirePasswords; } /** *

* The number of days that an IAM user password is valid. *

* * @return The number of days that an IAM user password is valid. */ public Integer maxPasswordAge() { return maxPasswordAge; } /** *

* Specifies the number of previous passwords that IAM users are prevented from reusing. *

* * @return Specifies the number of previous passwords that IAM users are prevented from reusing. */ public Integer passwordReusePrevention() { return passwordReusePrevention; } /** *

* Specifies whether IAM users are prevented from setting a new password after their password has expired. *

* * @return Specifies whether IAM users are prevented from setting a new password after their password has expired. */ public Boolean hardExpiry() { return hardExpiry; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(minimumPasswordLength()); hashCode = 31 * hashCode + Objects.hashCode(requireSymbols()); hashCode = 31 * hashCode + Objects.hashCode(requireNumbers()); hashCode = 31 * hashCode + Objects.hashCode(requireUppercaseCharacters()); hashCode = 31 * hashCode + Objects.hashCode(requireLowercaseCharacters()); hashCode = 31 * hashCode + Objects.hashCode(allowUsersToChangePassword()); hashCode = 31 * hashCode + Objects.hashCode(expirePasswords()); hashCode = 31 * hashCode + Objects.hashCode(maxPasswordAge()); hashCode = 31 * hashCode + Objects.hashCode(passwordReusePrevention()); hashCode = 31 * hashCode + Objects.hashCode(hardExpiry()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof PasswordPolicy)) { return false; } PasswordPolicy other = (PasswordPolicy) obj; return Objects.equals(minimumPasswordLength(), other.minimumPasswordLength()) && Objects.equals(requireSymbols(), other.requireSymbols()) && Objects.equals(requireNumbers(), other.requireNumbers()) && Objects.equals(requireUppercaseCharacters(), other.requireUppercaseCharacters()) && Objects.equals(requireLowercaseCharacters(), other.requireLowercaseCharacters()) && Objects.equals(allowUsersToChangePassword(), other.allowUsersToChangePassword()) && Objects.equals(expirePasswords(), other.expirePasswords()) && Objects.equals(maxPasswordAge(), other.maxPasswordAge()) && Objects.equals(passwordReusePrevention(), other.passwordReusePrevention()) && Objects.equals(hardExpiry(), other.hardExpiry()); } @Override public String toString() { return ToString.builder("PasswordPolicy").add("MinimumPasswordLength", minimumPasswordLength()) .add("RequireSymbols", requireSymbols()).add("RequireNumbers", requireNumbers()) .add("RequireUppercaseCharacters", requireUppercaseCharacters()) .add("RequireLowercaseCharacters", requireLowercaseCharacters()) .add("AllowUsersToChangePassword", allowUsersToChangePassword()).add("ExpirePasswords", expirePasswords()) .add("MaxPasswordAge", maxPasswordAge()).add("PasswordReusePrevention", passwordReusePrevention()) .add("HardExpiry", hardExpiry()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "MinimumPasswordLength": return Optional.ofNullable(clazz.cast(minimumPasswordLength())); case "RequireSymbols": return Optional.ofNullable(clazz.cast(requireSymbols())); case "RequireNumbers": return Optional.ofNullable(clazz.cast(requireNumbers())); case "RequireUppercaseCharacters": return Optional.ofNullable(clazz.cast(requireUppercaseCharacters())); case "RequireLowercaseCharacters": return Optional.ofNullable(clazz.cast(requireLowercaseCharacters())); case "AllowUsersToChangePassword": return Optional.ofNullable(clazz.cast(allowUsersToChangePassword())); case "ExpirePasswords": return Optional.ofNullable(clazz.cast(expirePasswords())); case "MaxPasswordAge": return Optional.ofNullable(clazz.cast(maxPasswordAge())); case "PasswordReusePrevention": return Optional.ofNullable(clazz.cast(passwordReusePrevention())); case "HardExpiry": return Optional.ofNullable(clazz.cast(hardExpiry())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((PasswordPolicy) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* Minimum length to require for IAM user passwords. *

* * @param minimumPasswordLength * Minimum length to require for IAM user passwords. * @return Returns a reference to this object so that method calls can be chained together. */ Builder minimumPasswordLength(Integer minimumPasswordLength); /** *

* Specifies whether to require symbols for IAM user passwords. *

* * @param requireSymbols * Specifies whether to require symbols for IAM user passwords. * @return Returns a reference to this object so that method calls can be chained together. */ Builder requireSymbols(Boolean requireSymbols); /** *

* Specifies whether to require numbers for IAM user passwords. *

* * @param requireNumbers * Specifies whether to require numbers for IAM user passwords. * @return Returns a reference to this object so that method calls can be chained together. */ Builder requireNumbers(Boolean requireNumbers); /** *

* Specifies whether to require uppercase characters for IAM user passwords. *

* * @param requireUppercaseCharacters * Specifies whether to require uppercase characters for IAM user passwords. * @return Returns a reference to this object so that method calls can be chained together. */ Builder requireUppercaseCharacters(Boolean requireUppercaseCharacters); /** *

* Specifies whether to require lowercase characters for IAM user passwords. *

* * @param requireLowercaseCharacters * Specifies whether to require lowercase characters for IAM user passwords. * @return Returns a reference to this object so that method calls can be chained together. */ Builder requireLowercaseCharacters(Boolean requireLowercaseCharacters); /** *

* Specifies whether IAM users are allowed to change their own password. *

* * @param allowUsersToChangePassword * Specifies whether IAM users are allowed to change their own password. * @return Returns a reference to this object so that method calls can be chained together. */ Builder allowUsersToChangePassword(Boolean allowUsersToChangePassword); /** *

* Indicates whether passwords in the account expire. Returns true if MaxPasswordAge contains a * value greater than 0. Returns false if MaxPasswordAge is 0 or not present. *

* * @param expirePasswords * Indicates whether passwords in the account expire. Returns true if MaxPasswordAge * contains a value greater than 0. Returns false if MaxPasswordAge is 0 or not present. * @return Returns a reference to this object so that method calls can be chained together. */ Builder expirePasswords(Boolean expirePasswords); /** *

* The number of days that an IAM user password is valid. *

* * @param maxPasswordAge * The number of days that an IAM user password is valid. * @return Returns a reference to this object so that method calls can be chained together. */ Builder maxPasswordAge(Integer maxPasswordAge); /** *

* Specifies the number of previous passwords that IAM users are prevented from reusing. *

* * @param passwordReusePrevention * Specifies the number of previous passwords that IAM users are prevented from reusing. * @return Returns a reference to this object so that method calls can be chained together. */ Builder passwordReusePrevention(Integer passwordReusePrevention); /** *

* Specifies whether IAM users are prevented from setting a new password after their password has expired. *

* * @param hardExpiry * Specifies whether IAM users are prevented from setting a new password after their password has * expired. * @return Returns a reference to this object so that method calls can be chained together. */ Builder hardExpiry(Boolean hardExpiry); } static final class BuilderImpl implements Builder { private Integer minimumPasswordLength; private Boolean requireSymbols; private Boolean requireNumbers; private Boolean requireUppercaseCharacters; private Boolean requireLowercaseCharacters; private Boolean allowUsersToChangePassword; private Boolean expirePasswords; private Integer maxPasswordAge; private Integer passwordReusePrevention; private Boolean hardExpiry; private BuilderImpl() { } private BuilderImpl(PasswordPolicy model) { minimumPasswordLength(model.minimumPasswordLength); requireSymbols(model.requireSymbols); requireNumbers(model.requireNumbers); requireUppercaseCharacters(model.requireUppercaseCharacters); requireLowercaseCharacters(model.requireLowercaseCharacters); allowUsersToChangePassword(model.allowUsersToChangePassword); expirePasswords(model.expirePasswords); maxPasswordAge(model.maxPasswordAge); passwordReusePrevention(model.passwordReusePrevention); hardExpiry(model.hardExpiry); } public final Integer getMinimumPasswordLength() { return minimumPasswordLength; } @Override public final Builder minimumPasswordLength(Integer minimumPasswordLength) { this.minimumPasswordLength = minimumPasswordLength; return this; } public final void setMinimumPasswordLength(Integer minimumPasswordLength) { this.minimumPasswordLength = minimumPasswordLength; } public final Boolean getRequireSymbols() { return requireSymbols; } @Override public final Builder requireSymbols(Boolean requireSymbols) { this.requireSymbols = requireSymbols; return this; } public final void setRequireSymbols(Boolean requireSymbols) { this.requireSymbols = requireSymbols; } public final Boolean getRequireNumbers() { return requireNumbers; } @Override public final Builder requireNumbers(Boolean requireNumbers) { this.requireNumbers = requireNumbers; return this; } public final void setRequireNumbers(Boolean requireNumbers) { this.requireNumbers = requireNumbers; } public final Boolean getRequireUppercaseCharacters() { return requireUppercaseCharacters; } @Override public final Builder requireUppercaseCharacters(Boolean requireUppercaseCharacters) { this.requireUppercaseCharacters = requireUppercaseCharacters; return this; } public final void setRequireUppercaseCharacters(Boolean requireUppercaseCharacters) { this.requireUppercaseCharacters = requireUppercaseCharacters; } public final Boolean getRequireLowercaseCharacters() { return requireLowercaseCharacters; } @Override public final Builder requireLowercaseCharacters(Boolean requireLowercaseCharacters) { this.requireLowercaseCharacters = requireLowercaseCharacters; return this; } public final void setRequireLowercaseCharacters(Boolean requireLowercaseCharacters) { this.requireLowercaseCharacters = requireLowercaseCharacters; } public final Boolean getAllowUsersToChangePassword() { return allowUsersToChangePassword; } @Override public final Builder allowUsersToChangePassword(Boolean allowUsersToChangePassword) { this.allowUsersToChangePassword = allowUsersToChangePassword; return this; } public final void setAllowUsersToChangePassword(Boolean allowUsersToChangePassword) { this.allowUsersToChangePassword = allowUsersToChangePassword; } public final Boolean getExpirePasswords() { return expirePasswords; } @Override public final Builder expirePasswords(Boolean expirePasswords) { this.expirePasswords = expirePasswords; return this; } public final void setExpirePasswords(Boolean expirePasswords) { this.expirePasswords = expirePasswords; } public final Integer getMaxPasswordAge() { return maxPasswordAge; } @Override public final Builder maxPasswordAge(Integer maxPasswordAge) { this.maxPasswordAge = maxPasswordAge; return this; } public final void setMaxPasswordAge(Integer maxPasswordAge) { this.maxPasswordAge = maxPasswordAge; } public final Integer getPasswordReusePrevention() { return passwordReusePrevention; } @Override public final Builder passwordReusePrevention(Integer passwordReusePrevention) { this.passwordReusePrevention = passwordReusePrevention; return this; } public final void setPasswordReusePrevention(Integer passwordReusePrevention) { this.passwordReusePrevention = passwordReusePrevention; } public final Boolean getHardExpiry() { return hardExpiry; } @Override public final Builder hardExpiry(Boolean hardExpiry) { this.hardExpiry = hardExpiry; return this; } public final void setHardExpiry(Boolean hardExpiry) { this.hardExpiry = hardExpiry; } @Override public PasswordPolicy build() { return new PasswordPolicy(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy