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

com.payneteasy.superfly.spring.SaltSourceFactoryBean Maven / Gradle / Ivy

package com.payneteasy.superfly.spring;

import java.util.Map;

import org.springframework.beans.factory.FactoryBean;

import com.payneteasy.superfly.password.SaltSource;

/**
 * {@link FactoryBean} for {@link SaltSource}. Produces it according to the
 * current policy value.
 * 
 * @author Roman Puchkovskiy
 */
public class SaltSourceFactoryBean extends AbstractPolicyDependingFactoryBean {

    private SaltSource source;

    private Map salts;

    public void setSalts(Map salts) {
        this.salts = salts;
    }

    public SaltSource getObject() throws Exception {
        if (source == null) {
            Policy p = findPolicyByIdentifier();
            if(salts.containsKey(p.name().toLowerCase())){
                source = salts.get(p.name().toLowerCase());
            } else
                throw new IllegalArgumentException();
        }
        return source;
    }

    public Class getObjectType() {
        return SaltSource.class;
    }

    public boolean isSingleton() {
        return true;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy