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

com.adobe.aemds.guide.common.GuideCaptcha Maven / Gradle / Ivy

/*
 * ***********************************************************************
 * ADOBE CONFIDENTIAL
 * __________________
 *
 * Copyright 2016 Adobe Systems Incorporated
 * All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 * ***********************************************************************
 */

package com.adobe.aemds.guide.common;

import com.adobe.aemds.guide.utils.AuthoringErrorMessages;
import com.adobe.aemds.guide.utils.GuideConstants;
import com.adobe.aemds.guide.utils.GuideUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;

/**
 * GuideCaptcha encapsulates basic properties of the adaptive forms Captcha Component.
 * @since 6.3
 */
public class GuideCaptcha extends GuideField {

    private static final Logger logger = LoggerFactory.getLogger(GuideCaptcha.class);

    /**
     * Returns the alternate text for a place holder icon for Captcha in authoring
     * @return alternate text for placeholder icon
     */
    public String getAuthoringAltText() {
        return externalize("Captcha");
    }

    /**
     * Returns the field type of the Adaptive Forms Component
     * @return String representing guide field type
     */
    public String getGuideFieldType() {
        return GuideConstants.GUIDE_FIELD_CAPTCHA;
    }

    /**
     * Returns the service type of the Adaptive Form Captcha
     * @return String representing guide captcha service type
     */

    public String getCaptchaService() {
        String captchaService = resourceProps.get("captchaService", "");

        if ("afcaptcha".equals(captchaService)) {
            logger.error(AuthoringErrorMessages.AUTHORING_ERROR_MAP.get(AuthoringErrorMessages.MSG_DEFAULT_CAPTCHA_0001));
        }

        return captchaService;
    }

    /**
     * Returns the locale from request
     * @return String representing locale
     */

    public String getLocale() {
        return GuideUtils.getAcceptLang(slingRequest);
    }

    @Override
    public Map getAuthoringConfig(){
        Map authoringConfig = super.getAuthoringConfig();
        String cloudServicePath = resourceProps.get("rcCloudServicePath", String.class);

        /*We would need to think of showing third party captcha's authoring related error messages,
        * if we publish the third party integration doc.
        * */
        if (StringUtils.equals(getCaptchaService(), "recaptcha") && StringUtils.isBlank(cloudServicePath)) {
            authoringConfig.put("isRecaptchaConfigMissing", true);
        } else {
            authoringConfig.put("isRecaptchaConfigMissing", false);
        }

        return  authoringConfig;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy