48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * The contents of this file are subject to the terms of the Common Development and
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * Distribution License (the License). You may not use this file except in compliance with the
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * specific language governing permission and limitations under the License.
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * When distributing Covered Software, include this CDDL Header Notice in each file and include
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * Header, with the fields enclosed by brackets [] replaced by your own identifying
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * information: "Portions copyright [year] [name of copyright owner]".
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * Copyright 2015 ForgeRock AS.
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrestpackage org.forgerock.openam.selfservice.config.beans;
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrestimport org.forgerock.openam.sm.config.ConfigAttribute;
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrestimport org.forgerock.openam.sm.config.ConfigSource;
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * Represents forgotten password console configuration.
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * @supported.all.api
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * @since 13.0.0
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrestpublic final class ForgottenPasswordConsoleConfig extends CommonConsoleConfig {
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest private final Map<Locale, String> subjectTranslations;
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest private final Map<Locale, String> messageTranslations;
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest private final Set<String> validQueryAttributes;
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest private ForgottenPasswordConsoleConfig(ForgottenPasswordBuilder builder) {
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest emailVerificationUrl = builder.emailVerificationUrl;
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest minimumAnswersToVerify = builder.minimumAnswersToVerify;
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest configProviderClass = builder.configProviderClass;
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest subjectTranslations = builder.subjectTranslations;
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest messageTranslations = builder.messageTranslations;
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest validQueryAttributes = builder.validQueryAttributes;
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * Gets the verification Url to be sent with the email body.
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * @return email verification Url
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * Get the minimum count of questions to verify.
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * @return minimum count
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * Whether the service is enabled.
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * @return whether the service is enabled
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * Whether email verification is enabled.
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * @return whether email verification is enabled
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * Gets the token expiry time in seconds.
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * @return the token expiry time
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * Whether the captcha stage is enabled.
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * @return whether the captcha stage is enabled
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * Whether the KBA stage is enabled.
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * @return whether the KBA stage is enabled
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * Gets the map of locales to subject strings.
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * @return the map of locales to subject text strings.
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest public Map<Locale, String> getSubjectTranslations() {
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * Gets the map of locales to email body text strings.
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest * @return the map of locales to email body text strings.
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest public Map<Locale, String> getMessageTranslations() {
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest * Get set of valid query attributes.
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest * @return valid query attributes
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest public Set<String> getValidQueryAttributes() {
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * Builder for {@link ForgottenPasswordConsoleConfig}.
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest public static final class ForgottenPasswordBuilder
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest extends CommonConsoleConfigBuilder<ForgottenPasswordConsoleConfig> {
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest private final Map<Locale, String> subjectTranslations;
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest private final Map<Locale, String> messageTranslations;
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest private final Set<String> validQueryAttributes;
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * Constructs a new builder.
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * Sets the email verification url.
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * @param emailVerificationUrl
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * email verification url
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest @ConfigAttribute("selfServiceForgottenPasswordConfirmationUrl")
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest public void setEmailVerificationUrl(String emailVerificationUrl) {
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest this.emailVerificationUrl = emailVerificationUrl;
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * Sets whether the service is enabled.
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * @param enabled
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * whether the service is enabled
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest @ConfigAttribute("selfServiceForgottenPasswordEnabled")
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * Sets the config provider class.
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * @param configProviderClass
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * config provider class
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest @ConfigAttribute("selfServiceForgottenPasswordServiceConfigClass")
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest public void setConfigProviderClass(String configProviderClass) {
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest this.configProviderClass = configProviderClass;
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * Sets the token expiry time.
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * @param tokenExpiry
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * token expiry time
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest @ConfigAttribute("selfServiceForgottenPasswordTokenTTL")
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest public void setTokenExpiry(long tokenExpiry) {
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * Sets whether email is enabled.
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * @param emailEnabled
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * whether email is enabled
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest @ConfigAttribute("selfServiceForgottenPasswordEmailVerificationEnabled")
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest public void setEmailEnabled(boolean emailEnabled) {
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * Sets the email subject translations.
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * @param subjectTranslations
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * email subject translations
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest @ConfigAttribute(value = "selfServiceForgottenPasswordEmailSubject",
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest transformer = LocaleMessageTransformer.class)
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest public void setSubjectTranslations(Map<Locale, String> subjectTranslations) {
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest this.subjectTranslations.putAll(subjectTranslations);
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * Sets the email body translations.
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * @param messageTranslations
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * email body translations
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest @ConfigAttribute(value = "selfServiceForgottenPasswordEmailBody",
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest transformer = LocaleMessageTransformer.class)
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest public void setMessageTranslations(Map<Locale, String> messageTranslations) {
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest this.messageTranslations.putAll(messageTranslations);
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * Sets whether captcha is enabled.
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * @param captchaEnabled
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * whether captcha is enabled
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest @ConfigAttribute("selfServiceForgottenPasswordCaptchaEnabled")
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest public void setCaptchaEnabled(boolean captchaEnabled) {
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * Sets whether KBA is enabled.
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * @param kbaEnabled
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * whether KBA is enabled
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest @ConfigAttribute("selfServiceForgottenPasswordKbaEnabled")
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest public void setKbaEnabled(boolean kbaEnabled) {
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * Sets the minimum number of answers to be verified.
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * @param minimumAnswersToVerify
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * minimum number of answers to be verified
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest @ConfigAttribute("selfServiceMinimumAnswersToVerify")
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest public void setMinimumAnswersToVerify(int minimumAnswersToVerify) {
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest this.minimumAnswersToVerify = minimumAnswersToVerify;
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * Sets the valid set of query attributes.
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * @param validQueryAttributes
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest * valid query attributes
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest @ConfigAttribute("selfServiceValidQueryAttributes")
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest public void setValidQueryAttributes(Set<String> validQueryAttributes) {
ea65b6bac936db133a660beef9d75f044dd7ce84Andrew Forrest this.validQueryAttributes.addAll(validQueryAttributes);
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest ForgottenPasswordConsoleConfig internalBuild() {
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest Reject.ifNull(configProviderClass, "Config provider class name required");
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest Reject.ifFalse(tokenExpiry > 0, "Token expiry must be greater than zero");
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest Reject.ifNull(emailVerificationUrl, "Email verification Url is required");
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest Reject.ifTrue(subjectTranslations.isEmpty(), "Subject translations are required");
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest Reject.ifTrue(messageTranslations.isEmpty(), "Message translations are required");
48dc7c385d64e5d3906d6979100f106e857b4c02Andrew Forrest Reject.ifFalse(minimumAnswersToVerify > 0, "Minimum questions to be verified must be greater than 0");