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

com.healthy.common.security.code.ValidateCodeProcessorHolder Maven / Gradle / Ivy

There is a newer version: 1.2.1.RELEASE
Show newest version
package com.healthy.common.security.code;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * ValidateCodeProcessorHolder
 *
 * @author xiaomingzhang
 */
@Component
public class ValidateCodeProcessorHolder {

    @Autowired
    private Map validateCodeProcessors;

    /**
     * Obtain the corresponding verification code processor by the verification code type
     *
     * @param type Verification code type
     * @return ValidateCodeProcessor
     */
    public ValidateCodeProcessor findValidateCodeProcessor(ValidateCodeType type) {
        return findValidateCodeProcessor(type.toString().toLowerCase());
    }

    /**
     * Obtain the corresponding verification code processor by the verification code type
     *
     * @param type Verification code type
     * @return ValidateCodeProcessor
     */
    public ValidateCodeProcessor findValidateCodeProcessor(String type) {
        String name = type.toLowerCase() + ValidateCodeProcessor.class.getSimpleName();
        ValidateCodeProcessor processor = validateCodeProcessors.get(name);
        if (processor == null) {
            throw new ValidateCodeException("验证码处理器" + name + "不存在");
        }
        return processor;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy