Package com.adito.security

Source Code of com.adito.security.UserDatabaseListDataSource

package com.adito.security;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts.util.MessageResources;
import org.apache.struts.util.ModuleUtils;

import com.adito.core.CoreServlet;
import com.adito.core.UserDatabaseManager;
import com.adito.properties.Pair;
import com.adito.properties.PairListDataSource;

/**
* Implementation of {@link PairListDataSource} that retrieves its data from the
* list of installed user databases.
*/
public class UserDatabaseListDataSource implements PairListDataSource {

    /*
     * (non-Javadoc)
     *
     * @see com.adito.properties.PairListDataSource#getValues(javax.servlet.http.HttpServletRequest)
     */
    public List getValues(HttpServletRequest request) {
        List<Pair> l = new ArrayList<Pair>();
        ServletContext context = CoreServlet.getServlet().getServletContext();
        for (UserDatabaseDefinition def : UserDatabaseManager.getInstance().getUserDatabaseDefinitions()) {
            l.add(new Pair(def.getName(),
                            ((MessageResources) context.getAttribute(def.getMessageResourcesKey()
                                            + ModuleUtils.getInstance().getModuleConfig(request, context).getPrefix())).getMessage("security.userDatabase.value."
                                            + def.getName())));
        }
        return l;
    }

}
TOP

Related Classes of com.adito.security.UserDatabaseListDataSource

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.